Skip to content

Commit

Permalink
Merge pull request #51 from haofengjiang/main
Browse files Browse the repository at this point in the history
mpc api estimate fee add params
  • Loading branch information
AeReach authored Mar 13, 2023
2 parents a216f40 + 715df4c commit a49087b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.cobo.custody.api.client.domain.account.*;
import com.cobo.custody.api.client.domain.transaction.*;

import java.math.BigDecimal;
import java.math.BigInteger;

public interface CoboMPCApiRestClient {
Expand All @@ -28,12 +29,12 @@ public interface CoboMPCApiRestClient {
ApiResponse<MPCListSpendable> listSpendable(String coin, String address);

ApiResponse<MPCPostTransaction> createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount,
String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit,
String toAddressDetails, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit,
Integer operation, String extraParameters);

ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);
ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit);

ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit);
ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit);

ApiResponse<MPCTransactionInfos> transactionsByRequestIds(String requestIds, Integer status);

Expand All @@ -42,10 +43,13 @@ ApiResponse<MPCPostTransaction> createTransaction(String coin, String requestId,
ApiResponse<MPCTransactionInfos> transactionsByTxhash(String txId, Integer transactionType);

ApiResponse<MPCTransactions> listTransactions(Long startTime, Long endTime, Integer status, String orderBy, String order,
Integer transactionType, String coins, String fromAddr, String toAddr,
Integer limit);
Integer transactionType, String coins, String fromAddr, String toAddr,
Integer limit);

ApiResponse<EstimateFeeDetails> estimateFee(String coin, BigInteger amount, String address, String replaceCoboId);
ApiResponse<EstimateFeeDetails> estimateFee(String coin, BigInteger amount, String address, String replaceCoboId,
String fromAddress, String toAddressDetails,
BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit,
String extraParameters);

