mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
set trade role from utility class in api #1146
This commit is contained in:
parent
caaf9f7b5b
commit
7308206a10
@ -561,10 +561,6 @@ public class CoreApi {
|
||||
return coreTradesService.getTrades();
|
||||
}
|
||||
|
||||
public String getTradeRole(String tradeId) {
|
||||
return coreTradesService.getTradeRole(tradeId);
|
||||
}
|
||||
|
||||
public List<ChatMessage> getChatMessages(String tradeId) {
|
||||
return coreTradesService.getChatMessages(tradeId);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import haveno.common.Payload;
|
||||
import haveno.core.api.model.builder.TradeInfoV1Builder;
|
||||
import haveno.core.trade.Contract;
|
||||
import haveno.core.trade.Trade;
|
||||
import haveno.core.trade.TradeUtil;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -142,10 +143,7 @@ public class TradeInfo implements Payload {
|
||||
}
|
||||
|
||||
public static TradeInfo toTradeInfo(Trade trade) {
|
||||
return toTradeInfo(trade, null);
|
||||
}
|
||||
|
||||
public static TradeInfo toTradeInfo(Trade trade, String role) {
|
||||
String role = TradeUtil.getRole(trade);
|
||||
ContractInfo contractInfo;
|
||||
if (trade.getContract() != null) {
|
||||
Contract contract = trade.getContract();
|
||||
|
@ -172,7 +172,7 @@ public class TradeUtil {
|
||||
* @param trade Trade
|
||||
* @return String describing a trader's role for a given trade
|
||||
*/
|
||||
public String getRole(Trade trade) {
|
||||
public static String getRole(Trade trade) {
|
||||
Offer offer = trade.getOffer();
|
||||
if (offer == null)
|
||||
throw new IllegalStateException(format("could not get role because no offer was found for trade '%s'",
|
||||
@ -191,7 +191,7 @@ public class TradeUtil {
|
||||
* @param currencyCode String
|
||||
* @return String describing a trader's role
|
||||
*/
|
||||
public String getRole(boolean isBuyerMakerAndSellerTaker, boolean isMaker, String currencyCode) {
|
||||
private static String getRole(boolean isBuyerMakerAndSellerTaker, boolean isMaker, String currencyCode) {
|
||||
if (isTraditionalCurrency(currencyCode)) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
if (isBuyerMakerAndSellerTaker)
|
||||
|
@ -96,9 +96,8 @@ class GrpcTradesService extends TradesImplBase {
|
||||
StreamObserver<GetTradeReply> responseObserver) {
|
||||
try {
|
||||
Trade trade = coreApi.getTrade(req.getTradeId());
|
||||
String role = coreApi.getTradeRole(req.getTradeId());
|
||||
var reply = GetTradeReply.newBuilder()
|
||||
.setTrade(toTradeInfo(trade, role).toProtoMessage())
|
||||
.setTrade(toTradeInfo(trade).toProtoMessage())
|
||||
.build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
|
Loading…
Reference in New Issue
Block a user