From e88da11bd75b1969c096a7df121526ec11a0f2cb Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 18 Sep 2021 15:56:33 -0300 Subject: [PATCH] Add trade.vol v offer.vol bugfix RE https://github.com/bisq-network/bisq/pull/5704 --- cli/src/main/java/bisq/cli/CliMain.java | 2 +- cli/src/main/java/bisq/cli/TradeFormat.java | 9 ++++----- .../test/java/bisq/cli/table/GetTradesSmokeTest.java | 11 +++++------ .../src/main/java/bisq/core/api/model/TradeInfo.java | 12 ++++++++++++ proto/src/main/proto/grpc.proto | 1 + 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cli/src/main/java/bisq/cli/CliMain.java b/cli/src/main/java/bisq/cli/CliMain.java index 9868ffd88e2..6f599678ac1 100644 --- a/cli/src/main/java/bisq/cli/CliMain.java +++ b/cli/src/main/java/bisq/cli/CliMain.java @@ -527,7 +527,7 @@ public static void run(String[] args) { } String oldOutput = TradeFormat.format(trade); String newOutput = toTradeTbl(trade).toString(); - // showDiffs(oldOutput, newOutput); + //showDiffs(oldOutput, newOutput); return; } case confirmpaymentstarted: { diff --git a/cli/src/main/java/bisq/cli/TradeFormat.java b/cli/src/main/java/bisq/cli/TradeFormat.java index 175f2ca748f..588a172a018 100644 --- a/cli/src/main/java/bisq/cli/TradeFormat.java +++ b/cli/src/main/java/bisq/cli/TradeFormat.java @@ -31,7 +31,6 @@ import static bisq.cli.ColumnHeaderConstants.*; import static bisq.cli.CurrencyFormat.*; -import static bisq.cli.table.AltcoinColumn.DISPLAY_MODE.*; import static bisq.cli.table.AltcoinColumn.DISPLAY_MODE.ALTCOIN_OFFER_VOLUME; import static bisq.cli.table.Column.JUSTIFY.LEFT; import static bisq.cli.table.Column.JUSTIFY.RIGHT; @@ -163,7 +162,7 @@ public static Table toTradeTbl(TradeInfo tradeInfo) { private static final Function toAmount = (t) -> isFiatOffer.test(t) ? t.getTradeAmountAsLong() - : t.getOffer().getVolume(); + : t.getTradeVolume(); private static final Function toMinerTxFee = (t) -> isTaker.test(t) @@ -382,13 +381,13 @@ private static String formatTradeData(String format, private static final Function priceFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") ? formatPrice(t.getTradePrice()) - : formatCryptoCurrencyPrice(t.getOffer().getPrice()); + : formatCryptoCurrencyPrice(t.getTradePrice()); @Deprecated private static final Function amountFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") ? formatSatoshis(t.getTradeAmountAsLong()) - : formatCryptoCurrencyOfferVolume(t.getOffer().getVolume()); + : formatCryptoCurrencyOfferVolume(t.getTradeVolume()); @Deprecated private static final BiFunction makerTakerMinerTxFeeFormat = (t, isTaker) -> { @@ -415,7 +414,7 @@ private static String formatTradeData(String format, @Deprecated private static final Function tradeCostFormat = (t) -> t.getOffer().getBaseCurrencyCode().equals("BTC") - ? formatOfferVolume(t.getOffer().getVolume()) + ? formatOfferVolume(t.getTradeVolume()) : formatSatoshis(t.getTradeAmountAsLong()); @Deprecated diff --git a/cli/src/test/java/bisq/cli/table/GetTradesSmokeTest.java b/cli/src/test/java/bisq/cli/table/GetTradesSmokeTest.java index 2ea15b284ae..711ecc40aee 100644 --- a/cli/src/test/java/bisq/cli/table/GetTradesSmokeTest.java +++ b/cli/src/test/java/bisq/cli/table/GetTradesSmokeTest.java @@ -14,11 +14,11 @@ public class GetTradesSmokeTest extends AbstractSmokeTest { static String usdTrade1 = "WpIrxCuM-c27b0523-ba0f-41e3-9743-73997f7a4fe2-173"; static String usdTrade2 = "tlyvu-1bf5faaa-0acc-4641-bac8-b7cf1d7cafd0-173"; - static String xmrTrade1 = "tueovh-f8b33c3d-89d9-44dd-8df4-99f0ce2b6d3e-173"; - static String xmrTrade2 = "NVPLTP-5e05423f-1859-4bc9-b634-389ab3866041-173"; - static String xmrTrade3 = "57815136-f942fb7a-2bda-4de7-8cc7-f19a40541b8e-173"; - static String xmrTrade4 = "kMdKwsl-11b90355-0729-4f0e-ad28-675e208c795f-173"; - static String xmrTrade5 = "AUCLRC-1258ed6f-cbda-4933-9c68-19ac08210486-173"; + static String xmrTrade1 = "0A1RT4QD-9716286e-bb41-42dd-a15c-d6ac62ae8430-173"; + static String xmrTrade2 = "K6TjR5Bk-8e1763fd-fc5a-4ac7-8374-5e2dbc0e646b-173"; + static String xmrTrade3 = "7187944-b879ebe0-cc0d-4a10-9e85-636135fe5718-173"; + static String xmrTrade4 = "6273836-9271ed6e-517d-4a77-a158-629fb514fc9d-173"; + static String xmrTrade5 = "G9DUFOVP-809561ff-414f-480b-ad34-4611cb5841f6-173"; public static void main(String[] args) { /* @@ -34,7 +34,6 @@ public static void main(String[] args) { getTrade(xmrTrade4); getTrade(xmrTrade5); */ - getTrade(xmrTrade1); } diff --git a/core/src/main/java/bisq/core/api/model/TradeInfo.java b/core/src/main/java/bisq/core/api/model/TradeInfo.java index 5779baf348e..38bf15256d2 100644 --- a/core/src/main/java/bisq/core/api/model/TradeInfo.java +++ b/core/src/main/java/bisq/core/api/model/TradeInfo.java @@ -51,6 +51,7 @@ public class TradeInfo implements Payload { private final String payoutTxId; private final long tradeAmountAsLong; private final long tradePrice; + private final long tradeVolume; private final String tradingPeerNodeAddress; private final String state; private final String phase; @@ -78,6 +79,7 @@ public TradeInfo(TradeInfoBuilder builder) { this.payoutTxId = builder.payoutTxId; this.tradeAmountAsLong = builder.tradeAmountAsLong; this.tradePrice = builder.tradePrice; + this.tradeVolume = builder.tradeVolume; this.tradingPeerNodeAddress = builder.tradingPeerNodeAddress; this.state = builder.state; this.phase = builder.phase; @@ -133,6 +135,7 @@ public static TradeInfo toTradeInfo(Trade trade, String role, boolean isMyOffer) .withPayoutTxId(trade.getPayoutTxId()) .withTradeAmountAsLong(trade.getTradeAmountAsLong()) .withTradePrice(trade.getTradePrice().getValue()) + .withTradeVolume(trade.getTradeVolume() == null ? 0 : trade.getTradeVolume().getValue()) .withTradingPeerNodeAddress(Objects.requireNonNull( trade.getTradingPeerNodeAddress()).getHostNameWithoutPostFix()) .withState(trade.getState().name()) @@ -169,6 +172,7 @@ public bisq.proto.grpc.TradeInfo toProtoMessage() { .setPayoutTxId(payoutTxId == null ? "" : payoutTxId) .setTradeAmountAsLong(tradeAmountAsLong) .setTradePrice(tradePrice) + .setTradeVolume(tradeVolume) .setTradingPeerNodeAddress(tradingPeerNodeAddress) .setState(state) .setPhase(phase) @@ -199,6 +203,7 @@ public static TradeInfo fromProto(bisq.proto.grpc.TradeInfo proto) { .withPayoutTxId(proto.getPayoutTxId()) .withTradeAmountAsLong(proto.getTradeAmountAsLong()) .withTradePrice(proto.getTradePrice()) + .withTradeVolume(proto.getTradeVolume()) .withTradePeriodState(proto.getTradePeriodState()) .withState(proto.getState()) .withPhase(proto.getPhase()) @@ -234,6 +239,7 @@ public static class TradeInfoBuilder { private String payoutTxId; private long tradeAmountAsLong; private long tradePrice; + private long tradeVolume; private String tradingPeerNodeAddress; private String state; private String phase; @@ -312,6 +318,11 @@ public TradeInfoBuilder withTradePrice(long tradePrice) { return this; } + public TradeInfoBuilder withTradeVolume(long tradeVolume) { + this.tradeVolume = tradeVolume; + return this; + } + public TradeInfoBuilder withTradePeriodState(String tradePeriodState) { this.tradePeriodState = tradePeriodState; return this; @@ -392,6 +403,7 @@ public String toString() { ", payoutTxId='" + payoutTxId + '\'' + "\n" + ", tradeAmountAsLong='" + tradeAmountAsLong + '\'' + "\n" + ", tradePrice='" + tradePrice + '\'' + "\n" + + ", tradeVolume='" + tradeVolume + '\'' + "\n" + ", tradingPeerNodeAddress='" + tradingPeerNodeAddress + '\'' + "\n" + ", state='" + state + '\'' + "\n" + ", phase='" + phase + '\'' + "\n" + diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 21221eda452..84e6ee18ad3 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -409,6 +409,7 @@ message TradeInfo { bool isWithdrawn = 23; string contractAsJson = 24; ContractInfo contract = 25; + uint64 tradeVolume = 26; } message ContractInfo {