ApiResponse<MPCTssNodeRequests> listTssNodeRequests(Integer requestType, Integer status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigDecimal;
import java.math.BigInteger;

public class MPCFee {
Expand All @@ -14,6 +15,9 @@ public class MPCFee {
@JsonProperty(value = "fee_used")
private String feeUsed;

@JsonProperty(value = "fee")
private BigDecimal fee;

public MPCCoin getFeeCoinDetail() {
return feeCoinDetail;
}
Expand Down Expand Up @@ -46,13 +50,22 @@ public void setFeeUsed(String feeUsed) {
this.feeUsed = feeUsed;
}

public BigDecimal getFee() {
return fee;
}

public void setFee(BigDecimal fee) {
this.fee = fee;
}

@Override
public String toString() {
return "{" +
"feeCoinDetail='" + feeCoinDetail + '\'' +
", gasPrice='" + gasPrice + '\'' +
", gasLimit='" + gasLimit + '\'' +
", feeUsed='" + feeUsed + '\'' +
", fee='" + fee + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.cobo.custody.api.client.domain.account.*;
import com.cobo.custody.api.client.domain.transaction.*;

import java.math.BigDecimal;
import java.math.BigInteger;

import static com.cobo.custody.api.client.impl.CoboApiServiceGenerator.createService;
Expand Down Expand Up @@ -68,19 +69,19 @@ public ApiResponse<MPCListSpendable> listSpendable(String coin, String address)

@Override
public ApiResponse<MPCPostTransaction> createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount,
String toAddressDetails, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit,
String toAddressDetails, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit,
Integer operation, String extraParameters) {
return executeSync(coboMPCApiService.createTransaction(coin, requestId, fromAddr, toAddr, amount,
toAddressDetails, fee, gasPrice, gasLimit, operation, extraParameters));
}

@Override
public ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
public ApiResponse<MPCPostTransaction> speedUpTransaction(String coboId, String requestId, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.speedUpTransaction(coboId, requestId, fee, gasPrice, gasLimit));
}

@Override
public ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigInteger fee, BigInteger gasPrice, BigInteger gasLimit) {
public ApiResponse<MPCPostTransaction> dropTransaction(String coboId, String requestId, BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit) {
return executeSync(coboMPCApiService.dropTransaction(coboId, requestId, fee, gasPrice, gasLimit));
}

Expand Down Expand Up @@ -108,8 +109,12 @@ public ApiResponse<MPCTransactions> listTransactions(Long startTime, Long endTim
}

@Override
public ApiResponse<EstimateFeeDetails> estimateFee(String coin, BigInteger amount, String address, String replaceCoboId) {
return executeSync(coboMPCApiService.estimateFee(coin, amount, address, replaceCoboId));
public ApiResponse<EstimateFeeDetails> estimateFee(String coin, BigInteger amount, String address, String replaceCoboId,
String fromAddress, String toAddressDetails,
BigDecimal fee, BigInteger gasPrice, BigInteger gasLimit,
String extraParameters) {
return executeSync(coboMPCApiService.estimateFee(coin, amount, address, replaceCoboId, fromAddress, toAddressDetails,
fee, gasPrice, gasLimit, extraParameters));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import retrofit2.Call;
import retrofit2.http.*;

import java.math.BigDecimal;
import java.math.BigInteger;

public interface CoboMPCApiService {
Expand Down Expand Up @@ -59,7 +60,7 @@ Call<ApiResponse<MPCPostTransaction>> createTransaction(@Field("coin") String co
@Field("to_address") String toAddr,
@Field("amount") BigInteger amount,
@Field("to_address_details") String toAddressDetails,
@Field("fee") BigInteger fee,
@Field("fee") BigDecimal fee,
@Field("gas_price") BigInteger gasPrice,
@Field("gas_limit") BigInteger gasLimit,
@Field("operation") Integer operation,
Expand All @@ -69,15 +70,15 @@ Call<ApiResponse<MPCPostTransaction>> createTransaction(@Field("coin") String co
@POST("/v1/custody/mpc/speedup_transaction/")
Call<ApiResponse<MPCPostTransaction>> speedUpTransaction(@Field("cobo_id") String coboId,
@Field("request_id") String requestId,
@Field("fee") BigInteger fee,
@Field("fee") BigDecimal fee,
@Field("gas_price") BigInteger gasPrice,
@Field("gas_limit") BigInteger gasLimit);

@FormUrlEncoded
@POST("/v1/custody/mpc/drop_transaction/")
Call<ApiResponse<MPCPostTransaction>> dropTransaction(@Field("cobo_id") String coboId,
@Field("request_id") String requestId,
@Field("fee") BigInteger fee,
@Field("fee") BigDecimal fee,
@Field("gas_price") BigInteger gasPrice,
@Field("gas_limit") BigInteger gasLimit);

Expand Down Expand Up @@ -109,7 +110,13 @@ Call<ApiResponse<MPCTransactions>> listTransactions(@Query("start_time") Long st
Call<ApiResponse<EstimateFeeDetails>> estimateFee(@Query("coin") String coin,
@Query("amount") BigInteger amount,
@Query("address") String address,
@Query("replace_cobo_id") String replaceCoboId);
@Query("replace_cobo_id") String replaceCoboId,
@Query("from_address") String fromAddress,
@Query("to_address_details") String toAddressDetails,
@Query("fee") BigDecimal fee,
@Query("gas_price") BigInteger gasPrice,
@Query("gas_limit") BigInteger gasLimit,
@Query("extra_parameters") String extraParameters);

@GET("/v1/custody/mpc/list_tss_node_requests/")
Call<ApiResponse<MPCTssNodeRequests>> listTssNodeRequests(@Query("request_type") Integer requestType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.math.BigInteger;

import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void testCreateTransaction() {
String toAddr = "0xEEACb7a5e53600c144C0b9839A834bb4b39E540c";
BigInteger amount = new BigInteger("10");
String toAddressDetails = null;
BigInteger fee = null;
BigDecimal fee = null;
BigInteger gasPrice = null;
BigInteger gasLimit = null;
Integer operation = null;
Expand Down Expand Up @@ -184,7 +185,8 @@ public void testEstimateFee() {
String coin = "GETH";
BigInteger amount = new BigInteger("10000");
String address = "0xEEACb7a5e53600c144C0b9839A834bb4b39E540c";
ApiResponse<EstimateFeeDetails> res = mpcClient.estimateFee(coin, amount, address, null);
ApiResponse<EstimateFeeDetails> res = mpcClient.estimateFee(coin, amount, address, null,
null, null, null, null, null, null);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}
Expand Down

0 comments on commit a49087b

Please sign in to comment.