From 2d6ce7bf99d69bfa85bb508e3e252232913c00a3 Mon Sep 17 00:00:00 2001 From: xiaqingchuan Date: Sun, 5 Feb 2023 22:04:38 +0800 Subject: [PATCH 1/4] feat: get tx auth signer --- .../java/io/sui/QueryClientImplIntTests.java | 17 +++++++++++++++++ src/main/java/io/sui/clients/QueryClient.java | 8 ++++++++ .../java/io/sui/clients/QueryClientImpl.java | 9 +++++++++ 3 files changed, 34 insertions(+) diff --git a/src/integrationTest/java/io/sui/QueryClientImplIntTests.java b/src/integrationTest/java/io/sui/QueryClientImplIntTests.java index 9490353..d4c457f 100644 --- a/src/integrationTest/java/io/sui/QueryClientImplIntTests.java +++ b/src/integrationTest/java/io/sui/QueryClientImplIntTests.java @@ -331,6 +331,23 @@ void getTransaction() throws ExecutionException, InterruptedException { // "0xb5e91320d3acc77b4d9e66a218031441b2be1bb3", moveEvent.getFields().get("object_id")); } + @Test + @DisplayName("Test getTransactionAuthSigners.") + void getTransactionAuthSigners() throws ExecutionException, InterruptedException { + CompletableFuture res = + client.getTransaction("49rpBTf2KUkf4aroydtZGAb5rsLGYoutoEPowNu3962q"); + CompletableFuture future = new CompletableFuture<>(); + res.whenComplete( + (transactionResponse, throwable) -> { + if (throwable != null) { + future.complete(throwable); + } else { + future.complete(transactionResponse); + } + }); + System.out.println(future.get()); + } + /** * Gets transactions in range. * diff --git a/src/main/java/io/sui/clients/QueryClient.java b/src/main/java/io/sui/clients/QueryClient.java index 1b5328d..b0d1057 100644 --- a/src/main/java/io/sui/clients/QueryClient.java +++ b/src/main/java/io/sui/clients/QueryClient.java @@ -97,6 +97,14 @@ public interface QueryClient { */ CompletableFuture getTransaction(String digest); + /** + * Return the authority public keys that commits to the authority signature of the transaction. + * + * @param transactionDigest the digest + * @return the Transaction auth signers + */ + CompletableFuture getTransactionAuthSigners(String transactionDigest); + /** * Gets transactions in range. * diff --git a/src/main/java/io/sui/clients/QueryClientImpl.java b/src/main/java/io/sui/clients/QueryClientImpl.java index 799ab50..a029eec 100644 --- a/src/main/java/io/sui/clients/QueryClientImpl.java +++ b/src/main/java/io/sui/clients/QueryClientImpl.java @@ -123,6 +123,15 @@ public CompletableFuture getTransaction(String digest) { "/sui_getTransaction", request, new TypeToken() {}.getType()); } + @Override + public CompletableFuture getTransactionAuthSigners(String transactionDigest) { + final JsonRpc20Request request = + this.jsonRpcClientProvider.createJsonRpc20Request( + "sui_getTransactionAuthSigners", Lists.newArrayList(transactionDigest)); + return this.jsonRpcClientProvider.callAndUnwrapResponse( + "/sui_getTransactionAuthSigners", request, new TypeToken() {}.getType()); + } + @Override public CompletableFuture> getTransactionsInRange(Long start, Long end) { final JsonRpc20Request request = From 2f749556358e44cda468aa484ea950a455657e4b Mon Sep 17 00:00:00 2001 From: xiaqingchuan Date: Wed, 8 Feb 2023 22:59:29 +0800 Subject: [PATCH 2/4] feat: mock data --- .../resources/mockdata/getAllBalances.json | 13 +++ src/test/resources/mockdata/getAllCoins.json | 36 ++++++++ src/test/resources/mockdata/getBalance.json | 11 +++ src/test/resources/mockdata/getCoins.json | 27 ++++++ .../mockdata/getTransactionAuthSigners.json | 83 +++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 src/test/resources/mockdata/getAllBalances.json create mode 100644 src/test/resources/mockdata/getAllCoins.json create mode 100644 src/test/resources/mockdata/getBalance.json create mode 100644 src/test/resources/mockdata/getCoins.json create mode 100644 src/test/resources/mockdata/getTransactionAuthSigners.json diff --git a/src/test/resources/mockdata/getAllBalances.json b/src/test/resources/mockdata/getAllBalances.json new file mode 100644 index 0000000..1115ff0 --- /dev/null +++ b/src/test/resources/mockdata/getAllBalances.json @@ -0,0 +1,13 @@ +{ + "jsonrpc":"2.0", + "result":[ + { + "coinType":"0x2::sui::SUI", + "coinObjectCount":3, + "totalBalance":299999999996450, + "lockedBalance":{ + } + } + ], + "id":1 +} diff --git a/src/test/resources/mockdata/getAllCoins.json b/src/test/resources/mockdata/getAllCoins.json new file mode 100644 index 0000000..80481cd --- /dev/null +++ b/src/test/resources/mockdata/getAllCoins.json @@ -0,0 +1,36 @@ +{ + "jsonrpc":"2.0", + "result":{ + "data":[ + { + "coinType":"0x2::sui::SUI", + "coinObjectId":"0x8cddb48cd184bfa3ac9b49de0c84041564900610", + "version":13, + "digest":"fKj1urWomKDVzv3Lw7gVk9NqEzjQlyl6aooP347f134=", + "balance":99999999996613, + "lockedUntilEpoch":null, + "previousTransaction":"BhCuUYDMMP3c1HrF6fUhRHzFHMmzBooFdxrZbLcGRgXX" + }, + { + "coinType":"0x2::sui::SUI", + "coinObjectId":"0xdf33ade37ae4bab4888c4e0490b773bce8e7c970", + "version":8, + "digest":"NkGa/Td7AWmmG8uCWmHEutojwfl3rle0bJgks1OIpHg=", + "balance":99999999999837, + "lockedUntilEpoch":null, + "previousTransaction":"GiQ2q8ZaATKMuR6RQz9fKso5LzgSKbpgGZ9Q8UB68sD2" + }, + { + "coinType":"0x2::sui::SUI", + "coinObjectId":"0xe488cb7a9ba10d8aa6a6f7d19658987081197360", + "version":1, + "digest":"orrj6PJjXYdmxtWmx/9Yo4TCczeXgWTJHUe6iKSQzEI=", + "balance":100000000000000, + "lockedUntilEpoch":null, + "previousTransaction":"J9n7MvcW6B5UjxoX1EHKHqsi53HzGPxjuEUJVURzyp4i" + } + ], + "nextCursor":null + }, + "id":1 +} diff --git a/src/test/resources/mockdata/getBalance.json b/src/test/resources/mockdata/getBalance.json new file mode 100644 index 0000000..8dad687 --- /dev/null +++ b/src/test/resources/mockdata/getBalance.json @@ -0,0 +1,11 @@ +{ + "jsonrpc":"2.0", + "result":{ + "coinType":"0x2::sui::SUI", + "coinObjectCount":3, + "totalBalance":299999999996450, + "lockedBalance":{ + } + }, + "id":1 +} diff --git a/src/test/resources/mockdata/getCoins.json b/src/test/resources/mockdata/getCoins.json new file mode 100644 index 0000000..b13e164 --- /dev/null +++ b/src/test/resources/mockdata/getCoins.json @@ -0,0 +1,27 @@ +{ + "jsonrpc":"2.0", + "result":{ + "data":[ + { + "coinType":"0x2::sui::SUI", + "coinObjectId":"0x8cddb48cd184bfa3ac9b49de0c84041564900610", + "version":13, + "digest":"fKj1urWomKDVzv3Lw7gVk9NqEzjQlyl6aooP347f134=", + "balance":99999999996613, + "lockedUntilEpoch":null, + "previousTransaction":"BhCuUYDMMP3c1HrF6fUhRHzFHMmzBooFdxrZbLcGRgXX" + }, + { + "coinType":"0x2::sui::SUI", + "coinObjectId":"0xdf33ade37ae4bab4888c4e0490b773bce8e7c970", + "version":8, + "digest":"NkGa/Td7AWmmG8uCWmHEutojwfl3rle0bJgks1OIpHg=", + "balance":99999999999837, + "lockedUntilEpoch":null, + "previousTransaction":"GiQ2q8ZaATKMuR6RQz9fKso5LzgSKbpgGZ9Q8UB68sD2" + } + ], + "nextCursor":null + }, + "id":1 +} diff --git a/src/test/resources/mockdata/getTransactionAuthSigners.json b/src/test/resources/mockdata/getTransactionAuthSigners.json new file mode 100644 index 0000000..879bf24 --- /dev/null +++ b/src/test/resources/mockdata/getTransactionAuthSigners.json @@ -0,0 +1,83 @@ +{ + "jsonrpc":"2.0", + "result":{ + "certificate":{ + "transactionDigest":"9tU1KNvA1WQTKGKQW73sFCivFfT6dpC3BC3bLj5XT8aj", + "data":{ + "transactions":[ + { + "ChangeEpoch":{ + "epoch":5, + "storage_charge":0, + "computation_charge":0 + } + } + ], + "sender":"0x0000000000000000000000000000000000000000", + "gasPayment":{ + "objectId":"0x0000000000000000000000000000000000000000", + "version":0, + "digest":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + }, + "gasPrice":1, + "gasBudget":0 + }, + "txSignature":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "authSignInfo":{ + "epoch":4, + "signature":"AYd9yzka6gSaqsd3rYQNHeW/d7v8gr+EmQFhACvUKt7rgcitBBqYuD0wySyHf6UZBw==", + "signers_map":[ + 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 16, 0, 0, 0, 0, 0, 2, 0, 3, 0 + ] + } + }, + "effects":{ + "status":{ + "status":"success" + }, + "gasUsed":{ + "computationCost":0, + "storageCost":0, + "storageRebate":0 + }, + "sharedObjects":[ + { + "objectId":"0x0000000000000000000000000000000000000005", + "version":5, + "digest":"E/NzJVvEDvUMJNhwP8mukq2PJIJjcNE+YJrSdTkqnms=" + } + ], + "transactionDigest":"9tU1KNvA1WQTKGKQW73sFCivFfT6dpC3BC3bLj5XT8aj", + "mutated":[ + { + "owner":{ + "Shared":{ + "initial_shared_version":1 + } + }, + "reference":{ + "objectId":"0x0000000000000000000000000000000000000005", + "version":6, + "digest":"bFzTlWud4Fyybulf8/z/l2NE4JAWuW+VV8iIcegl99U=" + } + } + ], + "gasObject":{ + "owner":{ + "AddressOwner":"0x0000000000000000000000000000000000000000" + }, + "reference":{ + "objectId":"0x0000000000000000000000000000000000000000", + "version":0, + "digest":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + } + }, + "dependencies":[ + "49rpBTf2KUkf4aroydtZGAb5rsLGYoutoEPowNu3962q" + ] + }, + "timestamp_ms":1675866483725, + "parsed_data":null + }, + "id":1 +} From 6edb993754b10f4fa6dd8a0fc0b5ba0f4d36503f Mon Sep 17 00:00:00 2001 From: xiaqingchuan Date: Wed, 8 Feb 2023 23:00:39 +0800 Subject: [PATCH 3/4] fix: paginated coins rename objectID to nextCursor --- .../java/io/sui/clients/QueryClientImpl.java | 7 +++++-- .../io/sui/models/objects/PaginatedCoins.java | 16 ++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/sui/clients/QueryClientImpl.java b/src/main/java/io/sui/clients/QueryClientImpl.java index a029eec..b4adc97 100644 --- a/src/main/java/io/sui/clients/QueryClientImpl.java +++ b/src/main/java/io/sui/clients/QueryClientImpl.java @@ -124,12 +124,15 @@ public CompletableFuture getTransaction(String digest) { } @Override - public CompletableFuture getTransactionAuthSigners(String transactionDigest) { + public CompletableFuture getTransactionAuthSigners( + String transactionDigest) { final JsonRpc20Request request = this.jsonRpcClientProvider.createJsonRpc20Request( "sui_getTransactionAuthSigners", Lists.newArrayList(transactionDigest)); return this.jsonRpcClientProvider.callAndUnwrapResponse( - "/sui_getTransactionAuthSigners", request, new TypeToken() {}.getType()); + "/sui_getTransactionAuthSigners", + request, + new TypeToken() {}.getType()); } @Override diff --git a/src/main/java/io/sui/models/objects/PaginatedCoins.java b/src/main/java/io/sui/models/objects/PaginatedCoins.java index 3a871a4..ab3e5c3 100644 --- a/src/main/java/io/sui/models/objects/PaginatedCoins.java +++ b/src/main/java/io/sui/models/objects/PaginatedCoins.java @@ -30,7 +30,7 @@ public class PaginatedCoins { private List data; - private String objectID; + private String nextCursor; public List getData() { return data; @@ -40,12 +40,12 @@ public void setData(List data) { this.data = data; } - public String getObjectID() { - return objectID; + public String getNextCursor() { + return nextCursor; } - public void setObjectID(String objectID) { - this.objectID = objectID; + public void getNextCursor(String nextCursor) { + this.nextCursor = nextCursor; } @Override @@ -57,16 +57,16 @@ public boolean equals(Object o) { return false; } PaginatedCoins that = (PaginatedCoins) o; - return Objects.equal(data, that.data) && Objects.equal(objectID, that.objectID); + return Objects.equal(data, that.data) && Objects.equal(nextCursor, that.nextCursor); } @Override public int hashCode() { - return Objects.hashCode(data, objectID); + return Objects.hashCode(data, nextCursor); } @Override public String toString() { - return "PaginatedCoins{" + "data=" + data + ", objectID=" + objectID + '}'; + return "PaginatedCoins{" + "data=" + data + ", nextCursor=" + nextCursor + '}'; } } From c18030e6cf4bfc00bd647eeb790b0b4180c2b9c6 Mon Sep 17 00:00:00 2001 From: thinkAfCod Date: Wed, 8 Feb 2023 15:03:45 +0000 Subject: [PATCH 4/4] commit badge --- .github/badges/jacoco.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/badges/jacoco.svg b/.github/badges/jacoco.svg index f755b10..cab99fd 100644 --- a/.github/badges/jacoco.svg +++ b/.github/badges/jacoco.svg @@ -1 +1 @@ -coverage33.2% \ No newline at end of file +coverage33% \ No newline at end of file