Skip to content

Commit

Permalink
Merge pull request #95 from haofengjiang/main
Browse files Browse the repository at this point in the history
mpc add address description update and get
  • Loading branch information
CoboZhu authored Oct 25, 2023
2 parents ef178a3 + e0a7f9e commit b1e84f0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface CoboMPCApiRestClient {

ApiResponse<MPCAddressList> generateAddresses(String chainCode, int count);

ApiResponse<MPCAddress> updateAddressDescription(String coin, String address, String description);

ApiResponse<MPCAddresses> listAddresses(String chainCode, String startId, String endId, Integer limit, Integer sort);

ApiResponse<MPCBalance> getBalance(String address, String chainCode, String coin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class MPCAddress {
private String hdPath;
private Integer encoding;

private String description;

public String getId() {
return id;
}
Expand Down Expand Up @@ -42,13 +44,22 @@ public void setEncoding(Integer encoding) {
this.encoding = encoding;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

@Override
public String toString() {
return "{" +
"id='" + id + '\'' +
", address='" + address + '\'' +
", hdPath='" + hdPath + '\'' +
", encoding='" + encoding + '\'' +
", description='" + description + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public ApiResponse<MPCAddressList> generateAddresses(String chainCode, int count
return executeSync(coboMPCApiService.generateAddresses(chainCode, count));
}

@Override
public ApiResponse<MPCAddress> updateAddressDescription(String coin, String address, String description) {
return executeSync(coboMPCApiService.updateAddressDescription(coin, address, description));
}

@Override
public ApiResponse<MPCAddresses> listAddresses(String chainCode, String startId, String endId, Integer limit, Integer sort) {
return executeSync(coboMPCApiService.listAddresses(chainCode, startId, endId, limit, sort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Call<ApiResponse<Boolean>> isValidAddress(@Query("coin") String coin,
Call<ApiResponse<MPCAddressList>> generateAddresses(@Field("chain_code") String chainCode,
@Field("count") int count);

@FormUrlEncoded
@POST("/v1/custody/mpc/update_address_description/")
Call<ApiResponse<MPCAddress>> updateAddressDescription(@Field("coin") String coin,
@Field("address") String address,
@Field("description") String description);

@GET("/v1/custody/mpc/list_addresses/")
Call<ApiResponse<MPCAddresses>> listAddresses(@Query("chain_code") String chainCode,
@Query("start_id") String startId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,22 @@ public void testGenerateAddresses() {
assertTrue(res.isSuccess());
}

@Test
public void testUpdateAddressDescription() {
String coin = "GETH";
String address = "0x3d514c74ac0747eb5b3f7c73459365ad4880f69a";
String description = "test";
ApiResponse<MPCAddress> res = mpcClient.updateAddressDescription(coin, address, description);
System.out.println(res);
System.out.println(res.getResult());
assertTrue(res.isSuccess());
}

@Test
public void testListAddresses() {
String chainCode = "GETH";
String startId = "1";
String endId = "100000";
String startId = "831317442287190282";
String endId = "831317442287190284";
int limit = 50;
int sort = 1;
ApiResponse<MPCAddresses> res = mpcClient.listAddresses(chainCode, startId, endId, limit, sort);
Expand Down

0 comments on commit b1e84f0

Please sign in to comment.