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

Support for the new, optional diagnosticEventsXdr field on the SorobanServer.sendTransaction method. #564

Merged
merged 1 commit into from
Jan 13, 2024
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: 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
Loading