From 9c4dfd2ac605dd78acbf363a97b2c1018730fdc8 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 29 Oct 2024 12:44:16 -0400 Subject: [PATCH 01/10] Serialize non-absent AccountSet `domain` values (#564) serialize empty string AccountSet.domain --- .../xrpl4j/model/transactions/AccountSet.java | 3 + .../binary/BinarySerializationTests.java | 30 +++++++ .../json/AccountSetJsonTests.java | 82 +++++++++++++++++++ .../org/xrpl/xrpl4j/tests/AccountSetIT.java | 66 +++++++++++++++ 4 files changed, 181 insertions(+) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java index be1af6b7a..800ee3e78 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java @@ -22,6 +22,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -261,6 +263,7 @@ default AccountSet normalizeSetFlag() { * @return An {@link Optional} of type {@link String} containing the domain. */ @JsonProperty("Domain") + @JsonInclude(Include.NON_ABSENT) Optional domain(); /** diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java index 524737872..7e9ebd316 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java @@ -136,6 +136,36 @@ public void serializeAccountSetTransactionWithNetworkId() throws JsonProcessingE assertSerializesAndDeserializes(accountSet, expectedBinary); } + @Test + public void serializeAccountSetTransactionWithDomain() throws JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(10598)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) + .domain("ABCD") + .build(); + + String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A73007702ABCD81140F3D0C7D2CFAB2EC8" + + "295451F0B3CA038E8E9CDCD"; + assertSerializesAndDeserializes(accountSet, expectedBinary); + } + + @Test + public void serializeAccountSetTransactionWithEmptyStringDomain() throws JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(10598)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) + .domain("") + .build(); + + String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A7300770081140F3D0C7D2CFAB2EC829545" + + "1F0B3CA038E8E9CDCD"; + assertSerializesAndDeserializes(accountSet, expectedBinary); + } + @Test public void serializeAccountSetTransactionWithEmptyFlags() throws JsonProcessingException { AccountSet accountSet = AccountSet.builder() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java index 6f6447209..9487cc2fd 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java @@ -80,6 +80,88 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep assertCanSerializeAndDeserialize(accountSet, json); } + @Test + public void accountSetWithEmptyDomain() throws JSONException, JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(5)) + .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .transferRate(UnsignedInteger.valueOf(1000000001)) + .tickSize(UnsignedInteger.valueOf(15)) + .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) + .emailHash("f9879d71855b5ff21e4963273a886bfc") + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) + .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .networkId(NetworkId.of(1024)) + .build(); + + String json = "{\n" + + " \"TransactionType\":\"AccountSet\",\n" + + " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\":\"12\",\n" + + " \"Sequence\":5,\n" + + " \"Flags\":2147483648,\n" + + " \"SetFlag\":5,\n" + + " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + + " \"TransferRate\":1000000001,\n" + + " \"TickSize\":15,\n" + + " \"ClearFlag\":8,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"NetworkID\": 1024,\n" + + " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + "}"; + + assertCanSerializeAndDeserialize(accountSet, json); + } + + @Test + public void accountSetWithEmptyStringDomain() throws JSONException, JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .domain("") + .sequence(UnsignedInteger.valueOf(5)) + .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .transferRate(UnsignedInteger.valueOf(1000000001)) + .tickSize(UnsignedInteger.valueOf(15)) + .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) + .emailHash("f9879d71855b5ff21e4963273a886bfc") + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) + .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .networkId(NetworkId.of(1024)) + .build(); + + String json = "{\n" + + " \"TransactionType\":\"AccountSet\",\n" + + " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\":\"12\",\n" + + " \"Sequence\":5,\n" + + " \"Flags\":2147483648,\n" + + " \"Domain\":\"\",\n" + + " \"SetFlag\":5,\n" + + " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + + " \"TransferRate\":1000000001,\n" + + " \"TickSize\":15,\n" + + " \"ClearFlag\":8,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"NetworkID\": 1024,\n" + + " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + "}"; + + assertCanSerializeAndDeserialize(accountSet, json); + } + @Test public void testJsonWithUnsetFlags() throws JsonProcessingException, JSONException { AccountSet accountSet = AccountSet.builder() diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java index 18e2e9378..582e3892f 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java @@ -392,6 +392,72 @@ void submitAndRetrieveAccountSetWithZeroClearFlagAndSetFlag() assertThat(accountSetTransactionResult.transaction().clearFlag()).isNotEmpty().get().isEqualTo(AccountSetFlag.NONE); } + @Test + void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingException { + KeyPair keyPair = constructRandomAccount(); + + /////////////////////// + // Get validated account info and validate account state + AccountInfoResult accountInfo = this.scanForResult( + () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) + ); + + FeeResult feeResult = xrplClient.fee(); + AccountSet setDomain = AccountSet.builder() + .account(keyPair.publicKey().deriveAddress()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .sequence(accountInfo.accountData().sequence()) + .signingPublicKey(keyPair.publicKey()) + .domain("ABCD") + .build(); + + SingleSignedTransaction signedSetDomain = signatureService.sign( + keyPair.privateKey(), setDomain + ); + SubmitResult response = xrplClient.submit(signedSetDomain); + + assertThat(response.engineResult()).isEqualTo("tesSUCCESS"); + assertThat(signedSetDomain.hash()).isEqualTo(response.transactionResult().hash()); + logger.info( + "AccountSet transaction successful: https://testnet.xrpl.org/transactions/" + response.transactionResult().hash() + ); + + this.scanForResult(() -> + this.getValidatedTransaction(signedSetDomain.hash(), AccountSet.class) + ); + accountInfo = this.scanForResult( + () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) + ); + assertThat(accountInfo.accountData().domain()).isNotEmpty().isEqualTo(setDomain.domain()); + + AccountSet clearDomain = AccountSet.builder() + .account(keyPair.publicKey().deriveAddress()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .sequence(accountInfo.accountData().sequence()) + .signingPublicKey(keyPair.publicKey()) + .domain("") + .build(); + + SingleSignedTransaction signedClearDomain = signatureService.sign( + keyPair.privateKey(), clearDomain + ); + SubmitResult clearDomainSubmitResult = xrplClient.submit(signedClearDomain); + + assertThat(clearDomainSubmitResult.engineResult()).isEqualTo("tesSUCCESS"); + assertThat(signedClearDomain.hash()).isEqualTo(clearDomainSubmitResult.transactionResult().hash()); + logger.info( + "AccountSet transaction successful: https://testnet.xrpl.org/transactions/" + + clearDomainSubmitResult.transactionResult().hash() + ); + + this.scanForResult(() -> + this.getValidatedTransaction(signedClearDomain.hash(), AccountSet.class) + ); + accountInfo = this.scanForResult( + () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) + ); + assertThat(accountInfo.accountData().domain()).isEmpty(); + } ////////////////////// // Test Helpers From 9aaa3facfac1bdf0d273f902f44179585e355ca7 Mon Sep 17 00:00:00 2001 From: David Fuelling Date: Tue, 29 Oct 2024 12:48:16 -0400 Subject: [PATCH 02/10] Update README.md (#565) Update README to v4.0.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2235569c5..a3c8987b9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ current [BOM](https://howtodoinjava.com/maven/maven-bom-bill-of-materials-depend org.xrpl xrpl4j-bom - 3.5.1 + 4.0.1 pom import From 666c9b65c7c63f5e222332d548a79778354b839d Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 29 Oct 2024 19:10:01 -0400 Subject: [PATCH 03/10] Fix more AccountSet fields (#566) * Add `WalletLocator` and `WalletSize` in `AccountSet` object. * Correct MessageKey serialization when its value is an empty string. --- .../model/ledger/AccountRootObject.java | 8 +++++ .../xrpl4j/model/transactions/AccountSet.java | 18 +++++++++++ .../binary/BinarySerializationTests.java | 18 +++++++---- .../json/AccountSetJsonTests.java | 31 ++++++++++--------- .../org/xrpl/xrpl4j/tests/AccountSetIT.java | 15 ++++++++- 5 files changed, 69 insertions(+), 21 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java index 3639c6562..97b7d9c5e 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java @@ -239,6 +239,14 @@ default LedgerEntryType ledgerEntryType() { @JsonProperty("AMMID") Optional ammId(); + /** + * An arbitrary 256-bit value that users can set. + * + * @return An {@link Optional} {@link String}. + */ + @JsonProperty("WalletLocator") + Optional walletLocator(); + /** * The unique ID of this {@link AccountRootObject} ledger object. * diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java index 800ee3e78..8814086c5 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AccountSet.java @@ -281,6 +281,7 @@ default AccountSet normalizeSetFlag() { * @return An {@link Optional} of type {@link String} containing the messaging public key. */ @JsonProperty("MessageKey") + @JsonInclude(Include.NON_ABSENT) Optional messageKey(); /** @@ -310,6 +311,23 @@ default AccountSet normalizeSetFlag() { @JsonProperty("NFTokenMinter") Optional
mintAccount(); + /** + * An arbitrary 256-bit value. If specified, the value is stored as part of the account but has no inherent meaning + * or requirements. + * + * @return The 256-bit value as a hex encoded {@link String}. + */ + @JsonProperty("WalletLocator") + Optional walletLocator(); + + /** + * Not used. This field is valid in AccountSet transactions but does nothing. + * + * @return An optionally present {@link UnsignedInteger}. + */ + @JsonProperty("WalletSize") + Optional walletSize(); + /** * Check email hash length. */ diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java index 7e9ebd316..298e019a6 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/BinarySerializationTests.java @@ -137,32 +137,38 @@ public void serializeAccountSetTransactionWithNetworkId() throws JsonProcessingE } @Test - public void serializeAccountSetTransactionWithDomain() throws JsonProcessingException { + public void serializeAccountSetTransactionWithPresentOptionalStringFields() throws JsonProcessingException { AccountSet accountSet = AccountSet.builder() .account(Address.of("rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw")) .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(10598)) .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .domain("ABCD") + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .emailHash("F9879D71855B5FF21E4963273A886BFC") + .walletLocator("F9879D71855B5FF21E4963273A886BFCF9879D71855B5FF21E4963273A886BFC") .build(); - String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A73007702ABCD81140F3D0C7D2CFAB2EC8" + - "295451F0B3CA038E8E9CDCD"; + String expectedBinary = "12000321FFFFFFFF240000296641F9879D71855B5FF21E4963273A886BFC57F98" + + "79D71855B5FF21E4963273A886BFCF9879D71855B5FF21E4963273A886BFC68400000000000000A722103AB" + + "40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB73007702ABCD81140F3D0C7D2" + + "CFAB2EC8295451F0B3CA038E8E9CDCD"; assertSerializesAndDeserializes(accountSet, expectedBinary); } @Test - public void serializeAccountSetTransactionWithEmptyStringDomain() throws JsonProcessingException { + public void serializeAccountSetTransactionWithEmptyStrings() throws JsonProcessingException { AccountSet accountSet = AccountSet.builder() .account(Address.of("rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw")) .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(10598)) .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .domain("") + .messageKey("") .build(); - String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A7300770081140F3D0C7D2CFAB2EC829545" + - "1F0B3CA038E8E9CDCD"; + String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A72007300" + + "770081140F3D0C7D2CFAB2EC8295451F0B3CA038E8E9CDCD"; assertSerializesAndDeserializes(accountSet, expectedBinary); } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java index 9487cc2fd..4f38e2afc 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java @@ -21,6 +21,7 @@ */ import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.base.Strings; import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; @@ -57,6 +58,8 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) .networkId(NetworkId.of(1024)) + .walletLocator("ABCD") + .walletSize(UnsignedInteger.ONE) .build(); String json = "{\n" + @@ -74,6 +77,8 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"NetworkID\": 1024,\n" + + " \"WalletSize\": 1,\n" + + " \"WalletLocator\": \"ABCD\",\n" + " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + "}"; @@ -81,17 +86,15 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep } @Test - public void accountSetWithEmptyDomain() throws JSONException, JsonProcessingException { + public void accountSetWithEmptyOptionalStringFields() throws JSONException, JsonProcessingException { AccountSet accountSet = AccountSet.builder() .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) .fee(XrpCurrencyAmount.ofDrops(12)) .sequence(UnsignedInteger.valueOf(5)) .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) - .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") .transferRate(UnsignedInteger.valueOf(1000000001)) .tickSize(UnsignedInteger.valueOf(15)) .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) - .emailHash("f9879d71855b5ff21e4963273a886bfc") .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) @@ -107,32 +110,31 @@ public void accountSetWithEmptyDomain() throws JSONException, JsonProcessingExce " \"Sequence\":5,\n" + " \"Flags\":2147483648,\n" + " \"SetFlag\":5,\n" + - " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + " \"TransferRate\":1000000001,\n" + " \"TickSize\":15,\n" + " \"ClearFlag\":8,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"NetworkID\": 1024,\n" + - " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + " \"NetworkID\": 1024\n" + "}"; assertCanSerializeAndDeserialize(accountSet, json); } @Test - public void accountSetWithEmptyStringDomain() throws JSONException, JsonProcessingException { + public void accountSetWithEmptyStringFields() throws JSONException, JsonProcessingException { AccountSet accountSet = AccountSet.builder() .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) .fee(XrpCurrencyAmount.ofDrops(12)) .domain("") + .messageKey("") + .emailHash(Strings.repeat("0", 32)) + .walletLocator(Strings.repeat("0", 64)) .sequence(UnsignedInteger.valueOf(5)) .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) - .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") .transferRate(UnsignedInteger.valueOf(1000000001)) .tickSize(UnsignedInteger.valueOf(15)) .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) - .emailHash("f9879d71855b5ff21e4963273a886bfc") .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) @@ -149,14 +151,15 @@ public void accountSetWithEmptyStringDomain() throws JSONException, JsonProcessi " \"Flags\":2147483648,\n" + " \"Domain\":\"\",\n" + " \"SetFlag\":5,\n" + - " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + + " \"MessageKey\":\"\",\n" + " \"TransferRate\":1000000001,\n" + " \"TickSize\":15,\n" + " \"ClearFlag\":8,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"NetworkID\": 1024,\n" + - " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + " \"WalletLocator\" : \"" + Strings.repeat("0", 64) + "\",\n" + + " \"EmailHash\" : \"" + Strings.repeat("0", 32) + "\",\n" + + " \"NetworkID\": 1024\n" + "}"; assertCanSerializeAndDeserialize(accountSet, json); @@ -174,7 +177,7 @@ public void testJsonWithUnsetFlags() throws JsonProcessingException, JSONExcepti .transferRate(UnsignedInteger.valueOf(1000000001)) .tickSize(UnsignedInteger.valueOf(15)) .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) - .emailHash("f9879d71855b5ff21e4963273a886bfc") + .emailHash(Strings.repeat("0", 32)) .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) @@ -196,7 +199,7 @@ public void testJsonWithUnsetFlags() throws JsonProcessingException, JSONExcepti " \"ClearFlag\":8,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + " \"EmailHash\":\"" + Strings.repeat("0", 32) + "\"\n" + "}"; assertCanSerializeAndDeserialize(accountSet, json); diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java index 582e3892f..4ff0d5afb 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AccountSetIT.java @@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.base.Strings; import com.google.common.primitives.UnsignedInteger; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; @@ -393,7 +394,7 @@ void submitAndRetrieveAccountSetWithZeroClearFlagAndSetFlag() } @Test - void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingException { + void setAndUnsetDomainAndMessageKey() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair keyPair = constructRandomAccount(); /////////////////////// @@ -409,6 +410,9 @@ void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingExcep .sequence(accountInfo.accountData().sequence()) .signingPublicKey(keyPair.publicKey()) .domain("ABCD") + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .emailHash("F9879D71855B5FF21E4963273A886BFC") + .walletLocator("F9879D71855B5FF21E4963273A886BFCF9879D71855B5FF21E4963273A886BFC") .build(); SingleSignedTransaction signedSetDomain = signatureService.sign( @@ -429,6 +433,9 @@ void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingExcep () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) ); assertThat(accountInfo.accountData().domain()).isNotEmpty().isEqualTo(setDomain.domain()); + assertThat(accountInfo.accountData().messageKey()).isNotEmpty().isEqualTo(setDomain.messageKey()); + assertThat(accountInfo.accountData().emailHash()).isNotEmpty().isEqualTo(setDomain.emailHash()); + assertThat(accountInfo.accountData().walletLocator()).isNotEmpty().isEqualTo(setDomain.walletLocator()); AccountSet clearDomain = AccountSet.builder() .account(keyPair.publicKey().deriveAddress()) @@ -436,6 +443,9 @@ void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingExcep .sequence(accountInfo.accountData().sequence()) .signingPublicKey(keyPair.publicKey()) .domain("") + .messageKey("") + .emailHash(Strings.repeat("0", 32)) + .walletLocator(Strings.repeat("0", 64)) .build(); SingleSignedTransaction signedClearDomain = signatureService.sign( @@ -457,6 +467,9 @@ void setAndUnsetDomain() throws JsonRpcClientErrorException, JsonProcessingExcep () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) ); assertThat(accountInfo.accountData().domain()).isEmpty(); + assertThat(accountInfo.accountData().messageKey()).isEmpty(); + assertThat(accountInfo.accountData().emailHash()).isEmpty(); + assertThat(accountInfo.accountData().walletLocator()).isEmpty(); } ////////////////////// From d9cdb42bda12bedd9f50f3655e5e91e4010938e8 Mon Sep 17 00:00:00 2001 From: David Fuelling Date: Tue, 29 Oct 2024 17:17:29 -0600 Subject: [PATCH 04/10] Update README.md Update to v4.0.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3c8987b9..6b7f8c5a1 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ current [BOM](https://howtodoinjava.com/maven/maven-bom-bill-of-materials-depend org.xrpl xrpl4j-bom - 4.0.1 + 4.0.2 pom import From 2966227d8e475b1925754c5f5836ba997eda251a Mon Sep 17 00:00:00 2001 From: David Fuelling Date: Tue, 29 Oct 2024 17:20:01 -0600 Subject: [PATCH 05/10] Update README.md Update Javadoc link for xrpl4j-core --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b7f8c5a1..70df87089 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ canonical JSON encoding). Read more about each here: Xrpl4j is structured as a Maven multi-module project, with the following modules: -- **xrpl4j-core**: [![javadoc](https://javadoc.io/badge2/org.xrpl/xrpl4j-binary-codec/javadoc.svg?color=blue)](https://javadoc.io/doc/org.xrpl/xrpl4j-binary-codec) +- **xrpl4j-core**: [![javadoc](https://javadoc.io/badge2/org.xrpl/xrpl4j-core/javadoc.svg?color=blue)](https://javadoc.io/doc/org.xrpl/xrpl4j-core) - Provides core primitives like seeds, public/private keys definitions (supports secp256k1 and ed25519 key types and signing algorithms), signature interfaces, address and binary codecs etc. Also provides Java objects which model XRP Ledger objects, as well as request parameters and response results for the `rippled` websocket and JSON RPC APIs. From d97ffb2131f19076cf63d715b8216b855b8d7fd6 Mon Sep 17 00:00:00 2001 From: David Fuelling Date: Tue, 29 Oct 2024 20:31:55 -0400 Subject: [PATCH 06/10] Add unit tests to validate signature in tx hash (#526) * Add unit tests to validate signature in tx hash --------- Co-authored-by: nkramer44 --- .../crypto/signing/SignedTransactionTest.java | 139 ++++++++++++++++-- 1 file changed, 123 insertions(+), 16 deletions(-) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignedTransactionTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignedTransactionTest.java index 490882afb..75ba502c2 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignedTransactionTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignedTransactionTest.java @@ -33,22 +33,28 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.Memo; +import org.xrpl.xrpl4j.model.transactions.MemoWrapper; import org.xrpl.xrpl4j.model.transactions.Payment; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; +import java.util.Arrays; +import java.util.Collections; + /** * Unit tests for {@link SingleSignedTransaction}. */ class SignedTransactionTest { /** - * This test constructs the transaction found here: - * https://livenet.xrpl.org/transactions/A7AE53FE15B02E6E2F3C610FB4BA30B12392EB110F1D5E8C20880555E8639B05 to check - * that the hash that's on livenet matches what this library computes. The hash you see in this test is different than - * the hash found on livenet because the real transaction did not set any flags on the transaction and {@link Payment} - * requires a flags field (Even if you set flags to 0, it affects the hash). However, we made {@link Payment#flags()} - * nullable during development and verified that the hashes match, so we are confident that our hash calculation is - * accurate. + * This test constructs the transaction with hash A7AE53FE15B02E6E2F3C610FB4BA30B12392EB110F1D5E8C20880555E8639B05 to + * check that the hash that's on livenet matches what this library computes. The hash you see in this test is + * different from the hash found on livenet because the real transaction did not set any flags on the transaction and + * {@link Payment} requires a flags field (Even if you set flags to 0, it affects the hash). However, we made + * {@link Payment#flags()} nullable during development and verified that the hashes match, so we are confident that + * our hash calculation is accurate. + * + * @see "https://livenet.xrpl.org/transactions/A7AE53FE15B02E6E2F3C610FB4BA30B12392EB110F1D5E8C20880555E8639B05" */ @Test public void computesCorrectTransactionHash() throws JsonProcessingException { @@ -65,18 +71,66 @@ public void computesCorrectTransactionHash() throws JsonProcessingException { .destinationTag(UnsignedInteger.valueOf(371969)) .build(); + final Signature signature = Signature.fromBase16( + "304502210093257D8E88D2A92CE55977641F72CCD235AB76B1AE189BE3377F30A69B131C49" + + "02200B79836114069F0D331418D05818908D85DE755AE5C2DDF42E9637FE1C11754F" + ); + final Payment signedPayment = Payment.builder().from(unsignedTransaction) - .transactionSignature(Signature.fromBase16( - "304502210093257D8E88D2A92CE55977641F72CCD235AB76B1AE189BE3377F30A6" + - "9B131C4902200B79836114069F0D331418D05818908D85DE755AE5C2DDF42E9637FE1C11754F" + .transactionSignature(signature) + .build(); + + SingleSignedTransaction signedTransaction = SingleSignedTransaction.builder() + .signedTransaction(signedPayment) + .signature(signature) + .unsignedTransaction(unsignedTransaction) + .build(); + + String expectedHash = "F847C96B2EEB0609F16C9DB9D74A0CB123B5EAF5B626207977335BF0A1EF53C3"; + assertThat(signedTransaction.hash().value()).isEqualTo(expectedHash); + assertThat(signedTransaction.unsignedTransaction()).isEqualTo(unsignedTransaction); + assertThat(signedTransaction.signedTransaction()).isEqualTo(signedPayment); + assertThat(signedTransaction.signedTransactionBytes().hexValue()).isEqualTo( + XrplBinaryCodec.getInstance().encode(ObjectMapperFactory.create().writeValueAsString(signedPayment)) + ); + } + + /** + * This test constructs the transaction with hash 1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997 to + * check that the hash that's on livenet matches what this library computes. + * + * @see "https://livenet.xrpl.org/transactions/1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997" + */ + @Test + public void computesCorrectTransactionHashWithUnsetFlags() throws JsonProcessingException { + final Payment unsignedTransaction = Payment.builder() + .account(Address.of("rGWx7VAsnwVKRbPFPpvy8Lo4nFf5xjj6Zb")) + .amount(XrpCurrencyAmount.ofDrops(1)) + .destination(Address.of("rxRpSNb1VktvzBz8JF2oJC6qaww6RZ7Lw")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .flags(PaymentFlags.of(TransactionFlags.UNSET.getValue())) // 0 + .lastLedgerSequence(UnsignedInteger.valueOf(86481544)) + .memos(Collections.singletonList( + MemoWrapper.builder() + .memo(Memo.builder() + .memoData("7B226F70223A226D696E74222C22616D6F756E74223A22313030303030303030222C22677061223A2230227D") + .build()) + .build() )) + .sequence(UnsignedInteger.valueOf(84987644)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("ED05DC98B76FCD734BD44CDF153C34F79728485D2F24F9381CF7A284223EA258CE") + ) .build(); - final Signature signature = Signature.builder().value( - UnsignedByteArray.of(BaseEncoding.base16() - .decode("304502210093257D8E88D2A92CE55977641F72CCD235AB76B1AE189BE3377F30A69B131C49" + - "02200B79836114069F0D331418D05818908D85DE755AE5C2DDF42E9637FE1C11754F")) - ).build(); + final Signature signature = Signature.fromBase16( + "ED6F91CCF14EE94EB072C7671A397A313E3E5CBDAFE773BB6B2F07A0E75A7E65F84B5516268DAEE12902265256" + + "EA1EF046B200148E14FF4E720C06519FD7F40F" + ); + + final Payment signedPayment = Payment.builder().from(unsignedTransaction) + .transactionSignature(signature) + .build(); SingleSignedTransaction signedTransaction = SingleSignedTransaction.builder() .signedTransaction(signedPayment) @@ -84,7 +138,7 @@ public void computesCorrectTransactionHash() throws JsonProcessingException { .unsignedTransaction(unsignedTransaction) .build(); - String expectedHash = "F847C96B2EEB0609F16C9DB9D74A0CB123B5EAF5B626207977335BF0A1EF53C3"; + String expectedHash = "1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997"; assertThat(signedTransaction.hash().value()).isEqualTo(expectedHash); assertThat(signedTransaction.unsignedTransaction()).isEqualTo(unsignedTransaction); assertThat(signedTransaction.signedTransaction()).isEqualTo(signedPayment); @@ -92,4 +146,57 @@ public void computesCorrectTransactionHash() throws JsonProcessingException { XrplBinaryCodec.getInstance().encode(ObjectMapperFactory.create().writeValueAsString(signedPayment)) ); } + + /** + * This test constructs the transaction with hash 1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997 to + * check that the hash that's on livenet _does not_ match when the signature is supplied incorrectly (i.e., this test + * validates that a transaction's signature is always used to compute a transaction hash). + * + * @see "https://livenet.xrpl.org/transactions/1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997" + */ + @Test + public void computesIncorrectTransactionHashWithoutSignature() throws JsonProcessingException { + final Payment unsignedTransaction = Payment.builder() + .account(Address.of("rGWx7VAsnwVKRbPFPpvy8Lo4nFf5xjj6Zb")) + .amount(XrpCurrencyAmount.ofDrops(1)) + .destination(Address.of("rxRpSNb1VktvzBz8JF2oJC6qaww6RZ7Lw")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .flags(PaymentFlags.of(TransactionFlags.UNSET.getValue())) // 0 + .lastLedgerSequence(UnsignedInteger.valueOf(86481544)) + .memos(Collections.singletonList( + MemoWrapper.builder() + .memo(Memo.builder() + .memoData("7B226F70223A226D696E74222C22616D6F756E74223A22313030303030303030222C22677061223A2230227D") + .build()) + .build() + )) + .sequence(UnsignedInteger.valueOf(84987644)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("ED05DC98B76FCD734BD44CDF153C34F79728485D2F24F9381CF7A284223EA258CE") + ) + .build(); + + final Signature emptySignature = Signature.fromBase16(""); + + final Payment signedPayment = Payment.builder().from(unsignedTransaction) + .transactionSignature(emptySignature) + .build(); + + SingleSignedTransaction signedTransaction = SingleSignedTransaction.builder() + .signedTransaction(signedPayment) + .signature(emptySignature) + .unsignedTransaction(unsignedTransaction) + .build(); + + String expectedHash = "1A1953AC3BA3123254AA912CE507514A6AAD05EED8981A870B45F604936F0997"; + assertThat(signedTransaction.hash().value()).isNotEqualTo(expectedHash); + assertThat(signedTransaction.hash().value()).isEqualTo( + "8E0EDE65ECE8A03ABDD7926B994B2F6F14514FDBD46714F4F511143A1F01A6D0" + ); + assertThat(signedTransaction.unsignedTransaction()).isEqualTo(unsignedTransaction); + assertThat(signedTransaction.signedTransaction()).isEqualTo(signedPayment); + assertThat(signedTransaction.signedTransactionBytes().hexValue()).isEqualTo( + XrplBinaryCodec.getInstance().encode(ObjectMapperFactory.create().writeValueAsString(signedPayment)) + ); + } } From 14f726419d857f7edb2dc86234a35d03d79566c6 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Sat, 2 Nov 2024 17:38:54 -0400 Subject: [PATCH 07/10] unknown transaction --- .../xrpl4j/model/flags/TransactionFlags.java | 4 + ...ntTransactionsTransactionDeserializer.java | 17 ++- .../modules/TransactionDeserializer.java | 1 + .../TransactionResultDeserializer.java | 15 ++- .../xrpl4j/model/transactions/AmmBid.java | 6 + .../model/transactions/Transaction.java | 10 ++ .../model/transactions/TransactionType.java | 6 +- .../transactions/UnknownTransaction.java | 48 ++++++++ .../xrpl4j/model/transactions/UnlModify.java | 4 +- .../xrpl4j/model/transactions/AmmBidTest.java | 54 +++++++++ .../model/transactions/AmmCreateTest.java | 40 +++++++ .../model/transactions/AmmDeleteTest.java | 38 ++++++ .../model/transactions/AmmDepositTest.java | 57 +++++++++ .../model/transactions/AmmVoteTest.java | 40 +++++++ .../model/transactions/AmmWithdrawTest.java | 26 ++++- .../model/transactions/ClawbackTest.java | 36 ++++++ .../model/transactions/DidDeleteTest.java | 18 +++ .../xrpl4j/model/transactions/DidSetTest.java | 28 +++++ .../model/transactions/OracleDeleteTest.java | 19 +++ .../model/transactions/OracleSetTest.java | 20 ++++ .../xrpl4j/model/transactions/SetFeeTest.java | 34 ++++++ .../transactions/TransactionTypeTests.java | 31 ++--- .../transactions/UnknownTransactionTest.java | 76 ++++++++++++ .../XChainAccountCreateCommitTest.java | 52 +++++++++ ...XChainAddAccountCreateAttestationTest.java | 38 ++++++ .../XChainAddClaimAttestationTest.java | 40 +++++++ .../model/transactions/XChainClaimTest.java | 33 ++++++ .../model/transactions/XChainCommitTest.java | 41 +++++++ .../transactions/XChainCreateBridgeTest.java | 32 +++++ .../transactions/XChainCreateClaimIdTest.java | 31 +++++ .../transactions/XChainModifyBridgeTest.java | 29 +++++ .../json/AccountDeleteJsonTests.java | 30 +++++ .../json/AccountSetJsonTests.java | 48 ++++++++ .../transactions/json/CheckJsonTests.java | 94 +++++++++++++++ .../json/EnableAmendmentJsonTests.java | 24 ++++ .../transactions/json/EscrowJsonTests.java | 110 ++++++++++++++++++ .../json/NfTokenAcceptOfferJsonTests.java | 35 ++++++ .../json/NfTokenBurnJsonTests.java | 30 +++++ .../json/NfTokenCancelOfferJsonTests.java | 33 ++++++ .../json/NfTokenCreateOfferJsonTests.java | 32 +++++ .../json/NfTokenMintJsonTests.java | 34 ++++++ .../transactions/json/OfferJsonTests.java | 62 ++++++++++ .../json/PaymentChannelJsonTests.java | 109 +++++++++++++++++ .../transactions/json/PaymentJsonTests.java | 32 +++++ .../json/SetRegularKeyJsonTest.java | 28 +++++ .../json/SignerListSetJsonTests.java | 30 +++++ .../json/TicketCreateJsonTest.java | 28 +++++ .../transactions/json/TrustSetJsonTests.java | 40 +++++++ .../transactions/json/UnlModifyJsonTests.java | 3 + 49 files changed, 1692 insertions(+), 34 deletions(-) create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java create mode 100644 xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java index a79f04ce0..8c03379a7 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java @@ -49,6 +49,10 @@ public class TransactionFlags extends Flags { TransactionFlags() { } + public static TransactionFlags of(long value) { + return new TransactionFlags(value); + } + /** * Flags indicating that a fully-canonical signature is required. This flag is highly recommended. * diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java index e4256eba6..4c2d0cd23 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java @@ -25,6 +25,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsTransaction; @@ -33,7 +36,9 @@ import org.xrpl.xrpl4j.model.transactions.Transaction; import java.io.IOException; +import java.util.ArrayList; import java.util.Optional; +import java.util.Set; /** * Custom Jackson Deserializer for {@link AccountTransactionsTransaction}s. This is necessary because Jackson @@ -41,6 +46,8 @@ */ public class AccountTransactionsTransactionDeserializer extends StdDeserializer> { + public static final Set EXTRA_TRANSACTION_FIELDS = Sets.newHashSet("ledger_index", "date", "hash"); + /** * No-args constructor. */ @@ -54,14 +61,20 @@ public AccountTransactionsTransaction deserialize( DeserializationContext ctxt ) throws IOException { ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); - JsonNode node = objectMapper.readTree(jsonParser); + ObjectNode node = objectMapper.readTree(jsonParser); - Transaction transaction = objectMapper.readValue(node.toString(), Transaction.class); long ledgerIndex = node.get("ledger_index").asLong(-1L); String hash = node.get("hash").asText(); Optional closeDate = Optional.ofNullable(node.get("date")) .map(JsonNode::asLong) .map(UnsignedLong::valueOf); + + // The Transaction is @JsonUnwrapped in AccountTransactionsTransaction, which means these three fields + // get added to the Transaction.unknownFields Map. To prevent that, we simply remove them from the JSON, because + // they should only show up in AccountTransactionsTransaction + node.remove(EXTRA_TRANSACTION_FIELDS); + Transaction transaction = objectMapper.readValue(node.toString(), Transaction.class); + return AccountTransactionsTransaction.builder() .transaction(transaction) .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(ledgerIndex))) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java index c4cb3a483..1eccf82a6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TransactionType; +import org.xrpl.xrpl4j.model.transactions.UnknownTransaction; import java.io.IOException; diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java index 7ab4c6795..932a9f277 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.Sets; import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; @@ -37,6 +38,7 @@ import java.io.IOException; import java.util.Optional; +import java.util.Set; /** * Custom deserializer for {@link TransactionResult}, which wraps the {@link Transaction} fields in the result JSON. @@ -48,6 +50,10 @@ */ public class TransactionResultDeserializer extends StdDeserializer> { + public static final Set EXTRA_TRANSACTION_FIELDS = Sets.newHashSet( + "ledger_index", "date", "hash", "status", "validated", "meta", "metaData" + ); + /** * No-args constructor. */ @@ -60,10 +66,6 @@ public TransactionResult deserialize(JsonParser jsonParser, DeserializationCo ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); ObjectNode objectNode = objectMapper.readTree(jsonParser); - JavaType javaType = objectMapper.getTypeFactory().constructType(new TypeReference() { - }); - T transaction = objectMapper.convertValue(objectNode, javaType); - LedgerIndex ledgerIndex = objectNode.has("ledger_index") ? LedgerIndex.of(UnsignedInteger.valueOf(objectNode.get("ledger_index").asInt())) : null; @@ -73,6 +75,11 @@ public TransactionResult deserialize(JsonParser jsonParser, DeserializationCo Optional metadata = getTransactionMetadata(objectMapper, objectNode); UnsignedLong closeDate = objectNode.has("date") ? UnsignedLong.valueOf(objectNode.get("date").asLong()) : null; + objectNode.remove(EXTRA_TRANSACTION_FIELDS); + JavaType javaType = objectMapper.getTypeFactory().constructType(new TypeReference() { + }); + T transaction = objectMapper.convertValue(objectNode, javaType); + return TransactionResult.builder() .transaction(transaction) .ledgerIndex(Optional.ofNullable(ledgerIndex)) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index b52da0635..3bc9261d1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -1,5 +1,7 @@ package org.xrpl.xrpl4j.model.transactions; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -10,6 +12,7 @@ import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.List; +import java.util.Map; import java.util.Optional; /** @@ -107,4 +110,7 @@ default TransactionFlags flags() { @JsonProperty("AuthAccounts") List authAccounts(); + /*@Override + @JsonAnyGetter + Map unknownFields();*/ } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index 9f4f1acaf..fb96cd14a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -20,7 +20,10 @@ * =========================LICENSE_END================================== */ +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; @@ -30,6 +33,7 @@ import org.xrpl.xrpl4j.crypto.signing.Signature; import java.util.List; +import java.util.Map; import java.util.Optional; /** @@ -90,6 +94,7 @@ public interface Transaction { .put(ImmutableDidDelete.class, TransactionType.DID_DELETE) .put(ImmutableOracleSet.class, TransactionType.ORACLE_SET) .put(ImmutableOracleDelete.class, TransactionType.ORACLE_DELETE) + .put(ImmutableUnknownTransaction.class, TransactionType.UNKNOWN) .build(); /** @@ -106,6 +111,7 @@ public interface Transaction { * @return A {@link TransactionType}. */ @JsonProperty("TransactionType") + @Value.Default // must be Default rather than Derived, otherwise Jackson treats "TransactionType" as an unknownField default TransactionType transactionType() { return typeMap.get(this.getClass()); } @@ -220,4 +226,8 @@ default PublicKey signingPublicKey() { @JsonProperty("NetworkID") Optional networkId(); + @JsonAnyGetter + @JsonInclude(Include.NON_ABSENT) + Map unknownFields(); + } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index bc19f8dbf..92cd912f1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -336,7 +336,9 @@ public enum TransactionType { * is subject to change.

*/ @Beta - ORACLE_DELETE("OracleDelete"); + ORACLE_DELETE("OracleDelete"), + + UNKNOWN("Unknown"); private final String value; @@ -358,7 +360,7 @@ public static TransactionType forValue(String value) { } } - throw new IllegalArgumentException("No matching TransactionType enum value for String value " + value); + return UNKNOWN; } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java new file mode 100644 index 000000000..1c8f1dbdc --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java @@ -0,0 +1,48 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; + +@Immutable +@JsonSerialize(as = ImmutableUnknownTransaction.class) +@JsonDeserialize(as = ImmutableUnknownTransaction.class) +public interface UnknownTransaction extends Transaction { + + /** + * Construct a {@code UnknownTransaction} builder. + * + * @return An {@link ImmutableUnknownTransaction.Builder}. + */ + static ImmutableUnknownTransaction.Builder builder() { + return ImmutableUnknownTransaction.builder(); + } + + /** + * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, + * which only has an UNKNOWN variant. Because this method is also annotated with {@link JsonProperty} of + * "TransactionType", this essentially overrides the "TransactionType" field in JSON, but {@link #transactionType()} + * will always be {@link TransactionType#UNKNOWN} and this field will contain the actual "TransactionType" field. + * + * @return A {@link String} containing the transaction type from JSON. + */ + @JsonProperty("TransactionType") + String unknownTransactionType(); + + @Override + @JsonIgnore + default TransactionType transactionType() { + return Transaction.super.transactionType(); + } + + @JsonProperty("Flags") + @Value.Default + default TransactionFlags flags() { + return TransactionFlags.EMPTY; + } + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java index e171a22e0..9ad15e842 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java @@ -62,7 +62,9 @@ static ImmutableUnlModify.Builder builder() { */ @Override @JsonProperty("Account") - @Value.Derived + // FIXME: Have to make this Default, otherwise JsonAnySetter adds this field to unknownFields. Other option + // is that's totally fine, which i think it is -- we should let the JSON set this field if it's there + @Value.Default default Address account() { return ACCOUNT_ZERO; } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index 0975e3aa0..9cfab3080 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -312,4 +312,58 @@ void testJsonWithXrpAmountBidMinAndMax() throws JSONException, JsonProcessingExc "}"; assertCanSerializeAndDeserialize(ammBid, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmBid bid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMBid\"\n" + + "}"; + + assertCanSerializeAndDeserialize(bid, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java index 275582f17..927f1820a 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java @@ -127,4 +127,44 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ammCreate, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmCreate ammCreate = AmmCreate.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"25\"\n" + + " },\n" + + " \"Amount2\" : \"250000000\",\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 6,\n" + + " \"TradingFee\" : 500,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMCreate\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammCreate, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java index 2889e572e..83681dfc7 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java @@ -46,4 +46,42 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ammDelete, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmDelete ammDelete = AmmDelete.builder() + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( + "EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156" + )) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156\",\n" + + " \"TransactionType\" : \"AMMDelete\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammDelete, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index 004816e7d..247367fd1 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -385,4 +385,61 @@ void constructTwoAssetIfEmptyDepositTestJson() throws JSONException, JsonProcess assertCanSerializeAndDeserialize(deposit, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(AmmDepositFlags.TWO_ASSET_IF_EMPTY) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .amount( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(10)) + .effectivePrice(XrpCurrencyAmount.ofDrops(10)) + .putUnknownFields("Foo", "Bar") + .build(); + + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.TWO_ASSET_IF_EMPTY); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Amount2\" : \"10\",\n" + + " \"EPrice\" : \"10\",\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + AmmDepositFlags.TWO_ASSET_IF_EMPTY + ",\n" + + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java index e0fee4500..8c285f51f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -128,4 +128,44 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(vote, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmVote vote = AmmVote.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 8,\n" + + " \"TradingFee\" : 600,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMVote\"\n" + + "}"; + + assertCanSerializeAndDeserialize(vote, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index 8f89e64ff..b59ed7cc7 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -1,7 +1,5 @@ package org.xrpl.xrpl4j.model.transactions; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; - import com.fasterxml.jackson.core.JsonProcessingException; import org.json.JSONException; import org.junit.jupiter.api.Test; @@ -212,6 +210,30 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce assertCanSerializeAndDeserialize(withdraw, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(AmmWithdrawFlags.LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"LPTokensIn\" : " + objectMapper.writeValueAsString(withdraw.lpTokensIn()) + "," + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + AmmWithdrawFlags.LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + private ImmutableIssuedCurrencyAmount amount() { return IssuedCurrencyAmount.builder() .currency("TST") diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java index 5eeb0410a..8eac63ea1 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java @@ -115,4 +115,40 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(clawback, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + Clawback clawback = Clawback.builder() + .account(Address.of("rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.ONE) + .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( + "02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC" + )) + .amount( + IssuedCurrencyAmount.builder() + .currency("FOO") + .issuer(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .value("314.159") + .build() + ) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"Clawback\",\n" + + " \"Account\": \"rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S\",\n" + + " \"Amount\": {\n" + + " \"currency\": \"FOO\",\n" + + " \"issuer\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + + " \"value\": \"314.159\"\n" + + " },\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + + "}"; + + assertCanSerializeAndDeserialize(clawback, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java index 739963267..b9d5951dd 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java @@ -62,6 +62,24 @@ void testJsonWithSetFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(transaction, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + DidDelete transaction = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"DIDDelete\", \n" + + " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 391,\n" + + " \"SigningPubKey\":\"%s\"\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(transaction, json); + } + private ImmutableDidDelete.Builder baseBuilder() { return DidDelete.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java index 09051f8c9..8541f0040 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java @@ -113,4 +113,32 @@ void testJsonWithSetFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(transaction, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + DidSet transaction = DidSet.builder() + .account(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(391)) + .didDocument(DidDocument.of("")) + .uri(DidUri.of("")) + .data(DidData.of("")) + .signingPublicKey(ED_PUBLIC_KEY) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"DIDSet\",\n" + + " \"Account\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 391,\n" + + " \"DIDDocument\": \"\",\n" + + " \"URI\": \"\",\n" + + " \"Data\": \"\",\n" + + " \"SigningPubKey\":\"%s\"\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(transaction, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java index 54e54264a..fbdcdf222 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java @@ -37,6 +37,25 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(oracleDelete, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + OracleDelete oracleDelete = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + String json = "\n" + + "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"OracleDelete\",\n" + + " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + + " \"OracleDocumentID\": 1,\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 391,\n" + + " \"SigningPubKey\": \"" + ED_PUBLIC_KEY_HEX + "\"\n" + + "}"; + + assertCanSerializeAndDeserialize(oracleDelete, json); + } + private static ImmutableOracleDelete.Builder baseBuilder() { return OracleDelete.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java index 05bdb2733..859417cb0 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java @@ -82,6 +82,26 @@ void testFullJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(oracleSet, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + OracleSet oracleSet = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + String json = "\n" + + "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"OracleSet\",\n" + + " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + + " \"OracleDocumentID\": 1,\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 391,\n" + + " \"SigningPubKey\": \"" + ED_PUBLIC_KEY_HEX + "\",\n" + + " \"LastUpdateTime\": 1\n" + + "}"; + + assertCanSerializeAndDeserialize(oracleSet, json); + } + private static ImmutableOracleSet.Builder baseBuilder() { return OracleSet.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java index 42018706f..49a83f717 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java @@ -155,4 +155,38 @@ public void testDeserializePostXrpFeesTransaction() throws JsonProcessingExcepti assertThat(redeserialized).isEqualTo(expected); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException { + SetFee expected = SetFee.builder() + .account(Address.of("rrrrrrrrrrrrrrrrrrrrrhoLvTp")) + .fee(XrpCurrencyAmount.ofDrops(0)) + .sequence(UnsignedInteger.valueOf(0)) + .baseFeeDrops(XrpCurrencyAmount.ofDrops(10)) + .reserveBaseDrops(XrpCurrencyAmount.ofDrops(10000000)) + .reserveIncrementDrops(XrpCurrencyAmount.ofDrops(2000000)) + .ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(66462465)))) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rrrrrrrrrrrrrrrrrrrrrhoLvTp\",\n" + + " \"BaseFeeDrops\": \"10\",\n" + + " \"Fee\": \"0\",\n" + + " \"LedgerSequence\": 66462465,\n" + + " \"ReserveBaseDrops\": \"10000000\",\n" + + " \"ReserveIncrementDrops\": \"2000000\",\n" + + " \"Sequence\": 0,\n" + + " \"SigningPubKey\": \"\",\n" + + " \"TransactionType\": \"SetFee\"}"; + + Transaction actual = objectMapper.readValue(json, Transaction.class); + assertThat(actual).isEqualTo(expected); + + String reserialized = objectMapper.writeValueAsString(actual); + Transaction redeserialized = objectMapper.readValue(reserialized, Transaction.class); + + assertThat(redeserialized).isEqualTo(expected); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java index 77beee833..af5e049c2 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java @@ -32,7 +32,9 @@ import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.EmptySource; +import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; /** * Unit tests for {@link TransactionType}. @@ -40,8 +42,9 @@ public class TransactionTypeTests { @ParameterizedTest - @ArgumentsSource(value = TransactionTypeValidArgumentProvider.class) - public void shouldReturnTransactionTypeForValidValues(String value) { + @EnumSource + public void shouldReturnTransactionTypeForValidValues(TransactionType type) { + String value = type.value(); TransactionType transactionType = TransactionType.forValue(value); assertNotNull(transactionType); assertTrue(transactionType instanceof TransactionType); @@ -50,28 +53,9 @@ public void shouldReturnTransactionTypeForValidValues(String value) { @EmptySource @NullSource @ParameterizedTest - @ArgumentsSource(value = TransactionTypeInvalidArgumentProvider.class) + @ValueSource(strings = {"bla", "blaaa", "123"}) public void shouldThrowIllegalArgumentExceptionForInvalidValues(String value) { - assertThrows(IllegalArgumentException.class, () -> TransactionType.forValue(value), - "No matching TransactionType enum value for String value " + value); - } - - public static class TransactionTypeValidArgumentProvider implements ArgumentsProvider { - - @Override - public java.util.stream.Stream provideArguments(ExtensionContext context) { - return java.util.stream.Stream.of(TransactionType.values()).map(TransactionType::value).map(Arguments::of); - } - - } - - public static class TransactionTypeInvalidArgumentProvider implements ArgumentsProvider { - - @Override - public java.util.stream.Stream provideArguments(ExtensionContext context) { - return java.util.stream.Stream.of("bla", "blaaa", "123").map(Arguments::of); - } - + assertThat(TransactionType.forValue(value)).isEqualTo(TransactionType.UNKNOWN); } @Test @@ -114,5 +98,6 @@ public void testTxTypeCapitalization() { assertThat(TransactionType.XCHAIN_CREATE_BRIDGE.value()).isEqualTo("XChainCreateBridge"); assertThat(TransactionType.XCHAIN_CREATE_CLAIM_ID.value()).isEqualTo("XChainCreateClaimID"); assertThat(TransactionType.XCHAIN_MODIFY_BRIDGE.value()).isEqualTo("XChainModifyBridge"); + assertThat(TransactionType.UNKNOWN.value()).isEqualTo("Unknown"); } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java new file mode 100644 index 000000000..aeacb2a42 --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java @@ -0,0 +1,76 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.base.Strings; +import com.google.common.collect.Maps; +import com.google.common.primitives.UnsignedInteger; +import org.immutables.value.Value.Immutable; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; +import org.xrpl.xrpl4j.model.transactions.AccountSet.AccountSetFlag; + +import java.util.HashMap; +import java.util.Optional; + +class UnknownTransactionTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + HashMap unknownFields = Maps.newHashMap(); + unknownFields.put("Domain", ""); + unknownFields.put("SetFlag", 5); + unknownFields.put("MessageKey", ""); + unknownFields.put("TransferRate", 1000000001); + unknownFields.put("TickSize", 15); + unknownFields.put("ClearFlag", 8); + unknownFields.put("NFTokenMinter", "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"); + unknownFields.put("WalletLocator", Strings.repeat("0", 64)); + unknownFields.put("EmailHash", Strings.repeat("0", 32)); + Transaction transaction = UnknownTransaction.builder() + .unknownTransactionType("AccountSet2") + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(5)) + .flags(TransactionFlags.of(2147483648L)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC")) + .unknownFields( + unknownFields + ) + .networkId(NetworkId.of(UnsignedInteger.valueOf(1024))) + .build(); + + // Same properties as AccountSet, but TransactionType is AccountSet2 + String json = "{\n" + + " \"TransactionType\":\"AccountSet2\",\n" + + " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\":\"12\",\n" + + " \"Sequence\":5,\n" + + " \"Flags\":2147483648,\n" + + " \"Domain\":\"\",\n" + + " \"SetFlag\":5,\n" + + " \"MessageKey\":\"\",\n" + + " \"TransferRate\":1000000001,\n" + + " \"TickSize\":15,\n" + + " \"ClearFlag\":8,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"WalletLocator\" : \"" + Strings.repeat("0", 64) + "\",\n" + + " \"EmailHash\" : \"" + Strings.repeat("0", 32) + "\",\n" + + " \"NetworkID\": 1024\n" + + "}"; + + assertCanSerializeAndDeserialize(transaction, json); + } + +} \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java index 9996af22a..05e79d8d5 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java @@ -213,4 +213,56 @@ void testJsonWithEmptySignatureReward() throws JSONException, JsonProcessingExce assertCanSerializeAndDeserialize(commit, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainAccountCreateCommit commit = XChainAccountCreateCommit.builder() + .account(Address.of("rwEqJ2UaQHe7jihxGqmx6J4xdbGiiyMaGa")) + .fee(XrpCurrencyAmount.ofDrops(1)) + .sequence(UnsignedInteger.ONE) + .destination(Address.of("rD323VyRjgzzhY4bFpo44rmyh2neB5d8Mo")) + .amount(XrpCurrencyAmount.ofDrops(20000000)) + .signatureReward(XrpCurrencyAmount.ofDrops(100)) + .signingPublicKey(ED_PUBLIC_KEY) + .xChainBridge( + XChainBridge.builder() + .lockingChainDoor(Address.of("rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4")) + .lockingChainIssue(Issue.XRP) + .issuingChainDoor(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) + .issuingChainIssue( + Issue.builder() + .currency("TST") + .issuer(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) + .build() + ) + .build() + ) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rwEqJ2UaQHe7jihxGqmx6J4xdbGiiyMaGa\",\n" + + " \"Fee\": \"1\",\n" + + " \"Sequence\": 1,\n" + + " \"Destination\": \"rD323VyRjgzzhY4bFpo44rmyh2neB5d8Mo\",\n" + + " \"TransactionType\": \"XChainAccountCreateCommit\",\n" + + " \"Amount\": \"20000000\",\n" + + " \"SignatureReward\": \"100\",\n" + + " \"SigningPubKey\": \"%s\",\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"TST\",\n" + + " \"issuer\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\"\n" + + " }\n" + + " }\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(commit, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java index dbb05e850..da41a745d 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java @@ -230,4 +230,42 @@ private ImmutableXChainAddAccountCreateAttestation.Builder baseBuilder() { .sequence(UnsignedInteger.ONE) .signingPublicKey(ED_PUBLIC_KEY); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainAddAccountCreateAttestation transaction = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rDr5okqGKmMpn44Bbhe5WAfDQx8e9XquEv\",\n" + + " \"TransactionType\": \"XChainAddAccountCreateAttestation\",\n" + + " \"OtherChainSource\": \"rUzB7yg1LcFa7m3q1hfrjr5w53vcWzNh3U\",\n" + + " \"Destination\": \"rJMfWNVbyjcCtds8kpoEjEbYQ41J5B6MUd\",\n" + + " \"Amount\": \"2000000000\",\n" + + " \"PublicKey\": \"EDF7C3F9C80C102AF6D241752B37356E91ED454F26A35C567CF6F8477960F66614\",\n" + + " \"Signature\": \"F95675BA8FDA21030DE1B687937A79E8491CE51832D6BEEBC071484FA5AF5B8A0E9AFF11A4AA46F09EC" + + "FFB04C6A8DAE8284AF3ED8128C7D0046D842448478500\",\n" + + " \"WasLockingChainSend\": 1,\n" + + " \"AttestationRewardAccount\": \"rpFp36UHW6FpEcZjZqq5jSJWY6UCj3k4Es\",\n" + + " \"AttestationSignerAccount\": \"rpWLegmW9WrFBzHUj7brhQNZzrxgLj9oxw\",\n" + + " \"XChainAccountCreateCount\": \"2\",\n" + + " \"SignatureReward\": \"204\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s,\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"Fee\": \"20\"\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(transaction, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java index d1c158446..09711426e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java @@ -236,4 +236,44 @@ private ImmutableXChainAddClaimAttestation.Builder baseBuilder() { ) .xChainClaimId(XChainClaimId.of(UnsignedLong.ONE)); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainAddClaimAttestation attestation = baseBuilder() + .wasLockingChainSend(false) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + + " \"Amount\": \"10000000\",\n" + + " \"AttestationRewardAccount\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + + " \"AttestationSignerAccount\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + + " \"Destination\": \"rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi\",\n" + + " \"Fee\": \"20\",\n" + + " \"LastLedgerSequence\": 19,\n" + + " \"OtherChainSource\": \"raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym\",\n" + + " \"PublicKey\": \"ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E1136\",\n" + + " \"Sequence\": 9,\n" + + " \"Signature\": \"7C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA5" + + "0E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C\",\n" + + " \"SigningPubKey\": \"ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C\",\n" + + " \"TransactionType\": \"XChainAddClaimAttestation\",\n" + + " \"WasLockingChainSend\": 0,\n" + + " \"XChainBridge\": {\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"LockingChainDoor\": \"rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"XChainClaimID\": \"1\"\n" + + " }"; + + assertCanSerializeAndDeserialize(attestation, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java index 4426f54dd..494223c60 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java @@ -134,6 +134,39 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(attestation, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainClaim attestation = baseBuilder() + .destinationTag(UnsignedInteger.ONE) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + + " \"Amount\": \"10000\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s,\n" + + " \"TransactionType\": \"XChainClaim\",\n" + + " \"XChainClaimID\": \"13f\",\n" + + " \"Destination\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + + " \"DestinationTag\": 1,\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " }\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(attestation, json); + } + private ImmutableXChainClaim.Builder baseBuilder() { return XChainClaim.builder() .account(Address.of("rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java index 270229447..832812cd0 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java @@ -139,6 +139,47 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(commit, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainCommit commit = baseBuilder() + .amount( + IssuedCurrencyAmount.builder() + .currency("CNY") + .issuer(Address.of("r45dBj4S3VvMMYXxr9vHX4Z4Ma6ifPMCkK")) + .value("5000") + .build() + ) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rMTi57fNy2UkUb4RcdoUeJm7gjxVQvxzUo\",\n" + + " \"TransactionType\": \"XChainCommit\",\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"Amount\": {" + + " \"currency\": \"CNY\",\n" + + " \"value\": \"5000\",\n" + + " \"issuer\": \"r45dBj4S3VvMMYXxr9vHX4Z4Ma6ifPMCkK\"\n" + + " },\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s,\n" + + " \"XChainClaimID\": \"13f\"\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(commit, json); + } + private ImmutableXChainCommit.Builder baseBuilder() { return XChainCommit.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java index f4bc61714..d15eb7937 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java @@ -103,6 +103,38 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(createBridge, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainCreateBridge createBridge = baseBuilder() + .minAccountCreateAmount(XrpCurrencyAmount.ofDrops(1000000)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("\n" + + "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"XChainCreateBridge\",\n" + + " \"Account\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"SignatureReward\": \"200\",\n" + + " \"MinAccountCreateAmount\": \"1000000\",\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(createBridge, json); + } + private ImmutableXChainCreateBridge.Builder baseBuilder() { return XChainCreateBridge.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java index ec1824104..ac5983c39 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java @@ -102,6 +102,37 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(claimId, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainCreateClaimId claimId = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("\n" + + "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + + " \"OtherChainSource\": \"rMTi57fNy2UkUb4RcdoUeJm7gjxVQvxzUo\",\n" + + " \"TransactionType\": \"XChainCreateClaimID\",\n" + + " \"SignatureReward\": \"100\",\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(claimId, json); + } + private ImmutableXChainCreateClaimId.Builder baseBuilder() { return XChainCreateClaimId.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java index caa0a86d3..bbcce697c 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java @@ -127,6 +127,35 @@ void testWithSigRewardAndMinAccountCreateAmount() throws JSONException, JsonProc assertCanSerializeAndDeserialize(modify, json); } + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + XChainModifyBridge modify = baseBuilder() + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("\n" + + "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"XChainModifyBridge\",\n" + + " \"Account\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + + " \"XChainBridge\": {\n" + + " \"LockingChainDoor\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + + " \"LockingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + + " \"IssuingChainIssue\": {\n" + + " \"currency\": \"XRP\"\n" + + " }\n" + + " },\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\": %s\n" + + "}", ED_PUBLIC_KEY.base16Value()); + + assertCanSerializeAndDeserialize(modify, json); + } + private ImmutableXChainModifyBridge.Builder baseBuilder() { return XChainModifyBridge.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java index 8177a0b61..674bb6f2e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java @@ -117,4 +117,34 @@ public void testJsonWithNonZeroFlags() throws JsonProcessingException, JSONExcep assertCanSerializeAndDeserialize(accountDelete, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + AccountDelete accountDelete = AccountDelete.builder() + .account(Address.of("rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm")) + .fee(XrpCurrencyAmount.ofDrops(5000000)) + .sequence(UnsignedInteger.valueOf(2470665)) + .destination(Address.of("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe")) + .destinationTag(UnsignedInteger.valueOf(13)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"AccountDelete\",\n" + + " \"Account\": \"rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm\",\n" + + " \"Destination\": \"rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe\",\n" + + " \"DestinationTag\": 13,\n" + + " \"Fee\": \"5000000\",\n" + + " \"Sequence\": 2470665,\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + + "}"; + + assertCanSerializeAndDeserialize(accountDelete, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java index 4f38e2afc..25f16a2b1 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java @@ -310,4 +310,52 @@ void testJsonWithUnrecognizedClearAndSetFlag() throws JSONException, JsonProcess assertCanSerializeAndDeserialize(accountSet, json); } + + @Test + public void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(5)) + .domain("6578616D706C652E636F6D") + .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .transferRate(UnsignedInteger.valueOf(1000000001)) + .tickSize(UnsignedInteger.valueOf(15)) + .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) + .emailHash("f9879d71855b5ff21e4963273a886bfc") + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) + .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .networkId(NetworkId.of(1024)) + .walletLocator("ABCD") + .walletSize(UnsignedInteger.ONE) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\":\"AccountSet\",\n" + + " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\":\"12\",\n" + + " \"Sequence\":5,\n" + + " \"Flags\":2147483648,\n" + + " \"Domain\":\"6578616D706C652E636F6D\",\n" + + " \"SetFlag\":5,\n" + + " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + + " \"TransferRate\":1000000001,\n" + + " \"TickSize\":15,\n" + + " \"ClearFlag\":8,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"NetworkID\": 1024,\n" + + " \"WalletSize\": 1,\n" + + " \"WalletLocator\": \"ABCD\",\n" + + " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + + "}"; + + assertCanSerializeAndDeserialize(accountSet, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java index b20288ed3..056979430 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java @@ -115,6 +115,34 @@ public void testCheckCancelJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(checkCancel, json); } + @Test + public void testCheckCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { + CheckCancel checkCancel = CheckCancel.builder() + .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) + .checkId(Hash256.of("49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0")) + .sequence(UnsignedInteger.valueOf(12)) + .fee(XrpCurrencyAmount.ofDrops(12)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey( "02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + + " \"TransactionType\": \"CheckCancel\",\n" + + " \"CheckID\": \"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0\",\n" + + " \"Sequence\": 12,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"12\"\n" + + "}"; + + assertCanSerializeAndDeserialize(checkCancel, json); + } + @Test public void testCheckCashJsonWithDeliverMin() throws JsonProcessingException, JSONException { CheckCash checkCash = CheckCash.builder() @@ -225,6 +253,36 @@ public void testCheckCashJsonWithNonZeroFlags() throws JsonProcessingException, assertCanSerializeAndDeserialize(checkCash, json); } + @Test + public void testCheckCashJsonWithUnknownFields() throws JsonProcessingException, JSONException { + CheckCash checkCash = CheckCash.builder() + .account(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) + .checkId(Hash256.of("838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334")) + .sequence(UnsignedInteger.ONE) + .fee(XrpCurrencyAmount.ofDrops(12)) + .deliverMin(XrpCurrencyAmount.ofDrops(100)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + + " \"TransactionType\": \"CheckCash\",\n" + + " \"DeliverMin\": \"100\",\n" + + " \"CheckID\": \"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"12\"\n" + + "}"; + + assertCanSerializeAndDeserialize(checkCash, json); + } + @Test public void testCheckCreateJson() throws JsonProcessingException, JSONException { CheckCreate checkCreate = CheckCreate.builder() @@ -340,4 +398,40 @@ public void testCheckCreateJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(checkCreate, json); } + + @Test + public void testCheckCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { + CheckCreate checkCreate = CheckCreate.builder() + .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) + .sequence(UnsignedInteger.ONE) + .fee(XrpCurrencyAmount.ofDrops(12)) + .destination(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) + .destinationTag(UnsignedInteger.ONE) + .sendMax(XrpCurrencyAmount.ofDrops(100000000)) + .expiration(UnsignedInteger.valueOf(570113521)) + .invoiceId(Hash256.of("6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"CheckCreate\",\n" + + " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + + " \"Destination\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + + " \"SendMax\": \"100000000\",\n" + + " \"Expiration\": 570113521,\n" + + " \"InvoiceID\": \"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B\",\n" + + " \"DestinationTag\": 1,\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"12\"\n" + + "}"; + + assertCanSerializeAndDeserialize(checkCreate, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java index 372360b7e..85486ade3 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java @@ -56,4 +56,28 @@ public void testJson() throws JsonProcessingException, JSONException { assertCanSerializeAndDeserialize(enableAmendment, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + EnableAmendment enableAmendment = EnableAmendment.builder() + .account(Address.of("rrrrrrrrrrrrrrrrrrrrrhoLvTp")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(2470665)) + .amendment(Hash256.of("42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE")) + .ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(67850752)))) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{" + + "\"Foo\" : \"Bar\",\n" + + "\"Account\":\"rrrrrrrrrrrrrrrrrrrrrhoLvTp\"," + + "\"Fee\":\"12\"," + + "\"LedgerSequence\":67850752," + + "\"Sequence\":2470665," + + "\"SigningPubKey\":\"\"," + + "\"TransactionType\":\"EnableAmendment\"," + + "\"Amendment\":\"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE\"}"; + + assertCanSerializeAndDeserialize(enableAmendment, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java index 6c7c39f87..c9b1b7aaa 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java @@ -166,6 +166,50 @@ public void testEscrowCreateJsonWithNonZeroFlags() assertCanSerializeAndDeserialize(escrowCreate, json); } + @Test + public void testEscrowCreateJsonWithUnknownFields() + throws JsonProcessingException, JSONException, DerEncodingException { + EscrowCreate escrowCreate = EscrowCreate.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.ONE) + .amount(XrpCurrencyAmount.ofDrops(10000)) + .destination(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .destinationTag(UnsignedInteger.valueOf(23480)) + .cancelAfter(UnsignedLong.valueOf(533257958)) + .finishAfter(UnsignedLong.valueOf(533171558)) + .condition(CryptoConditionReader.readCondition( + BaseEncoding.base16() + .decode("A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100")) + ) + .sourceTag(UnsignedInteger.valueOf(11747)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"TransactionType\": \"EscrowCreate\",\n" + + " \"Amount\": \"10000\",\n" + + " \"Destination\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + + " \"CancelAfter\": 533257958,\n" + + " \"FinishAfter\": 533171558,\n" + + " \"Condition\": \"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100\",\n" + + " \"DestinationTag\": 23480,\n" + + " \"SourceTag\": 11747,\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"12\"\n" + + "}"; + + assertCanSerializeAndDeserialize(escrowCreate, json); + } + @Test public void testEscrowCancelJson() throws JsonProcessingException, JSONException { EscrowCancel escrowCancel = EscrowCancel.builder() @@ -247,6 +291,35 @@ public void testEscrowCancelJsonWithNonZeroFlags() throws JsonProcessingExceptio assertCanSerializeAndDeserialize(escrowCancel, json); } + @Test + public void testEscrowCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { + EscrowCancel escrowCancel = EscrowCancel.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.ONE) + .owner(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .offerSequence(UnsignedInteger.valueOf(7)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"TransactionType\": \"EscrowCancel\",\n" + + " \"Owner\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"OfferSequence\": 7,\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"12\"\n" + + "}"; + assertCanSerializeAndDeserialize(escrowCancel, json); + } + @Test public void testEscrowFinishJson() throws JsonProcessingException, JSONException, DerEncodingException { EscrowFinish escrowFinish = EscrowFinish.builder() @@ -393,4 +466,41 @@ void testEscrowFinishJsonWithMalformedFulfillment() throws JsonProcessingExcepti assertThat(escrowFinish.fulfillmentRawValue()).isNotEmpty().get() .isEqualTo("123"); } + + @Test + public void testEscrowFinishJsonWithUnknownFields() + throws JsonProcessingException, JSONException, DerEncodingException { + EscrowFinish escrowFinish = EscrowFinish.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(330)) + .sequence(UnsignedInteger.ONE) + .owner(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .offerSequence(UnsignedInteger.valueOf(7)) + .condition(CryptoConditionReader.readCondition(BaseEncoding.base16().decode( + "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100")) + ) + .fulfillment(CryptoConditionReader.readFulfillment(BaseEncoding.base16().decode("A0028000"))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"TransactionType\": \"EscrowFinish\",\n" + + " \"Owner\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"OfferSequence\": 7,\n" + + " \"Condition\": \"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100\",\n" + + " \"Fulfillment\": \"A0028000\",\n" + + " \"Sequence\": 1,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"330\"\n" + + "}"; + + assertCanSerializeAndDeserialize(escrowFinish, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java index 0c4b82073..d9216d18f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java @@ -156,4 +156,39 @@ public void testNfTokenAcceptOfferWithOnlyBuyOffer() throws JsonProcessingExcept assertCanSerializeAndDeserialize(nfTokenAcceptOffer, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + + Hash256 offer = Hash256.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); + NfTokenAcceptOffer nfTokenAcceptOffer = NfTokenAcceptOffer.builder() + .fee(XrpCurrencyAmount.ofDrops(12)) + .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) + .sequence(UnsignedInteger.valueOf(12)) + .brokerFee(XrpCurrencyAmount.ofDrops(10)) + .buyOffer(offer) + .sellOffer(offer) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"NFTokenAcceptOffer\",\n" + + " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 12,\n" + + " \"NFTokenBuyOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + + " \"NFTokenSellOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"NFTokenBrokerFee\": \"10\"\n" + + "}"; + + assertCanSerializeAndDeserialize(nfTokenAcceptOffer, json); + } + } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java index 51d734f08..27bacd498 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java @@ -116,4 +116,34 @@ public void testNfTokenBurnJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(nfTokenBurn, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + + NfTokenId id = NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); + NfTokenBurn nfTokenBurn = NfTokenBurn.builder() + .fee(XrpCurrencyAmount.ofDrops(12)) + .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) + .sequence(UnsignedInteger.valueOf(12)) + .nfTokenId(id) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"NFTokenBurn\",\n" + + " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 12,\n" + + " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + + "}"; + + assertCanSerializeAndDeserialize(nfTokenBurn, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java index 5bc21ef08..d4f1a02d4 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java @@ -130,4 +130,37 @@ public void testNfTokenCancelOfferJsonWithNonZeroFlags() throws JsonProcessingEx assertCanSerializeAndDeserialize(nfTokenCancelOffer, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + Hash256 offer = Hash256.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); + List offers = new ArrayList<>(); + offers.add(offer); + NfTokenCancelOffer nfTokenCancelOffer = NfTokenCancelOffer.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(12)) + .tokenOffers(offers) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"NFTokenCancelOffer\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 12,\n" + + " \"NetworkID\": 1024,\n" + + " \"NFTokenOffers\": [" + + " \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\"" + + " ],\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + + "}"; + + assertCanSerializeAndDeserialize(nfTokenCancelOffer, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java index 880cfa734..832a7ff3c 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java @@ -94,4 +94,36 @@ public void testJsonWithFlags() throws JsonProcessingException, JSONException { assertCanSerializeAndDeserialize(nfTokenCreateOffer, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + + NfTokenId id = NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); + NfTokenCreateOffer nfTokenCreateOffer = NfTokenCreateOffer.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .nfTokenId(id) + .sequence(UnsignedInteger.valueOf(12)) + .amount(XrpCurrencyAmount.ofDrops(2000L)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"NFTokenCreateOffer\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 12,\n" + + " \"Amount\": \"2000\",\n" + + " \"NetworkID\": 1024,\n" + + " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + + "}"; + + assertCanSerializeAndDeserialize(nfTokenCreateOffer, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java index 662baeb6c..f52801b0a 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java @@ -127,4 +127,38 @@ public void testMinimalNfTokenMintWithUriJson() throws JsonProcessingException, assertCanSerializeAndDeserialize(nfTokenMint, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + NfTokenMint nfTokenMint = NfTokenMint.builder() + .fee(XrpCurrencyAmount.ofDrops(12)) + .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) + .tokenTaxon(UnsignedLong.valueOf(146999694L)) + .sequence(UnsignedInteger.valueOf(12)) + .transferFee(TransferFee.of(UnsignedInteger.valueOf(1000))) + .flags(NfTokenMintFlags.builder() + .tfTransferable(true) + .build()) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"NFTokenMint\",\n" + + " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + + " \"Fee\": \"12\",\n" + + " \"Flags\": 2147483656,\n" + + " \"Sequence\": 12,\n" + + " \"TransferFee\": 1000,\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenTaxon\": 146999694\n" + + "}"; + + assertCanSerializeAndDeserialize(nfTokenMint, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java index 6f7ec73b8..0d3ef0c9d 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java @@ -114,6 +114,34 @@ public void testOfferCancelJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(offerCancel, json); } + @Test + public void testOfferCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { + OfferCancel offerCancel = OfferCancel.builder() + .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) + .sequence(UnsignedInteger.valueOf(12)) + .offerSequence(UnsignedInteger.valueOf(13)) + .fee(XrpCurrencyAmount.ofDrops(14)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + + " \"TransactionType\": \"OfferCancel\",\n" + + " \"Sequence\": 12,\n" + + " \"OfferSequence\": 13,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Fee\": \"14\"\n" + + "}"; + + assertCanSerializeAndDeserialize(offerCancel, json); + } + @Test public void testOfferCreateJson() throws JsonProcessingException, JSONException { OfferCreate offerCreate = OfferCreate.builder() @@ -178,4 +206,38 @@ public void testOfferCreateJsonWithFlags() throws JsonProcessingException, JSONE assertCanSerializeAndDeserialize(offerCreate, json); } + @Test + public void testOfferCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { + OfferCreate offerCreate = OfferCreate.builder() + .account(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) + .sequence(UnsignedInteger.ONE) + .fee(XrpCurrencyAmount.ofDrops(12)) + .offerSequence(UnsignedInteger.valueOf(13)) + .takerPays(XrpCurrencyAmount.ofDrops(14)) + .takerGets(XrpCurrencyAmount.ofDrops(15)) + .expiration(UnsignedInteger.valueOf(16)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + + " \"TransactionType\": \"OfferCreate\",\n" + + " \"Sequence\": 1,\n" + + " \"OfferSequence\": 13,\n" + + " \"TakerPays\": \"14\",\n" + + " \"TakerGets\": \"15\",\n" + + " \"Fee\": \"12\",\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Expiration\": 16\n" + + "}"; + + assertCanSerializeAndDeserialize(offerCreate, json); + } + } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java index c0541fd10..251e65df8 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java @@ -153,6 +153,46 @@ public void testPaymentChannelCreateJsonWithNonZeroFlags() throws JsonProcessing assertCanSerializeAndDeserialize(create, json); } + @Test + public void testPaymentChannelCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { + PaymentChannelCreate create = PaymentChannelCreate.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .sourceTag(UnsignedInteger.valueOf(11747)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.ONE) + .amount(XrpCurrencyAmount.ofDrops(10000)) + .destination(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .destinationTag(UnsignedInteger.valueOf(23480)) + .settleDelay(UnsignedInteger.valueOf(86400)) + .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") + .cancelAfter(UnsignedLong.valueOf(533171558)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"TransactionType\": \"PaymentChannelCreate\",\n" + + " \"Amount\": \"10000\",\n" + + " \"Destination\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + + " \"SettleDelay\": 86400,\n" + + " \"PublicKey\": \"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A\",\n" + + " \"CancelAfter\": 533171558,\n" + + " \"DestinationTag\": 23480,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"SourceTag\": 11747\n" + + "}"; + + assertCanSerializeAndDeserialize(create, json); + } + @Test public void testPaymentChannelClaimJson() throws JsonProcessingException, JSONException { PaymentChannelClaim claim = PaymentChannelClaim.builder() @@ -223,6 +263,43 @@ public void testPaymentChannelClaimJsonWithFlags() throws JsonProcessingExceptio assertCanSerializeAndDeserialize(claim, json); } + @Test + public void testPaymentChannelClaimJsonWithUnknownFields() throws JsonProcessingException, JSONException { + PaymentChannelClaim claim = PaymentChannelClaim.builder() + .account(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.ONE) + .channel(Hash256.of("C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198")) + .balance(XrpCurrencyAmount.ofDrops(1000000)) + .amount(XrpCurrencyAmount.ofDrops(1000000)) + .signature("30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779E" + + "F4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B") + .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"TransactionType\": \"PaymentChannelClaim\",\n" + + " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + + " \"Balance\": \"1000000\",\n" + + " \"Amount\": \"1000000\",\n" + + " \"NetworkID\": 1024,\n" + + " \"Signature\": \"30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4" + + "779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B\",\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"PublicKey\": \"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A\"\n" + + "}"; + assertCanSerializeAndDeserialize(claim, json); + } + @Test public void testPaymentChannelFundJson() throws JsonProcessingException, JSONException { PaymentChannelFund fund = PaymentChannelFund.builder() @@ -312,4 +389,36 @@ public void testPaymentChannelFundJsonWithNonZeroFlags() throws JsonProcessingEx assertCanSerializeAndDeserialize(fund, json); } + + @Test + public void testPaymentChannelFundJsonWithUnknownFields() throws JsonProcessingException, JSONException { + PaymentChannelFund fund = PaymentChannelFund.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.ONE) + .channel(Hash256.of("C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198")) + .amount(XrpCurrencyAmount.ofDrops(200000)) + .expiration(UnsignedLong.valueOf(543171558)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"10\",\n" + + " \"Sequence\": 1,\n" + + " \"TransactionType\": \"PaymentChannelFund\",\n" + + " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + + " \"Amount\": \"200000\",\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"Expiration\": 543171558\n" + + "}"; + + assertCanSerializeAndDeserialize(fund, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java index a5713e920..16b2f7543 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java @@ -157,4 +157,36 @@ public void testComplicatedJson() throws JsonProcessingException, JSONException assertCanSerializeAndDeserialize(payment, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + Payment payment = Payment.builder() + .account(Address.of("r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb")) + .destination(Address.of("r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C")) + .amount(XrpCurrencyAmount.ofDrops(25000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .flags(PaymentFlags.UNSET) + .sequence(UnsignedInteger.valueOf(2)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Account\": \"r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb\",\n" + + " \"Destination\": \"r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C\",\n" + + " \"TransactionType\": \"Payment\",\n" + + " \"Amount\": \"25000000\",\n" + + " \"Fee\": \"10\",\n" + + " \"Flags\": 0,\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"Sequence\": 2\n" + + " }"; + + assertCanSerializeAndDeserialize(payment, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java index 54b8e5cd5..074f8984c 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java @@ -111,4 +111,32 @@ public void testSetRegularKeyJsonWithNonZeroFlags() throws JsonProcessingExcepti assertCanSerializeAndDeserialize(setRegularKey, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + SetRegularKey setRegularKey = SetRegularKey.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.ONE) + .regularKey(Address.of("rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Sequence\": 1,\n" + + " \"TransactionType\": \"SetRegularKey\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"12\",\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + + " \"RegularKey\": \"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\"\n" + + "}"; + + assertCanSerializeAndDeserialize(setRegularKey, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java index 749f60883..c59eef731 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java @@ -177,4 +177,34 @@ public void testSignerListSetJsonWithNonZeroFlags() throws JsonProcessingExcepti assertCanSerializeAndDeserialize(signerListSet, json); } + + @Test + public void testSignerListSetJsonWithNonZeroFlagstestJsonWithUnknownFields() + throws JsonProcessingException, JSONException { + SignerListSet signerListSet = SignerListSet.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.ONE) + .signerQuorum(UnsignedInteger.ZERO) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(TransactionFlags.FULLY_CANONICAL_SIG) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = String.format("{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"Sequence\": 1,\n" + + " \"TransactionType\": \"SignerListSet\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"12\",\n" + + " \"Flags\": %s,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"SignerQuorum\": 0\n" + + "}", TransactionFlags.FULLY_CANONICAL_SIG.getValue()); + + assertCanSerializeAndDeserialize(signerListSet, json); + } + } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java index 23403cc91..f7ea93204 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java @@ -111,4 +111,32 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ticketCreate, json); } + + @Test + void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { + TicketCreate ticketCreate = TicketCreate.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.ONE) + .ticketCount(UnsignedInteger.valueOf(200)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"TicketCreate\",\n" + + " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\": \"12\",\n" + + " \"Sequence\": 1,\n" + + " \"NetworkID\": 1024,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TicketCount\": 200\n" + + "}"; + + assertCanSerializeAndDeserialize(ticketCreate, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java index 157d93be4..09452f983 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java @@ -144,4 +144,44 @@ public void testTrustSetWithQualityJson() throws JsonProcessingException, JSONEx assertCanSerializeAndDeserialize(trustSet, json); } + + @Test + public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { + TrustSet trustSet = TrustSet.builder() + .account(Address.of("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .flags(TrustSetFlags.builder() + .tfClearNoRipple() + .build()) + .sequence(UnsignedInteger.valueOf(12)) + .limitAmount(IssuedCurrencyAmount.builder() + .currency("USD") + .issuer(Address.of("rsP3mgGb2tcYUrxiLFiHJiQXhsziegtwBc")) + .value("100") + .build()) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .networkId(NetworkId.of(1024)) + .putUnknownFields("Foo", "Bar") + .build(); + + String json = "{\n" + + " \"Foo\" : \"Bar\",\n" + + " \"TransactionType\": \"TrustSet\",\n" + + " \"Account\": \"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\",\n" + + " \"Fee\": \"12\",\n" + + " \"Flags\": 2147745792,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"LimitAmount\": {\n" + + " \"currency\": \"USD\",\n" + + " \"issuer\": \"rsP3mgGb2tcYUrxiLFiHJiQXhsziegtwBc\",\n" + + " \"value\": \"100\"\n" + + " },\n" + + " \"NetworkID\": 1024,\n" + + " \"Sequence\": 12\n" + + "}"; + + assertCanSerializeAndDeserialize(trustSet, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java index 3b9646413..3226642b2 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java @@ -20,12 +20,15 @@ * =========================LICENSE_END================================== */ +import static org.assertj.core.api.Assertions.assertThat; + import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; +import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.UnlModify; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; From e19502cc45e93e3d2e1a6f3b5cc5ac3e5393073b Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Sat, 2 Nov 2024 17:46:30 -0400 Subject: [PATCH 08/10] javadoc --- .../transactions/UnknownTransaction.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java index 1c8f1dbdc..7a54f0122 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java @@ -8,6 +8,9 @@ import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.flags.TransactionFlags; +/** + * Mapping for any transaction type that is unrecognized/unsupported by xrpl4j. + */ @Immutable @JsonSerialize(as = ImmutableUnknownTransaction.class) @JsonDeserialize(as = ImmutableUnknownTransaction.class) @@ -23,7 +26,9 @@ static ImmutableUnknownTransaction.Builder builder() { } /** - * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, + * The actual transaction type found in the {@code "TransactionType"} field of the transaction JSON. + * + *

This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, * which only has an UNKNOWN variant. Because this method is also annotated with {@link JsonProperty} of * "TransactionType", this essentially overrides the "TransactionType" field in JSON, but {@link #transactionType()} * will always be {@link TransactionType#UNKNOWN} and this field will contain the actual "TransactionType" field. @@ -33,12 +38,24 @@ static ImmutableUnknownTransaction.Builder builder() { @JsonProperty("TransactionType") String unknownTransactionType(); + /** + * The {@link TransactionType} of this UnknownTransaction, which will always be {@link TransactionType#UNKNOWN}. + * {@link #unknownTransactionType()} contains the actual transaction type value. + * + * @return {@link TransactionType#UNKNOWN}. + */ @Override @JsonIgnore + @Value.Derived default TransactionType transactionType() { return Transaction.super.transactionType(); } + /** + * A set of {@link TransactionFlags}. + * + * @return A {@link TransactionFlags}. + */ @JsonProperty("Flags") @Value.Default default TransactionFlags flags() { From 2c7c292c0716ed23af88bf6ef2998fd55052c17e Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Sat, 2 Nov 2024 17:49:02 -0400 Subject: [PATCH 09/10] Revert "javadoc" This reverts commit e19502cc45e93e3d2e1a6f3b5cc5ac3e5393073b. --- .../transactions/UnknownTransaction.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java index 7a54f0122..1c8f1dbdc 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java @@ -8,9 +8,6 @@ import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.flags.TransactionFlags; -/** - * Mapping for any transaction type that is unrecognized/unsupported by xrpl4j. - */ @Immutable @JsonSerialize(as = ImmutableUnknownTransaction.class) @JsonDeserialize(as = ImmutableUnknownTransaction.class) @@ -26,9 +23,7 @@ static ImmutableUnknownTransaction.Builder builder() { } /** - * The actual transaction type found in the {@code "TransactionType"} field of the transaction JSON. - * - *

This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, + * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, * which only has an UNKNOWN variant. Because this method is also annotated with {@link JsonProperty} of * "TransactionType", this essentially overrides the "TransactionType" field in JSON, but {@link #transactionType()} * will always be {@link TransactionType#UNKNOWN} and this field will contain the actual "TransactionType" field. @@ -38,24 +33,12 @@ static ImmutableUnknownTransaction.Builder builder() { @JsonProperty("TransactionType") String unknownTransactionType(); - /** - * The {@link TransactionType} of this UnknownTransaction, which will always be {@link TransactionType#UNKNOWN}. - * {@link #unknownTransactionType()} contains the actual transaction type value. - * - * @return {@link TransactionType#UNKNOWN}. - */ @Override @JsonIgnore - @Value.Derived default TransactionType transactionType() { return Transaction.super.transactionType(); } - /** - * A set of {@link TransactionFlags}. - * - * @return A {@link TransactionFlags}. - */ @JsonProperty("Flags") @Value.Default default TransactionFlags flags() { From 18f9dabc006712ebdb000519d7fd2ef4ef746b33 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Sat, 2 Nov 2024 17:49:02 -0400 Subject: [PATCH 10/10] Revert "unknown transaction" This reverts commit 14f726419d857f7edb2dc86234a35d03d79566c6. --- .../xrpl4j/model/flags/TransactionFlags.java | 4 - ...ntTransactionsTransactionDeserializer.java | 17 +-- .../modules/TransactionDeserializer.java | 1 - .../TransactionResultDeserializer.java | 15 +-- .../xrpl4j/model/transactions/AmmBid.java | 6 - .../model/transactions/Transaction.java | 10 -- .../model/transactions/TransactionType.java | 6 +- .../transactions/UnknownTransaction.java | 48 -------- .../xrpl4j/model/transactions/UnlModify.java | 4 +- .../xrpl4j/model/transactions/AmmBidTest.java | 54 --------- .../model/transactions/AmmCreateTest.java | 40 ------- .../model/transactions/AmmDeleteTest.java | 38 ------ .../model/transactions/AmmDepositTest.java | 57 --------- .../model/transactions/AmmVoteTest.java | 40 ------- .../model/transactions/AmmWithdrawTest.java | 26 +---- .../model/transactions/ClawbackTest.java | 36 ------ .../model/transactions/DidDeleteTest.java | 18 --- .../xrpl4j/model/transactions/DidSetTest.java | 28 ----- .../model/transactions/OracleDeleteTest.java | 19 --- .../model/transactions/OracleSetTest.java | 20 ---- .../xrpl4j/model/transactions/SetFeeTest.java | 34 ------ .../transactions/TransactionTypeTests.java | 31 +++-- .../transactions/UnknownTransactionTest.java | 76 ------------ .../XChainAccountCreateCommitTest.java | 52 --------- ...XChainAddAccountCreateAttestationTest.java | 38 ------ .../XChainAddClaimAttestationTest.java | 40 ------- .../model/transactions/XChainClaimTest.java | 33 ------ .../model/transactions/XChainCommitTest.java | 41 ------- .../transactions/XChainCreateBridgeTest.java | 32 ----- .../transactions/XChainCreateClaimIdTest.java | 31 ----- .../transactions/XChainModifyBridgeTest.java | 29 ----- .../json/AccountDeleteJsonTests.java | 30 ----- .../json/AccountSetJsonTests.java | 48 -------- .../transactions/json/CheckJsonTests.java | 94 --------------- .../json/EnableAmendmentJsonTests.java | 24 ---- .../transactions/json/EscrowJsonTests.java | 110 ------------------ .../json/NfTokenAcceptOfferJsonTests.java | 35 ------ .../json/NfTokenBurnJsonTests.java | 30 ----- .../json/NfTokenCancelOfferJsonTests.java | 33 ------ .../json/NfTokenCreateOfferJsonTests.java | 32 ----- .../json/NfTokenMintJsonTests.java | 34 ------ .../transactions/json/OfferJsonTests.java | 62 ---------- .../json/PaymentChannelJsonTests.java | 109 ----------------- .../transactions/json/PaymentJsonTests.java | 32 ----- .../json/SetRegularKeyJsonTest.java | 28 ----- .../json/SignerListSetJsonTests.java | 30 ----- .../json/TicketCreateJsonTest.java | 28 ----- .../transactions/json/TrustSetJsonTests.java | 40 ------- .../transactions/json/UnlModifyJsonTests.java | 3 - 49 files changed, 34 insertions(+), 1692 deletions(-) delete mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java delete mode 100644 xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java index 8c03379a7..a79f04ce0 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/TransactionFlags.java @@ -49,10 +49,6 @@ public class TransactionFlags extends Flags { TransactionFlags() { } - public static TransactionFlags of(long value) { - return new TransactionFlags(value); - } - /** * Flags indicating that a fully-canonical signature is required. This flag is highly recommended. * diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java index 4c2d0cd23..e4256eba6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AccountTransactionsTransactionDeserializer.java @@ -25,9 +25,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsTransaction; @@ -36,9 +33,7 @@ import org.xrpl.xrpl4j.model.transactions.Transaction; import java.io.IOException; -import java.util.ArrayList; import java.util.Optional; -import java.util.Set; /** * Custom Jackson Deserializer for {@link AccountTransactionsTransaction}s. This is necessary because Jackson @@ -46,8 +41,6 @@ */ public class AccountTransactionsTransactionDeserializer extends StdDeserializer> { - public static final Set EXTRA_TRANSACTION_FIELDS = Sets.newHashSet("ledger_index", "date", "hash"); - /** * No-args constructor. */ @@ -61,20 +54,14 @@ public AccountTransactionsTransaction deserialize( DeserializationContext ctxt ) throws IOException { ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); - ObjectNode node = objectMapper.readTree(jsonParser); + JsonNode node = objectMapper.readTree(jsonParser); + Transaction transaction = objectMapper.readValue(node.toString(), Transaction.class); long ledgerIndex = node.get("ledger_index").asLong(-1L); String hash = node.get("hash").asText(); Optional closeDate = Optional.ofNullable(node.get("date")) .map(JsonNode::asLong) .map(UnsignedLong::valueOf); - - // The Transaction is @JsonUnwrapped in AccountTransactionsTransaction, which means these three fields - // get added to the Transaction.unknownFields Map. To prevent that, we simply remove them from the JSON, because - // they should only show up in AccountTransactionsTransaction - node.remove(EXTRA_TRANSACTION_FIELDS); - Transaction transaction = objectMapper.readValue(node.toString(), Transaction.class); - return AccountTransactionsTransaction.builder() .transaction(transaction) .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(ledgerIndex))) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java index 1eccf82a6..c4cb3a483 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TransactionType; -import org.xrpl.xrpl4j.model.transactions.UnknownTransaction; import java.io.IOException; diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java index 932a9f277..7ab4c6795 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.Sets; import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; @@ -38,7 +37,6 @@ import java.io.IOException; import java.util.Optional; -import java.util.Set; /** * Custom deserializer for {@link TransactionResult}, which wraps the {@link Transaction} fields in the result JSON. @@ -50,10 +48,6 @@ */ public class TransactionResultDeserializer extends StdDeserializer> { - public static final Set EXTRA_TRANSACTION_FIELDS = Sets.newHashSet( - "ledger_index", "date", "hash", "status", "validated", "meta", "metaData" - ); - /** * No-args constructor. */ @@ -66,6 +60,10 @@ public TransactionResult deserialize(JsonParser jsonParser, DeserializationCo ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec(); ObjectNode objectNode = objectMapper.readTree(jsonParser); + JavaType javaType = objectMapper.getTypeFactory().constructType(new TypeReference() { + }); + T transaction = objectMapper.convertValue(objectNode, javaType); + LedgerIndex ledgerIndex = objectNode.has("ledger_index") ? LedgerIndex.of(UnsignedInteger.valueOf(objectNode.get("ledger_index").asInt())) : null; @@ -75,11 +73,6 @@ public TransactionResult deserialize(JsonParser jsonParser, DeserializationCo Optional metadata = getTransactionMetadata(objectMapper, objectNode); UnsignedLong closeDate = objectNode.has("date") ? UnsignedLong.valueOf(objectNode.get("date").asLong()) : null; - objectNode.remove(EXTRA_TRANSACTION_FIELDS); - JavaType javaType = objectMapper.getTypeFactory().constructType(new TypeReference() { - }); - T transaction = objectMapper.convertValue(objectNode, javaType); - return TransactionResult.builder() .transaction(transaction) .ledgerIndex(Optional.ofNullable(ledgerIndex)) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index 3bc9261d1..b52da0635 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -1,7 +1,5 @@ package org.xrpl.xrpl4j.model.transactions; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -12,7 +10,6 @@ import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.List; -import java.util.Map; import java.util.Optional; /** @@ -110,7 +107,4 @@ default TransactionFlags flags() { @JsonProperty("AuthAccounts") List authAccounts(); - /*@Override - @JsonAnyGetter - Map unknownFields();*/ } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index fb96cd14a..9f4f1acaf 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -20,10 +20,7 @@ * =========================LICENSE_END================================== */ -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; @@ -33,7 +30,6 @@ import org.xrpl.xrpl4j.crypto.signing.Signature; import java.util.List; -import java.util.Map; import java.util.Optional; /** @@ -94,7 +90,6 @@ public interface Transaction { .put(ImmutableDidDelete.class, TransactionType.DID_DELETE) .put(ImmutableOracleSet.class, TransactionType.ORACLE_SET) .put(ImmutableOracleDelete.class, TransactionType.ORACLE_DELETE) - .put(ImmutableUnknownTransaction.class, TransactionType.UNKNOWN) .build(); /** @@ -111,7 +106,6 @@ public interface Transaction { * @return A {@link TransactionType}. */ @JsonProperty("TransactionType") - @Value.Default // must be Default rather than Derived, otherwise Jackson treats "TransactionType" as an unknownField default TransactionType transactionType() { return typeMap.get(this.getClass()); } @@ -226,8 +220,4 @@ default PublicKey signingPublicKey() { @JsonProperty("NetworkID") Optional networkId(); - @JsonAnyGetter - @JsonInclude(Include.NON_ABSENT) - Map unknownFields(); - } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index 92cd912f1..bc19f8dbf 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -336,9 +336,7 @@ public enum TransactionType { * is subject to change.

*/ @Beta - ORACLE_DELETE("OracleDelete"), - - UNKNOWN("Unknown"); + ORACLE_DELETE("OracleDelete"); private final String value; @@ -360,7 +358,7 @@ public static TransactionType forValue(String value) { } } - return UNKNOWN; + throw new IllegalArgumentException("No matching TransactionType enum value for String value " + value); } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java deleted file mode 100644 index 1c8f1dbdc..000000000 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.xrpl.xrpl4j.model.transactions; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import org.immutables.value.Value; -import org.immutables.value.Value.Immutable; -import org.xrpl.xrpl4j.model.flags.TransactionFlags; - -@Immutable -@JsonSerialize(as = ImmutableUnknownTransaction.class) -@JsonDeserialize(as = ImmutableUnknownTransaction.class) -public interface UnknownTransaction extends Transaction { - - /** - * Construct a {@code UnknownTransaction} builder. - * - * @return An {@link ImmutableUnknownTransaction.Builder}. - */ - static ImmutableUnknownTransaction.Builder builder() { - return ImmutableUnknownTransaction.builder(); - } - - /** - * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType}, - * which only has an UNKNOWN variant. Because this method is also annotated with {@link JsonProperty} of - * "TransactionType", this essentially overrides the "TransactionType" field in JSON, but {@link #transactionType()} - * will always be {@link TransactionType#UNKNOWN} and this field will contain the actual "TransactionType" field. - * - * @return A {@link String} containing the transaction type from JSON. - */ - @JsonProperty("TransactionType") - String unknownTransactionType(); - - @Override - @JsonIgnore - default TransactionType transactionType() { - return Transaction.super.transactionType(); - } - - @JsonProperty("Flags") - @Value.Default - default TransactionFlags flags() { - return TransactionFlags.EMPTY; - } - -} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java index 9ad15e842..e171a22e0 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnlModify.java @@ -62,9 +62,7 @@ static ImmutableUnlModify.Builder builder() { */ @Override @JsonProperty("Account") - // FIXME: Have to make this Default, otherwise JsonAnySetter adds this field to unknownFields. Other option - // is that's totally fine, which i think it is -- we should let the JSON set this field if it's there - @Value.Default + @Value.Derived default Address account() { return ACCOUNT_ZERO; } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index 9cfab3080..0975e3aa0 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -312,58 +312,4 @@ void testJsonWithXrpAmountBidMinAndMax() throws JSONException, JsonProcessingExc "}"; assertCanSerializeAndDeserialize(ammBid, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmBid bid = AmmBid.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .asset(Issue.XRP) - .asset2( - Issue.builder() - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .currency("TST") - .build() - ) - .addAuthAccounts( - AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), - AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) - ) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.valueOf(9)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"AuthAccounts\" : [\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + - " }\n" + - " },\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + - " }\n" + - " }\n" + - " ],\n" + - " \"Fee\" : \"10\",\n" + - " \"Sequence\" : 9,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TransactionType\" : \"AMMBid\"\n" + - "}"; - - assertCanSerializeAndDeserialize(bid, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java index 927f1820a..275582f17 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java @@ -127,44 +127,4 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ammCreate, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmCreate ammCreate = AmmCreate.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .amount( - IssuedCurrencyAmount.builder() - .currency("TST") - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .value("25") - .build() - ) - .amount2(XrpCurrencyAmount.ofDrops(250000000)) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.valueOf(6)) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"Amount\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + - " \"value\" : \"25\"\n" + - " },\n" + - " \"Amount2\" : \"250000000\",\n" + - " \"Fee\" : \"10\",\n" + - " \"Sequence\" : 6,\n" + - " \"TradingFee\" : 500,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TransactionType\" : \"AMMCreate\"\n" + - "}"; - - assertCanSerializeAndDeserialize(ammCreate, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java index 83681dfc7..2889e572e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java @@ -46,42 +46,4 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ammDelete, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmDelete ammDelete = AmmDelete.builder() - .asset(Issue.XRP) - .asset2( - Issue.builder() - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .currency("TST") - .build() - ) - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.valueOf(9)) - .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( - "EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156" - )) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"Fee\" : \"10\",\n" + - " \"Sequence\" : 9,\n" + - " \"SigningPubKey\" : \"EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156\",\n" + - " \"TransactionType\" : \"AMMDelete\"\n" + - "}"; - - assertCanSerializeAndDeserialize(ammDelete, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index 247367fd1..004816e7d 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -385,61 +385,4 @@ void constructTwoAssetIfEmptyDepositTestJson() throws JSONException, JsonProcess assertCanSerializeAndDeserialize(deposit, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmDeposit deposit = AmmDeposit.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .flags(AmmDepositFlags.TWO_ASSET_IF_EMPTY) - .asset(Issue.XRP) - .asset2( - Issue.builder() - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .currency("TST") - .build() - ) - .amount( - IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("100") - .build() - ) - .amount2(XrpCurrencyAmount.ofDrops(10)) - .effectivePrice(XrpCurrencyAmount.ofDrops(10)) - .putUnknownFields("Foo", "Bar") - .build(); - - assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.TWO_ASSET_IF_EMPTY); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"" + deposit.account() + "\",\n" + - " \"Amount\" : {\n" + - " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + - " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"value\" : \"100\"\n" + - " },\n" + - " \"Amount2\" : \"10\",\n" + - " \"EPrice\" : \"10\",\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + AmmDepositFlags.TWO_ASSET_IF_EMPTY + ",\n" + - " \"Sequence\" : 0,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TransactionType\" : \"AMMDeposit\"\n" + - "}"; - - assertCanSerializeAndDeserialize(deposit, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java index 8c285f51f..e0fee4500 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -128,44 +128,4 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(vote, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmVote vote = AmmVote.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .asset(Issue.XRP) - .asset2( - Issue.builder() - .currency("TST") - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .build() - ) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.valueOf(8)) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"Fee\" : \"10\",\n" + - " \"Sequence\" : 8,\n" + - " \"TradingFee\" : 600,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TransactionType\" : \"AMMVote\"\n" + - "}"; - - assertCanSerializeAndDeserialize(vote, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index b59ed7cc7..8f89e64ff 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -1,5 +1,7 @@ package org.xrpl.xrpl4j.model.transactions; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + import com.fasterxml.jackson.core.JsonProcessingException; import org.json.JSONException; import org.junit.jupiter.api.Test; @@ -210,30 +212,6 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce assertCanSerializeAndDeserialize(withdraw, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AmmWithdraw withdraw = baseBuilder() - .flags(AmmWithdrawFlags.LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"LPTokensIn\" : " + objectMapper.writeValueAsString(withdraw.lpTokensIn()) + "," + - " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + - " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + - " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + AmmWithdrawFlags.LP_TOKEN + ",\n" + - " \"Sequence\" : 0,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TransactionType\" : \"AMMWithdraw\"\n" + - "}"; - - assertCanSerializeAndDeserialize(withdraw, json); - } - private ImmutableIssuedCurrencyAmount amount() { return IssuedCurrencyAmount.builder() .currency("TST") diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java index 8eac63ea1..5eeb0410a 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/ClawbackTest.java @@ -115,40 +115,4 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(clawback, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - Clawback clawback = Clawback.builder() - .account(Address.of("rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.ONE) - .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( - "02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC" - )) - .amount( - IssuedCurrencyAmount.builder() - .currency("FOO") - .issuer(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .value("314.159") - .build() - ) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"Clawback\",\n" + - " \"Account\": \"rp6abvbTbjoce8ZDJkT6snvxTZSYMBCC9S\",\n" + - " \"Amount\": {\n" + - " \"currency\": \"FOO\",\n" + - " \"issuer\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + - " \"value\": \"314.159\"\n" + - " },\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + - "}"; - - assertCanSerializeAndDeserialize(clawback, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java index b9d5951dd..739963267 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidDeleteTest.java @@ -62,24 +62,6 @@ void testJsonWithSetFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(transaction, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - DidDelete transaction = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"DIDDelete\", \n" + - " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 391,\n" + - " \"SigningPubKey\":\"%s\"\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(transaction, json); - } - private ImmutableDidDelete.Builder baseBuilder() { return DidDelete.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java index 8541f0040..09051f8c9 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DidSetTest.java @@ -113,32 +113,4 @@ void testJsonWithSetFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(transaction, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - DidSet transaction = DidSet.builder() - .account(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.valueOf(391)) - .didDocument(DidDocument.of("")) - .uri(DidUri.of("")) - .data(DidData.of("")) - .signingPublicKey(ED_PUBLIC_KEY) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"DIDSet\",\n" + - " \"Account\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 391,\n" + - " \"DIDDocument\": \"\",\n" + - " \"URI\": \"\",\n" + - " \"Data\": \"\",\n" + - " \"SigningPubKey\":\"%s\"\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(transaction, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java index fbdcdf222..54e54264a 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleDeleteTest.java @@ -37,25 +37,6 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(oracleDelete, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - OracleDelete oracleDelete = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - String json = "\n" + - "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"OracleDelete\",\n" + - " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + - " \"OracleDocumentID\": 1,\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 391,\n" + - " \"SigningPubKey\": \"" + ED_PUBLIC_KEY_HEX + "\"\n" + - "}"; - - assertCanSerializeAndDeserialize(oracleDelete, json); - } - private static ImmutableOracleDelete.Builder baseBuilder() { return OracleDelete.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java index 859417cb0..05bdb2733 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/OracleSetTest.java @@ -82,26 +82,6 @@ void testFullJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(oracleSet, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - OracleSet oracleSet = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - String json = "\n" + - "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"OracleSet\",\n" + - " \"Account\": \"rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex\",\n" + - " \"OracleDocumentID\": 1,\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 391,\n" + - " \"SigningPubKey\": \"" + ED_PUBLIC_KEY_HEX + "\",\n" + - " \"LastUpdateTime\": 1\n" + - "}"; - - assertCanSerializeAndDeserialize(oracleSet, json); - } - private static ImmutableOracleSet.Builder baseBuilder() { return OracleSet.builder() .account(Address.of("rp4pqYgrTAtdPHuZd1ZQWxrzx45jxYcZex")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java index 49a83f717..42018706f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/SetFeeTest.java @@ -155,38 +155,4 @@ public void testDeserializePostXrpFeesTransaction() throws JsonProcessingExcepti assertThat(redeserialized).isEqualTo(expected); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException { - SetFee expected = SetFee.builder() - .account(Address.of("rrrrrrrrrrrrrrrrrrrrrhoLvTp")) - .fee(XrpCurrencyAmount.ofDrops(0)) - .sequence(UnsignedInteger.valueOf(0)) - .baseFeeDrops(XrpCurrencyAmount.ofDrops(10)) - .reserveBaseDrops(XrpCurrencyAmount.ofDrops(10000000)) - .reserveIncrementDrops(XrpCurrencyAmount.ofDrops(2000000)) - .ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(66462465)))) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rrrrrrrrrrrrrrrrrrrrrhoLvTp\",\n" + - " \"BaseFeeDrops\": \"10\",\n" + - " \"Fee\": \"0\",\n" + - " \"LedgerSequence\": 66462465,\n" + - " \"ReserveBaseDrops\": \"10000000\",\n" + - " \"ReserveIncrementDrops\": \"2000000\",\n" + - " \"Sequence\": 0,\n" + - " \"SigningPubKey\": \"\",\n" + - " \"TransactionType\": \"SetFee\"}"; - - Transaction actual = objectMapper.readValue(json, Transaction.class); - assertThat(actual).isEqualTo(expected); - - String reserialized = objectMapper.writeValueAsString(actual); - Transaction redeserialized = objectMapper.readValue(reserialized, Transaction.class); - - assertThat(redeserialized).isEqualTo(expected); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java index af5e049c2..77beee833 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java @@ -32,9 +32,7 @@ import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.EmptySource; -import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.NullSource; -import org.junit.jupiter.params.provider.ValueSource; /** * Unit tests for {@link TransactionType}. @@ -42,9 +40,8 @@ public class TransactionTypeTests { @ParameterizedTest - @EnumSource - public void shouldReturnTransactionTypeForValidValues(TransactionType type) { - String value = type.value(); + @ArgumentsSource(value = TransactionTypeValidArgumentProvider.class) + public void shouldReturnTransactionTypeForValidValues(String value) { TransactionType transactionType = TransactionType.forValue(value); assertNotNull(transactionType); assertTrue(transactionType instanceof TransactionType); @@ -53,9 +50,28 @@ public void shouldReturnTransactionTypeForValidValues(TransactionType type) { @EmptySource @NullSource @ParameterizedTest - @ValueSource(strings = {"bla", "blaaa", "123"}) + @ArgumentsSource(value = TransactionTypeInvalidArgumentProvider.class) public void shouldThrowIllegalArgumentExceptionForInvalidValues(String value) { - assertThat(TransactionType.forValue(value)).isEqualTo(TransactionType.UNKNOWN); + assertThrows(IllegalArgumentException.class, () -> TransactionType.forValue(value), + "No matching TransactionType enum value for String value " + value); + } + + public static class TransactionTypeValidArgumentProvider implements ArgumentsProvider { + + @Override + public java.util.stream.Stream provideArguments(ExtensionContext context) { + return java.util.stream.Stream.of(TransactionType.values()).map(TransactionType::value).map(Arguments::of); + } + + } + + public static class TransactionTypeInvalidArgumentProvider implements ArgumentsProvider { + + @Override + public java.util.stream.Stream provideArguments(ExtensionContext context) { + return java.util.stream.Stream.of("bla", "blaaa", "123").map(Arguments::of); + } + } @Test @@ -98,6 +114,5 @@ public void testTxTypeCapitalization() { assertThat(TransactionType.XCHAIN_CREATE_BRIDGE.value()).isEqualTo("XChainCreateBridge"); assertThat(TransactionType.XCHAIN_CREATE_CLAIM_ID.value()).isEqualTo("XChainCreateClaimID"); assertThat(TransactionType.XCHAIN_MODIFY_BRIDGE.value()).isEqualTo("XChainModifyBridge"); - assertThat(TransactionType.UNKNOWN.value()).isEqualTo("Unknown"); } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java deleted file mode 100644 index aeacb2a42..000000000 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.xrpl.xrpl4j.model.transactions; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.Strings; -import com.google.common.collect.Maps; -import com.google.common.primitives.UnsignedInteger; -import org.immutables.value.Value.Immutable; -import org.json.JSONException; -import org.junit.jupiter.api.Test; -import org.xrpl.xrpl4j.crypto.keys.PublicKey; -import org.xrpl.xrpl4j.model.AbstractJsonTest; -import org.xrpl.xrpl4j.model.flags.TransactionFlags; -import org.xrpl.xrpl4j.model.transactions.AccountSet.AccountSetFlag; - -import java.util.HashMap; -import java.util.Optional; - -class UnknownTransactionTest extends AbstractJsonTest { - - @Test - void testJson() throws JSONException, JsonProcessingException { - HashMap unknownFields = Maps.newHashMap(); - unknownFields.put("Domain", ""); - unknownFields.put("SetFlag", 5); - unknownFields.put("MessageKey", ""); - unknownFields.put("TransferRate", 1000000001); - unknownFields.put("TickSize", 15); - unknownFields.put("ClearFlag", 8); - unknownFields.put("NFTokenMinter", "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"); - unknownFields.put("WalletLocator", Strings.repeat("0", 64)); - unknownFields.put("EmailHash", Strings.repeat("0", 32)); - Transaction transaction = UnknownTransaction.builder() - .unknownTransactionType("AccountSet2") - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.valueOf(5)) - .flags(TransactionFlags.of(2147483648L)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC")) - .unknownFields( - unknownFields - ) - .networkId(NetworkId.of(UnsignedInteger.valueOf(1024))) - .build(); - - // Same properties as AccountSet, but TransactionType is AccountSet2 - String json = "{\n" + - " \"TransactionType\":\"AccountSet2\",\n" + - " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\":\"12\",\n" + - " \"Sequence\":5,\n" + - " \"Flags\":2147483648,\n" + - " \"Domain\":\"\",\n" + - " \"SetFlag\":5,\n" + - " \"MessageKey\":\"\",\n" + - " \"TransferRate\":1000000001,\n" + - " \"TickSize\":15,\n" + - " \"ClearFlag\":8,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"WalletLocator\" : \"" + Strings.repeat("0", 64) + "\",\n" + - " \"EmailHash\" : \"" + Strings.repeat("0", 32) + "\",\n" + - " \"NetworkID\": 1024\n" + - "}"; - - assertCanSerializeAndDeserialize(transaction, json); - } - -} \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java index 05e79d8d5..9996af22a 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAccountCreateCommitTest.java @@ -213,56 +213,4 @@ void testJsonWithEmptySignatureReward() throws JSONException, JsonProcessingExce assertCanSerializeAndDeserialize(commit, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainAccountCreateCommit commit = XChainAccountCreateCommit.builder() - .account(Address.of("rwEqJ2UaQHe7jihxGqmx6J4xdbGiiyMaGa")) - .fee(XrpCurrencyAmount.ofDrops(1)) - .sequence(UnsignedInteger.ONE) - .destination(Address.of("rD323VyRjgzzhY4bFpo44rmyh2neB5d8Mo")) - .amount(XrpCurrencyAmount.ofDrops(20000000)) - .signatureReward(XrpCurrencyAmount.ofDrops(100)) - .signingPublicKey(ED_PUBLIC_KEY) - .xChainBridge( - XChainBridge.builder() - .lockingChainDoor(Address.of("rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4")) - .lockingChainIssue(Issue.XRP) - .issuingChainDoor(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) - .issuingChainIssue( - Issue.builder() - .currency("TST") - .issuer(Address.of("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")) - .build() - ) - .build() - ) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rwEqJ2UaQHe7jihxGqmx6J4xdbGiiyMaGa\",\n" + - " \"Fee\": \"1\",\n" + - " \"Sequence\": 1,\n" + - " \"Destination\": \"rD323VyRjgzzhY4bFpo44rmyh2neB5d8Mo\",\n" + - " \"TransactionType\": \"XChainAccountCreateCommit\",\n" + - " \"Amount\": \"20000000\",\n" + - " \"SignatureReward\": \"100\",\n" + - " \"SigningPubKey\": \"%s\",\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"TST\",\n" + - " \"issuer\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\"\n" + - " }\n" + - " }\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(commit, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java index da41a745d..dbb05e850 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddAccountCreateAttestationTest.java @@ -230,42 +230,4 @@ private ImmutableXChainAddAccountCreateAttestation.Builder baseBuilder() { .sequence(UnsignedInteger.ONE) .signingPublicKey(ED_PUBLIC_KEY); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainAddAccountCreateAttestation transaction = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rDr5okqGKmMpn44Bbhe5WAfDQx8e9XquEv\",\n" + - " \"TransactionType\": \"XChainAddAccountCreateAttestation\",\n" + - " \"OtherChainSource\": \"rUzB7yg1LcFa7m3q1hfrjr5w53vcWzNh3U\",\n" + - " \"Destination\": \"rJMfWNVbyjcCtds8kpoEjEbYQ41J5B6MUd\",\n" + - " \"Amount\": \"2000000000\",\n" + - " \"PublicKey\": \"EDF7C3F9C80C102AF6D241752B37356E91ED454F26A35C567CF6F8477960F66614\",\n" + - " \"Signature\": \"F95675BA8FDA21030DE1B687937A79E8491CE51832D6BEEBC071484FA5AF5B8A0E9AFF11A4AA46F09EC" + - "FFB04C6A8DAE8284AF3ED8128C7D0046D842448478500\",\n" + - " \"WasLockingChainSend\": 1,\n" + - " \"AttestationRewardAccount\": \"rpFp36UHW6FpEcZjZqq5jSJWY6UCj3k4Es\",\n" + - " \"AttestationSignerAccount\": \"rpWLegmW9WrFBzHUj7brhQNZzrxgLj9oxw\",\n" + - " \"XChainAccountCreateCount\": \"2\",\n" + - " \"SignatureReward\": \"204\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s,\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"r3nCVTbZGGYoWvZ58BcxDmiMUU7ChMa1eC\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"Fee\": \"20\"\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(transaction, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java index 09711426e..d1c158446 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainAddClaimAttestationTest.java @@ -236,44 +236,4 @@ private ImmutableXChainAddClaimAttestation.Builder baseBuilder() { ) .xChainClaimId(XChainClaimId.of(UnsignedLong.ONE)); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainAddClaimAttestation attestation = baseBuilder() - .wasLockingChainSend(false) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + - " \"Amount\": \"10000000\",\n" + - " \"AttestationRewardAccount\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + - " \"AttestationSignerAccount\": \"rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3\",\n" + - " \"Destination\": \"rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi\",\n" + - " \"Fee\": \"20\",\n" + - " \"LastLedgerSequence\": 19,\n" + - " \"OtherChainSource\": \"raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym\",\n" + - " \"PublicKey\": \"ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E1136\",\n" + - " \"Sequence\": 9,\n" + - " \"Signature\": \"7C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA5" + - "0E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C\",\n" + - " \"SigningPubKey\": \"ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C\",\n" + - " \"TransactionType\": \"XChainAddClaimAttestation\",\n" + - " \"WasLockingChainSend\": 0,\n" + - " \"XChainBridge\": {\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"LockingChainDoor\": \"rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"XChainClaimID\": \"1\"\n" + - " }"; - - assertCanSerializeAndDeserialize(attestation, json); - } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java index 494223c60..4426f54dd 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainClaimTest.java @@ -134,39 +134,6 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(attestation, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainClaim attestation = baseBuilder() - .destinationTag(UnsignedInteger.ONE) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + - " \"Amount\": \"10000\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s,\n" + - " \"TransactionType\": \"XChainClaim\",\n" + - " \"XChainClaimID\": \"13f\",\n" + - " \"Destination\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + - " \"DestinationTag\": 1,\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " }\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(attestation, json); - } - private ImmutableXChainClaim.Builder baseBuilder() { return XChainClaim.builder() .account(Address.of("rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw")) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java index 832812cd0..270229447 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCommitTest.java @@ -139,47 +139,6 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(commit, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainCommit commit = baseBuilder() - .amount( - IssuedCurrencyAmount.builder() - .currency("CNY") - .issuer(Address.of("r45dBj4S3VvMMYXxr9vHX4Z4Ma6ifPMCkK")) - .value("5000") - .build() - ) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rMTi57fNy2UkUb4RcdoUeJm7gjxVQvxzUo\",\n" + - " \"TransactionType\": \"XChainCommit\",\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"Amount\": {" + - " \"currency\": \"CNY\",\n" + - " \"value\": \"5000\",\n" + - " \"issuer\": \"r45dBj4S3VvMMYXxr9vHX4Z4Ma6ifPMCkK\"\n" + - " },\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s,\n" + - " \"XChainClaimID\": \"13f\"\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(commit, json); - } - private ImmutableXChainCommit.Builder baseBuilder() { return XChainCommit.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java index d15eb7937..f4bc61714 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateBridgeTest.java @@ -103,38 +103,6 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(createBridge, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainCreateBridge createBridge = baseBuilder() - .minAccountCreateAmount(XrpCurrencyAmount.ofDrops(1000000)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("\n" + - "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"XChainCreateBridge\",\n" + - " \"Account\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"SignatureReward\": \"200\",\n" + - " \"MinAccountCreateAmount\": \"1000000\",\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(createBridge, json); - } - private ImmutableXChainCreateBridge.Builder baseBuilder() { return XChainCreateBridge.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java index ac5983c39..ec1824104 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainCreateClaimIdTest.java @@ -102,37 +102,6 @@ void testJsonWithFullyCanonicalSigFlags() throws JSONException, JsonProcessingEx assertCanSerializeAndDeserialize(claimId, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainCreateClaimId claimId = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("\n" + - "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rahDmoXrtPdh7sUdrPjini3gcnTVYjbjjw\",\n" + - " \"OtherChainSource\": \"rMTi57fNy2UkUb4RcdoUeJm7gjxVQvxzUo\",\n" + - " \"TransactionType\": \"XChainCreateClaimID\",\n" + - " \"SignatureReward\": \"100\",\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(claimId, json); - } - private ImmutableXChainCreateClaimId.Builder baseBuilder() { return XChainCreateClaimId.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java index bbcce697c..caa0a86d3 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/XChainModifyBridgeTest.java @@ -127,35 +127,6 @@ void testWithSigRewardAndMinAccountCreateAmount() throws JSONException, JsonProc assertCanSerializeAndDeserialize(modify, json); } - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - XChainModifyBridge modify = baseBuilder() - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("\n" + - "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"XChainModifyBridge\",\n" + - " \"Account\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + - " \"XChainBridge\": {\n" + - " \"LockingChainDoor\": \"rhWQzvdmhf5vFS35vtKUSUwNZHGT53qQsg\",\n" + - " \"LockingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " },\n" + - " \"IssuingChainDoor\": \"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh\",\n" + - " \"IssuingChainIssue\": {\n" + - " \"currency\": \"XRP\"\n" + - " }\n" + - " },\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\": %s\n" + - "}", ED_PUBLIC_KEY.base16Value()); - - assertCanSerializeAndDeserialize(modify, json); - } - private ImmutableXChainModifyBridge.Builder baseBuilder() { return XChainModifyBridge.builder() .fee(XrpCurrencyAmount.ofDrops(10)) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java index 674bb6f2e..8177a0b61 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountDeleteJsonTests.java @@ -117,34 +117,4 @@ public void testJsonWithNonZeroFlags() throws JsonProcessingException, JSONExcep assertCanSerializeAndDeserialize(accountDelete, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - AccountDelete accountDelete = AccountDelete.builder() - .account(Address.of("rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm")) - .fee(XrpCurrencyAmount.ofDrops(5000000)) - .sequence(UnsignedInteger.valueOf(2470665)) - .destination(Address.of("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe")) - .destinationTag(UnsignedInteger.valueOf(13)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"AccountDelete\",\n" + - " \"Account\": \"rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm\",\n" + - " \"Destination\": \"rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe\",\n" + - " \"DestinationTag\": 13,\n" + - " \"Fee\": \"5000000\",\n" + - " \"Sequence\": 2470665,\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + - "}"; - - assertCanSerializeAndDeserialize(accountDelete, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java index 25f16a2b1..4f38e2afc 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/AccountSetJsonTests.java @@ -310,52 +310,4 @@ void testJsonWithUnrecognizedClearAndSetFlag() throws JSONException, JsonProcess assertCanSerializeAndDeserialize(accountSet, json); } - - @Test - public void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - AccountSet accountSet = AccountSet.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.valueOf(5)) - .domain("6578616D706C652E636F6D") - .setFlag(AccountSetFlag.ACCOUNT_TXN_ID) - .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") - .transferRate(UnsignedInteger.valueOf(1000000001)) - .tickSize(UnsignedInteger.valueOf(15)) - .clearFlag(AccountSetFlag.DEFAULT_RIPPLE) - .emailHash("f9879d71855b5ff21e4963273a886bfc") - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) - .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .networkId(NetworkId.of(1024)) - .walletLocator("ABCD") - .walletSize(UnsignedInteger.ONE) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\":\"AccountSet\",\n" + - " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\":\"12\",\n" + - " \"Sequence\":5,\n" + - " \"Flags\":2147483648,\n" + - " \"Domain\":\"6578616D706C652E636F6D\",\n" + - " \"SetFlag\":5,\n" + - " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + - " \"TransferRate\":1000000001,\n" + - " \"TickSize\":15,\n" + - " \"ClearFlag\":8,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"NetworkID\": 1024,\n" + - " \"WalletSize\": 1,\n" + - " \"WalletLocator\": \"ABCD\",\n" + - " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + - "}"; - - assertCanSerializeAndDeserialize(accountSet, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java index 056979430..b20288ed3 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/CheckJsonTests.java @@ -115,34 +115,6 @@ public void testCheckCancelJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(checkCancel, json); } - @Test - public void testCheckCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { - CheckCancel checkCancel = CheckCancel.builder() - .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) - .checkId(Hash256.of("49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0")) - .sequence(UnsignedInteger.valueOf(12)) - .fee(XrpCurrencyAmount.ofDrops(12)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey( "02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + - " \"TransactionType\": \"CheckCancel\",\n" + - " \"CheckID\": \"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0\",\n" + - " \"Sequence\": 12,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"12\"\n" + - "}"; - - assertCanSerializeAndDeserialize(checkCancel, json); - } - @Test public void testCheckCashJsonWithDeliverMin() throws JsonProcessingException, JSONException { CheckCash checkCash = CheckCash.builder() @@ -253,36 +225,6 @@ public void testCheckCashJsonWithNonZeroFlags() throws JsonProcessingException, assertCanSerializeAndDeserialize(checkCash, json); } - @Test - public void testCheckCashJsonWithUnknownFields() throws JsonProcessingException, JSONException { - CheckCash checkCash = CheckCash.builder() - .account(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) - .checkId(Hash256.of("838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334")) - .sequence(UnsignedInteger.ONE) - .fee(XrpCurrencyAmount.ofDrops(12)) - .deliverMin(XrpCurrencyAmount.ofDrops(100)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + - " \"TransactionType\": \"CheckCash\",\n" + - " \"DeliverMin\": \"100\",\n" + - " \"CheckID\": \"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"12\"\n" + - "}"; - - assertCanSerializeAndDeserialize(checkCash, json); - } - @Test public void testCheckCreateJson() throws JsonProcessingException, JSONException { CheckCreate checkCreate = CheckCreate.builder() @@ -398,40 +340,4 @@ public void testCheckCreateJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(checkCreate, json); } - - @Test - public void testCheckCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { - CheckCreate checkCreate = CheckCreate.builder() - .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) - .sequence(UnsignedInteger.ONE) - .fee(XrpCurrencyAmount.ofDrops(12)) - .destination(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) - .destinationTag(UnsignedInteger.ONE) - .sendMax(XrpCurrencyAmount.ofDrops(100000000)) - .expiration(UnsignedInteger.valueOf(570113521)) - .invoiceId(Hash256.of("6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B")) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"CheckCreate\",\n" + - " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + - " \"Destination\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + - " \"SendMax\": \"100000000\",\n" + - " \"Expiration\": 570113521,\n" + - " \"InvoiceID\": \"6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B\",\n" + - " \"DestinationTag\": 1,\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"12\"\n" + - "}"; - - assertCanSerializeAndDeserialize(checkCreate, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java index 85486ade3..372360b7e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EnableAmendmentJsonTests.java @@ -56,28 +56,4 @@ public void testJson() throws JsonProcessingException, JSONException { assertCanSerializeAndDeserialize(enableAmendment, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - EnableAmendment enableAmendment = EnableAmendment.builder() - .account(Address.of("rrrrrrrrrrrrrrrrrrrrrhoLvTp")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.valueOf(2470665)) - .amendment(Hash256.of("42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE")) - .ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(67850752)))) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{" + - "\"Foo\" : \"Bar\",\n" + - "\"Account\":\"rrrrrrrrrrrrrrrrrrrrrhoLvTp\"," + - "\"Fee\":\"12\"," + - "\"LedgerSequence\":67850752," + - "\"Sequence\":2470665," + - "\"SigningPubKey\":\"\"," + - "\"TransactionType\":\"EnableAmendment\"," + - "\"Amendment\":\"42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE\"}"; - - assertCanSerializeAndDeserialize(enableAmendment, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java index c9b1b7aaa..6c7c39f87 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/EscrowJsonTests.java @@ -166,50 +166,6 @@ public void testEscrowCreateJsonWithNonZeroFlags() assertCanSerializeAndDeserialize(escrowCreate, json); } - @Test - public void testEscrowCreateJsonWithUnknownFields() - throws JsonProcessingException, JSONException, DerEncodingException { - EscrowCreate escrowCreate = EscrowCreate.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.ONE) - .amount(XrpCurrencyAmount.ofDrops(10000)) - .destination(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .destinationTag(UnsignedInteger.valueOf(23480)) - .cancelAfter(UnsignedLong.valueOf(533257958)) - .finishAfter(UnsignedLong.valueOf(533171558)) - .condition(CryptoConditionReader.readCondition( - BaseEncoding.base16() - .decode("A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100")) - ) - .sourceTag(UnsignedInteger.valueOf(11747)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"TransactionType\": \"EscrowCreate\",\n" + - " \"Amount\": \"10000\",\n" + - " \"Destination\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + - " \"CancelAfter\": 533257958,\n" + - " \"FinishAfter\": 533171558,\n" + - " \"Condition\": \"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100\",\n" + - " \"DestinationTag\": 23480,\n" + - " \"SourceTag\": 11747,\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"12\"\n" + - "}"; - - assertCanSerializeAndDeserialize(escrowCreate, json); - } - @Test public void testEscrowCancelJson() throws JsonProcessingException, JSONException { EscrowCancel escrowCancel = EscrowCancel.builder() @@ -291,35 +247,6 @@ public void testEscrowCancelJsonWithNonZeroFlags() throws JsonProcessingExceptio assertCanSerializeAndDeserialize(escrowCancel, json); } - @Test - public void testEscrowCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { - EscrowCancel escrowCancel = EscrowCancel.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.ONE) - .owner(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .offerSequence(UnsignedInteger.valueOf(7)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"TransactionType\": \"EscrowCancel\",\n" + - " \"Owner\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"OfferSequence\": 7,\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"12\"\n" + - "}"; - assertCanSerializeAndDeserialize(escrowCancel, json); - } - @Test public void testEscrowFinishJson() throws JsonProcessingException, JSONException, DerEncodingException { EscrowFinish escrowFinish = EscrowFinish.builder() @@ -466,41 +393,4 @@ void testEscrowFinishJsonWithMalformedFulfillment() throws JsonProcessingExcepti assertThat(escrowFinish.fulfillmentRawValue()).isNotEmpty().get() .isEqualTo("123"); } - - @Test - public void testEscrowFinishJsonWithUnknownFields() - throws JsonProcessingException, JSONException, DerEncodingException { - EscrowFinish escrowFinish = EscrowFinish.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(330)) - .sequence(UnsignedInteger.ONE) - .owner(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .offerSequence(UnsignedInteger.valueOf(7)) - .condition(CryptoConditionReader.readCondition(BaseEncoding.base16().decode( - "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100")) - ) - .fulfillment(CryptoConditionReader.readFulfillment(BaseEncoding.base16().decode("A0028000"))) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"TransactionType\": \"EscrowFinish\",\n" + - " \"Owner\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"OfferSequence\": 7,\n" + - " \"Condition\": \"A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100\",\n" + - " \"Fulfillment\": \"A0028000\",\n" + - " \"Sequence\": 1,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"330\"\n" + - "}"; - - assertCanSerializeAndDeserialize(escrowFinish, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java index d9216d18f..0c4b82073 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenAcceptOfferJsonTests.java @@ -156,39 +156,4 @@ public void testNfTokenAcceptOfferWithOnlyBuyOffer() throws JsonProcessingExcept assertCanSerializeAndDeserialize(nfTokenAcceptOffer, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - - Hash256 offer = Hash256.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); - NfTokenAcceptOffer nfTokenAcceptOffer = NfTokenAcceptOffer.builder() - .fee(XrpCurrencyAmount.ofDrops(12)) - .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) - .sequence(UnsignedInteger.valueOf(12)) - .brokerFee(XrpCurrencyAmount.ofDrops(10)) - .buyOffer(offer) - .sellOffer(offer) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"NFTokenAcceptOffer\",\n" + - " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 12,\n" + - " \"NFTokenBuyOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + - " \"NFTokenSellOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"NFTokenBrokerFee\": \"10\"\n" + - "}"; - - assertCanSerializeAndDeserialize(nfTokenAcceptOffer, json); - } - } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java index 27bacd498..51d734f08 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenBurnJsonTests.java @@ -116,34 +116,4 @@ public void testNfTokenBurnJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(nfTokenBurn, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - - NfTokenId id = NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); - NfTokenBurn nfTokenBurn = NfTokenBurn.builder() - .fee(XrpCurrencyAmount.ofDrops(12)) - .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) - .sequence(UnsignedInteger.valueOf(12)) - .nfTokenId(id) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"NFTokenBurn\",\n" + - " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 12,\n" + - " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + - "}"; - - assertCanSerializeAndDeserialize(nfTokenBurn, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java index d4f1a02d4..5bc21ef08 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCancelOfferJsonTests.java @@ -130,37 +130,4 @@ public void testNfTokenCancelOfferJsonWithNonZeroFlags() throws JsonProcessingEx assertCanSerializeAndDeserialize(nfTokenCancelOffer, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - Hash256 offer = Hash256.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); - List offers = new ArrayList<>(); - offers.add(offer); - NfTokenCancelOffer nfTokenCancelOffer = NfTokenCancelOffer.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.valueOf(12)) - .tokenOffers(offers) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"NFTokenCancelOffer\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 12,\n" + - " \"NetworkID\": 1024,\n" + - " \"NFTokenOffers\": [" + - " \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\"" + - " ],\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + - "}"; - - assertCanSerializeAndDeserialize(nfTokenCancelOffer, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java index 832a7ff3c..880cfa734 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenCreateOfferJsonTests.java @@ -94,36 +94,4 @@ public void testJsonWithFlags() throws JsonProcessingException, JSONException { assertCanSerializeAndDeserialize(nfTokenCreateOffer, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - - NfTokenId id = NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"); - NfTokenCreateOffer nfTokenCreateOffer = NfTokenCreateOffer.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .nfTokenId(id) - .sequence(UnsignedInteger.valueOf(12)) - .amount(XrpCurrencyAmount.ofDrops(2000L)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"NFTokenCreateOffer\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 12,\n" + - " \"Amount\": \"2000\",\n" + - " \"NetworkID\": 1024,\n" + - " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + - "}"; - - assertCanSerializeAndDeserialize(nfTokenCreateOffer, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java index f52801b0a..662baeb6c 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/NfTokenMintJsonTests.java @@ -127,38 +127,4 @@ public void testMinimalNfTokenMintWithUriJson() throws JsonProcessingException, assertCanSerializeAndDeserialize(nfTokenMint, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - NfTokenMint nfTokenMint = NfTokenMint.builder() - .fee(XrpCurrencyAmount.ofDrops(12)) - .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) - .tokenTaxon(UnsignedLong.valueOf(146999694L)) - .sequence(UnsignedInteger.valueOf(12)) - .transferFee(TransferFee.of(UnsignedInteger.valueOf(1000))) - .flags(NfTokenMintFlags.builder() - .tfTransferable(true) - .build()) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"NFTokenMint\",\n" + - " \"Account\": \"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba\",\n" + - " \"Fee\": \"12\",\n" + - " \"Flags\": 2147483656,\n" + - " \"Sequence\": 12,\n" + - " \"TransferFee\": 1000,\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NFTokenTaxon\": 146999694\n" + - "}"; - - assertCanSerializeAndDeserialize(nfTokenMint, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java index 0d3ef0c9d..6f7ec73b8 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/OfferJsonTests.java @@ -114,34 +114,6 @@ public void testOfferCancelJsonWithNonZeroFlags() throws JsonProcessingException assertCanSerializeAndDeserialize(offerCancel, json); } - @Test - public void testOfferCancelJsonWithUnknownFields() throws JsonProcessingException, JSONException { - OfferCancel offerCancel = OfferCancel.builder() - .account(Address.of("rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo")) - .sequence(UnsignedInteger.valueOf(12)) - .offerSequence(UnsignedInteger.valueOf(13)) - .fee(XrpCurrencyAmount.ofDrops(14)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo\",\n" + - " \"TransactionType\": \"OfferCancel\",\n" + - " \"Sequence\": 12,\n" + - " \"OfferSequence\": 13,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Fee\": \"14\"\n" + - "}"; - - assertCanSerializeAndDeserialize(offerCancel, json); - } - @Test public void testOfferCreateJson() throws JsonProcessingException, JSONException { OfferCreate offerCreate = OfferCreate.builder() @@ -206,38 +178,4 @@ public void testOfferCreateJsonWithFlags() throws JsonProcessingException, JSONE assertCanSerializeAndDeserialize(offerCreate, json); } - @Test - public void testOfferCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { - OfferCreate offerCreate = OfferCreate.builder() - .account(Address.of("rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy")) - .sequence(UnsignedInteger.ONE) - .fee(XrpCurrencyAmount.ofDrops(12)) - .offerSequence(UnsignedInteger.valueOf(13)) - .takerPays(XrpCurrencyAmount.ofDrops(14)) - .takerGets(XrpCurrencyAmount.ofDrops(15)) - .expiration(UnsignedInteger.valueOf(16)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy\",\n" + - " \"TransactionType\": \"OfferCreate\",\n" + - " \"Sequence\": 1,\n" + - " \"OfferSequence\": 13,\n" + - " \"TakerPays\": \"14\",\n" + - " \"TakerGets\": \"15\",\n" + - " \"Fee\": \"12\",\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Expiration\": 16\n" + - "}"; - - assertCanSerializeAndDeserialize(offerCreate, json); - } - } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java index 251e65df8..c0541fd10 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentChannelJsonTests.java @@ -153,46 +153,6 @@ public void testPaymentChannelCreateJsonWithNonZeroFlags() throws JsonProcessing assertCanSerializeAndDeserialize(create, json); } - @Test - public void testPaymentChannelCreateJsonWithUnknownFields() throws JsonProcessingException, JSONException { - PaymentChannelCreate create = PaymentChannelCreate.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .sourceTag(UnsignedInteger.valueOf(11747)) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.ONE) - .amount(XrpCurrencyAmount.ofDrops(10000)) - .destination(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .destinationTag(UnsignedInteger.valueOf(23480)) - .settleDelay(UnsignedInteger.valueOf(86400)) - .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") - .cancelAfter(UnsignedLong.valueOf(533171558)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"TransactionType\": \"PaymentChannelCreate\",\n" + - " \"Amount\": \"10000\",\n" + - " \"Destination\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + - " \"SettleDelay\": 86400,\n" + - " \"PublicKey\": \"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A\",\n" + - " \"CancelAfter\": 533171558,\n" + - " \"DestinationTag\": 23480,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"SourceTag\": 11747\n" + - "}"; - - assertCanSerializeAndDeserialize(create, json); - } - @Test public void testPaymentChannelClaimJson() throws JsonProcessingException, JSONException { PaymentChannelClaim claim = PaymentChannelClaim.builder() @@ -263,43 +223,6 @@ public void testPaymentChannelClaimJsonWithFlags() throws JsonProcessingExceptio assertCanSerializeAndDeserialize(claim, json); } - @Test - public void testPaymentChannelClaimJsonWithUnknownFields() throws JsonProcessingException, JSONException { - PaymentChannelClaim claim = PaymentChannelClaim.builder() - .account(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.ONE) - .channel(Hash256.of("C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198")) - .balance(XrpCurrencyAmount.ofDrops(1000000)) - .amount(XrpCurrencyAmount.ofDrops(1000000)) - .signature("30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779E" + - "F4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B") - .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"TransactionType\": \"PaymentChannelClaim\",\n" + - " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + - " \"Balance\": \"1000000\",\n" + - " \"Amount\": \"1000000\",\n" + - " \"NetworkID\": 1024,\n" + - " \"Signature\": \"30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4" + - "779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B\",\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"PublicKey\": \"32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A\"\n" + - "}"; - assertCanSerializeAndDeserialize(claim, json); - } - @Test public void testPaymentChannelFundJson() throws JsonProcessingException, JSONException { PaymentChannelFund fund = PaymentChannelFund.builder() @@ -389,36 +312,4 @@ public void testPaymentChannelFundJsonWithNonZeroFlags() throws JsonProcessingEx assertCanSerializeAndDeserialize(fund, json); } - - @Test - public void testPaymentChannelFundJsonWithUnknownFields() throws JsonProcessingException, JSONException { - PaymentChannelFund fund = PaymentChannelFund.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(10)) - .sequence(UnsignedInteger.ONE) - .channel(Hash256.of("C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198")) - .amount(XrpCurrencyAmount.ofDrops(200000)) - .expiration(UnsignedLong.valueOf(543171558)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"10\",\n" + - " \"Sequence\": 1,\n" + - " \"TransactionType\": \"PaymentChannelFund\",\n" + - " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + - " \"Amount\": \"200000\",\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"Expiration\": 543171558\n" + - "}"; - - assertCanSerializeAndDeserialize(fund, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java index 16b2f7543..a5713e920 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/PaymentJsonTests.java @@ -157,36 +157,4 @@ public void testComplicatedJson() throws JsonProcessingException, JSONException assertCanSerializeAndDeserialize(payment, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - Payment payment = Payment.builder() - .account(Address.of("r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb")) - .destination(Address.of("r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C")) - .amount(XrpCurrencyAmount.ofDrops(25000000)) - .fee(XrpCurrencyAmount.ofDrops(10)) - .flags(PaymentFlags.UNSET) - .sequence(UnsignedInteger.valueOf(2)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Account\": \"r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb\",\n" + - " \"Destination\": \"r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C\",\n" + - " \"TransactionType\": \"Payment\",\n" + - " \"Amount\": \"25000000\",\n" + - " \"Fee\": \"10\",\n" + - " \"Flags\": 0,\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"Sequence\": 2\n" + - " }"; - - assertCanSerializeAndDeserialize(payment, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java index 074f8984c..54b8e5cd5 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SetRegularKeyJsonTest.java @@ -111,32 +111,4 @@ public void testSetRegularKeyJsonWithNonZeroFlags() throws JsonProcessingExcepti assertCanSerializeAndDeserialize(setRegularKey, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - SetRegularKey setRegularKey = SetRegularKey.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.ONE) - .regularKey(Address.of("rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD")) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Sequence\": 1,\n" + - " \"TransactionType\": \"SetRegularKey\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"12\",\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"NetworkID\": 1024,\n" + - " \"RegularKey\": \"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\"\n" + - "}"; - - assertCanSerializeAndDeserialize(setRegularKey, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java index c59eef731..749f60883 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/SignerListSetJsonTests.java @@ -177,34 +177,4 @@ public void testSignerListSetJsonWithNonZeroFlags() throws JsonProcessingExcepti assertCanSerializeAndDeserialize(signerListSet, json); } - - @Test - public void testSignerListSetJsonWithNonZeroFlagstestJsonWithUnknownFields() - throws JsonProcessingException, JSONException { - SignerListSet signerListSet = SignerListSet.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.ONE) - .signerQuorum(UnsignedInteger.ZERO) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .flags(TransactionFlags.FULLY_CANONICAL_SIG) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = String.format("{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"Sequence\": 1,\n" + - " \"TransactionType\": \"SignerListSet\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"12\",\n" + - " \"Flags\": %s,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"SignerQuorum\": 0\n" + - "}", TransactionFlags.FULLY_CANONICAL_SIG.getValue()); - - assertCanSerializeAndDeserialize(signerListSet, json); - } - } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java index f7ea93204..23403cc91 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TicketCreateJsonTest.java @@ -111,32 +111,4 @@ void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ticketCreate, json); } - - @Test - void testJsonWithUnknownFields() throws JSONException, JsonProcessingException { - TicketCreate ticketCreate = TicketCreate.builder() - .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .sequence(UnsignedInteger.ONE) - .ticketCount(UnsignedInteger.valueOf(200)) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"TicketCreate\",\n" + - " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + - " \"Fee\": \"12\",\n" + - " \"Sequence\": 1,\n" + - " \"NetworkID\": 1024,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"TicketCount\": 200\n" + - "}"; - - assertCanSerializeAndDeserialize(ticketCreate, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java index 09452f983..157d93be4 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/TrustSetJsonTests.java @@ -144,44 +144,4 @@ public void testTrustSetWithQualityJson() throws JsonProcessingException, JSONEx assertCanSerializeAndDeserialize(trustSet, json); } - - @Test - public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException { - TrustSet trustSet = TrustSet.builder() - .account(Address.of("ra5nK24KXen9AHvsdFTKHSANinZseWnPcX")) - .fee(XrpCurrencyAmount.ofDrops(12)) - .flags(TrustSetFlags.builder() - .tfClearNoRipple() - .build()) - .sequence(UnsignedInteger.valueOf(12)) - .limitAmount(IssuedCurrencyAmount.builder() - .currency("USD") - .issuer(Address.of("rsP3mgGb2tcYUrxiLFiHJiQXhsziegtwBc")) - .value("100") - .build()) - .signingPublicKey( - PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") - ) - .networkId(NetworkId.of(1024)) - .putUnknownFields("Foo", "Bar") - .build(); - - String json = "{\n" + - " \"Foo\" : \"Bar\",\n" + - " \"TransactionType\": \"TrustSet\",\n" + - " \"Account\": \"ra5nK24KXen9AHvsdFTKHSANinZseWnPcX\",\n" + - " \"Fee\": \"12\",\n" + - " \"Flags\": 2147745792,\n" + - " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + - " \"LimitAmount\": {\n" + - " \"currency\": \"USD\",\n" + - " \"issuer\": \"rsP3mgGb2tcYUrxiLFiHJiQXhsziegtwBc\",\n" + - " \"value\": \"100\"\n" + - " },\n" + - " \"NetworkID\": 1024,\n" + - " \"Sequence\": 12\n" + - "}"; - - assertCanSerializeAndDeserialize(trustSet, json); - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java index 3226642b2..3b9646413 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java @@ -20,15 +20,12 @@ * =========================LICENSE_END================================== */ -import static org.assertj.core.api.Assertions.assertThat; - import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; -import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.UnlModify; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;