Skip to content

Commit

Permalink
Add trade.vol v offer.vol bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ghubstan committed Sep 18, 2021
1 parent a0d743e commit e88da11
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cli/src/main/java/bisq/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
9 changes: 4 additions & 5 deletions cli/src/main/java/bisq/cli/TradeFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -163,7 +162,7 @@ public static Table toTradeTbl(TradeInfo tradeInfo) {
private static final Function<TradeInfo, Long> toAmount = (t) ->
isFiatOffer.test(t)
? t.getTradeAmountAsLong()
: t.getOffer().getVolume();
: t.getTradeVolume();

private static final Function<TradeInfo, Long> toMinerTxFee = (t) ->
isTaker.test(t)
Expand Down Expand Up @@ -382,13 +381,13 @@ private static String formatTradeData(String format,
private static final Function<TradeInfo, String> priceFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatPrice(t.getTradePrice())
: formatCryptoCurrencyPrice(t.getOffer().getPrice());
: formatCryptoCurrencyPrice(t.getTradePrice());

@Deprecated
private static final Function<TradeInfo, String> amountFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatSatoshis(t.getTradeAmountAsLong())
: formatCryptoCurrencyOfferVolume(t.getOffer().getVolume());
: formatCryptoCurrencyOfferVolume(t.getTradeVolume());

@Deprecated
private static final BiFunction<TradeInfo, Boolean, String> makerTakerMinerTxFeeFormat = (t, isTaker) -> {
Expand All @@ -415,7 +414,7 @@ private static String formatTradeData(String format,
@Deprecated
private static final Function<TradeInfo, String> tradeCostFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatOfferVolume(t.getOffer().getVolume())
? formatOfferVolume(t.getTradeVolume())
: formatSatoshis(t.getTradeAmountAsLong());

@Deprecated
Expand Down
11 changes: 5 additions & 6 deletions cli/src/test/java/bisq/cli/table/GetTradesSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/*
Expand All @@ -34,7 +34,6 @@ public static void main(String[] args) {
getTrade(xmrTrade4);
getTrade(xmrTrade5);
*/

getTrade(xmrTrade1);
}

Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/bisq/core/api/model/TradeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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" +
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ message TradeInfo {
bool isWithdrawn = 23;
string contractAsJson = 24;
ContractInfo contract = 25;
uint64 tradeVolume = 26;
}

message ContractInfo {
Expand Down

0 comments on commit e88da11

Please sign in to comment.