mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Include isMyOffer flag in API's trade/offer proto wrappers
Optionally displaying an ENABLED column in CLI side getoffer output depends on the value of offer.isMyOffer, which is passed via new boolean arguments to the trade & offer pojo builders.
This commit is contained in:
parent
1a56a5161a
commit
0e9c6650e3
2 changed files with 15 additions and 7 deletions
|
@ -63,7 +63,7 @@ public class OfferInfo implements Payload {
|
|||
private final long date;
|
||||
private final String state;
|
||||
private final boolean isActivated;
|
||||
private final boolean isMyOffer;
|
||||
private boolean isMyOffer;
|
||||
|
||||
public OfferInfo(OfferInfoBuilder builder) {
|
||||
this.id = builder.id;
|
||||
|
@ -93,13 +93,19 @@ public class OfferInfo implements Payload {
|
|||
this.isMyOffer = builder.isMyOffer;
|
||||
}
|
||||
|
||||
// Allow isMyOffer to be set on new offers' OfferInfo instances.
|
||||
public void setIsMyOffer(boolean myOffer) {
|
||||
isMyOffer = myOffer;
|
||||
}
|
||||
|
||||
public static OfferInfo toOfferInfo(Offer offer) {
|
||||
// Offer is not mine.
|
||||
// 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 getOfferInfoBuilder(offer, false).build();
|
||||
}
|
||||
|
||||
public static OfferInfo toOfferInfo(OpenOffer openOffer) {
|
||||
// OpenOffer is mine.
|
||||
// An OpenOffer is always my offer.
|
||||
return getOfferInfoBuilder(openOffer.getOffer(), true)
|
||||
.withTriggerPrice(openOffer.getTriggerPrice())
|
||||
.withIsActivated(!openOffer.isDeactivated())
|
||||
|
|
|
@ -92,11 +92,11 @@ public class TradeInfo implements Payload {
|
|||
this.contract = builder.contract;
|
||||
}
|
||||
|
||||
public static TradeInfo toTradeInfo(Trade trade) {
|
||||
return toTradeInfo(trade, null);
|
||||
public static TradeInfo toNewTradeInfo(Trade trade) {
|
||||
return toTradeInfo(trade, null, false);
|
||||
}
|
||||
|
||||
public static TradeInfo toTradeInfo(Trade trade, String role) {
|
||||
public static TradeInfo toTradeInfo(Trade trade, String role, boolean isMyOffer) {
|
||||
ContractInfo contractInfo;
|
||||
if (trade.getContract() != null) {
|
||||
Contract contract = trade.getContract();
|
||||
|
@ -116,8 +116,10 @@ public class TradeInfo implements Payload {
|
|||
contractInfo = ContractInfo.emptyContract.get();
|
||||
}
|
||||
|
||||
OfferInfo offerInfo = toOfferInfo(trade.getOffer());
|
||||
offerInfo.setIsMyOffer(isMyOffer);
|
||||
return new TradeInfoBuilder()
|
||||
.withOffer(toOfferInfo(trade.getOffer()))
|
||||
.withOffer(offerInfo)
|
||||
.withTradeId(trade.getId())
|
||||
.withShortId(trade.getShortId())
|
||||
.withDate(trade.getDate().getTime())
|
||||
|
|
Loading…
Add table
Reference in a new issue