diff --git a/CHANGELOG.md b/CHANGELOG.md index 79f59f26e..0534e71d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - This applies to `submit`, `signAndSubmit`, `restoreFootprint`, and therefore to `ContractClient.invoke` when it submits. - fix: always encode text as UTF-8 in `Scv.toString(String)`, `Sep10Challenge` (`web_auth_domain` / `client_domain`), `Util.paddedByteArray(String, int)`, and the `SorobanServer` request body. They used the JVM default charset, so non-ASCII text produced different bytes on JVMs where that is not UTF-8. - chore: upgrade generated XDR definitions to Protocol 30. +- refactor: deprecate `GetEventsResponse.EventInfo.inSuccessfulContractCall`. Stellar RPC no longer returns it from `getEvents` ([stellar-rpc#1050](https://github.com/stellar/stellar-rpc/pull/1050)), so it is `null` with newer servers. It will be removed in the next major release. ## 5.0.0 diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetEventsResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetEventsResponse.java index 3ad85538c..2504c9879 100644 --- a/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetEventsResponse.java +++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetEventsResponse.java @@ -51,8 +51,14 @@ public static class EventInfo { /** The field can be parsed as {@link org.stellar.sdk.xdr.SCVal} object. */ String value; - /** The field will be removed in the next version. */ - Boolean inSuccessfulContractCall; + /** + * Whether the event was emitted during a successful contract call. + * + * @deprecated Stellar RPC no longer returns this field from {@code getEvents} (stellar-rpc#1050), so it is + * {@code null} with newer servers. It will be removed in the next major release. + */ + @Deprecated Boolean inSuccessfulContractCall; /** * Parses the {@code topic} field from a list of strings to a list of {@link diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java index bd28cc3a5..b8b56df23 100644 --- a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import com.google.gson.reflect.TypeToken; import java.io.IOException; @@ -56,4 +57,24 @@ public void testDeserialize() throws IOException { GetEventsResponse.EventInfo eventInfo2 = getEventsResponse.getResult().getEvents().get(2); assertEquals(eventInfo2.getType(), EventFilterType.DIAGNOSTIC); } + + @Test + public void testDeserializeWithoutInSuccessfulContractCall() { + // Stellar RPC no longer returns inSuccessfulContractCall (stellar-rpc#1050). + String json = + "{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"result\":{\"latestLedger\":100," + + "\"cursor\":\"0000000463856472064-0000000000\",\"events\":[{\"type\":\"contract\"," + + "\"ledger\":108,\"ledgerClosedAt\":\"2023-07-23T14:47:01Z\"," + + "\"contractId\":\"CBQHNAXSI55GX2GN6D67GK7BHVPSLJUGZQEU7WJ5LKR5PNUCGLIMAO4K\"," + + "\"id\":\"0000000463856472064-0000000000\",\"topic\":[\"AAAADwAAAAdDT1VOVEVSAA==\"]," + + "\"value\":\"AAAAAwAAAAE=\",\"txHash\":" + + "\"db86e94aa98b7d38213c041ebbb727fbaabf0b7c435de594f36c2d51fc61926d\"}]}}"; + + SorobanRpcResponse getEventsResponse = + GsonSingleton.getInstance() + .fromJson(json, new TypeToken>() {}.getType()); + GetEventsResponse.EventInfo eventInfo = getEventsResponse.getResult().getEvents().get(0); + assertEquals(eventInfo.getValue(), "AAAAAwAAAAE="); + assertNull(eventInfo.getInSuccessfulContractCall()); + } }