mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-12-12 21:03:32 +01:00
set offer trigger price and state from open offer
This commit is contained in:
parent
e33d93eee8
commit
ca9bdf7c29
@ -18,7 +18,7 @@
|
|||||||
package bisq.core.api.model;
|
package bisq.core.api.model;
|
||||||
|
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OpenOffer;
|
||||||
import bisq.common.Payload;
|
import bisq.common.Payload;
|
||||||
import bisq.common.proto.ProtoUtil;
|
import bisq.common.proto.ProtoUtil;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -94,10 +94,13 @@ public class OfferInfo implements Payload {
|
|||||||
return getOfferInfoBuilder(offer).build();
|
return getOfferInfoBuilder(offer).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OfferInfo toOfferInfo(Offer offer, long triggerPrice) {
|
public static OfferInfo toOfferInfo(Offer offer, OpenOffer openOffer) {
|
||||||
// The Offer does not have a triggerPrice attribute, so we get
|
OfferInfoBuilder builder = getOfferInfoBuilder(offer);
|
||||||
// the base OfferInfoBuilder, then add the OpenOffer's triggerPrice.
|
if (openOffer != null) {
|
||||||
return getOfferInfoBuilder(offer).withTriggerPrice(triggerPrice).build();
|
builder.withState(openOffer.getState().name());
|
||||||
|
builder.withTriggerPrice(openOffer.getTriggerPrice());
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OfferInfoBuilder getOfferInfoBuilder(Offer offer) {
|
private static OfferInfoBuilder getOfferInfoBuilder(Offer offer) {
|
||||||
|
@ -82,7 +82,6 @@ public class Offer implements NetworkPayload, PersistablePayload {
|
|||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
SCHEDULED,
|
|
||||||
OFFER_FEE_RESERVED,
|
OFFER_FEE_RESERVED,
|
||||||
AVAILABLE,
|
AVAILABLE,
|
||||||
NOT_AVAILABLE,
|
NOT_AVAILABLE,
|
||||||
|
@ -696,7 +696,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||||||
// schedule txs
|
// schedule txs
|
||||||
openOffer.setScheduledTxHashes(scheduledTxHashes);
|
openOffer.setScheduledTxHashes(scheduledTxHashes);
|
||||||
openOffer.setScheduledAmount(scheduledAmount.toString());
|
openOffer.setScheduledAmount(scheduledAmount.toString());
|
||||||
openOffer.getOffer().setState(Offer.State.SCHEDULED);
|
openOffer.setState(OpenOffer.State.SCHEDULED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle result
|
// handle result
|
||||||
|
@ -39,7 +39,7 @@ import io.grpc.ServerInterceptor;
|
|||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -91,7 +91,7 @@ class GrpcOffersService extends OffersImplBase {
|
|||||||
Offer offer = coreApi.getMyOffer(req.getId());
|
Offer offer = coreApi.getMyOffer(req.getId());
|
||||||
OpenOffer openOffer = coreApi.getMyOpenOffer(req.getId());
|
OpenOffer openOffer = coreApi.getMyOpenOffer(req.getId());
|
||||||
var reply = GetMyOfferReply.newBuilder()
|
var reply = GetMyOfferReply.newBuilder()
|
||||||
.setOffer(toOfferInfo(offer, openOffer.getTriggerPrice()).toProtoMessage())
|
.setOffer(toOfferInfo(offer, openOffer).toProtoMessage())
|
||||||
.build();
|
.build();
|
||||||
responseObserver.onNext(reply);
|
responseObserver.onNext(reply);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
@ -123,9 +123,11 @@ class GrpcOffersService extends OffersImplBase {
|
|||||||
public void getMyOffers(GetMyOffersRequest req,
|
public void getMyOffers(GetMyOffersRequest req,
|
||||||
StreamObserver<GetMyOffersReply> responseObserver) {
|
StreamObserver<GetMyOffersReply> responseObserver) {
|
||||||
try {
|
try {
|
||||||
List<OfferInfo> result = coreApi.getMyOffers(req.getDirection(), req.getCurrencyCode())
|
List<OfferInfo> result = new ArrayList<OfferInfo>();
|
||||||
.stream().map(OfferInfo::toOfferInfo)
|
for (Offer offer : coreApi.getMyOffers(req.getDirection(), req.getCurrencyCode())) {
|
||||||
.collect(Collectors.toList());
|
OpenOffer openOffer = coreApi.getMyOpenOffer(offer.getId());
|
||||||
|
result.add(toOfferInfo(offer, openOffer));
|
||||||
|
}
|
||||||
var reply = GetMyOffersReply.newBuilder()
|
var reply = GetMyOffersReply.newBuilder()
|
||||||
.addAllOffers(result.stream()
|
.addAllOffers(result.stream()
|
||||||
.map(OfferInfo::toProtoMessage)
|
.map(OfferInfo::toProtoMessage)
|
||||||
@ -161,7 +163,8 @@ class GrpcOffersService extends OffersImplBase {
|
|||||||
offer -> {
|
offer -> {
|
||||||
// This result handling consumer's accept operation will return
|
// This result handling consumer's accept operation will return
|
||||||
// the new offer to the gRPC client after async placement is done.
|
// the new offer to the gRPC client after async placement is done.
|
||||||
OfferInfo offerInfo = toOfferInfo(offer);
|
OpenOffer openOffer = coreApi.getMyOpenOffer(offer.getId());
|
||||||
|
OfferInfo offerInfo = toOfferInfo(offer, openOffer);
|
||||||
CreateOfferReply reply = CreateOfferReply.newBuilder()
|
CreateOfferReply reply = CreateOfferReply.newBuilder()
|
||||||
.setOffer(offerInfo.toProtoMessage())
|
.setOffer(offerInfo.toProtoMessage())
|
||||||
.build();
|
.build();
|
||||||
|
@ -1450,12 +1450,11 @@ message Offer {
|
|||||||
enum State {
|
enum State {
|
||||||
PB_ERROR = 0;
|
PB_ERROR = 0;
|
||||||
UNKNOWN = 1;
|
UNKNOWN = 1;
|
||||||
SCHEDULED = 2;
|
OFFER_FEE_RESERVED = 2;
|
||||||
OFFER_FEE_RESERVED = 3;
|
AVAILABLE = 3;
|
||||||
AVAILABLE = 4;
|
NOT_AVAILABLE = 4;
|
||||||
NOT_AVAILABLE = 5;
|
REMOVED = 5;
|
||||||
REMOVED = 6;
|
MAKER_OFFLINE = 6;
|
||||||
MAKER_OFFLINE = 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OfferPayload offer_payload = 1;
|
OfferPayload offer_payload = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user