Skip to content

Commit

Permalink
feat: add txHash to GetTransactionResponse and `GetTransactionsRe…
Browse files Browse the repository at this point in the history
…sponse.Transaction`.
  • Loading branch information
overcat committed Oct 14, 2024
1 parent b3aa31e commit b1ecb74
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ continued engagement as we shape the future of this project together.
- refactor!: remove `amount` and `numAccounts` from `AssetResponse`.
- refactor!: remove `cost` from `SimulateTransactionResponse`, the correct resource costs can now be retrieved from the `transactionData`.
- refactor!: remove `pagingToken` from `GetEventsResponse.EventInfo`, use `GetEventsResponse.cursor` instead.
- feat: add `txHash` to `GetTransactionResponse` and `GetTransactionsResponse.Transaction`.

### Breaking changes
- refactor!: Refactored the handling of exceptions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
public class GetTransactionResponse {
GetTransactionStatus status;

String txHash;

Long latestLedger;

Long latestLedgerCloseTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GetTransactionsResponse {
@Value
public static class Transaction {
TransactionStatus status;
String txHash;
Integer applicationOrder;
Boolean feeBump;

Expand Down
12 changes: 11 additions & 1 deletion src/test/java/org/stellar/sdk/SorobanServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.stellar.sdk.responses.sorobanrpc.GetLatestLedgerResponse;
import org.stellar.sdk.responses.sorobanrpc.GetLedgerEntriesResponse;
import org.stellar.sdk.responses.sorobanrpc.GetNetworkResponse;
import org.stellar.sdk.responses.sorobanrpc.GetTransactionResponse;
import org.stellar.sdk.responses.sorobanrpc.GetTransactionsResponse;
import org.stellar.sdk.responses.sorobanrpc.GetVersionInfoResponse;
import org.stellar.sdk.responses.sorobanrpc.SendTransactionResponse;
Expand Down Expand Up @@ -500,7 +501,10 @@ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)

HttpUrl baseUrl = mockWebServer.url("");
SorobanServer server = new SorobanServer(baseUrl.toString());
server.getTransaction(hash);
GetTransactionResponse tx = server.getTransaction(hash);
assertEquals(tx.getStatus(), GetTransactionResponse.GetTransactionStatus.SUCCESS);
assertEquals(
tx.getTxHash(), "8faa3e6bb29d9d8469bbcabdbfd800f3be1899f4736a3a2fa83cd58617c072fe");

server.close();
mockWebServer.close();
Expand Down Expand Up @@ -552,6 +556,9 @@ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
assertEquals(
resp.getTransactions().get(0).getStatus(),
GetTransactionsResponse.TransactionStatus.FAILED);
assertEquals(
resp.getTransactions().get(0).getTxHash(),
"171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d");
assertEquals(resp.getTransactions().get(0).getApplicationOrder().longValue(), 1L);
assertEquals(resp.getTransactions().get(0).getFeeBump(), false);
assertEquals(
Expand All @@ -569,6 +576,9 @@ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
assertEquals(
resp.getTransactions().get(3).getStatus(),
GetTransactionsResponse.TransactionStatus.SUCCESS);
assertEquals(
resp.getTransactions().get(0).getTxHash(),
"171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d");
assertEquals(resp.getTransactions().get(3).getApplicationOrder().longValue(), 4L);
assertEquals(resp.getTransactions().get(3).getFeeBump(), false);
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public void testDeserializeSuccess() throws IOException {
assertEquals(
getTransactionResponse.getResult().getStatus(),
GetTransactionResponse.GetTransactionStatus.SUCCESS);
assertEquals(
getTransactionResponse.getResult().getTxHash(),
"171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d");
assertEquals(getTransactionResponse.getResult().getLatestLedger().longValue(), 79289L);
assertEquals(
getTransactionResponse.getResult().getLatestLedgerCloseTime().longValue(), 1690387240L);
Expand Down Expand Up @@ -66,6 +69,9 @@ public void testDeserializeFailed() throws IOException {
assertEquals(
getTransactionResponse.getResult().getStatus(),
GetTransactionResponse.GetTransactionStatus.FAILED);
assertEquals(
getTransactionResponse.getResult().getTxHash(),
"171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d");
assertEquals(getTransactionResponse.getResult().getLatestLedger().longValue(), 79289L);
assertEquals(
getTransactionResponse.getResult().getLatestLedgerCloseTime().longValue(), 1690387240L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public void testDeserialize() throws IOException {
assertEquals(
getTransactionsResponse.getTransactions().get(0).getStatus(),
GetTransactionsResponse.TransactionStatus.FAILED);
assertEquals(
getTransactionsResponse.getTransactions().get(0).getTxHash(),
"171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d");

assertEquals(
getTransactionsResponse.getTransactions().get(0).getApplicationOrder().longValue(), 1L);
assertEquals(getTransactionsResponse.getTransactions().get(0).getFeeBump(), false);
Expand All @@ -51,6 +55,9 @@ public void testDeserialize() throws IOException {
assertEquals(
getTransactionsResponse.getTransactions().get(3).getStatus(),
GetTransactionsResponse.TransactionStatus.SUCCESS);
assertEquals(
getTransactionsResponse.getTransactions().get(3).getTxHash(),
"8faa3e6bb29d9d8469bbcabdbfd800f3be1899f4736a3a2fa83cd58617c072fe");
assertEquals(
getTransactionsResponse.getTransactions().get(3).getApplicationOrder().longValue(), 4L);
assertEquals(getTransactionsResponse.getTransactions().get(3).getFeeBump(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"id": "198cb1a8-9104-4446-a269-88bf000c2721",
"result": {
"status": "FAILED",
"txHash": "171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d",
"latestLedger": "79289",
"latestLedgerCloseTime": "1690387240",
"oldestLedger": "77850",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"id": "198cb1a8-9104-4446-a269-88bf000c2721",
"result": {
"status": "SUCCESS",
"txHash": "171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d",
"latestLedger": "79289",
"latestLedgerCloseTime": "1690387240",
"oldestLedger": "77850",
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/responses/sorobanrpc/get_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"transactions": [
{
"status": "FAILED",
"txHash": "171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d",
"applicationOrder": 1,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACDz21Q3CTITlGqRus3/96/05EDivbtfJncNQKt64BTbAAAASwAAKkyAAXlMwAAAAEAAAAAAAAAAAAAAABmWeASAAAAAQAAABR3YWxsZXQ6MTcxMjkwNjMzNjUxMAAAAAEAAAABAAAAAIPPbVDcJMhOUapG6zf/3r/TkQOK9u18mdw1Aq3rgFNsAAAAAQAAAABwOSvou8mtwTtCkysVioO35TSgyRir2+WGqO8FShG/GAAAAAFVQUgAAAAAAO371tlrHUfK+AvmQvHje1jSUrvJb3y3wrJ7EplQeqTkAAAAAAX14QAAAAAAAAAAAeuAU2wAAABAn+6A+xXvMasptAm9BEJwf5Y9CLLQtV44TsNqS8ocPmn4n8Rtyb09SBiFoMv8isYgeQU5nAHsIwBNbEKCerusAQ==",
Expand All @@ -15,6 +16,7 @@
},
{
"status": "SUCCESS",
"txHash": "a3dd2e58b8f985647b0bd65141fd8274023bdd77ff280b94e89cdb26f88e121b",
"applicationOrder": 2,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAAC4EZup+ewCs/doS3hKbeAa4EviBHqAFYM09oHuLtqrGAAPQkAAGgQZAAAANgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAAAq6aHAHZ2sd9aPbRsskrlXMLWIwqs4Sv2Bk+VwuIR+9wAAABdIdugAAAAAAAAAAAIu2qsYAAAAQERzKOqYYiPXNwsiL8ADAG/f45RBssmf3umGzw4qKkLGlObuPdX0buWmTGrhI13SG38F2V8Mp9DI+eDkcCjMSAOGVuCcAAAAQHnm0o/r+Gsl+6oqBgSbqoSY37gflvQB3zZRghuir0N75UVerd0Q50yG5Zfu08i2crhx6uk+5HYTl8/Sa7uZ+Qc=",
Expand All @@ -25,6 +27,7 @@
},
{
"status": "SUCCESS",
"txHash": "782fe0b775dbf301ae952ff765db5987c69374efc47218c665d6df49b0a9d0e9",
"applicationOrder": 3,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACwtG/IRC5DZE1UdekijEsoQEPM/uOwZ3iY/Y8UZ3b9xAAPQkAAGgRHAAAANgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAADgdupKeB04lazKXCOb+E1JfxaM3tI4Xsb/qDa1MWOvXgAAABdIdugAAAAAAAAAAAJndv3EAAAAQKcTimw6KKcM0AeCMxXJcEK/hS9ROoj/qpMFppGNAr4W3ifSOSTGAFbA+cIVHmaV4p7xGcR+9JnUN1YjamvJZwSGVuCcAAAAQK9Cp775JbnYA793SXkkWWbmvnEFTiDPiFyTHxTphCwBDB1zqkXqGG6Q5O3dAyqkNJvj1XNRDsmY4pKV41qijQU=",
Expand All @@ -35,6 +38,7 @@
},
{
"status": "SUCCESS",
"txHash": "8faa3e6bb29d9d8469bbcabdbfd800f3be1899f4736a3a2fa83cd58617c072fe",
"applicationOrder": 4,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACxMt2gKYOehEoVbmh9vfvZ4mVzXFSNTbAU5S4a8zorrAA4wrwAHLqRAAAADAAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAAAAAAAAAAAALEy3aApg56EShVuaH29+9niZXNcVI1NsBTlLhrzOiusz3K+BVgRzXig/Bhz1TL5Qy+Ibv6cDvCfdaAtBMMFPcYAAAAAHXUVmJM11pdJSKKV52UJrVYlvxaPLmmg17nMe0HGy0MAAAABAAAAAAAAAAEAAAAAAAAAAAAAAACxMt2gKYOehEoVbmh9vfvZ4mVzXFSNTbAU5S4a8zorrM9yvgVYEc14oPwYc9Uy+UMviG7+nA7wn3WgLQTDBT3GAAAAAB11FZiTNdaXSUiiledlCa1WJb8Wjy5poNe5zHtBxstDAAAAAAAAAAEAAAAAAAAAAQAAAAcddRWYkzXWl0lIopXnZQmtViW/Fo8uaaDXucx7QcbLQwAAAAEAAAAGAAAAAbolCtTsMrJvK0M2SaskFsaMajj3iAZbXxELZHwDyE5dAAAAFAAAAAEABf2jAAAd1AAAAGgAAAAAADjCWAAAAAHzOiusAAAAQM+qaiMKxMoCVNjdRIh3X9CSxkjAm0BpXYDB9Fd+DS0guYKiY3TMaVe243UB008iBn5ynQv724rReXlg7iFqXQA=",
Expand Down Expand Up @@ -66,6 +70,7 @@
},
{
"status": "FAILED",
"txHash": "cd510e50d7f75c3b09c7d0cf4fdb1d37338d36c1287caf321f03f8980186b10c",
"applicationOrder": 1,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAAAxLMEcxmfUgNzL687Js4sX/jmFQDqTo1Lj4KDoC1PeSQAehIAAAAIJAAtMUQAAAAEAAAAAAAAAAAAAAABmWeAVAAAAAQAAAAlwc3BiOjMyMTcAAAAAAAACAAAAAQAAAACKlutUN5GT3UOoE2BUkNtJEwoipGOinBFsQtXgpIZMxQAAAAEAAAAA433o+yremWU3t88cKpfpHR+JMFR44JHzmBGni6hqCEYAAAACQVRVQUgAAAAAAAAAAAAAAGfK1mN4mg51jbX6by6TWghGynQ463doEDgzriqZo9bzAAAAAAaOd4AAAAABAAAAAIqW61Q3kZPdQ6gTYFSQ20kTCiKkY6KcEWxC1eCkhkzFAAAAAQAAAADjfej7Kt6ZZTe3zxwql+kdH4kwVHjgkfOYEaeLqGoIRgAAAAJBVFVTRAAAAAAAAAAAAAAAZ8rWY3iaDnWNtfpvLpNaCEbKdDjrd2gQODOuKpmj1vMAAAAAADh1IAAAAAAAAAACC1PeSQAAAEBoad/kqj/4Sqq5tC6HyeMm5LJKM1VqKRGZc3e4uvA3ITThwn2nNMRJRegdQrLrPBTSgw51nY8npilXVIds7I0OpIZMxQAAAEDTZNaLjIDMWPDdCxa1ZB28vUxTcS/0xykOFTI/JAz096vX6Y7wI0QvnbPM7KCoL0cJAciD+pJxNqXQ2Aff1hoO",
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/soroban_server/get_transaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"id": "198cb1a8-9104-4446-a269-88bf000c2721",
"result": {
"status": "SUCCESS",
"txHash": "8faa3e6bb29d9d8469bbcabdbfd800f3be1899f4736a3a2fa83cd58617c072fe",
"latestLedger": "79289",
"latestLedgerCloseTime": "1690387240",
"oldestLedger": "77850",
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/soroban_server/get_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"transactions": [
{
"status": "FAILED",
"txHash": "171359fff0edbf0a9d9d11014d0407486ff9f6a6e8f7673f97244acccb355b2d",
"applicationOrder": 1,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACDz21Q3CTITlGqRus3/96/05EDivbtfJncNQKt64BTbAAAASwAAKkyAAXlMwAAAAEAAAAAAAAAAAAAAABmWeASAAAAAQAAABR3YWxsZXQ6MTcxMjkwNjMzNjUxMAAAAAEAAAABAAAAAIPPbVDcJMhOUapG6zf/3r/TkQOK9u18mdw1Aq3rgFNsAAAAAQAAAABwOSvou8mtwTtCkysVioO35TSgyRir2+WGqO8FShG/GAAAAAFVQUgAAAAAAO371tlrHUfK+AvmQvHje1jSUrvJb3y3wrJ7EplQeqTkAAAAAAX14QAAAAAAAAAAAeuAU2wAAABAn+6A+xXvMasptAm9BEJwf5Y9CLLQtV44TsNqS8ocPmn4n8Rtyb09SBiFoMv8isYgeQU5nAHsIwBNbEKCerusAQ==",
Expand All @@ -15,6 +16,7 @@
},
{
"status": "SUCCESS",
"txHash": "a3dd2e58b8f985647b0bd65141fd8274023bdd77ff280b94e89cdb26f88e121b",
"applicationOrder": 2,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAAC4EZup+ewCs/doS3hKbeAa4EviBHqAFYM09oHuLtqrGAAPQkAAGgQZAAAANgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAAAq6aHAHZ2sd9aPbRsskrlXMLWIwqs4Sv2Bk+VwuIR+9wAAABdIdugAAAAAAAAAAAIu2qsYAAAAQERzKOqYYiPXNwsiL8ADAG/f45RBssmf3umGzw4qKkLGlObuPdX0buWmTGrhI13SG38F2V8Mp9DI+eDkcCjMSAOGVuCcAAAAQHnm0o/r+Gsl+6oqBgSbqoSY37gflvQB3zZRghuir0N75UVerd0Q50yG5Zfu08i2crhx6uk+5HYTl8/Sa7uZ+Qc=",
Expand All @@ -25,6 +27,7 @@
},
{
"status": "SUCCESS",
"txHash": "782fe0b775dbf301ae952ff765db5987c69374efc47218c665d6df49b0a9d0e9",
"applicationOrder": 3,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACwtG/IRC5DZE1UdekijEsoQEPM/uOwZ3iY/Y8UZ3b9xAAPQkAAGgRHAAAANgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAABB90WssODNIgi6BHveqzxTRmIpvAFRyVNM+Hm2GVuCcAAAAAAAAAADgdupKeB04lazKXCOb+E1JfxaM3tI4Xsb/qDa1MWOvXgAAABdIdugAAAAAAAAAAAJndv3EAAAAQKcTimw6KKcM0AeCMxXJcEK/hS9ROoj/qpMFppGNAr4W3ifSOSTGAFbA+cIVHmaV4p7xGcR+9JnUN1YjamvJZwSGVuCcAAAAQK9Cp775JbnYA793SXkkWWbmvnEFTiDPiFyTHxTphCwBDB1zqkXqGG6Q5O3dAyqkNJvj1XNRDsmY4pKV41qijQU=",
Expand All @@ -35,6 +38,7 @@
},
{
"status": "SUCCESS",
"txHash": "8faa3e6bb29d9d8469bbcabdbfd800f3be1899f4736a3a2fa83cd58617c072fe",
"applicationOrder": 4,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAACxMt2gKYOehEoVbmh9vfvZ4mVzXFSNTbAU5S4a8zorrAA4wrwAHLqRAAAADAAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAAAAAAAAAAAALEy3aApg56EShVuaH29+9niZXNcVI1NsBTlLhrzOiusz3K+BVgRzXig/Bhz1TL5Qy+Ibv6cDvCfdaAtBMMFPcYAAAAAHXUVmJM11pdJSKKV52UJrVYlvxaPLmmg17nMe0HGy0MAAAABAAAAAAAAAAEAAAAAAAAAAAAAAACxMt2gKYOehEoVbmh9vfvZ4mVzXFSNTbAU5S4a8zorrM9yvgVYEc14oPwYc9Uy+UMviG7+nA7wn3WgLQTDBT3GAAAAAB11FZiTNdaXSUiiledlCa1WJb8Wjy5poNe5zHtBxstDAAAAAAAAAAEAAAAAAAAAAQAAAAcddRWYkzXWl0lIopXnZQmtViW/Fo8uaaDXucx7QcbLQwAAAAEAAAAGAAAAAbolCtTsMrJvK0M2SaskFsaMajj3iAZbXxELZHwDyE5dAAAAFAAAAAEABf2jAAAd1AAAAGgAAAAAADjCWAAAAAHzOiusAAAAQM+qaiMKxMoCVNjdRIh3X9CSxkjAm0BpXYDB9Fd+DS0guYKiY3TMaVe243UB008iBn5ynQv724rReXlg7iFqXQA=",
Expand Down Expand Up @@ -66,6 +70,7 @@
},
{
"status": "FAILED",
"txHash": "cd510e50d7f75c3b09c7d0cf4fdb1d37338d36c1287caf321f03f8980186b10c",
"applicationOrder": 1,
"feeBump": false,
"envelopeXdr": "AAAAAgAAAAAxLMEcxmfUgNzL687Js4sX/jmFQDqTo1Lj4KDoC1PeSQAehIAAAAIJAAtMUQAAAAEAAAAAAAAAAAAAAABmWeAVAAAAAQAAAAlwc3BiOjMyMTcAAAAAAAACAAAAAQAAAACKlutUN5GT3UOoE2BUkNtJEwoipGOinBFsQtXgpIZMxQAAAAEAAAAA433o+yremWU3t88cKpfpHR+JMFR44JHzmBGni6hqCEYAAAACQVRVQUgAAAAAAAAAAAAAAGfK1mN4mg51jbX6by6TWghGynQ463doEDgzriqZo9bzAAAAAAaOd4AAAAABAAAAAIqW61Q3kZPdQ6gTYFSQ20kTCiKkY6KcEWxC1eCkhkzFAAAAAQAAAADjfej7Kt6ZZTe3zxwql+kdH4kwVHjgkfOYEaeLqGoIRgAAAAJBVFVTRAAAAAAAAAAAAAAAZ8rWY3iaDnWNtfpvLpNaCEbKdDjrd2gQODOuKpmj1vMAAAAAADh1IAAAAAAAAAACC1PeSQAAAEBoad/kqj/4Sqq5tC6HyeMm5LJKM1VqKRGZc3e4uvA3ITThwn2nNMRJRegdQrLrPBTSgw51nY8npilXVIds7I0OpIZMxQAAAEDTZNaLjIDMWPDdCxa1ZB28vUxTcS/0xykOFTI/JAz096vX6Y7wI0QvnbPM7KCoL0cJAciD+pJxNqXQ2Aff1hoO",
Expand Down

0 comments on commit b1ecb74

Please sign in to comment.