Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get tx auth signer #83

Merged
merged 4 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/integrationTest/java/io/sui/QueryClientImplIntTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransactionResponse> res =
client.getTransaction("49rpBTf2KUkf4aroydtZGAb5rsLGYoutoEPowNu3962q");
CompletableFuture<Object> 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.
*
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/sui/clients/QueryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public interface QueryClient {
*/
CompletableFuture<TransactionResponse> 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<TransactionResponse> getTransactionAuthSigners(String transactionDigest);

/**
* Gets transactions in range.
*
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/sui/clients/QueryClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ public CompletableFuture<TransactionResponse> getTransaction(String digest) {
"/sui_getTransaction", request, new TypeToken<TransactionResponse>() {}.getType());
}

@Override
public CompletableFuture<TransactionResponse> getTransactionAuthSigners(
String transactionDigest) {
final JsonRpc20Request request =
this.jsonRpcClientProvider.createJsonRpc20Request(
"sui_getTransactionAuthSigners", Lists.newArrayList(transactionDigest));
return this.jsonRpcClientProvider.callAndUnwrapResponse(
"/sui_getTransactionAuthSigners",
request,
new TypeToken<TransactionResponse>() {}.getType());
}

@Override
public CompletableFuture<List<String>> getTransactionsInRange(Long start, Long end) {
final JsonRpc20Request request =
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/sui/models/objects/PaginatedCoins.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PaginatedCoins {

private List<Coin> data;

private String objectID;
private String nextCursor;

public List<Coin> getData() {
return data;
Expand All @@ -40,12 +40,12 @@ public void setData(List<Coin> 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
Expand All @@ -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 + '}';
}
}
13 changes: 13 additions & 0 deletions src/test/resources/mockdata/getAllBalances.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"jsonrpc":"2.0",
"result":[
{
"coinType":"0x2::sui::SUI",
"coinObjectCount":3,
"totalBalance":299999999996450,
"lockedBalance":{
}
}
],
"id":1
}
36 changes: 36 additions & 0 deletions src/test/resources/mockdata/getAllCoins.json
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions src/test/resources/mockdata/getBalance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"jsonrpc":"2.0",
"result":{
"coinType":"0x2::sui::SUI",
"coinObjectCount":3,
"totalBalance":299999999996450,
"lockedBalance":{
}
},
"id":1
}
27 changes: 27 additions & 0 deletions src/test/resources/mockdata/getCoins.json
Original file line number Diff line number Diff line change
@@ -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
}
83 changes: 83 additions & 0 deletions src/test/resources/mockdata/getTransactionAuthSigners.json
Original file line number Diff line number Diff line change
@@ -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
}