Skip to content

Commit

Permalink
Merge pull request #17 from CoboCustody/mpc_api
Browse files Browse the repository at this point in the history
update mpc api
  • Loading branch information
caixiao-QA authored Nov 17, 2022
2 parents 2ba2ea3 + 0060ca3 commit f62fdc1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface CoboMPCApiRestClient {
ApiResponse<MPCAddresses> getAddressList(String chainCode, int pageIndex, int pageLength, Integer sortFlag);
ApiResponse<MPCWalletAsset> getWalletAssetList(String address, String chainCode);
ApiResponse<Void> createTransaction(String coin, String requestId, String fromAddr, String toAddr, BigInteger amount);
ApiResponse<MPCTransactionInfo> getTransaction(String requestId, String txId);
ApiResponse<MPCTransactionInfo> getTransaction(String requestId);
ApiResponse<MPCTransactions> listWalletTransactions(String address, String coin,
String maxId, String minId,
Integer limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class MPCAssetCoinInfo {
private String coin;
@JsonProperty(value = "chain_coin")
private String chainCoin;
@JsonProperty(value = "chain_code")
private String chainCode;
@JsonProperty(value = "display_code")
private String displayCode;
private String description;
Expand All @@ -19,12 +19,12 @@ public void setCoin(String coin) {
this.coin = coin;
}

public String getChainCoin() {
return chainCoin;
public String getChainCode() {
return chainCode;
}

public void setChainCoin(String chainCoin) {
this.chainCoin = chainCoin;
public void setChainCode(String chainCode) {
this.chainCode = chainCode;
}

public String getDisplayCode() {
Expand Down Expand Up @@ -55,7 +55,7 @@ public void setAmount(Long amount) {
public String toString() {
return "{" +
"coin='" + coin + '\'' +
", chain_coin='" + chainCoin + '\'' +
", chain_code='" + chainCode + '\'' +
", display_code='" + displayCode + '\'' +
", description='" + description + '\'' +
", amount='" + amount + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

public class MPCTransaction {
private String id;
private Long time;
@JsonProperty(value = "create_time")
private Long createTime;
private Integer status;
@JsonProperty(value = "chain_coin")
@JsonProperty(value = "chain_code")
private String chainCode;
private String coin;
private List<Web3Token> tokens;
Expand All @@ -21,12 +22,12 @@ public void setId(String id) {
this.id = id;
}

public Long getTime() {
return time;
public Long getCreateTime() {
return createTime;
}

public void setTime(Long time) {
this.time = time;
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}

public Integer getStatus() {
Expand Down Expand Up @@ -65,11 +66,11 @@ public void setTokens(List<Web3Token> tokens) {
public String toString() {
return "{" +
"id='" + id + '\'' +
"time='" + time + '\'' +
"status='" + status + '\'' +
"chain_code='" + chainCode + '\'' +
"coin='" + coin + '\'' +
"tokens='" + tokens + '\'' +
", create_time='" + createTime + '\'' +
", status='" + status + '\'' +
", chain_code='" + chainCode + '\'' +
", coin='" + coin + '\'' +
", tokens='" + tokens + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void setAmount(Double amount) {
public String toString() {
return "{" +
"name='" + name + '\'' +
"amount='" + amount + '\'' +
", amount='" + amount + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public ApiResponse<Void> createTransaction(String coin, String requestId, String
}

@Override
public ApiResponse<MPCTransactionInfo> getTransaction(String requestId, String txId) {
return executeSync(coboMPCApiService.getTransaction(requestId, txId));
public ApiResponse<MPCTransactionInfo> getTransaction(String requestId) {
return executeSync(coboMPCApiService.getTransaction(requestId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ Call<ApiResponse<Void>> createTransaction(@Field("coin") String coin,
@Field("amount") BigInteger amount);

@GET("/v1/custody/mpc/transaction_info/")
Call<ApiResponse<MPCTransactionInfo>> getTransaction(@Query("request_id") String requestId,
@Query("tx_id") String txId);
Call<ApiResponse<MPCTransactionInfo>> getTransaction(@Query("request_id") String requestId);

@GET("/v1/custody/mpc/list_transactions/")
Call<ApiResponse<MPCTransactions>> listWalletTransactions(@Query("address") String address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ public void tearDown() {
@Test
public void testGetSupportedChains() {
ApiResponse<MPCChains> res = mpcClient.getSupportedChains();
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

@Test
public void testgetSupportedCoins() {
String chainCode = "GETH";
ApiResponse<MPCCoins> res = mpcClient.getSupportedCoins(chainCode);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

@Test
public void testBatchNewAddress() {
String chainCode = "GETH";
int count = 10;
int count = 2;
ApiResponse<MPCAddresses> res = mpcClient.batchNewAddress(chainCode, count);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

Expand All @@ -68,7 +68,7 @@ public void testGetAddressList() {
int pageLength = 10;
Integer sortFlag = 0;
ApiResponse<MPCAddresses> res = mpcClient.getAddressList(chainCode, pageIndex, pageLength, sortFlag);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

Expand All @@ -77,7 +77,7 @@ public void testGetWalletAssetList() {
String address = "0x4897e732734a7b4265cf48201b0ad2adb06657ba";
String chainCode = "GETH";
ApiResponse<MPCWalletAsset> res = mpcClient.getWalletAssetList(address, chainCode);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

Expand All @@ -89,14 +89,15 @@ public void testCreateTransaction() {
String toAddr = "0xEEACb7a5e53600c144C0b9839A834bb4b39E540c";
BigInteger amount = new BigInteger("10");
ApiResponse<Void> res = mpcClient.createTransaction(coin, requestId, fromAddr, toAddr, amount);
System.out.println(requestId);
assertTrue(res.isSuccess());
}

@Test
public void testGetTransaction() {
String requestId = "1668492939032";
ApiResponse<MPCTransactionInfo> res = mpcClient.getTransaction(requestId, null);
System.out.println(res);
String requestId = "1668678820274";
ApiResponse<MPCTransactionInfo> res = mpcClient.getTransaction(requestId);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

Expand All @@ -109,7 +110,7 @@ public void testListWalletTransactions() {
int limit = 10;

ApiResponse<MPCTransactions> res = mpcClient.listWalletTransactions(address, coin, maxId, minId, limit);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}
}

0 comments on commit f62fdc1

Please sign in to comment.