mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-02 03:36:24 -04:00
provide trade start time, duration, and deadline in grpc api
This commit is contained in:
parent
384e771712
commit
75b8eb1dc9
4 changed files with 45 additions and 2 deletions
|
@ -99,6 +99,9 @@ public class TradeInfo implements Payload {
|
||||||
private final boolean isCompleted;
|
private final boolean isCompleted;
|
||||||
private final String contractAsJson;
|
private final String contractAsJson;
|
||||||
private final ContractInfo contract;
|
private final ContractInfo contract;
|
||||||
|
private final long startTime;
|
||||||
|
private final long maxDurationMs;
|
||||||
|
private final long deadlineTime;
|
||||||
|
|
||||||
public TradeInfo(TradeInfoV1Builder builder) {
|
public TradeInfo(TradeInfoV1Builder builder) {
|
||||||
this.offer = builder.getOffer();
|
this.offer = builder.getOffer();
|
||||||
|
@ -140,6 +143,9 @@ public class TradeInfo implements Payload {
|
||||||
this.isCompleted = builder.isCompleted();
|
this.isCompleted = builder.isCompleted();
|
||||||
this.contractAsJson = builder.getContractAsJson();
|
this.contractAsJson = builder.getContractAsJson();
|
||||||
this.contract = builder.getContract();
|
this.contract = builder.getContract();
|
||||||
|
this.startTime = builder.getStartTime();
|
||||||
|
this.maxDurationMs = builder.getMaxDurationMs();
|
||||||
|
this.deadlineTime = builder.getDeadlineTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TradeInfo toTradeInfo(Trade trade) {
|
public static TradeInfo toTradeInfo(Trade trade) {
|
||||||
|
@ -202,6 +208,9 @@ public class TradeInfo implements Payload {
|
||||||
.withContractAsJson(trade.getContractAsJson())
|
.withContractAsJson(trade.getContractAsJson())
|
||||||
.withContract(contractInfo)
|
.withContract(contractInfo)
|
||||||
.withOffer(toOfferInfo(trade.getOffer()))
|
.withOffer(toOfferInfo(trade.getOffer()))
|
||||||
|
.withStartTime(trade.getStartDate().getTime())
|
||||||
|
.withMaxDurationMs(trade.getMaxTradePeriod())
|
||||||
|
.withDeadlineTime(trade.getMaxTradePeriodDate().getTime())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +260,9 @@ public class TradeInfo implements Payload {
|
||||||
.setIsPayoutUnlocked(isPayoutUnlocked)
|
.setIsPayoutUnlocked(isPayoutUnlocked)
|
||||||
.setContractAsJson(contractAsJson == null ? "" : contractAsJson)
|
.setContractAsJson(contractAsJson == null ? "" : contractAsJson)
|
||||||
.setContract(contract.toProtoMessage())
|
.setContract(contract.toProtoMessage())
|
||||||
|
.setStartTime(startTime)
|
||||||
|
.setMaxDurationMs(maxDurationMs)
|
||||||
|
.setDeadlineTime(deadlineTime)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +307,9 @@ public class TradeInfo implements Payload {
|
||||||
.withIsPayoutUnlocked(proto.getIsPayoutUnlocked())
|
.withIsPayoutUnlocked(proto.getIsPayoutUnlocked())
|
||||||
.withContractAsJson(proto.getContractAsJson())
|
.withContractAsJson(proto.getContractAsJson())
|
||||||
.withContract((ContractInfo.fromProto(proto.getContract())))
|
.withContract((ContractInfo.fromProto(proto.getContract())))
|
||||||
|
.withStartTime(proto.getStartTime())
|
||||||
|
.withMaxDurationMs(proto.getMaxDurationMs())
|
||||||
|
.withDeadlineTime(proto.getDeadlineTime())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +354,9 @@ public class TradeInfo implements Payload {
|
||||||
", offer=" + offer + "\n" +
|
", offer=" + offer + "\n" +
|
||||||
", contractAsJson=" + contractAsJson + "\n" +
|
", contractAsJson=" + contractAsJson + "\n" +
|
||||||
", contract=" + contract + "\n" +
|
", contract=" + contract + "\n" +
|
||||||
|
", startTime=" + startTime + "\n" +
|
||||||
|
", maxDurationMs=" + maxDurationMs + "\n" +
|
||||||
|
", deadlineTime=" + deadlineTime + "\n" +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,9 @@ public final class TradeInfoV1Builder {
|
||||||
private String contractAsJson;
|
private String contractAsJson;
|
||||||
private ContractInfo contract;
|
private ContractInfo contract;
|
||||||
private String closingStatus;
|
private String closingStatus;
|
||||||
|
private long startTime;
|
||||||
|
private long maxDurationMs;
|
||||||
|
private long deadlineTime;
|
||||||
|
|
||||||
public TradeInfoV1Builder withOffer(OfferInfo offer) {
|
public TradeInfoV1Builder withOffer(OfferInfo offer) {
|
||||||
this.offer = offer;
|
this.offer = offer;
|
||||||
|
@ -284,6 +287,21 @@ public final class TradeInfoV1Builder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TradeInfoV1Builder withStartTime(long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TradeInfoV1Builder withMaxDurationMs(long maxDurationMs) {
|
||||||
|
this.maxDurationMs = maxDurationMs;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TradeInfoV1Builder withDeadlineTime(long deadlineTime) {
|
||||||
|
this.deadlineTime = deadlineTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TradeInfo build() {
|
public TradeInfo build() {
|
||||||
return new TradeInfo(this);
|
return new TradeInfo(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2153,6 +2153,10 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getMaxTradePeriod() {
|
||||||
|
return getOffer().getPaymentMethod().getMaxTradePeriod();
|
||||||
|
}
|
||||||
|
|
||||||
public Date getHalfTradePeriodDate() {
|
public Date getHalfTradePeriodDate() {
|
||||||
return new Date(getStartTime() + getMaxTradePeriod() / 2);
|
return new Date(getStartTime() + getMaxTradePeriod() / 2);
|
||||||
}
|
}
|
||||||
|
@ -2161,8 +2165,8 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
||||||
return new Date(getStartTime() + getMaxTradePeriod());
|
return new Date(getStartTime() + getMaxTradePeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getMaxTradePeriod() {
|
public Date getStartDate() {
|
||||||
return getOffer().getPaymentMethod().getMaxTradePeriod();
|
return new Date(getStartTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getStartTime() {
|
private long getStartTime() {
|
||||||
|
|
|
@ -908,6 +908,9 @@ message TradeInfo {
|
||||||
string maker_deposit_tx_id = 37;
|
string maker_deposit_tx_id = 37;
|
||||||
string taker_deposit_tx_id = 38;
|
string taker_deposit_tx_id = 38;
|
||||||
string payout_tx_id = 39;
|
string payout_tx_id = 39;
|
||||||
|
uint64 start_time = 40;
|
||||||
|
uint64 max_duration_ms = 41;
|
||||||
|
uint64 deadline_time = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ContractInfo {
|
message ContractInfo {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue