mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Stub out canceloffer api method
The implementation will be added to CoreOffersService in the next PR.
This commit is contained in:
parent
2746b27674
commit
027a7d5cd3
@ -17,6 +17,7 @@
|
||||
|
||||
package bisq.cli;
|
||||
|
||||
import bisq.proto.grpc.CancelOfferRequest;
|
||||
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
|
||||
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
|
||||
import bisq.proto.grpc.CreateOfferRequest;
|
||||
@ -74,6 +75,7 @@ public class CliMain {
|
||||
|
||||
private enum Method {
|
||||
createoffer,
|
||||
canceloffer,
|
||||
getoffer,
|
||||
getoffers,
|
||||
takeoffer,
|
||||
@ -238,6 +240,18 @@ public class CliMain {
|
||||
out.println(formatOfferTable(singletonList(reply.getOffer()), currencyCode));
|
||||
return;
|
||||
}
|
||||
case canceloffer: {
|
||||
if (nonOptionArgs.size() < 2)
|
||||
throw new IllegalArgumentException("incorrect parameter count, expecting offer id");
|
||||
|
||||
var offerId = nonOptionArgs.get(1);
|
||||
var request = CancelOfferRequest.newBuilder()
|
||||
.setId(offerId)
|
||||
.build();
|
||||
offersService.cancelOffer(request);
|
||||
out.println("offer canceled and removed from offer book");
|
||||
return;
|
||||
}
|
||||
case getoffer: {
|
||||
if (nonOptionArgs.size() < 2)
|
||||
throw new IllegalArgumentException("incorrect parameter count, expecting offer id");
|
||||
@ -246,7 +260,7 @@ public class CliMain {
|
||||
var request = GetOfferRequest.newBuilder()
|
||||
.setId(offerId)
|
||||
.build();
|
||||
var reply = offersService.getOffer(request);
|
||||
var reply =offersService.getOffer(request);
|
||||
out.println(formatOfferTable(singletonList(reply.getOffer()),
|
||||
reply.getOffer().getCounterCurrencyCode()));
|
||||
return;
|
||||
@ -475,6 +489,7 @@ public class CliMain {
|
||||
stream.format(rowFormat, "", "amount (btc), min amount, use mkt based price, \\", "");
|
||||
stream.format(rowFormat, "", "fixed price (btc) | mkt price margin (%), \\", "");
|
||||
stream.format(rowFormat, "", "security deposit (%)", "");
|
||||
stream.format(rowFormat, "canceloffer", "offer id", "Cancel offer with id");
|
||||
stream.format(rowFormat, "getoffer", "offer id", "Get current offer with id");
|
||||
stream.format(rowFormat, "getoffers", "buy | sell, currency code", "Get current offers");
|
||||
stream.format(rowFormat, "takeoffer", "offer id", "Take offer with id");
|
||||
|
@ -142,6 +142,10 @@ public class CoreApi {
|
||||
paymentAccount);
|
||||
}
|
||||
|
||||
public void cancelOffer(String id) {
|
||||
coreOffersService.cancelOffer(id);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PaymentAccounts
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -160,6 +160,10 @@ class CoreOffersService {
|
||||
paymentAccount);
|
||||
}
|
||||
|
||||
void cancelOffer(String id) {
|
||||
log.info("TODO");
|
||||
}
|
||||
|
||||
private void placeOffer(Offer offer,
|
||||
double buyerSecurityDeposit,
|
||||
boolean useSavingsWallet,
|
||||
|
@ -21,6 +21,8 @@ import bisq.core.api.CoreApi;
|
||||
import bisq.core.api.model.OfferInfo;
|
||||
import bisq.core.offer.Offer;
|
||||
|
||||
import bisq.proto.grpc.CancelOfferReply;
|
||||
import bisq.proto.grpc.CancelOfferRequest;
|
||||
import bisq.proto.grpc.CreateOfferReply;
|
||||
import bisq.proto.grpc.CreateOfferRequest;
|
||||
import bisq.proto.grpc.GetOfferReply;
|
||||
@ -114,4 +116,19 @@ class GrpcOffersService extends OffersGrpc.OffersImplBase {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelOffer(CancelOfferRequest req,
|
||||
StreamObserver<CancelOfferReply> responseObserver) {
|
||||
try {
|
||||
coreApi.cancelOffer(req.getId());
|
||||
var reply = CancelOfferReply.newBuilder().build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
} catch (IllegalStateException | IllegalArgumentException cause) {
|
||||
var ex = new StatusRuntimeException(Status.UNKNOWN.withDescription(cause.getMessage()));
|
||||
responseObserver.onError(ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ service Offers {
|
||||
}
|
||||
rpc CreateOffer (CreateOfferRequest) returns (CreateOfferReply) {
|
||||
}
|
||||
rpc CancelOffer (CancelOfferRequest) returns (CancelOfferReply) {
|
||||
}
|
||||
}
|
||||
|
||||
message GetOfferRequest {
|
||||
@ -85,6 +87,13 @@ message CreateOfferReply {
|
||||
OfferInfo offer = 1;
|
||||
}
|
||||
|
||||
message CancelOfferRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message CancelOfferReply {
|
||||
}
|
||||
|
||||
message OfferInfo {
|
||||
string id = 1;
|
||||
string direction = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user