Skip to content

Commit

Permalink
Support for the new, optional diagnosticEventsXdr field on the `Sor…
Browse files Browse the repository at this point in the history
…obanServer.sendTransaction` method. (#564)
  • Loading branch information
overcat authored Jan 13, 2024
1 parent 97e0295 commit b71b106
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ As this project is pre 1.0, breaking changes may happen for minor version bumps.

### Update
* Support resource leeway parameter when simulating Soroban transactions. ([#561](https://github.com/stellar/java-stellar-sdk/pull/561))
* Support for the new, optional `diagnosticEventsXdr` field on the `SorobanServer.sendTransaction` method. ([#564](https://github.com/stellar/java-stellar-sdk/pull/564))

### Breaking changes
* The types of the following fields have changed. ([#560](https://github.com/stellar/java-stellar-sdk/pull/560))
| field | before | now |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ public class GetLedgerEntriesResponse {

@Value
public static class LedgerEntryResult {
/** The field can be parsed as {@link org.stellar.sdk.xdr.LedgerKey} object. */
String key;

/**
* The field can be parsed as {@link org.stellar.sdk.xdr.LedgerEntry.LedgerEntryData} object.
*/
String xdr;

@SerializedName("lastModifiedLedgerSeq")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public class GetTransactionResponse {

Boolean feeBump;

/** The field can be parsed as {@link org.stellar.sdk.xdr.TransactionEnvelope} object. */
String envelopeXdr;

/** The field can be parsed as {@link org.stellar.sdk.xdr.TransactionResult} object. */
String resultXdr;

/** The field can be parsed as {@link org.stellar.sdk.xdr.TransactionMeta} object. */
String resultMetaXdr;

Long ledger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.stellar.sdk.responses.sorobanrpc;

import java.util.List;
import lombok.Value;

/**
Expand All @@ -12,8 +13,12 @@
public class SendTransactionResponse {
SendTransactionStatus status;

/** The field can be parsed as {@link org.stellar.sdk.xdr.TransactionResult} object. */
String errorResultXdr;

/** The elements inside can be parsed as {@link org.stellar.sdk.xdr.DiagnosticEvent} objects. */
List<String> diagnosticEventsXdr;

String hash;

Long latestLedger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
public class SimulateTransactionResponse {
String error;

/** The field can be parsed as {@link org.stellar.sdk.xdr.SorobanTransactionData} object. */
String transactionData;

/** The elements inside can be parsed as {@link org.stellar.sdk.xdr.DiagnosticEvent} objects. */
List<String> events;

Long minResourceFee;
Expand All @@ -42,8 +44,14 @@ public class SimulateTransactionResponse {

@Value
public static class SimulateHostFunctionResult {

/**
* The elements inside can be parsed as {@link org.stellar.sdk.xdr.SorobanAuthorizationEntry}
* objects.
*/
List<String> auth;

/** The field can be parsed as {@link org.stellar.sdk.xdr.SCVal} object. */
String xdr;
}

Expand All @@ -58,6 +66,7 @@ public static class SimulateTransactionCost {

@Value
public static class RestorePreamble {
/** The field can be parsed as {@link org.stellar.sdk.xdr.SorobanTransactionData} object. */
String transactionData;

Long minResourceFee;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public void testDeserializeError() {
new TypeToken<SorobanRpcResponse<SendTransactionResponse>>() {}.getType());
SendTransactionResponse data = getTransactionResponse.getResult();
assertEquals(data.getErrorResultXdr(), "AAAAAAAAf67////6AAAAAA==");
assertEquals(data.getDiagnosticEventsXdr().size(), 1);
assertEquals(
data.getDiagnosticEventsXdr().get(0),
"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgr/p6gt6h8MrmSw+WNJnu3+sCP9dHXx7jR8IH0sG6Cy0AAAAPAAAABWhlbGxvAAAAAAAADwAAAAVBbG9oYQAAAA==");
assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.ERROR);
assertEquals(
data.getHash(), "3b0c982bb8245be869d34ec822f999deb68f3a8480cf6e663643cf2f6e397e64");
Expand All @@ -33,6 +37,7 @@ public void testDeserializePending() {
new TypeToken<SorobanRpcResponse<SendTransactionResponse>>() {}.getType());
SendTransactionResponse data = getTransactionResponse.getResult();
assertNull(data.getErrorResultXdr());
assertNull(data.getDiagnosticEventsXdr());
assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.PENDING);
assertEquals(
data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
Expand All @@ -49,6 +54,7 @@ public void testDeserializeDuplicate() {
new TypeToken<SorobanRpcResponse<SendTransactionResponse>>() {}.getType());
SendTransactionResponse data = getTransactionResponse.getResult();
assertNull(data.getErrorResultXdr());
assertNull(data.getDiagnosticEventsXdr());
assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.DUPLICATE);
assertEquals(
data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
Expand All @@ -65,6 +71,7 @@ public void testDeserializeTryAgainLater() {
new TypeToken<SorobanRpcResponse<SendTransactionResponse>>() {}.getType());
SendTransactionResponse data = getTransactionResponse.getResult();
assertNull(data.getErrorResultXdr());
assertNull(data.getDiagnosticEventsXdr());
assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.TRY_AGAIN_LATER);
assertEquals(
data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
Expand All @@ -78,6 +85,7 @@ public void testDeserializeTryAgainLater() {
+ " \"id\": \"b96311af98d54d7cbb8736dbb0ed7730\",\n"
+ " \"result\": {\n"
+ " \"errorResultXdr\": \"AAAAAAAAf67////6AAAAAA==\",\n"
+ " \"diagnosticEventsXdr\": [\"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgr/p6gt6h8MrmSw+WNJnu3+sCP9dHXx7jR8IH0sG6Cy0AAAAPAAAABWhlbGxvAAAAAAAADwAAAAVBbG9oYQAAAA==\"],"
+ " \"status\": \"ERROR\",\n"
+ " \"hash\": \"3b0c982bb8245be869d34ec822f999deb68f3a8480cf6e663643cf2f6e397e64\",\n"
+ " \"latestLedger\": \"62\",\n"
Expand Down

0 comments on commit b71b106

Please sign in to comment.