mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 14:44:10 +01:00
Merge pull request #6094 from ghubstan/3-fix-is-activated-setting-bug
API bug-fix for incorrect BsqSwap's OfferInfo.isActivated value [No. 3]
This commit is contained in:
commit
b3b488c38c
@ -35,6 +35,7 @@ import static io.grpc.Status.Code.NOT_FOUND;
|
||||
import static java.lang.String.format;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static protobuf.OfferDirection.BUY;
|
||||
|
||||
@ -45,7 +46,7 @@ public class BsqSwapOfferTest extends AbstractOfferTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
AbstractOfferTest.setUp();
|
||||
AbstractOfferTest.setUp(false);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@ -137,6 +138,7 @@ public class BsqSwapOfferTest extends AbstractOfferTest {
|
||||
numFetchAttempts++;
|
||||
var fetchedBsqSwapOffer = aliceClient.getOffer(bsqSwapOffer.getId());
|
||||
assertEquals(bsqSwapOffer.getId(), fetchedBsqSwapOffer.getId());
|
||||
assertTrue(fetchedBsqSwapOffer.getIsActivated());
|
||||
log.debug("Alice found her (my) new bsq swap offer on attempt # {}.", numFetchAttempts);
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
@ -159,6 +161,7 @@ public class BsqSwapOfferTest extends AbstractOfferTest {
|
||||
numFetchAttempts++;
|
||||
var fetchedBsqSwapOffer = bobClient.getOffer(bsqSwapOffer.getId());
|
||||
assertEquals(bsqSwapOffer.getId(), fetchedBsqSwapOffer.getId());
|
||||
assertTrue(fetchedBsqSwapOffer.getIsActivated());
|
||||
log.debug("Bob found new available bsq swap offer on attempt # {}.", numFetchAttempts);
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
|
@ -68,6 +68,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
log.debug("Sell BSQ (Buy BTC) Offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -89,6 +90,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -119,6 +121,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
log.debug("SELL 20K BSQ Offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -140,6 +143,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -170,6 +174,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
log.debug("BUY 1-2K BSQ Offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -191,6 +196,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -221,6 +227,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
log.debug("SELL 5-10K BSQ Offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -242,6 +249,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
|
@ -60,6 +60,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
log.debug("Offer #1:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -79,6 +80,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -109,6 +111,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
log.debug("Offer #2:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -128,6 +131,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -158,6 +162,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
log.debug("Offer #3:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -177,6 +182,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
|
@ -77,6 +77,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
log.debug("Offer #1:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -94,6 +95,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
@ -126,6 +128,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
log.debug("Offer #2:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -143,6 +146,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
@ -175,6 +179,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
log.debug("Offer #3:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -192,6 +197,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
@ -224,6 +230,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
log.debug("Offer #4:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -241,6 +248,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
@ -273,12 +281,14 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
|
||||
triggerPrice);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
genBtcBlocksThenWait(1, 4000); // give time to add to offer book
|
||||
newOffer = aliceClient.getOffer(newOffer.getId());
|
||||
log.debug("Offer #5:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(triggerPrice, newOffer.getTriggerPrice());
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
log.debug("Sell XMR (Buy BTC) offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -90,6 +91,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -118,6 +120,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
log.debug("Buy XMR (Sell BTC) offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -137,6 +140,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertFalse(newOffer.getUseMarketBasedPrice());
|
||||
@ -168,6 +172,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
log.debug("Pending Sell XMR (Buy BTC) offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -191,6 +196,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
log.debug("Available Sell XMR (Buy BTC) offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(BUY.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
@ -224,6 +230,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
log.debug("Buy XMR (Sell BTC) offer:\n{}", toOfferTable.apply(newOffer));
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertTrue(newOffer.getIsMyPendingOffer());
|
||||
assertFalse(newOffer.getIsActivated());
|
||||
|
||||
String newOfferId = newOffer.getId();
|
||||
assertNotEquals("", newOfferId);
|
||||
@ -242,6 +249,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
|
||||
newOffer = aliceClient.getOffer(newOfferId);
|
||||
assertTrue(newOffer.getIsMyOffer());
|
||||
assertFalse(newOffer.getIsMyPendingOffer());
|
||||
assertTrue(newOffer.getIsActivated());
|
||||
assertEquals(newOfferId, newOffer.getId());
|
||||
assertEquals(SELL.name(), newOffer.getDirection());
|
||||
assertTrue(newOffer.getUseMarketBasedPrice());
|
||||
|
@ -22,7 +22,7 @@ import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OpenOffer;
|
||||
|
||||
import static bisq.core.api.model.ContractInfo.emptyContract;
|
||||
import static bisq.core.api.model.OfferInfo.toMyOfferInfo;
|
||||
import static bisq.core.api.model.OfferInfo.toMyInactiveOfferInfo;
|
||||
import static bisq.core.offer.OpenOffer.State.CANCELED;
|
||||
import static java.lang.String.format;
|
||||
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||
@ -37,7 +37,7 @@ public class CanceledTradeInfo {
|
||||
throw new IllegalArgumentException(format("offer '%s' is not canceled", myCanceledOpenOffer.getId()));
|
||||
|
||||
Offer offer = myCanceledOpenOffer.getOffer();
|
||||
OfferInfo offerInfo = toMyOfferInfo(offer);
|
||||
OfferInfo offerInfo = toMyInactiveOfferInfo(offer);
|
||||
|
||||
return new TradeInfoV1Builder()
|
||||
.withOffer(offerInfo)
|
||||
|
@ -113,14 +113,18 @@ public class OfferInfo implements Payload {
|
||||
this.protocolVersion = builder.getProtocolVersion();
|
||||
}
|
||||
|
||||
public static OfferInfo toMyOfferInfo(Offer offer) {
|
||||
return getBuilder(offer, true).build();
|
||||
public static OfferInfo toMyInactiveOfferInfo(Offer offer) {
|
||||
return getBuilder(offer, true)
|
||||
.withIsActivated(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static OfferInfo toOfferInfo(Offer offer) {
|
||||
// Assume the offer is not mine, but isMyOffer can be reset to true, i.e., when
|
||||
// calling TradeInfo toTradeInfo(Trade trade, String role, boolean isMyOffer);
|
||||
return getBuilder(offer, false).build();
|
||||
return getBuilder(offer, false)
|
||||
.withIsActivated(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static OfferInfo toMyPendingOfferInfo(Offer myNewOffer) {
|
||||
@ -130,21 +134,24 @@ public class OfferInfo implements Payload {
|
||||
// column that will show a PENDING value when this.isMyPendingOffer = true.
|
||||
return getBuilder(myNewOffer, true)
|
||||
.withIsMyPendingOffer(true)
|
||||
.withIsActivated(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static OfferInfo toMyOfferInfo(OpenOffer openOffer) {
|
||||
// An OpenOffer is always my offer.
|
||||
var currencyCode = openOffer.getOffer().getCurrencyCode();
|
||||
Optional<Price> optionalTriggerPrice = openOffer.getTriggerPrice() > 0
|
||||
var offer = openOffer.getOffer();
|
||||
var currencyCode = offer.getCurrencyCode();
|
||||
var isActivated = !openOffer.isDeactivated();
|
||||
Optional<Price> optionalTriggerPrice = (!offer.isBsqSwapOffer() && openOffer.getTriggerPrice() > 0)
|
||||
? Optional.of(Price.valueOf(currencyCode, openOffer.getTriggerPrice()))
|
||||
: Optional.empty();
|
||||
var preciseTriggerPrice = optionalTriggerPrice
|
||||
.map(value -> reformatMarketPrice(value.toPlainString(), currencyCode))
|
||||
.orElse("0");
|
||||
return getBuilder(openOffer.getOffer(), true)
|
||||
return getBuilder(offer, true)
|
||||
.withTriggerPrice(preciseTriggerPrice)
|
||||
.withIsActivated(!openOffer.isDeactivated())
|
||||
.withIsActivated(isActivated)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
import static bisq.core.api.model.BsqSwapTradeInfo.toBsqSwapTradeInfo;
|
||||
import static bisq.core.api.model.OfferInfo.toMyOfferInfo;
|
||||
import static bisq.core.api.model.OfferInfo.toMyInactiveOfferInfo;
|
||||
import static bisq.core.api.model.OfferInfo.toOfferInfo;
|
||||
import static bisq.core.api.model.PaymentAccountPayloadInfo.toPaymentAccountPayloadInfo;
|
||||
import static bisq.core.offer.OfferDirection.BUY;
|
||||
@ -50,7 +50,7 @@ public class TradeInfo implements Payload {
|
||||
// view and interact with trades.
|
||||
|
||||
private static final BiFunction<TradeModel, Boolean, OfferInfo> toOfferInfo = (tradeModel, isMyOffer) ->
|
||||
isMyOffer ? toMyOfferInfo(tradeModel.getOffer()) : toOfferInfo(tradeModel.getOffer());
|
||||
isMyOffer ? toMyInactiveOfferInfo(tradeModel.getOffer()) : toOfferInfo(tradeModel.getOffer());
|
||||
|
||||
private static final Function<TradeModel, String> toPeerNodeAddress = (tradeModel) ->
|
||||
tradeModel.getTradingPeerNodeAddress() == null
|
||||
|
@ -125,8 +125,10 @@ class GrpcOffersService extends OffersImplBase {
|
||||
try {
|
||||
String offerId = req.getId();
|
||||
Optional<OpenOffer> myOpenOffer = coreApi.findMyOpenOffer(offerId);
|
||||
Offer offer = myOpenOffer.map(OpenOffer::getOffer)
|
||||
.orElseGet(() -> coreApi.getOffer(offerId));
|
||||
OfferInfo offerInfo = myOpenOffer.map(OfferInfo::toMyOfferInfo)
|
||||
.orElseGet(() -> toOfferInfo(coreApi.getOffer(offerId)));
|
||||
.orElseGet(() -> toOfferInfo(offer));
|
||||
var reply = GetOfferReply.newBuilder()
|
||||
.setOffer(offerInfo.toProtoMessage())
|
||||
.build();
|
||||
@ -174,7 +176,8 @@ class GrpcOffersService extends OffersImplBase {
|
||||
StreamObserver<GetBsqSwapOffersReply> responseObserver) {
|
||||
try {
|
||||
List<OfferInfo> result = coreApi.getBsqSwapOffers(req.getDirection())
|
||||
.stream().map(OfferInfo::toOfferInfo)
|
||||
.stream()
|
||||
.map(OfferInfo::toOfferInfo)
|
||||
.collect(Collectors.toList());
|
||||
var reply = GetBsqSwapOffersReply.newBuilder()
|
||||
.addAllBsqSwapOffers(result.stream()
|
||||
@ -193,7 +196,8 @@ class GrpcOffersService extends OffersImplBase {
|
||||
StreamObserver<GetOffersReply> responseObserver) {
|
||||
try {
|
||||
List<OfferInfo> result = coreApi.getOffers(req.getDirection(), req.getCurrencyCode())
|
||||
.stream().map(OfferInfo::toOfferInfo)
|
||||
.stream()
|
||||
.map(OfferInfo::toOfferInfo)
|
||||
.collect(Collectors.toList());
|
||||
var reply = GetOffersReply.newBuilder()
|
||||
.addAllOffers(result.stream()
|
||||
@ -212,7 +216,9 @@ class GrpcOffersService extends OffersImplBase {
|
||||
StreamObserver<GetMyBsqSwapOffersReply> responseObserver) {
|
||||
try {
|
||||
List<OfferInfo> result = coreApi.getMyBsqSwapOffers(req.getDirection())
|
||||
.stream().map(OfferInfo::toOfferInfo)
|
||||
.stream()
|
||||
.map(o -> coreApi.getMyOpenBsqSwapOffer(o.getId()))
|
||||
.map(OfferInfo::toMyOfferInfo)
|
||||
.collect(Collectors.toList());
|
||||
var reply = GetMyBsqSwapOffersReply.newBuilder()
|
||||
.addAllBsqSwapOffers(result.stream()
|
||||
|
Loading…
Reference in New Issue
Block a user