diff --git a/pom.xml b/pom.xml index 526d9ef17..fb2dd8045 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ com.github.ben-manes.caffeine caffeine - 2.8.8 + 2.9.3 com.ripple.cryptoconditions @@ -74,7 +74,7 @@ org.assertj assertj-core - 3.23.1 + 3.24.2 test @@ -356,7 +356,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 + 3.1.2 integration-tests @@ -445,7 +445,7 @@ org.jacoco - 0.8.8 + 0.8.10 jacoco-maven-plugin diff --git a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java index e7928a663..a0c7d04f9 100644 --- a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java +++ b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java @@ -64,6 +64,8 @@ import org.xrpl.xrpl4j.model.client.ledger.LedgerResult; import org.xrpl.xrpl4j.model.client.nft.NftBuyOffersRequestParams; import org.xrpl.xrpl4j.model.client.nft.NftBuyOffersResult; +import org.xrpl.xrpl4j.model.client.nft.NftInfoRequestParams; +import org.xrpl.xrpl4j.model.client.nft.NftInfoResult; import org.xrpl.xrpl4j.model.client.nft.NftSellOffersRequestParams; import org.xrpl.xrpl4j.model.client.nft.NftSellOffersResult; import org.xrpl.xrpl4j.model.client.path.BookOffersRequestParams; @@ -511,6 +513,26 @@ public NftSellOffersResult nftSellOffers(NftSellOffersRequestParams params) thro return jsonRpcClient.send(request, NftSellOffersResult.class); } + /** + * Returns information about a given NFT. This method is only supported on Clio servers. Sending this request to a + * Reporting Mode or rippled node will result in an exception. + * + * @param params The {@link NftInfoRequestParams} to send in the request. + * + * @return The {@link NftInfoResult} returned by the {@code nft_info} method call. + * + * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error, or if the request was made to a + * non-Clio node. + */ + public NftInfoResult nftInfo(NftInfoRequestParams params) throws JsonRpcClientErrorException { + JsonRpcRequest request = JsonRpcRequest.builder() + .method(XrplMethods.NFT_INFO) + .addParams(params) + .build(); + + return jsonRpcClient.send(request, NftInfoResult.class); + } + /** * Get the {@link AccountObjectsResult} for the account specified in {@code params} by making an account_objects * method call. diff --git a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java index f141f1a16..728ac8640 100644 --- a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java +++ b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java @@ -79,6 +79,8 @@ import org.xrpl.xrpl4j.model.client.ledger.LedgerResult; import org.xrpl.xrpl4j.model.client.nft.NftBuyOffersRequestParams; import org.xrpl.xrpl4j.model.client.nft.NftBuyOffersResult; +import org.xrpl.xrpl4j.model.client.nft.NftInfoRequestParams; +import org.xrpl.xrpl4j.model.client.nft.NftInfoResult; import org.xrpl.xrpl4j.model.client.nft.NftSellOffersRequestParams; import org.xrpl.xrpl4j.model.client.nft.NftSellOffersResult; import org.xrpl.xrpl4j.model.client.path.BookOffersRequestParams; @@ -1023,4 +1025,24 @@ public void nftSellOffers() throws JsonRpcClientErrorException { assertThat(jsonRpcRequestArgumentCaptor.getValue().params().get(0)).isEqualTo(nftSellOffersRequestParams); } + @Test + void nftInfo() throws JsonRpcClientErrorException { + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.VALIDATED) + .build(); + + NftInfoResult mockResult = mock(NftInfoResult.class); + when(jsonRpcClientMock.send( + JsonRpcRequest.builder() + .method(XrplMethods.NFT_INFO) + .addParams(params) + .build(), + NftInfoResult.class + )).thenReturn(mockResult); + + NftInfoResult result = xrplClient.nftInfo(params); + + assertThat(result).isEqualTo(mockResult); + } } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java index 9077711f4..2c038ad4a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java @@ -114,6 +114,11 @@ public class XrplMethods { */ public static final String NFT_SELL_OFFERS = "nft_sell_offers"; + /** + * Constant for the nft_info Clio API method. + */ + public static final String NFT_INFO = "nft_info"; + // Transaction methods /** * Constant for the sign rippled API method. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/BuyOffer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/BuyOffer.java index 6e9b8d65d..37ff8a9d2 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/BuyOffer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/BuyOffer.java @@ -53,7 +53,6 @@ static ImmutableBuyOffer.Builder builder() { * * @return The {@link CurrencyAmount}. */ - @JsonProperty("Amount") CurrencyAmount amount(); /** @@ -62,7 +61,6 @@ static ImmutableBuyOffer.Builder builder() { * * @return The {@link NfTokenOfferFlags} for this object. */ - @JsonProperty("Flags") NfTokenOfferFlags flags(); /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParams.java index 878f9759e..7c82f738f 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParams.java @@ -21,11 +21,13 @@ */ import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplRequestParams; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; @@ -56,6 +58,21 @@ static ImmutableNftBuyOffersRequestParams.Builder builder() { @JsonProperty("nft_id") NfTokenId nfTokenId(); + /** + * Specifies the ledger version to request. A ledger version can be specified by ledger hash, + * numerical ledger index, or a shortcut value. + * + * @return A {@link LedgerSpecifier} specifying the ledger version to request. + */ + @JsonUnwrapped + @Value.Default + // This field was missing in xrpl4j <= 3.1.2. Normally, this would be a required field, but in order + // to not make a breaking change, this needs to be defaulted. rippled will default to "validated" for you, + // so defaulting to LedgerSpecifier.VALIDATED preserves the existing 3.x.x behavior. + default LedgerSpecifier ledgerSpecifier() { + return LedgerSpecifier.VALIDATED; + } + /** * Limit the number of buy offers for the {@link NfTokenId}. The server is not required to honor * this value. Must be within the inclusive range 10 to 400. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResult.java index 7b3fa483b..b42fb2b18 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResult.java @@ -23,11 +23,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; +import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import java.util.List; +import java.util.Optional; /** * The result of an "nft_buy_offers" rippled API method call. @@ -59,4 +62,19 @@ static ImmutableNftBuyOffersResult.Builder builder() { * @return {@link List} of all {@link BuyOffer}s owned by an account. */ List offers(); + + /** + * The limit, as specified in the {@link NftBuyOffersRequestParams}. + * + * @return An optionally-present {@link UnsignedInteger}. + */ + Optional limit(); + + /** + * Server-defined value indicating the response is paginated. Pass this to the next call to resume where this + * call left off. Omitted when there are no additional pages after this one. + * + * @return An optionally-present {@link Marker} containing a marker. + */ + Optional marker(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParams.java new file mode 100644 index 000000000..7a6b495ac --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParams.java @@ -0,0 +1,50 @@ +package org.xrpl.xrpl4j.model.client.nft; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.client.XrplRequestParams; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; + +/** + * Request parameters for the {@code nft_info} RPC request. This request is only supported on Clio servers. + */ +@Immutable +@JsonSerialize(as = ImmutableNftInfoRequestParams.class) +@JsonDeserialize(as = ImmutableNftInfoRequestParams.class) +public interface NftInfoRequestParams extends XrplRequestParams { + + /** + * Construct a {@code NftInfoRequestParams} builder. + * + * @return An {@link ImmutableNftInfoRequestParams.Builder}. + */ + static ImmutableNftInfoRequestParams.Builder builder() { + return ImmutableNftInfoRequestParams.builder(); + } + + /** + * A unique identifier for the non-fungible token (NFT). + * + * @return An {@link NfTokenId}. + */ + @JsonProperty("nft_id") + NfTokenId nfTokenId(); + + /** + * Specifies the ledger version to request. A ledger version can be specified by ledger hash, numerical ledger index, + * or a shortcut value. + * + *

Because {@code nft_info} is only supported on Clio nodes, and because Clio does not have access to non-validated + * ledgers, specifying a ledger that has not yet been validated, or specifying a ledger index shortcut other than + * {@link LedgerSpecifier#VALIDATED} will result in Clio returning an error. + * + * @return A {@link LedgerSpecifier} specifying the ledger version to request. + */ + @JsonUnwrapped + LedgerSpecifier ledgerSpecifier(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResult.java new file mode 100644 index 000000000..fea5eca55 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResult.java @@ -0,0 +1,118 @@ +package org.xrpl.xrpl4j.model.client.nft; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import com.google.common.primitives.UnsignedLong; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.client.XrplResult; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; +import org.xrpl.xrpl4j.model.flags.NfTokenFlags; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; +import org.xrpl.xrpl4j.model.transactions.NfTokenUri; +import org.xrpl.xrpl4j.model.transactions.TransferFee; + +import java.util.Optional; + +/** + * The result of an {@code nft_info} RPC call. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableNftInfoResult.class) +@JsonDeserialize(as = ImmutableNftInfoResult.class) +public interface NftInfoResult extends XrplResult { + + /** + * Construct a {@code NftInfoResult} builder. + * + * @return An {@link ImmutableNftInfoResult.Builder}. + */ + static ImmutableNftInfoResult.Builder builder() { + return ImmutableNftInfoResult.builder(); + } + + /** + * A unique identifier for the non-fungible token (NFT). + * + * @return An {@link NfTokenId}. + */ + @JsonProperty("nft_id") + NfTokenId nftId(); + + /** + * The ledger index of the most recent ledger version where the state of this NFT was modified, as in the NFT was + * minted (created), changed ownership (traded), or burned (destroyed). The information returned contains whatever + * happened most recently compared to the requested ledger. + * + * @return A {@link LedgerIndex}. + */ + @JsonProperty("ledger_index") + LedgerIndex ledgerIndex(); + + /** + * The account ID of this NFT's owner at this ledger index. + * + * @return An {@link Address}. + */ + Address owner(); + + /** + * Whether the NFT is burned at the request ledger. + * + * @return {@code true} if the NFT is burned at this ledger, or {@code false} otherwise. + */ + @JsonProperty("is_burned") + boolean burned(); + + /** + * The flag set of this NFT. + * + * @return An {@link NfTokenFlags}. + */ + NfTokenFlags flags(); + + /** + * The transfer fee of this NFT. + * + * @return A {@link TransferFee}. + */ + @JsonProperty("transfer_fee") + TransferFee transferFee(); + + /** + * The account ID which denotes the issuer of this NFT. + * + * @return An {@link Address}. + */ + Address issuer(); + + /** + * The NFT’s taxon. + * + * @return An {@link UnsignedLong} denoting the taxon. + */ + @JsonProperty("nft_taxon") + UnsignedLong nftTaxon(); + + /** + * The NFT’s sequence number. + * + * @return An {@link UnsignedInteger}. + */ + @JsonProperty("nft_serial") + UnsignedInteger nftSerial(); + + /** + * This field is empty if the NFT is not burned at this ledger but does not have a URI. If the NFT is not burned at + * this ledger, and it does have a URI, this field is a string containing the decoded URI of the NFT. + * + *

NOTE: If you need to retrieve the URI of a burnt token, re-request nft_info for this token, specifying the + * ledger_index as the one previous to the index where this token was burned. + * + * @return An optionally-present {@link NfTokenUri}. + */ + Optional uri(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParams.java index a7003561f..c01e5544a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParams.java @@ -21,11 +21,13 @@ */ import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplRequestParams; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; @@ -56,6 +58,21 @@ static ImmutableNftSellOffersRequestParams.Builder builder() { @JsonProperty("nft_id") NfTokenId nfTokenId(); + /** + * Specifies the ledger version to request. A ledger version can be specified by ledger hash, + * numerical ledger index, or a shortcut value. + * + * @return A {@link LedgerSpecifier} specifying the ledger version to request. + */ + @JsonUnwrapped + @Value.Default + // This field was missing in xrpl4j <= 3.1.2. Normally, this would be a required field, but in order + // to not make a breaking change, this needs to be defaulted. rippled will default to "validated" for you, + // so defaulting to LedgerSpecifier.VALIDATED preserves the existing 3.x.x behavior. + default LedgerSpecifier ledgerSpecifier() { + return LedgerSpecifier.VALIDATED; + } + /** * Limit the number of sell offers for the {@link NfTokenId}. The server is not required to honor * this value. Must be within the inclusive range 10 to 400. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersResult.java index a1aca21d9..e5bfadebe 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersResult.java @@ -23,11 +23,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; +import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import java.util.List; +import java.util.Optional; /** * The result of an "nft_sell_offers" rippled API method call. @@ -60,4 +63,19 @@ static ImmutableNftSellOffersResult.Builder builder() { * @return {@link List} of all {@link SellOffer}s owned by an account. */ List offers(); + + /** + * The limit, as specified in the {@link NftSellOffersRequestParams}. + * + * @return An optionally-present {@link UnsignedInteger}. + */ + Optional limit(); + + /** + * Server-defined value indicating the response is paginated. Pass this to the next call to resume where this + * call left off. Omitted when there are no additional pages after this one. + * + * @return An optionally-present {@link Marker} containing a marker. + */ + Optional marker(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/SellOffer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/SellOffer.java index 6fd2fcb10..3dd869832 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/SellOffer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/SellOffer.java @@ -51,7 +51,6 @@ static ImmutableSellOffer.Builder builder() { * * @return The {@link CurrencyAmount}. */ - @JsonProperty("Amount") CurrencyAmount amount(); /** @@ -59,7 +58,6 @@ static ImmutableSellOffer.Builder builder() { * * @return The {@link NfTokenOfferFlags} for this object. */ - @JsonProperty("Flags") NfTokenOfferFlags flags(); /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfo.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfo.java index fa5d01f0b..25eaa33e6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfo.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfo.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,7 @@ import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; import java.io.IOException; @@ -177,6 +178,14 @@ default boolean isLedgerInCompleteLedgers(final UnsignedLong ledgerIndex) { @JsonProperty("validation_quorum") Optional validationQuorum(); + /** + * The {@link NetworkId} of the network that this server is connected to. + * + * @return An optionally-present {@link NetworkId}. + */ + @JsonProperty("network_id") + Optional networkId(); + /** * Deserializes complete_ledgers field in the server_info response from hyphen-separated ledger indices to list of * range of UnsignedLong values. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdDeserializer.java new file mode 100644 index 000000000..f247d66a2 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdDeserializer.java @@ -0,0 +1,47 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +/*- + * ========================LICENSE_START================================= + * xrpl4j :: core + * %% + * Copyright (C) 2020 - 2023 XRPL Foundation and its contributors + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.google.common.primitives.UnsignedInteger; +import org.xrpl.xrpl4j.model.transactions.NetworkId; + +import java.io.IOException; + +/** + * Custom Jackson deserializer for {@link NetworkId}s. + */ +public class NetworkIdDeserializer extends StdDeserializer { + + /** + * No-args constructor. + */ + public NetworkIdDeserializer() { + super(NetworkId.class); + } + + @Override + public NetworkId deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + return NetworkId.of(UnsignedInteger.valueOf(jsonParser.getValueAsLong())); + } +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdSerializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdSerializer.java new file mode 100644 index 000000000..947301b46 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/NetworkIdSerializer.java @@ -0,0 +1,46 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +/*- + * ========================LICENSE_START================================= + * xrpl4j :: core + * %% + * Copyright (C) 2020 - 2023 XRPL Foundation and its contributors + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; +import org.xrpl.xrpl4j.model.transactions.NetworkId; + +import java.io.IOException; + +/** + * Custom Jackson serializer for {@link NetworkId}s. + */ +public class NetworkIdSerializer extends StdScalarSerializer { + + /** + * No-args constructor. + */ + public NetworkIdSerializer() { + super(NetworkId.class); + } + + @Override + public void serialize(NetworkId networkId, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeNumber(networkId.value().longValue()); + } +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObject.java index 0f8dada23..07ecc3f1f 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObject.java @@ -147,4 +147,11 @@ default LedgerEntryType ledgerEntryType() { */ @JsonProperty("Flags") NfTokenOfferFlags flags(); + + /** + * The unique ID of this {@link NfTokenOfferObject}. + * + * @return A {@link Hash256} containing the ID. + */ + Hash256 index(); } 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 b82f7b217..ace5b6994 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 @@ -205,7 +205,11 @@ default void checkTickSize() { * */ enum AccountSetFlag { - + /** + * This flag will do nothing but exists to accurately deserialize AccountSet transactions whose {@code SetFlag} + * or {@code ClearFlag} fields are zero. + */ + NONE(0), /** * Require a destination tag to send transactions to this account. */ @@ -274,7 +278,7 @@ enum AccountSetFlag { */ DISALLOW_INCOMING_TRUSTLINE(15); - int value; + final int value; AccountSetFlag(int value) { this.value = value; 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 ccbdbbd36..3eca5a090 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 @@ -198,4 +198,7 @@ default PublicKey signingPublicKey() { @JsonProperty("TxnSignature") Optional transactionSignature(); + @JsonProperty("NetworkID") + Optional networkId(); + } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadata.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadata.java index d804e97b9..d815a6f09 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadata.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadata.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,9 +31,9 @@ import java.util.Optional; /** - * Transaction metadata is a section of data that gets added to a transaction after it is processed. - * Any transaction that gets included in a ledger has metadata, regardless of whether it is successful. - * The transaction metadata describes the outcome of the transaction in detail. + * Transaction metadata is a section of data that gets added to a transaction after it is processed. Any transaction + * that gets included in a ledger has metadata, regardless of whether it is successful. The transaction metadata + * describes the outcome of the transaction in detail. * * @see "https://xrpl.org/transaction-metadata.html" */ @@ -52,8 +52,8 @@ static ImmutableTransactionMetadata.Builder builder() { } /** - * The transaction's position within the ledger that included it. This is zero-indexed. - * For example, the value 2 means it was the 3rd transaction in that ledger. + * The transaction's position within the ledger that included it. This is zero-indexed. For example, the value 2 means + * it was the 3rd transaction in that ledger. * * @return index of transaction within ledger. */ @@ -69,15 +69,41 @@ static ImmutableTransactionMetadata.Builder builder() { String transactionResult(); /** - * The Currency Amount actually received by the Destination account. - * Use this field to determine how much was delivered, regardless of whether the transaction is a partial payment. - * Omitted for non-Payment transactions. + * The Currency Amount actually received by the Destination account. Use this field to determine how much was + * delivered, regardless of whether the transaction is a partial payment. Omitted for non-Payment transactions. * * @return delivered amount for payments, otherwise empty for non-payments. */ @JsonProperty("delivered_amount") Optional deliveredAmount(); + /** + * The {@link NfTokenId} of the {@link org.xrpl.xrpl4j.model.ledger.NfToken} that was changed as a result of this + * transaction. Only present in metadata for {@link NfTokenMint} and {@link NfTokenAcceptOffer} transactions. + * + * @return An optionally-present {@link NfTokenId}. + */ + @JsonProperty("nftoken_id") + Optional nfTokenId(); + + /** + * The {@link NfTokenId}s of the {@link org.xrpl.xrpl4j.model.ledger.NfToken}s changed by a {@link NfTokenCancelOffer} + * transaction. Only present in metadata for {@link NfTokenCancelOffer} transactions. + * + * @return A {@link List} of {@link NfTokenId}s. + */ + @JsonProperty("nftoken_ids") + List nfTokenIds(); + + /** + * The ID of the offer created by {@link NfTokenCreateOffer} transactions. Only present in metadata for + * {@link NfTokenCreateOffer} transactions. + * + * @return An optionally-present {@link Hash256} denoting the offer ID. + */ + @JsonProperty("offer_id") + Optional offerId(); + @JsonProperty("AffectedNodes") List affectedNodes(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index a36145cd2..3e887b29a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -37,6 +37,8 @@ import org.xrpl.xrpl4j.model.jackson.modules.Hash256Serializer; import org.xrpl.xrpl4j.model.jackson.modules.MarkerDeserializer; import org.xrpl.xrpl4j.model.jackson.modules.MarkerSerializer; +import org.xrpl.xrpl4j.model.jackson.modules.NetworkIdDeserializer; +import org.xrpl.xrpl4j.model.jackson.modules.NetworkIdSerializer; import org.xrpl.xrpl4j.model.jackson.modules.NfTokenIdDeserializer; import org.xrpl.xrpl4j.model.jackson.modules.NfTokenIdSerializer; import org.xrpl.xrpl4j.model.jackson.modules.NfTokenUriSerializer; @@ -51,6 +53,7 @@ import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.util.Locale; +import java.util.Objects; /** * Wrapped immutable classes for providing type-safe objects. @@ -334,6 +337,10 @@ public boolean equals(Object obj) { /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. + * + *

Valid values for this field are between 0 and 50000 inclusive, allowing transfer rates of between 0.00% and + * 50.00% in increments of 0.001. If this field is provided in a {@link NfTokenMint} transaction, the transaction + * MUST have the {@code tfTransferable} flag enabled. */ @Value.Immutable @Wrapped @@ -349,15 +356,20 @@ public String toString() { /** * Construct {@link TransferFee} as a percentage value. * + *

The given percentage value must have at most 3 decimal places of precision, and must be + * between {@code 0} and {@code 50.000}.

+ * * @param percent of type {@link BigDecimal} + * * @return {@link TransferFee} */ - static TransferFee ofPercent(BigDecimal percent) { + public static TransferFee ofPercent(BigDecimal percent) { + Objects.requireNonNull(percent); Preconditions.checkArgument( - Math.max(0, percent.stripTrailingZeros().scale()) <= 2, - "Percent value should have a maximum of 2 decimal places." + Math.max(0, percent.stripTrailingZeros().scale()) <= 3, + "Percent value should have a maximum of 3 decimal places." ); - return TransferFee.of(UnsignedInteger.valueOf(percent.scaleByPowerOfTen(2).toBigIntegerExact())); + return TransferFee.of(UnsignedInteger.valueOf(percent.scaleByPowerOfTen(3).toBigIntegerExact())); } @@ -374,4 +386,30 @@ public void validateBounds() { } + /** + * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing a Network ID. + */ + @Value.Immutable + @Wrapped + @JsonSerialize(as = NetworkId.class, using = NetworkIdSerializer.class) + @JsonDeserialize(as = NetworkId.class, using = NetworkIdDeserializer.class) + abstract static class _NetworkId extends Wrapper implements Serializable { + + @Override + public String toString() { + return this.value().toString(); + } + + /** + * Construct a {@link NetworkId} from a {@code long}. The supplied value must be less than or equal to + * 4,294,967,295, the largest unsigned 32-bit integer. + * + * @param networkId A {@code long}. + * + * @return A {@link NetworkId}. + */ + public static NetworkId of(long networkId) { + return NetworkId.of(UnsignedInteger.valueOf(networkId)); + } + } } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/DeletedNode.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/DeletedNode.java index d84c0cca0..b9f36497c 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/DeletedNode.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/DeletedNode.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; +import java.util.Optional; + /** * A {@link DeletedNode} in transaction metadata indicates that the transaction removed an object from the ledger. * @@ -23,4 +25,13 @@ public interface DeletedNode extends AffectedNode { @JsonProperty("FinalFields") T finalFields(); + /** + * The {@link T} containing the fields of the ledger object if it was modified before it was removed in the same + * transaction. This field will rarely be present, but may be present under certain conditions. + * + * @return An {@link Optional} {@link T}. + */ + @JsonProperty("PreviousFields") + Optional previousFields(); + } diff --git a/xrpl4j-core/src/main/resources/definitions.json b/xrpl4j-core/src/main/resources/definitions.json index 768ae28b3..1911bd47a 100644 --- a/xrpl4j-core/src/main/resources/definitions.json +++ b/xrpl4j-core/src/main/resources/definitions.json @@ -1,29 +1,33 @@ { "TYPES": { - "Validation": 10003, "Done": -1, + "Unknown": -2, + "NotPresent": 0, + "UInt16": 1, + "UInt32": 2, + "UInt64": 3, "Hash128": 4, + "Hash256": 5, + "Amount": 6, "Blob": 7, "AccountID": 8, - "Amount": 6, - "Hash256": 5, - "UInt8": 16, - "Vector256": 19, "STObject": 14, - "Unknown": -2, - "Transaction": 10001, + "STArray": 15, + "UInt8": 16, "Hash160": 17, "PathSet": 18, + "Vector256": 19, + "UInt96": 20, + "UInt192": 21, + "UInt384": 22, + "UInt512": 23, + "Issue": 24, + "Transaction": 10001, "LedgerEntry": 10002, - "UInt16": 1, - "NotPresent": 0, - "UInt64": 3, - "UInt32": 2, - "STArray": 15 + "Validation": 10003, + "Metadata": 10004 }, "LEDGER_ENTRY_TYPES": { - "Any": -3, - "Child": -2, "Invalid": -1, "AccountRoot": 97, "DirectoryNode": 100, @@ -36,13 +40,17 @@ "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, - "DepositPreauth": 112, "Check": 67, - "Nickname": 110, - "Contract": 99, + "DepositPreauth": 112, + "NegativeUNL": 78, "NFTokenPage": 80, "NFTokenOffer": 55, - "NegativeUNL": 78 + "AMM": 121, + "Any": -3, + "Child": -2, + "Nickname": 110, + "Contract": 99, + "GeneratorMap": 103 }, "FIELDS": [ [ @@ -66,279 +74,279 @@ } ], [ - "LedgerEntryType", + "ObjectEndMarker", { "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt16" + "type": "STObject" } ], [ - "TransactionType", + "ArrayEndMarker", { - "nth": 2, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt16" + "type": "STArray" } ], [ - "SignerWeight", + "hash", { - "nth": 3, + "nth": 257, "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt16" + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" } ], [ - "TransferFee", + "index", { - "nth": 4, + "nth": 258, "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt16" + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" } ], [ - "Flags", + "taker_gets_funded", { - "nth": 2, + "nth": 258, "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" + "isSerialized": false, + "isSigningField": false, + "type": "Amount" } ], [ - "SourceTag", + "taker_pays_funded", { - "nth": 3, + "nth": 259, "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "UInt32" + "isSerialized": false, + "isSigningField": false, + "type": "Amount" } ], [ - "Sequence", + "LedgerEntry", { - "nth": 4, + "nth": 1, "isVLEncoded": false, - "isSerialized": true, + "isSerialized": false, "isSigningField": true, - "type": "UInt32" + "type": "LedgerEntry" } ], [ - "PreviousTxnLgrSeq", + "Transaction", { - "nth": 5, + "nth": 1, "isVLEncoded": false, - "isSerialized": true, + "isSerialized": false, "isSigningField": true, - "type": "UInt32" + "type": "Transaction" } ], [ - "LedgerSequence", + "Validation", { - "nth": 6, + "nth": 1, "isVLEncoded": false, - "isSerialized": true, + "isSerialized": false, "isSigningField": true, - "type": "UInt32" + "type": "Validation" } ], [ - "CloseTime", + "Metadata", { - "nth": 7, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "Metadata" } ], [ - "ParentCloseTime", + "CloseResolution", { - "nth": 8, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "SigningTime", + "Method", { - "nth": 9, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "Expiration", + "TransactionResult", { - "nth": 10, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "TransferRate", + "TickSize", { - "nth": 11, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "WalletSize", + "UNLModifyDisabling", { - "nth": 12, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "OwnerCount", + "HookResult", { - "nth": 13, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt8" } ], [ - "DestinationTag", + "LedgerEntryType", { - "nth": 14, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "HighQualityIn", + "TransactionType", { - "nth": 16, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "HighQualityOut", + "SignerWeight", { - "nth": 17, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "LowQualityIn", + "TransferFee", { - "nth": 18, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "LowQualityOut", + "TradingFee", { - "nth": 19, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "QualityIn", + "DiscountedFee", { - "nth": 20, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "QualityOut", + "Version", { - "nth": 21, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "StampEscrow", + "HookStateChangeCount", { - "nth": 22, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "BondAmount", + "HookEmitCount", { - "nth": 23, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "LoadFee", + "HookExecutionIndex", { - "nth": 24, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "OfferSequence", + "HookApiVersion", { - "nth": 25, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "UInt16" } ], [ - "FirstLedgerSequence", + "NetworkID", { - "nth": 26, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -346,9 +354,9 @@ } ], [ - "LastLedgerSequence", + "Flags", { - "nth": 27, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -356,9 +364,9 @@ } ], [ - "TransactionIndex", + "SourceTag", { - "nth": 28, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -366,9 +374,9 @@ } ], [ - "OperationLimit", + "Sequence", { - "nth": 29, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -376,9 +384,9 @@ } ], [ - "ReferenceFeeUnits", + "PreviousTxnLgrSeq", { - "nth": 30, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -386,9 +394,9 @@ } ], [ - "ReserveBase", + "LedgerSequence", { - "nth": 31, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -396,9 +404,9 @@ } ], [ - "ReserveIncrement", + "CloseTime", { - "nth": 32, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -406,9 +414,9 @@ } ], [ - "SetFlag", + "ParentCloseTime", { - "nth": 33, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -416,9 +424,9 @@ } ], [ - "ClearFlag", + "SigningTime", { - "nth": 34, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -426,9 +434,9 @@ } ], [ - "SignerQuorum", + "Expiration", { - "nth": 35, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -436,9 +444,9 @@ } ], [ - "CancelAfter", + "TransferRate", { - "nth": 36, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -446,9 +454,9 @@ } ], [ - "FinishAfter", + "WalletSize", { - "nth": 37, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -456,99 +464,669 @@ } ], [ - "IndexNext", + "OwnerCount", { - "nth": 1, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "UInt32" + } + ], + [ + "DestinationTag", + { + "nth": 14, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HighQualityIn", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HighQualityOut", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LowQualityIn", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LowQualityOut", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "QualityIn", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "QualityOut", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "StampEscrow", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "BondAmount", + { + "nth": 23, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LoadFee", + { + "nth": 24, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "OfferSequence", + { + "nth": 25, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FirstLedgerSequence", + { + "nth": 26, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "LastLedgerSequence", + { + "nth": 27, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TransactionIndex", + { + "nth": 28, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "OperationLimit", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReferenceFeeUnits", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReserveBase", + { + "nth": 31, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ReserveIncrement", + { + "nth": 32, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SetFlag", + { + "nth": 33, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "ClearFlag", + { + "nth": 34, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SignerQuorum", + { + "nth": 35, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "CancelAfter", + { + "nth": 36, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FinishAfter", + { + "nth": 37, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SignerListID", + { + "nth": 38, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "SettleDelay", + { + "nth": 39, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TicketCount", + { + "nth": 40, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TicketSequence", + { + "nth": 41, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "NFTokenTaxon", + { + "nth": 42, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "MintedNFTokens", + { + "nth": 43, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "BurnedNFTokens", + { + "nth": 44, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HookStateCount", + { + "nth": 45, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "EmitGeneration", + { + "nth": 46, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "VoteWeight", + { + "nth": 48, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "FirstNFTokenSequence", + { + "nth": 50, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "IndexNext", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "IndexPrevious", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "BookNode", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "OwnerNode", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "BaseFee", + { + "nth": 5, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ExchangeRate", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "LowNode", + { + "nth": 7, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HighNode", + { + "nth": 8, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "DestinationNode", + { + "nth": 9, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "Cookie", + { + "nth": 10, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ServerVersion", + { + "nth": 11, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "NFTokenOfferNode", + { + "nth": 12, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "EmitBurden", + { + "nth": 13, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookOn", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookInstructionCount", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookReturnCode", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ReferenceCount", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "EmailHash", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash128" + } + ], + [ + "TakerPaysCurrency", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "TakerPaysIssuer", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "TakerGetsCurrency", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" } ], [ - "IndexPrevious", + "TakerGetsIssuer", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "LedgerHash", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "ParentHash", { "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "BookNode", + "TransactionHash", { "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "OwnerNode", + "AccountHash", { "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "BaseFee", + "PreviousTxnID", { "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "ExchangeRate", + "LedgerIndex", { "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "LowNode", + "WalletLocator", { "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "HighNode", + "RootIndex", { "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "Hash256" } ], [ - "EmailHash", + "AccountTxnID", { - "nth": 1, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash128" + "type": "Hash256" } ], [ - "LedgerHash", + "NFTokenID", { - "nth": 1, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -556,9 +1134,9 @@ } ], [ - "ParentHash", + "EmitParentTxnID", { - "nth": 2, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -566,9 +1144,9 @@ } ], [ - "TransactionHash", + "EmitNonce", { - "nth": 3, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -576,9 +1154,9 @@ } ], [ - "AccountHash", + "EmitHookHash", { - "nth": 4, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -586,9 +1164,9 @@ } ], [ - "PreviousTxnID", + "AMMID", { - "nth": 5, + "nth": 14, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -596,9 +1174,9 @@ } ], [ - "LedgerIndex", + "BookDirectory", { - "nth": 6, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -606,9 +1184,9 @@ } ], [ - "WalletLocator", + "InvoiceID", { - "nth": 7, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -616,9 +1194,9 @@ } ], [ - "RootIndex", + "Nickname", { - "nth": 8, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -626,9 +1204,9 @@ } ], [ - "AccountTxnID", + "Amendment", { - "nth": 9, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -636,9 +1214,9 @@ } ], [ - "NFTokenID", + "Digest", { - "nth": 10, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -646,9 +1224,9 @@ } ], [ - "BookDirectory", + "Channel", { - "nth": 16, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -656,9 +1234,9 @@ } ], [ - "InvoiceID", + "ConsensusHash", { - "nth": 17, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -666,9 +1244,9 @@ } ], [ - "Nickname", + "CheckID", { - "nth": 18, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -676,9 +1254,9 @@ } ], [ - "Amendment", + "ValidatedHash", { - "nth": 19, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -686,9 +1264,9 @@ } ], [ - "TicketID", + "PreviousPageMin", { - "nth": 20, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -696,9 +1274,9 @@ } ], [ - "Digest", + "NextPageMin", { - "nth": 21, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -706,22 +1284,62 @@ } ], [ - "hash", + "NFTokenBuyOffer", { - "nth": 257, + "nth": 28, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Hash256" } ], [ - "index", + "NFTokenSellOffer", { - "nth": 258, + "nth": 29, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookStateKey", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookHash", + { + "nth": 31, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookNamespace", + { + "nth": 32, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookSetTxnID", + { + "nth": 33, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, "type": "Hash256" } ], @@ -736,9 +1354,99 @@ } ], [ - "Balance", + "Balance", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "LimitAmount", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "TakerPays", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "TakerGets", + { + "nth": 5, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "LowLimit", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "HighLimit", + { + "nth": 7, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "Fee", + { + "nth": 8, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "SendMax", + { + "nth": 9, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "DeliverMin", + { + "nth": 10, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "Amount2", { - "nth": 2, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -746,9 +1454,9 @@ } ], [ - "LimitAmount", + "BidMin", { - "nth": 3, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -756,9 +1464,9 @@ } ], [ - "TakerPays", + "BidMax", { - "nth": 4, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -766,9 +1474,9 @@ } ], [ - "TakerGets", + "MinimumOffer", { - "nth": 5, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -776,9 +1484,9 @@ } ], [ - "LowLimit", + "RippleEscrow", { - "nth": 6, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -786,9 +1494,9 @@ } ], [ - "HighLimit", + "DeliveredAmount", { - "nth": 7, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -796,9 +1504,9 @@ } ], [ - "Fee", + "NFTokenBrokerFee", { - "nth": 8, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -806,9 +1514,9 @@ } ], [ - "SendMax", + "BaseFeeDrops", { - "nth": 9, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -816,9 +1524,9 @@ } ], [ - "DeliverMin", + "ReserveBaseDrops", { - "nth": 10, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -826,9 +1534,9 @@ } ], [ - "MinimumOffer", + "ReserveIncrementDrops", { - "nth": 16, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -836,9 +1544,9 @@ } ], [ - "RippleEscrow", + "LPTokenOut", { - "nth": 17, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -846,9 +1554,9 @@ } ], [ - "DeliveredAmount", + "LPTokenIn", { - "nth": 18, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -856,9 +1564,9 @@ } ], [ - "NFTokenBrokerFee", + "EPrice", { - "nth": 19, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -866,22 +1574,22 @@ } ], [ - "taker_gets_funded", + "Price", { - "nth": 258, + "nth": 28, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], [ - "taker_pays_funded", + "LPTokenBalance", { - "nth": 259, + "nth": 31, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], @@ -1086,49 +1794,49 @@ } ], [ - "Account", + "HookStateData", { - "nth": 1, + "nth": 22, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Owner", + "HookReturnString", { - "nth": 2, + "nth": 23, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Destination", + "HookParameterName", { - "nth": 3, + "nth": 24, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Issuer", + "HookParameterValue", { - "nth": 4, + "nth": 25, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Authorize", + "Account", { - "nth": 5, + "nth": 1, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1136,9 +1844,9 @@ } ], [ - "Unauthorize", + "Owner", { - "nth": 6, + "nth": 2, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1146,9 +1854,9 @@ } ], [ - "Target", + "Destination", { - "nth": 7, + "nth": 3, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1156,9 +1864,9 @@ } ], [ - "RegularKey", + "Issuer", { - "nth": 8, + "nth": 4, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1166,9 +1874,9 @@ } ], [ - "NFTokenMinter", + "Authorize", { - "nth": 9, + "nth": 5, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1176,623 +1884,523 @@ } ], [ - "ObjectEndMarker", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "TransactionMetaData", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "CreatedNode", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "DeletedNode", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "ModifiedNode", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "PreviousFields", + "Unauthorize", { "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "FinalFields", - { - "nth": 7, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "NewFields", + "RegularKey", { "nth": 8, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "TemplateEntry", + "NFTokenMinter", { "nth": 9, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "Memo", + "EmitCallback", { "nth": 10, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "SignerEntry", - { - "nth": 11, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "NFToken", - { - "nth": 12, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "Signer", + "HookAccount", { "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "Majority", - { - "nth": 18, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "DisabledValidator", + "Indexes", { - "nth": 19, - "isVLEncoded": false, + "nth": 1, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Vector256" } ], [ - "ArrayEndMarker", + "Hashes", { - "nth": 1, - "isVLEncoded": false, + "nth": 2, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Signers", + "Amendments", { "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": false, - "type": "STArray" - } - ], - [ - "SignerEntries", - { - "nth": 4, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Template", + "NFTokenOffers", { - "nth": 5, - "isVLEncoded": false, + "nth": 4, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Necessary", + "Paths", { - "nth": 6, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "PathSet" } ], [ - "Sufficient", + "Asset", { - "nth": 7, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Issue" } ], [ - "AffectedNodes", + "Asset2", { - "nth": 8, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Issue" } ], [ - "Memos", + "TransactionMetaData", { - "nth": 9, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "NFTokens", + "CreatedNode", { - "nth": 10, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Majorities", + "DeletedNode", { - "nth": 16, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "DisabledValidators", + "ModifiedNode", { - "nth": 17, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "CloseResolution", + "PreviousFields", { - "nth": 1, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "Method", + "FinalFields", { - "nth": 2, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TransactionResult", + "NewFields", { - "nth": 3, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TakerPaysCurrency", + "TemplateEntry", { - "nth": 1, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerPaysIssuer", + "Memo", { - "nth": 2, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsCurrency", + "SignerEntry", { - "nth": 3, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsIssuer", + "NFToken", { - "nth": 4, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "Paths", + "EmitDetails", { - "nth": 1, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "PathSet" + "type": "STObject" } ], [ - "Indexes", + "Hook", { - "nth": 1, - "isVLEncoded": true, + "nth": 14, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Hashes", + "Signer", { - "nth": 2, - "isVLEncoded": true, + "nth": 16, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Amendments", + "Majority", { - "nth": 3, - "isVLEncoded": true, + "nth": 18, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "NFTokenOffers", + "DisabledValidator", { - "nth": 4, - "isVLEncoded": true, + "nth": 19, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Transaction", + "EmittedTxn", { - "nth": 1, + "nth": 20, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Transaction" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "LedgerEntry", + "HookExecution", { - "nth": 1, + "nth": 21, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "LedgerEntry" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "Validation", + "HookDefinition", { - "nth": 1, + "nth": 22, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Validation" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "SignerListID", + "HookParameter", { - "nth": 38, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "SettleDelay", + "HookGrant", { - "nth": 39, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketCount", + "VoteEntry", { - "nth": 40, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketSequence", + "AuctionSlot", { - "nth": 41, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "NFTokenTaxon", + "AuthAccount", { - "nth": 42, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "MintedNFTokens", + "Signers", { - "nth": 43, + "nth": 3, "isVLEncoded": false, "isSerialized": true, - "isSigningField": true, - "type": "UInt32" + "isSigningField": false, + "type": "STArray" } ], [ - "BurnedNFTokens", + "SignerEntries", { - "nth": 44, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STArray" } ], [ - "Channel", + "Template", { - "nth": 22, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ConsensusHash", + "Necessary", { - "nth": 23, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "CheckID", + "Sufficient", { - "nth": 24, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ValidatedHash", + "AffectedNodes", { - "nth": 25, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "PreviousPageMin", + "Memos", { - "nth": 26, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NextPageMin", + "NFTokens", { - "nth": 27, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenBuyOffer", + "Hooks", { - "nth": 28, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenSellOffer", + "VoteSlots", { - "nth": 29, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "TickSize", + "Majorities", { "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "UNLModifyDisabling", + "DisabledValidators", { "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "DestinationNode", + "HookExecutions", { - "nth": 9, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "Cookie", + "HookParameters", { - "nth": 10, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "ServerVersion", + "HookGrants", { - "nth": 11, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "NFTokenOfferNode", + "AuthAccounts", { - "nth": 12, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ] ], @@ -1810,6 +2418,9 @@ "telCAN_NOT_QUEUE_BLOCKED": -389, "telCAN_NOT_QUEUE_FEE": -388, "telCAN_NOT_QUEUE_FULL": -387, + "telWRONG_NETWORK": -386, + "telREQUIRES_NETWORK_ID": -385, + "telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384, "temMALFORMED": -299, "temBAD_AMOUNT": -298, @@ -1844,8 +2455,12 @@ "temBAD_TICK_SIZE": -269, "temINVALID_ACCOUNT_ID": -268, "temCANNOT_PREAUTH_SELF": -267, - "temUNCERTAIN": -266, - "temUNKNOWN": -265, + "temINVALID_COUNT": -266, + "temUNCERTAIN": -265, + "temUNKNOWN": -264, + "temSEQ_AND_TICKET": -263, + "temBAD_NFTOKEN_TRANSFER_FEE": -262, + "temBAD_AMM_TOKENS": -261, "tefFAILURE": -199, "tefALREADY": -198, @@ -1867,7 +2482,8 @@ "tefINVARIANT_FAILED": -182, "tefTOO_BIG": -181, "tefNO_TICKET": -180, - "tefTOKEN_IS_NOT_TRANSFERABLE": -179, + "tefNFTOKEN_IS_NOT_TRANSFERABLE": -179, + "terRETRY": -99, "terFUNDS_SPENT": -98, "terINSUF_FEE_B": -97, @@ -1879,6 +2495,8 @@ "terLAST": -91, "terNO_RIPPLE": -90, "terQUEUED": -89, + "terPRE_TICKET": -88, + "terNO_AMM": -87, "tesSUCCESS": 0, @@ -1921,19 +2539,20 @@ "tecHAS_OBLIGATIONS": 151, "tecTOO_SOON": 152, "tecMAX_SEQUENCE_REACHED": 154, - "tecNO_SUITABLE_PAGE": 155, - "tecBUY_SELL_MISMATCH": 156, - "tecOFFER_TYPE_MISMATCH": 157, - "tecCANT_ACCEPT_OWN_OFFER": 158, + "tecNO_SUITABLE_NFTOKEN_PAGE": 155, + "tecNFTOKEN_BUY_SELL_MISMATCH": 156, + "tecNFTOKEN_OFFER_TYPE_MISMATCH": 157, + "tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158, "tecINSUFFICIENT_FUNDS": 159, "tecOBJECT_NOT_FOUND": 160, "tecINSUFFICIENT_PAYMENT": 161, - "tecINCORRECT_ASSET": 162, - "tecTOO_MANY": 163 + "tecUNFUNDED_AMM": 162, + "tecAMM_BALANCE": 163, + "tecAMM_FAILED": 164, + "tecAMM_INVALID_TOKENS": 165 }, "TRANSACTION_TYPES": { "Invalid": -1, - "Payment": 0, "EscrowCreate": 1, "EscrowFinish": 2, @@ -1956,11 +2575,18 @@ "DepositPreauth": 19, "TrustSet": 20, "AccountDelete": 21, + "SetHook": 22, "NFTokenMint": 25, "NFTokenBurn": 26, "NFTokenCreateOffer": 27, "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, + "Clawback": 30, + "AMMCreate": 35, + "AMMDeposit": 36, + "AMMWithdraw": 37, + "AMMVote": 38, + "AMMBid": 39, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 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 8054640a5..8520ac601 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 @@ -58,6 +58,7 @@ import org.xrpl.xrpl4j.model.transactions.EscrowFinish; import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.OfferCancel; import org.xrpl.xrpl4j.model.transactions.OfferCreate; import org.xrpl.xrpl4j.model.transactions.Payment; @@ -85,6 +86,20 @@ private static IssuedCurrencyAmount currencyAmount(int amount) { .build(); } + @Test + public void serializeAccountSetTransactionWithNetworkId() throws JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(10598)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) + .build(); + + String expectedBinary = "12000321FFFFFFFF240000296668400000000000000A730081140F3D0C7D2CFAB2EC8295451F0B3CA03" + + "8E8E9CDCD"; + assertSerializesAndDeserializes(accountSet, expectedBinary); + } + @Test public void serializeAccountSetTransactionWithEmptyFlags() throws JsonProcessingException { AccountSet accountSet = AccountSet.builder() @@ -134,9 +149,10 @@ public void serializeAccountDelete() throws JsonProcessingException { .sequence(UnsignedInteger.valueOf(2470665)) .destination(Address.of("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe")) .destinationTag(UnsignedInteger.valueOf(13)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120015240025B3092E0000000D6840000000004C4B40730081140596915CFDEEE" + + String expectedBinary = "12001521FFFFFFFF240025B3092E0000000D6840000000004C4B40730081140596915CFDEEE" + "3A695B3EFD6BDA9AC788A368B7B8314F667B0CA50CC7709A220B0561B85E53A48461FA8"; assertSerializesAndDeserializes(accountDelete, expectedBinary); } @@ -180,9 +196,10 @@ public void serializeCheckCancel() throws JsonProcessingException { .checkId(Hash256.of("49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0")) .sequence(UnsignedInteger.valueOf(12)) .fee(XrpCurrencyAmount.ofDrops(12)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120012240000000C501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97" + + String expectedBinary = "12001221FFFFFFFF240000000C501849647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97" + "F67E9977FB068400000000000000C730081147990EC5D1D8DF69E070A968D4B186986FDF06ED0"; assertSerializesAndDeserializes(checkCancel, expectedBinary); } @@ -257,9 +274,10 @@ public void serializeCheckCashWithXrpAmount() throws JsonProcessingException { .sequence(UnsignedInteger.ONE) .fee(XrpCurrencyAmount.ofDrops(12)) .amount(XrpCurrencyAmount.ofDrops(100)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12001124000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4" + + String expectedBinary = "12001121FFFFFFFF24000000015018838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4" + "056FCBD657F5733461400000000000006468400000000000000C7300811449FF0C73CA6AF9733DA805F76CA2C37776B7C46B"; assertSerializesAndDeserializes(checkCash, expectedBinary); } @@ -310,9 +328,10 @@ void serializeCheckCreate() throws JsonProcessingException { .sendMax(XrpCurrencyAmount.ofDrops(100000000)) .expiration(UnsignedInteger.valueOf(570113521)) .invoiceId(Hash256.of("6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B")) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12001024000000012A21FB3DF12E0000000150116F1DFD1D0FE8A32E40E1F2C05CF1C" + + String expectedBinary = "12001021FFFFFFFF24000000012A21FB3DF12E0000000150116F1DFD1D0FE8A32E40E1F2C05CF1C" + "15545BAB56B617F9C6C2D63A6B704BEF59B68400000000000000C694000000005F5E100730081147990EC5D1D8DF69E070A96" + "8D4B186986FDF06ED0831449FF0C73CA6AF9733DA805F76CA2C37776B7C46B"; assertSerializesAndDeserializes(checkCreate, expectedBinary); @@ -365,9 +384,10 @@ void serializeDepositPreAuth() throws JsonProcessingException { .authorize(Address.of("rDJFnv5sEfp42LMFiX3mVQKczpFTdxYDzM")) .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(65)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120013240000004168400000000000000A730081148A928D14A643F388AC0D26B" + + String expectedBinary = "12001321FFFFFFFF240000004168400000000000000A730081148A928D14A643F388AC0D26B" + "AF9755B07EB0A2B44851486FFE2A17E861BA0FE9A3ED8352F895D80E789E0"; assertSerializesAndDeserializes(preAuth, expectedBinary); } @@ -416,9 +436,10 @@ void serializeEscrowCreate() throws JsonProcessingException, DerEncodingExceptio .condition(CryptoConditionReader.readCondition(BaseEncoding.base16().decode( "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100")) ) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12000124000000012E00005BB82024258D09812025258D0980614000000000000064684" + + String expectedBinary = "12000121FFFFFFFF24000000012E00005BB82024258D09812025258D0980614000000000000064684" + "00000000000000C7300701127A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100" + "8114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8314B5F762798A53D543A014CAF8B297CFF8F2F937E8"; assertSerializesAndDeserializes(checkCreate, expectedBinary); @@ -478,9 +499,10 @@ void serializeEscrowCancel() throws JsonProcessingException { .sequence(UnsignedInteger.ONE) .owner(Address.of("r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2")) .offerSequence(UnsignedInteger.valueOf(25)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120004240000000120190000001968400000000000000C73008114EE5F7CF61504C7" + + String expectedBinary = "12000421FFFFFFFF240000000120190000001968400000000000000C73008114EE5F7CF61504C7" + "CF7E0C22562EB19CC7ACB0FCBA8214EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA"; assertSerializesAndDeserializes(escrowCancel, expectedBinary); } @@ -529,9 +551,10 @@ void serializeEscrowFinish() throws JsonProcessingException, DerEncodingExceptio "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100") )) .fulfillment(CryptoConditionReader.readFulfillment(BaseEncoding.base16().decode("A0028000"))) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120002240000000320190000001968400000000000014A7300701004A0028000701127A02" + + String expectedBinary = "12000221FFFFFFFF240000000320190000001968400000000000014A7300701004A0028000701127A02" + "58020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B8558101008114E151CA3207BAB5B91D2F0E4D35" + "ECDFD4551C69A18214E151CA3207BAB5B91D2F0E4D35ECDFD4551C69A1"; assertSerializesAndDeserializes(escrowFinish, expectedBinary); @@ -597,9 +620,10 @@ void serializeXrpPaymentWithEmptyFlags() throws JsonProcessingException { .amount(XrpCurrencyAmount.ofDrops(12345)) .fee(XrpCurrencyAmount.ofDrops(789)) .sequence(UnsignedInteger.valueOf(56565656)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120000230000000124035F1F982E0000000261400000000000303968" + + String expectedBinary = "12000021FFFFFFFF230000000124035F1F982E0000000261400000000000303968" + "400000000000031573008114EE39E6D05CFD6A90DAB700A1D70149ECEE29DFEC83140000000000000000000000000000000000000001"; assertSerializesAndDeserializes(payment, expectedBinary); } @@ -708,9 +732,10 @@ void serializePaymentChannelCreateWithEmptyFlags() throws JsonProcessingExceptio .settleDelay(UnsignedInteger.ONE) .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") .cancelAfter(UnsignedLong.valueOf(533171558)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12000D230000000124000000012E0000000220241FC78D66202700000001614000" + + String expectedBinary = "12000D21FFFFFFFF230000000124000000012E0000000220241FC78D66202700000001614000" + "000000002710684000000000000064712132D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0" + "F0A730081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983144B4E9C06F24296074F7BC48F92A97916C6DC5EA9"; assertSerializesAndDeserializes(create, expectedBinary); @@ -772,9 +797,10 @@ void serializePaymentChannelClaimWithEmptyFlags() throws JsonProcessingException .signature("30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4779E" + "F4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B") .publicKey("32D2471DB72B27E3310F355BB33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A") + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12000F24000000015016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749D" + + String expectedBinary = "12000F21FFFFFFFF24000000015016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749D" + "CDD3B9E5992CA61986140000000000F42406240000000000F424068400000000000000A712132D2471DB72B27E3310F355B" + "B33E339BF26F8392D5A93D3BC0FC3B566612DA0F0A7300764630440220718D264EF05CAED7C781FF6DE298DCAC68D002562" + "C9BF3A07C1E721B420C0DAB02203A5A4779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B81142042" + @@ -840,9 +866,10 @@ void serializePaymentChannelFund() throws JsonProcessingException { .channel(Hash256.of("C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198")) .amount(XrpCurrencyAmount.ofDrops(200000)) .expiration(UnsignedLong.valueOf(543171558)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedJson = "12000E24000000012A206023E65016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC7" + + String expectedJson = "12000E21FFFFFFFF24000000012A206023E65016C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC7" + "49DCDD3B9E5992CA6198614000000000030D4068400000000000000A730081144B4E9C06F24296074F7BC48F92A97916C6DC5EA9"; assertSerializesAndDeserializes(fund, expectedJson); @@ -895,10 +922,11 @@ void serializeTrustSetWithEmptyFlags() throws JsonProcessingException { .issuer(Address.of("rUx4xgE7bNWCCgGcXv1CCoQyTcCeZ275YG")) .value("10000000") .build()) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120014240000002C63D6438D7EA4C68000000000000000000000000000574347000000" + + String expectedBinary = "12001421FFFFFFFF240000002C63D6438D7EA4C68000000000000000000000000000574347000000" + "0000832297BEF589D59F9C03A84F920F8D9128CC1CE468400000000000000C73008114BE6C30732AE33CF2AF3344CE8172A6B9" + "300183E3"; assertSerializesAndDeserializes(trustSet, expectedBinary); @@ -1411,9 +1439,10 @@ public void serializeOfferCreateWithEmptyFlags() throws JsonProcessingException .sequence(UnsignedInteger.valueOf(11223344)) .offerSequence(UnsignedInteger.valueOf(123)) .expiration(UnsignedInteger.valueOf(456)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "1200072400AB41302A000001C820190000007B64D5071AFD498D0000000000000000000" + + String expectedBinary = "12000721FFFFFFFF2400AB41302A000001C820190000007B64D5071AFD498D0000000000000000000" + "0000000005743470000000000832297BEF589D59F9C03A84F920F8D9128CC1CE465D5038D7EA4C6800000000000000000000000" + "00005743470000000000832297BEF589D59F9C03A84F920F8D9128CC1CE468400000000000012C73008114832297BEF589D59F9" + "C03A84F920F8D9128CC1CE4"; @@ -1467,9 +1496,10 @@ public void serializeOfferCancel() throws JsonProcessingException { .account(Address.of("rUx4xgE7bNWCCgGcXv1CCoQyTcCeZ275YG")) .sequence(UnsignedInteger.valueOf(11223344)) .offerSequence(UnsignedInteger.valueOf(123)) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "1200082400AB413020190000007B68400000000000012C73008114832297BEF589" + + String expectedBinary = "12000821FFFFFFFF2400AB413020190000007B68400000000000012C73008114832297BEF589" + "D59F9C03A84F920F8D9128CC1CE4"; assertSerializesAndDeserializes(offerCreate, expectedBinary); } @@ -1511,9 +1541,10 @@ public void serializeSetRegularKey() throws JsonProcessingException { .fee(XrpCurrencyAmount.ofDrops(12)) .sequence(UnsignedInteger.ONE) .regularKey(Address.of("rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD")) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "120005240000000168400000000000000C730081144B4E9C06F24296074F7BC48F92" + + String expectedBinary = "12000521FFFFFFFF240000000168400000000000000C730081144B4E9C06F24296074F7BC48F92" + "A97916C6DC5EA988140A4B24D606281E6E5A78D9F80E039F5E66FA5AC5"; assertSerializesAndDeserializes(setRegularKey, expectedBinary); @@ -1578,9 +1609,10 @@ void serializeSignerListSet() throws JsonProcessingException { .build() ) ) + .networkId(NetworkId.of(UnsignedInteger.MAX_VALUE)) .build(); - String expectedBinary = "12000C240000000120230000000368400000000000000C730081144B4E9C06F24296074" + + String expectedBinary = "12000C21FFFFFFFF240000000120230000000368400000000000000C730081144B4E9C06F24296074" + "F7BC48F92A97916C6DC5EA9F4EB1300028114204288D2E47F8EF6C99BCC457966320D12409711E1EB13000181147908A7F0EDD4" + "8EA896C3580A399F0EE78611C8E3E1EB13000181143A4C02EA95AD6AC3BED92FA036E0BBFB712C030CE1F1"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java index 82cd1927d..dc476683d 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java @@ -43,7 +43,7 @@ public void loadFixtures() throws IOException { ObjectMapper objectMapper = BinaryCodecObjectMapperFactory.getObjectMapper(); fieldHeaderCodec = new FieldHeaderCodec(new DefaultDefinitionsProvider(objectMapper).get(), objectMapper); fieldTests = FixtureUtils.getDataDrivenFixtures().fieldTests(); - assertThat(fieldTests).hasSize(125); + assertThat(fieldTests).hasSize(123); } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenOfferObjectJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenOfferObjectJsonTests.java index 95cbbe378..461ae4541 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenOfferObjectJsonTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenOfferObjectJsonTests.java @@ -45,6 +45,7 @@ public void testJsonWithXrpAmount() throws JsonProcessingException, JSONExceptio .previousTransactionLedgerSequence(UnsignedInteger.valueOf(14090896)) .nfTokenId(NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65")) .flags(NfTokenOfferFlags.BUY_TOKEN) + .index(Hash256.of("AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3")) .build(); String json = "{\n" + @@ -55,6 +56,7 @@ public void testJsonWithXrpAmount() throws JsonProcessingException, JSONExceptio " \"Destination\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"PreviousTxnID\": \"E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879\",\n" + " \"PreviousTxnLgrSeq\": 14090896,\n" + + " \"index\": \"AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3\",\n" + " \"LedgerEntryType\": \"NFTokenOffer\"\n" + "}"; @@ -77,6 +79,7 @@ public void testJsonWithIssuedCurrencyAmount() throws JsonProcessingException, J .previousTransactionLedgerSequence(UnsignedInteger.valueOf(14090896)) .nfTokenId(NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65")) .flags(NfTokenOfferFlags.BUY_TOKEN) + .index(Hash256.of("AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3")) .build(); String json = "{\n" + @@ -91,6 +94,7 @@ public void testJsonWithIssuedCurrencyAmount() throws JsonProcessingException, J " \"Destination\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"PreviousTxnID\": \"E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879\",\n" + " \"PreviousTxnLgrSeq\": 14090896,\n" + + " \"index\": \"AEBABA4FAC212BF28E0F9A9C3788A47B085557EC5D1429E7A8266FB859C863B3\",\n" + " \"LedgerEntryType\": \"NFTokenOffer\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenSellOffersResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenSellOffersResultTest.java index fa9dfc38e..da11b0c48 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenSellOffersResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenSellOffersResultTest.java @@ -21,6 +21,7 @@ */ 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; @@ -28,6 +29,7 @@ import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -38,24 +40,21 @@ public class NfTokenSellOffersResultTest extends AbstractJsonTest { @Test public void testWithXrpAmount() throws JsonProcessingException, JSONException { - SellOffer sellOffer = SellOffer.builder() - .amount(XrpCurrencyAmount.ofDrops(1000)) - .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .flags(NfTokenOfferFlags.AUTHORIZED) - .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .build(); - - List list = new ArrayList<>(); - list.add(sellOffer); - NftSellOffersResult params = NftSellOffersResult.builder() .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .offers(list) + .addOffers( + SellOffer.builder() + .amount(XrpCurrencyAmount.ofDrops(1000)) + .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .flags(NfTokenOfferFlags.AUTHORIZED) + .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .build() + ) .build(); String offer = "{\n" + - " \"Flags\": 2,\n" + - " \"Amount\": \"1000\",\n" + + " \"flags\": 2,\n" + + " \"amount\": \"1000\",\n" + " \"owner\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + " \"nft_offer_index\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + "}"; @@ -70,29 +69,26 @@ public void testWithXrpAmount() throws JsonProcessingException, JSONException { @Test public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException { - SellOffer sellOffer = SellOffer.builder() - .amount(IssuedCurrencyAmount.builder() - .issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys")) - .currency("USD") - .value("100") - .build() - ) - .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .flags(NfTokenOfferFlags.AUTHORIZED) - .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .build(); - - List list = new ArrayList<>(); - list.add(sellOffer); - NftSellOffersResult params = NftSellOffersResult.builder() .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .offers(list) + .addOffers( + SellOffer.builder() + .amount(IssuedCurrencyAmount.builder() + .issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys")) + .currency("USD") + .value("100") + .build() + ) + .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .flags(NfTokenOfferFlags.AUTHORIZED) + .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .build() + ) .build(); String offer = "{\n" + - " \"Flags\": 2,\n" + - " \"Amount\": {\n" + + " \"flags\": 2,\n" + + " \"amount\": {\n" + " \"issuer\": \"rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys\",\n" + " \"currency\": \"USD\",\n" + " \"value\": \"100\"\n" + @@ -108,4 +104,21 @@ public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONE assertCanSerializeAndDeserialize(params, json); } + + @Test + public void testWithLimitAndMarker() throws JsonProcessingException, JSONException { + NftSellOffersResult params = NftSellOffersResult.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .limit(UnsignedInteger.ONE) + .marker(Marker.of("123")) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"limit\": 1,\n" + + " \"marker\": \"123\"\n" + + "}"; + + assertCanSerializeAndDeserialize(params, json); + } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParamsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParamsTest.java index 87fbd8b79..e334eab44 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParamsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParamsTest.java @@ -25,19 +25,55 @@ import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; +import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; public class NftBuyOffersRequestParamsTest extends AbstractJsonTest { @Test - public void testWithRequiredValue() throws JsonProcessingException, JSONException { + public void testWithLedgerIndexShortcut() throws JsonProcessingException, JSONException { NftBuyOffersRequestParams params = NftBuyOffersRequestParams.builder() .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.CURRENT) .build(); String json = "{\n" + - " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": \"current\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithLedgerIndexNumber() throws JsonProcessingException, JSONException { + NftBuyOffersRequestParams params = NftBuyOffersRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.of(100)) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": 100\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithLedgerHash() throws JsonProcessingException, JSONException { + NftBuyOffersRequestParams params = NftBuyOffersRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier( + LedgerSpecifier.of(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + ) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_hash\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + " }"; assertCanSerializeAndDeserialize(params, json); @@ -54,6 +90,7 @@ public void testWithAllValues() throws JsonProcessingException, JSONException { String json = "{\n" + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + " \"limit\": 10,\n" + + " \"ledger_index\": \"validated\",\n" + " \"marker\": \"123\"\n" + " }"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResultTest.java index ac44bf75c..db1f2a9e2 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResultTest.java @@ -21,6 +21,7 @@ */ 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; @@ -28,6 +29,7 @@ import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -38,25 +40,21 @@ public class NftBuyOffersResultTest extends AbstractJsonTest { @Test public void testWithXrpCurrencyAmount() throws JsonProcessingException, JSONException { - - BuyOffer buyOffer = BuyOffer.builder() - .amount(XrpCurrencyAmount.ofDrops(1000)) - .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .flags(NfTokenOfferFlags.BUY_TOKEN) - .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .build(); - - List list = new ArrayList<>(); - list.add(buyOffer); - NftBuyOffersResult params = NftBuyOffersResult.builder() .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .offers(list) + .addOffers( + BuyOffer.builder() + .amount(XrpCurrencyAmount.ofDrops(1000)) + .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .flags(NfTokenOfferFlags.BUY_TOKEN) + .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .build() + ) .build(); String offer = "{\n" + - " \"Flags\": 1,\n" + - " \"Amount\": \"1000\",\n" + + " \"flags\": 1,\n" + + " \"amount\": \"1000\",\n" + " \"owner\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" + " \"nft_offer_index\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + "}"; @@ -70,31 +68,44 @@ public void testWithXrpCurrencyAmount() throws JsonProcessingException, JSONExce } @Test - public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException { - - BuyOffer buyOffer = BuyOffer.builder() - .amount(IssuedCurrencyAmount.builder() - .issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys")) - .currency("USD") - .value("100") - .build() - ) - .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) - .flags(NfTokenOfferFlags.BUY_TOKEN) - .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + public void testWithLimitAndMarker() throws JsonProcessingException, JSONException { + NftBuyOffersResult params = NftBuyOffersResult.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .limit(UnsignedInteger.ONE) + .marker(Marker.of("123")) .build(); - List list = new ArrayList<>(); - list.add(buyOffer); + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"limit\": 1,\n" + + " \"marker\": \"123\"\n" + + "}"; + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException { NftBuyOffersResult params = NftBuyOffersResult.builder() .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) - .offers(list) + .addOffers( + BuyOffer.builder() + .amount(IssuedCurrencyAmount.builder() + .issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys")) + .currency("USD") + .value("100") + .build() + ) + .owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW")) + .flags(NfTokenOfferFlags.BUY_TOKEN) + .nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .build() + ) .build(); String offer = "{\n" + - " \"Flags\": 1,\n" + - " \"Amount\": {\n" + + " \"flags\": 1,\n" + + " \"amount\": {\n" + " \"issuer\": \"rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys\",\n" + " \"currency\": \"USD\",\n" + " \"value\": \"100\"\n" + diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParamsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParamsTest.java new file mode 100644 index 000000000..1b5b26b0c --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoRequestParamsTest.java @@ -0,0 +1,59 @@ +package org.xrpl.xrpl4j.model.client.nft; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; +import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; + +class NftInfoRequestParamsTest extends AbstractJsonTest { + + @Test + void testWithLedgerIndexShortcut() throws JSONException, JsonProcessingException { + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.VALIDATED) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": \"validated\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + void testWithLedgerIndexNumber() throws JSONException, JsonProcessingException { + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.of(100)) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": 100\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + void testWithLedgerHash() throws JSONException, JsonProcessingException { + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier( + LedgerSpecifier.of(Hash256.of("C53ECF838647FA5A4C780377025FEC7999AB4182590510CA461444B207AB74A9")) + ) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_hash\": \"C53ECF838647FA5A4C780377025FEC7999AB4182590510CA461444B207AB74A9\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } +} \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResultTest.java new file mode 100644 index 000000000..b2dc295f0 --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftInfoResultTest.java @@ -0,0 +1,81 @@ +package org.xrpl.xrpl4j.model.client.nft; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import com.google.common.primitives.UnsignedLong; +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.flags.NfTokenFlags; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; +import org.xrpl.xrpl4j.model.transactions.NfTokenUri; +import org.xrpl.xrpl4j.model.transactions.TransferFee; + +class NftInfoResultTest extends AbstractJsonTest { + + @Test + void testJsonWithUri() throws JSONException, JsonProcessingException { + NftInfoResult result = NftInfoResult.builder() + .nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) + .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269))) + .owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk")) + .burned(false) + .flags(NfTokenFlags.TRANSFERABLE) + .transferFee(TransferFee.of(UnsignedInteger.ZERO)) + .issuer(Address.of("rHVokeuSnjPjz718qdb47bGXBBHNMP3KDQ")) + .nftTaxon(UnsignedLong.ZERO) + .nftSerial(UnsignedInteger.ZERO) + .uri(NfTokenUri.of("https://xrpl.org")) + .status("success") + .build(); + + String json = "{\n" + + " \"nft_id\": \"00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000\",\n" + + " \"ledger_index\": 269,\n" + + " \"owner\": \"rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk\",\n" + + " \"is_burned\": false,\n" + + " \"flags\": 8,\n" + + " \"transfer_fee\": 0,\n" + + " \"issuer\": \"rHVokeuSnjPjz718qdb47bGXBBHNMP3KDQ\",\n" + + " \"nft_taxon\": 0,\n" + + " \"nft_serial\": 0,\n" + + " \"uri\": \"https://xrpl.org\",\n" + + " \"status\": \"success\"\n" + + " }"; + + assertCanSerializeAndDeserialize(result, json); + } + + @Test + void testJsonWithoutUri() throws JSONException, JsonProcessingException { + NftInfoResult result = NftInfoResult.builder() + .nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) + .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269))) + .owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk")) + .burned(false) + .flags(NfTokenFlags.TRANSFERABLE) + .transferFee(TransferFee.of(UnsignedInteger.ZERO)) + .issuer(Address.of("rHVokeuSnjPjz718qdb47bGXBBHNMP3KDQ")) + .nftTaxon(UnsignedLong.ZERO) + .nftSerial(UnsignedInteger.ZERO) + .status("success") + .build(); + + String json = "{\n" + + " \"nft_id\": \"00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000\",\n" + + " \"ledger_index\": 269,\n" + + " \"owner\": \"rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk\",\n" + + " \"is_burned\": false,\n" + + " \"flags\": 8,\n" + + " \"transfer_fee\": 0,\n" + + " \"issuer\": \"rHVokeuSnjPjz718qdb47bGXBBHNMP3KDQ\",\n" + + " \"nft_taxon\": 0,\n" + + " \"nft_serial\": 0,\n" + + " \"status\": \"success\"\n" + + " }"; + + assertCanSerializeAndDeserialize(result, json); + } +} \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParamsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParamsTest.java index 67ed8fca5..e4277f8db 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParamsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftSellOffersRequestParamsTest.java @@ -25,6 +25,8 @@ import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; +import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; @@ -37,7 +39,55 @@ public void testWithRequiredValue() throws JsonProcessingException, JSONExceptio .build(); String json = "{\n" + - " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": \"validated\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithLedgerIndexShortcut() throws JsonProcessingException, JSONException { + NftSellOffersRequestParams params = NftSellOffersRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.CURRENT) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": \"current\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithLedgerIndexNumber() throws JsonProcessingException, JSONException { + NftSellOffersRequestParams params = NftSellOffersRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier(LedgerSpecifier.of(100)) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": 100\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } + + @Test + public void testWithLedgerHash() throws JsonProcessingException, JSONException { + NftSellOffersRequestParams params = NftSellOffersRequestParams.builder() + .nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + .ledgerSpecifier( + LedgerSpecifier.of(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007")) + ) + .build(); + + String json = "{\n" + + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_hash\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" + " }"; assertCanSerializeAndDeserialize(params, json); @@ -53,6 +103,7 @@ public void testWithAllValues() throws JsonProcessingException, JSONException { String json = "{\n" + " \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" + + " \"ledger_index\": \"validated\",\n" + " \"limit\": 10,\n" + " \"marker\": \"123\"\n" + " }"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfoResultTest.java index 40edaae57..f7a1da78f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/serverinfo/ServerInfoResultTest.java @@ -33,6 +33,7 @@ import org.xrpl.xrpl4j.model.client.serverinfo.ServerInfo.LastClose; import org.xrpl.xrpl4j.model.client.serverinfo.ServerInfo.ValidatedLedger; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; import java.math.BigDecimal; @@ -47,7 +48,83 @@ public class ServerInfoResultTest extends AbstractJsonTest { @Test - void serverInfoResultTest() throws JSONException, JsonProcessingException { + void testJsonWithNetworkId() throws JsonProcessingException { + String json = "{\n" + + " \"info\": {\n" + + " \"build_version\": \"1.7.0\",\n" + + " \"amendment_blocked\": false,\n" + + " \"complete_ledgers\": \"61881385-62562429\",\n" + + " \"hostid\": \"LARD\",\n" + + " \"io_latency_ms\": 2,\n" + + " \"jq_trans_overflow\": \"0\",\n" + + " \"last_close\": {\n" + + " \"converge_time_s\": 3.002,\n" + + " \"proposers\": 38\n" + + " },\n" + + " \"load_factor\": 511.83203125,\n" + + " \"network_id\": 25,\n" + + " \"load_factor_server\": 1,\n" + + " \"peers\": 261,\n" + + " \"pubkey_node\": \"n9MozjnGB3tpULewtTsVtuudg5JqYFyV3QFdAtVLzJaxHcBaxuXD\",\n" + + " \"server_state\": \"full\",\n" + + " \"server_state_duration_us\": \"2274468435925\",\n" + + " \"time\": \"2021-Mar-30 15:37:51.486384 UTC\",\n" + + " \"uptime\": 2274704,\n" + + " \"validated_ledger\": {\n" + + " \"age\": 4,\n" + + " \"base_fee_xrp\": 0.00001,\n" + + " \"hash\": \"E5A958048D98D4EFEEDD2BC3F36D23893BBC1D9354CB3E739068D2DFDE3D1AA3\",\n" + + " \"reserve_base_xrp\": 20.1,\n" + + " \"reserve_inc_xrp\": 5.0,\n" + + " \"seq\": 62562429\n" + + " },\n" + + " \"validation_quorum\": 31\n" + + " },\n" + + " \"status\": \"success\"\n" + + "}"; + + ServerInfo serverInfo = RippledServerInfo.builder() + .buildVersion("1.7.0") + .completeLedgers(LedgerRangeUtils.completeLedgersToListOfRange("61881385-62562429")) + .hostId("LARD") + .ioLatencyMs(UnsignedLong.valueOf(2)) + .jqTransOverflow("0") + .lastClose(LastClose.builder() + .convergeTimeSeconds(BigDecimal.valueOf(3.002)) + .proposers(UnsignedInteger.valueOf(38)) + .build()) + .loadFactor(new BigDecimal("511.83203125")) + .networkId(NetworkId.of(25)) + .loadFactorServer(BigDecimal.ONE) + .peers(UnsignedInteger.valueOf(261)) + .publicKeyNode("n9MozjnGB3tpULewtTsVtuudg5JqYFyV3QFdAtVLzJaxHcBaxuXD") + .serverState("full") + .serverStateDurationUs("2274468435925") + .time(ZonedDateTime.parse("2021-Mar-30 15:37:51.486384 UTC", + DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSS z", Locale.US)).withZoneSameLocal(ZoneId.of("UTC"))) + .upTime(UnsignedLong.valueOf(2274704)) + .validatedLedger(ValidatedLedger.builder() + .age(UnsignedInteger.valueOf(4)) + .hash(Hash256.of("E5A958048D98D4EFEEDD2BC3F36D23893BBC1D9354CB3E739068D2DFDE3D1AA3")) + .reserveBaseXrp(XrpCurrencyAmount.ofDrops(20100000)) + .reserveIncXrp(XrpCurrencyAmount.ofDrops(5000000)) + .sequence(LedgerIndex.of(UnsignedInteger.valueOf(62562429))) + .baseFeeXrp(new BigDecimal("0.000010")) + .build()) + .validationQuorum(UnsignedInteger.valueOf(31)) + .build(); + ImmutableServerInfoResult.Builder resultBuilder = ServerInfoResult.builder() + .info(serverInfo) + .status("success"); + + ServerInfoResult result = Assertions.assertDoesNotThrow(() -> resultBuilder.build()); + + assertCanDeserialize(json, result); + assertThat(result.info()).isEqualTo(serverInfo); + } + + @Test + void testJsonWithoutNetworkId() throws JsonProcessingException { String json = "{\n" + " \"info\": {\n" + " \"build_version\": \"1.7.0\",\n" + diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NetworkIdTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NetworkIdTest.java new file mode 100644 index 000000000..23a68032d --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NetworkIdTest.java @@ -0,0 +1,90 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.assertj.core.api.Assertions; +import org.immutables.value.Value; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; + +public class NetworkIdTest { + + ObjectMapper objectMapper = ObjectMapperFactory.create(); + + @Test + void testBounds() { + NetworkId networkId = NetworkId.of(UnsignedInteger.ZERO); + assertThat(networkId.value()).isEqualTo(UnsignedInteger.ZERO); + + networkId = NetworkId.of(UnsignedInteger.MAX_VALUE); + assertThat(networkId.value()).isEqualTo(UnsignedInteger.MAX_VALUE); + } + + @Test + void testToString() { + NetworkId networkId = NetworkId.of(UnsignedInteger.valueOf(1024)); + assertThat(networkId.toString()).isEqualTo("1024"); + } + + @Test + void testBoundsWithLongConstructor() { + NetworkId networkId = NetworkId.of(0); + assertThat(networkId.value()).isEqualTo(UnsignedInteger.ZERO); + + networkId = NetworkId.of(1); + assertThat(networkId.value()).isEqualTo(UnsignedInteger.ONE); + + networkId = NetworkId.of(4_294_967_295L); + assertThat(networkId.value()).isEqualTo(UnsignedInteger.MAX_VALUE); + + assertThatThrownBy(() -> NetworkId.of(4_294_967_296L)) + .isInstanceOf(IllegalArgumentException.class); + + assertThatThrownBy(() -> NetworkId.of(-1)) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + void testJson() throws JsonProcessingException, JSONException { + NetworkId networkId = NetworkId.of(UnsignedInteger.valueOf(1000)); + NetworkIdWrapper wrapper = NetworkIdWrapper.of(networkId); + + String json = "{\"networkId\": 1000}"; + assertSerializesAndDeserializes(wrapper, json); + } + + private void assertSerializesAndDeserializes( + NetworkIdWrapper wrapper, + String json + ) throws JsonProcessingException, JSONException { + String serialized = objectMapper.writeValueAsString(wrapper); + JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); + NetworkIdWrapper deserialized = objectMapper.readValue( + serialized, NetworkIdWrapper.class + ); + Assertions.assertThat(deserialized).isEqualTo(wrapper); + } + + + @Value.Immutable + @JsonSerialize(as = ImmutableNetworkIdWrapper.class) + @JsonDeserialize(as = ImmutableNetworkIdWrapper.class) + interface NetworkIdWrapper { + + static NetworkIdWrapper of(NetworkId networkId) { + return ImmutableNetworkIdWrapper.builder().networkId(networkId).build(); + } + + NetworkId networkId(); + + } +} diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NfTokenMintTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NfTokenMintTest.java index 16a0ea347..40adc1dfc 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NfTokenMintTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/NfTokenMintTest.java @@ -117,16 +117,14 @@ public void transferFeeUsingPercent() { .flags(NfTokenMintFlags.builder() .tfTransferable(true) .build()) - .transferFee(TransferFee.ofPercent(BigDecimal.valueOf(99.99))) + .transferFee(TransferFee.ofPercent(BigDecimal.valueOf(49.99))) .build(); - assertThat(nfTokenMint.transferFee().equals(Optional.of(9999))); + assertThat(nfTokenMint.transferFee().equals(Optional.of(49_990))); } @Test public void txWithUri() { - - UnsignedLong taxon = UnsignedLong.valueOf(146999694L); String uri = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi"; NfTokenMint nfTokenMint = NfTokenMint.builder() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java index f6567d73d..d572a6f42 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java @@ -18,10 +18,8 @@ import org.xrpl.xrpl4j.model.transactions.metadata.AffectedNode; import org.xrpl.xrpl4j.model.transactions.metadata.CreatedNode; import org.xrpl.xrpl4j.model.transactions.metadata.DeletedNode; -import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableCreatedNode; import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableDeletedNode; import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableMetaNfTokenOfferObject; -import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableModifiedNode; import org.xrpl.xrpl4j.model.transactions.metadata.MetaAccountRootObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaCheckObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaDepositPreAuthObject; @@ -39,8 +37,6 @@ import org.xrpl.xrpl4j.model.transactions.metadata.ModifiedNode; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransferFeeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransferFeeTest.java index a0c775533..2cf53a3f4 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransferFeeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransferFeeTest.java @@ -45,39 +45,59 @@ public class TransferFeeTest { ObjectMapper objectMapper = ObjectMapperFactory.create(); @Test - public void transferFeeEquality() { + void ofPercent() { + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(0)).value()).isEqualTo(UnsignedInteger.valueOf(0)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(0.000)).value()).isEqualTo(UnsignedInteger.valueOf(0)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.999)).value()).isEqualTo(UnsignedInteger.valueOf(49_999)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.99)).value()).isEqualTo(UnsignedInteger.valueOf(49_990)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.9)).value()).isEqualTo(UnsignedInteger.valueOf(49_900)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(50)).value()).isEqualTo(UnsignedInteger.valueOf(50_000)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(50.000)).value()).isEqualTo(UnsignedInteger.valueOf(50_000)); + } + + @Test + void ofPercentWithNull() { + assertThatThrownBy(() -> TransferFee.ofPercent(null)) + .isInstanceOf(NullPointerException.class); + } + @Test + public void transferFeeEquality() { assertThat(TransferFee.of(UnsignedInteger.ONE)).isEqualTo(TransferFee.of(UnsignedInteger.ONE)); assertThat(TransferFee.of(UnsignedInteger.valueOf(10))) .isEqualTo(TransferFee.of(UnsignedInteger.valueOf(10))); - assertThat(TransferFee.ofPercent(BigDecimal.valueOf(99.99))) - .isEqualTo(TransferFee.ofPercent(BigDecimal.valueOf(99.99))); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.99))) + .isEqualTo(TransferFee.ofPercent(BigDecimal.valueOf(49.99))); - assertThat(TransferFee.ofPercent(BigDecimal.valueOf(99.9))) - .isEqualTo(TransferFee.ofPercent(BigDecimal.valueOf(99.90))); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.9))) + .isEqualTo(TransferFee.ofPercent(BigDecimal.valueOf(49.90))); - assertThat(TransferFee.ofPercent(BigDecimal.valueOf(99.9)).value()) - .isEqualTo(UnsignedInteger.valueOf(9990)); + assertThat(TransferFee.ofPercent(BigDecimal.valueOf(49.9)).value()) + .isEqualTo(UnsignedInteger.valueOf(49900)); } @Test public void percentValueIncorrectFormat() { - assertThrows( - IllegalArgumentException.class, - () -> TransferFee.ofPercent(BigDecimal.valueOf(99.999)), - "Percent value should have a maximum of 2 decimal places." - ); + assertThatThrownBy( + () -> TransferFee.ofPercent(BigDecimal.valueOf(25.2929)) + ).isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("Percent value should have a maximum of 3 decimal places."); } @Test public void validateBounds() { assertDoesNotThrow(() -> TransferFee.of(UnsignedInteger.valueOf(49999))); + assertDoesNotThrow(() -> TransferFee.ofPercent(BigDecimal.valueOf(49.999))); assertDoesNotThrow(() -> TransferFee.of(UnsignedInteger.valueOf(50000))); + assertDoesNotThrow(() -> TransferFee.ofPercent(BigDecimal.valueOf(50.000))); assertThatThrownBy(() -> TransferFee.of(UnsignedInteger.valueOf(50001))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("TransferFee should be in the range 0 to 50000."); + assertThatThrownBy(() -> TransferFee.ofPercent(BigDecimal.valueOf(50.001))) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("TransferFee should be in the range 0 to 50000."); } @Test 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 83425d25c..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; public class AccountDeleteJsonTests extends AbstractJsonTest { @@ -44,6 +45,7 @@ public void testJson() throws JsonProcessingException, JSONException { .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -53,6 +55,7 @@ public void testJson() throws JsonProcessingException, JSONException { " \"DestinationTag\": 13,\n" + " \"Fee\": \"5000000\",\n" + " \"Sequence\": 2470665,\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + "}"; 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 ce88119d4..764e91430 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 @@ -32,6 +32,7 @@ import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.AccountSet.AccountSetFlag; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; public class AccountSetJsonTests extends AbstractJsonTest { @@ -54,6 +55,7 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep ) .flags(AccountSetTransactionFlags.of(TransactionFlags.FULLY_CANONICAL_SIG.getValue())) .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -70,6 +72,7 @@ public void fullyPopulatedAccountSet() throws JSONException, JsonProcessingExcep " \"ClearFlag\":8,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"NetworkID\": 1024,\n" + " \"EmailHash\":\"f9879d71855b5ff21e4963273a886bfc\"\n" + "}"; @@ -153,4 +156,42 @@ public void testJsonWithEmptyFlags() throws JsonProcessingException, JSONExcepti assertCanSerializeAndDeserialize(accountSet, json); } + + @Test + void testJsonWithZeroClearFlagAndSetFlag() throws JSONException, JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .fee(XrpCurrencyAmount.ofDrops(12)) + .sequence(UnsignedInteger.valueOf(5)) + .domain("6578616D706C652E636F6D") + .setFlag(AccountSetFlag.NONE) + .messageKey("03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB") + .transferRate(UnsignedInteger.valueOf(1000000001)) + .tickSize(UnsignedInteger.valueOf(15)) + .clearFlag(AccountSetFlag.NONE) + .emailHash("f9879d71855b5ff21e4963273a886bfc") + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .mintAccount(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn")) + .build(); + + String json = "{\n" + + " \"TransactionType\":\"AccountSet\",\n" + + " \"Account\":\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + + " \"Fee\":\"12\",\n" + + " \"Sequence\":5,\n" + + " \"Domain\":\"6578616D706C652E636F6D\",\n" + + " \"SetFlag\":0,\n" + + " \"MessageKey\":\"03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB\",\n" + + " \"TransferRate\":1000000001,\n" + + " \"TickSize\":15,\n" + + " \"ClearFlag\":0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NFTokenMinter\" : \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\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 268dd0a76..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 @@ -32,6 +32,7 @@ import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; public class CheckJsonTests extends AbstractJsonTest { @@ -46,6 +47,7 @@ public void testCheckCancelJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey( "02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -54,6 +56,7 @@ public void testCheckCancelJson() throws JsonProcessingException, JSONException " \"CheckID\": \"49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0\",\n" + " \"Sequence\": 12,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"12\"\n" + "}"; @@ -123,6 +126,7 @@ public void testCheckCashJsonWithDeliverMin() throws JsonProcessingException, JS .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -132,6 +136,7 @@ public void testCheckCashJsonWithDeliverMin() throws JsonProcessingException, JS " \"CheckID\": \"838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334\",\n" + " \"Sequence\": 1,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"12\"\n" + "}"; @@ -234,6 +239,7 @@ public void testCheckCreateJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -246,6 +252,7 @@ public void testCheckCreateJson() throws JsonProcessingException, JSONException " \"DestinationTag\": 1,\n" + " \"Sequence\": 1,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"12\"\n" + "}"; 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 cc97a2ef9..df7609290 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 @@ -38,6 +38,7 @@ import org.xrpl.xrpl4j.model.transactions.EscrowCancel; import org.xrpl.xrpl4j.model.transactions.EscrowCreate; import org.xrpl.xrpl4j.model.transactions.EscrowFinish; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; public class EscrowJsonTests extends AbstractJsonTest { @@ -61,6 +62,7 @@ public void testEscrowCreateJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -75,6 +77,7 @@ public void testEscrowCreateJson() throws JsonProcessingException, JSONException " \"SourceTag\": 11747,\n" + " \"Sequence\": 1,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"12\"\n" + "}"; @@ -175,6 +178,7 @@ public void testEscrowCancelJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -184,6 +188,7 @@ public void testEscrowCancelJson() throws JsonProcessingException, JSONException " \"OfferSequence\": 7,\n" + " \"Sequence\": 1,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"12\"\n" + "}"; assertCanSerializeAndDeserialize(escrowCancel, json); @@ -258,6 +263,7 @@ public void testEscrowFinishJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -269,6 +275,7 @@ public void testEscrowFinishJson() throws JsonProcessingException, JSONException " \"Fulfillment\": \"A0028000\",\n" + " \"Sequence\": 1,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"330\"\n" + "}"; 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 939f60fc2..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.NfTokenAcceptOffer; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -48,6 +49,7 @@ public void testMinimalNfTokenAcceptOfferJson() throws JsonProcessingException, .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -58,6 +60,7 @@ public void testMinimalNfTokenAcceptOfferJson() throws JsonProcessingException, " \"NFTokenBuyOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + " \"NFTokenSellOffer\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"NFTokenBrokerFee\": \"10\"\n" + "}"; 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 e759ce14e..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 @@ -28,6 +28,7 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.NfTokenBurn; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -46,6 +47,7 @@ public void testMinimalNfTokenBurnJson() throws JsonProcessingException, JSONExc .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -54,6 +56,7 @@ public void testMinimalNfTokenBurnJson() throws JsonProcessingException, JSONExc " \"Fee\": \"12\",\n" + " \"Sequence\": 12,\n" + " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + "}"; 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 4b1bab7ac..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.NfTokenCancelOffer; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -50,6 +51,7 @@ public void testMinimalNfTokenCancelOfferJson() throws JsonProcessingException, .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -57,6 +59,7 @@ public void testMinimalNfTokenCancelOfferJson() throws JsonProcessingException, " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"Fee\": \"12\",\n" + " \"Sequence\": 12,\n" + + " \"NetworkID\": 1024,\n" + " \"NFTokenOffers\": [" + " \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\"" + " ],\n" + 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 2c4303ba0..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 @@ -28,6 +28,7 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.NfTokenCreateOfferFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.NfTokenCreateOffer; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -47,6 +48,7 @@ public void testMinimalNfTokenCreateOfferJson() throws JsonProcessingException, .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -55,6 +57,7 @@ public void testMinimalNfTokenCreateOfferJson() throws JsonProcessingException, " \"Fee\": \"12\",\n" + " \"Sequence\": 12,\n" + " \"Amount\": \"2000\",\n" + + " \"NetworkID\": 1024,\n" + " \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\"\n" + "}"; 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 4852ee03f..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.NfTokenMintFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.NfTokenMint; import org.xrpl.xrpl4j.model.transactions.NfTokenUri; import org.xrpl.xrpl4j.model.transactions.TransferFee; @@ -50,6 +51,7 @@ public void testMinimalNfTokenMintJson() throws JsonProcessingException, JSONExc .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -59,6 +61,7 @@ public void testMinimalNfTokenMintJson() throws JsonProcessingException, JSONExc " \"Flags\": 2147483656,\n" + " \"Sequence\": 12,\n" + " \"TransferFee\": 1000,\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"NFTokenTaxon\": 146999694\n" + "}"; 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 cc0afa282..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.flags.OfferCreateFlags; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.OfferCancel; import org.xrpl.xrpl4j.model.transactions.OfferCreate; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -45,6 +46,7 @@ public void testOfferCancelJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -53,6 +55,7 @@ public void testOfferCancelJson() throws JsonProcessingException, JSONException " \"Sequence\": 12,\n" + " \"OfferSequence\": 13,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Fee\": \"14\"\n" + "}"; @@ -124,6 +127,7 @@ public void testOfferCreateJson() throws JsonProcessingException, JSONException .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -135,6 +139,7 @@ public void testOfferCreateJson() throws JsonProcessingException, JSONException " \"TakerGets\": \"15\",\n" + " \"Fee\": \"12\",\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"Expiration\": 16\n" + "}"; 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 558f09a99..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 @@ -31,6 +31,7 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.PaymentChannelClaim; import org.xrpl.xrpl4j.model.transactions.PaymentChannelCreate; import org.xrpl.xrpl4j.model.transactions.PaymentChannelFund; @@ -54,6 +55,7 @@ public void testPaymentChannelCreateJson() throws JsonProcessingException, JSONE .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -68,6 +70,7 @@ public void testPaymentChannelCreateJson() throws JsonProcessingException, JSONE " \"CancelAfter\": 533171558,\n" + " \"DestinationTag\": 23480,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"SourceTag\": 11747\n" + "}"; @@ -165,6 +168,7 @@ public void testPaymentChannelClaimJson() throws JsonProcessingException, JSONEx .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -175,6 +179,7 @@ public void testPaymentChannelClaimJson() throws JsonProcessingException, JSONEx " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + " \"Balance\": \"1000000\",\n" + " \"Amount\": \"1000000\",\n" + + " \"NetworkID\": 1024,\n" + " \"Signature\": \"30440220718D264EF05CAED7C781FF6DE298DCAC68D002562C9BF3A07C1E721B420C0DAB02203A5A4" + "779EF4D2CCC7BC3EF886676D803A9981B928D3B8ACA483B80ECA3CD7B9B\",\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + @@ -230,6 +235,7 @@ public void testPaymentChannelFundJson() throws JsonProcessingException, JSONExc .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -239,6 +245,7 @@ public void testPaymentChannelFundJson() throws JsonProcessingException, JSONExc " \"TransactionType\": \"PaymentChannelFund\",\n" + " \"Channel\": \"C1AE6DDDEEC05CF2978C0BAD6FE302948E9533691DC749DCDD3B9E5992CA6198\",\n" + " \"Amount\": \"200000\",\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"Expiration\": 543171558\n" + "}"; 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 d55c2322e..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 @@ -31,6 +31,7 @@ import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.PathStep; import org.xrpl.xrpl4j.model.transactions.Payment; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -51,6 +52,7 @@ public void testJson() throws JsonProcessingException, JSONException { .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -60,6 +62,7 @@ public void testJson() throws JsonProcessingException, JSONException { " \"Amount\": \"25000000\",\n" + " \"Fee\": \"10\",\n" + " \"Flags\": 0,\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"Sequence\": 2\n" + " }"; 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 4c8514e64..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 @@ -28,6 +28,7 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.SetRegularKey; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -43,6 +44,7 @@ public void testSetRegularKeyJson() throws JsonProcessingException, JSONExceptio .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -51,6 +53,7 @@ public void testSetRegularKeyJson() throws JsonProcessingException, JSONExceptio " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"Fee\": \"12\",\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"NetworkID\": 1024,\n" + " \"RegularKey\": \"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\"\n" + "}"; 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 03f5d636e..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 @@ -30,6 +30,7 @@ import org.xrpl.xrpl4j.model.ledger.SignerEntry; import org.xrpl.xrpl4j.model.ledger.SignerEntryWrapper; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.SignerListSet; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -65,6 +66,7 @@ public void testSignerListSetJson() throws JsonProcessingException, JSONExceptio .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -73,6 +75,7 @@ public void testSignerListSetJson() throws JsonProcessingException, JSONExceptio " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"Fee\": \"12\",\n" + " \"SignerQuorum\": 3,\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"SignerEntries\": [\n" + " {\n" + 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 7276ba43f..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 @@ -28,6 +28,7 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.TicketCreate; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -43,6 +44,7 @@ void testJson() throws JSONException, JsonProcessingException { .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -50,6 +52,7 @@ void testJson() throws JSONException, JsonProcessingException { " \"Account\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" + " \"Fee\": \"12\",\n" + " \"Sequence\": 1,\n" + + " \"NetworkID\": 1024,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TicketCount\": 200\n" + "}"; 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 07fdb99b8..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 @@ -29,6 +29,7 @@ import org.xrpl.xrpl4j.model.flags.TrustSetFlags; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.NetworkId; import org.xrpl.xrpl4j.model.transactions.TrustSet; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -51,6 +52,7 @@ public void testMinimalTrustSetJson() throws JsonProcessingException, JSONExcept .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .networkId(NetworkId.of(1024)) .build(); String json = "{\n" + @@ -64,6 +66,7 @@ public void testMinimalTrustSetJson() throws JsonProcessingException, JSONExcept " \"issuer\": \"rsP3mgGb2tcYUrxiLFiHJiQXhsziegtwBc\",\n" + " \"value\": \"100\"\n" + " },\n" + + " \"NetworkID\": 1024,\n" + " \"Sequence\": 12\n" + "}"; diff --git a/xrpl4j-core/src/test/resources/data-driven-tests.json b/xrpl4j-core/src/test/resources/data-driven-tests.json index 4eae1bfab..ed7647ea0 100644 --- a/xrpl4j-core/src/test/resources/data-driven-tests.json +++ b/xrpl4j-core/src/test/resources/data-driven-tests.json @@ -483,13 +483,6 @@ "type": 5, "expected_hex": "5013" }, - { - "type_name": "Hash256", - "name": "TicketID", - "nth_of_type": 20, - "type": 5, - "expected_hex": "5014" - }, { "type_name": "Hash256", "name": "Digest", @@ -721,13 +714,6 @@ "type": 8, "expected_hex": "84" }, - { - "type_name": "AccountID", - "name": "Target", - "nth_of_type": 7, - "type": 8, - "expected_hex": "87" - }, { "type_name": "AccountID", "name": "RegularKey", diff --git a/xrpl4j-core/src/test/resources/tx_meta_manual_fixtures.json.zip b/xrpl4j-core/src/test/resources/tx_meta_manual_fixtures.json.zip index 6013a430c..c8fba08e4 100644 Binary files a/xrpl4j-core/src/test/resources/tx_meta_manual_fixtures.json.zip and b/xrpl4j-core/src/test/resources/tx_meta_manual_fixtures.json.zip differ 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 7124e1825..0ea468489 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 @@ -33,6 +33,7 @@ import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; +import org.xrpl.xrpl4j.model.client.transactions.TransactionResult; import org.xrpl.xrpl4j.model.flags.AccountRootFlags; import org.xrpl.xrpl4j.model.flags.AccountSetTransactionFlags; import org.xrpl.xrpl4j.model.transactions.AccountSet; @@ -343,6 +344,46 @@ void disableMasterFailsWithNoSignerList() throws JsonRpcClientErrorException, Js logger.info("AccountSet SetFlag transaction failed successfully:"); } + @Test + void submitAndRetrieveAccountSetWithZeroClearFlagAndSetFlag() + 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 accountSet = AccountSet.builder() + .account(keyPair.publicKey().deriveAddress()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .sequence(accountInfo.accountData().sequence()) + .setFlag(AccountSetFlag.NONE) + .clearFlag(AccountSetFlag.NONE) + .signingPublicKey(keyPair.publicKey()) + .build(); + + SingleSignedTransaction signedAccountSet = signatureService.sign( + keyPair.privateKey(), accountSet + ); + SubmitResult response = xrplClient.submit(signedAccountSet); + + assertThat(response.engineResult()).isEqualTo("tesSUCCESS"); + assertThat(signedAccountSet.hash()).isEqualTo(response.transactionResult().hash()); + logger.info( + "AccountSet transaction successful: https://testnet.xrpl.org/transactions/" + response.transactionResult().hash() + ); + + TransactionResult accountSetTransactionResult = this.scanForResult(() -> + this.getValidatedTransaction(signedAccountSet.hash(), AccountSet.class) + ); + + assertThat(accountSetTransactionResult.transaction().setFlag()).isNotEmpty().get().isEqualTo(AccountSetFlag.NONE); + assertThat(accountSetTransactionResult.transaction().clearFlag()).isNotEmpty().get().isEqualTo(AccountSetFlag.NONE); + } + ////////////////////// // Test Helpers ////////////////////// diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java index 16255ab3a..cc0a143d2 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java @@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.collect.Lists; import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.junit.jupiter.api.Test; @@ -58,6 +59,7 @@ import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.NfTokenMint; import org.xrpl.xrpl4j.model.transactions.NfTokenUri; +import org.xrpl.xrpl4j.model.transactions.TransactionMetadata; import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -93,6 +95,13 @@ void mint() throws JsonRpcClientErrorException, JsonProcessingException { assertThat(mintSubmitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); assertThat(signedMint.hash()).isEqualTo(mintSubmitResult.transactionResult().hash()); + TransactionResult validatedMint = this.scanForResult( + () -> this.getValidatedTransaction( + mintSubmitResult.transactionResult().hash(), + NfTokenMint.class + ) + ); + NfTokenObject nfToken = this.scanForResult( () -> { try { @@ -103,11 +112,15 @@ void mint() throws JsonRpcClientErrorException, JsonProcessingException { }, result -> result.accountNfts().stream() .anyMatch(nft -> nft.uri().get().equals(uri)) - ).accountNfts() + ) + .accountNfts() .stream().filter(nft -> nft.uri().get().equals(uri)) .findFirst() .get(); + assertThat(validatedMint.metadata().flatMap(TransactionMetadata::nfTokenId)) + .isNotEmpty().get().isEqualTo(nfToken.nfTokenId()); + Optional maybeNfTokenPage = xrplClient.accountObjects( AccountObjectsRequestParams.of(nfTokenMint.account()) ).accountObjects().stream() @@ -143,7 +156,6 @@ void mintFromOtherMinterAccount() throws JsonRpcClientErrorException, JsonProces () -> this.getValidatedAccountInfo(keyPair.publicKey().deriveAddress()) ); - AccountSet accountSet = AccountSet.builder() .account(keyPair.publicKey().deriveAddress()) .sequence(accountInfoResult.accountData().sequence()) @@ -360,7 +372,7 @@ void mintAndCreateOffer() throws JsonRpcClientErrorException, JsonProcessingExce assertThat(signedOffer.hash()).isEqualTo(nfTokenCreateOfferSubmitResult.transactionResult().hash()); //verify the offer was created - this.scanForResult( + TransactionResult validatedOfferCreate = this.scanForResult( () -> this.getValidatedTransaction( nfTokenCreateOfferSubmitResult.transactionResult().hash(), NfTokenCreateOffer.class @@ -368,14 +380,22 @@ void mintAndCreateOffer() throws JsonRpcClientErrorException, JsonProcessingExce ); logger.info("NFT Create Offer (Sell) transaction was validated successfully."); - this.scanForResult( + NfTokenOfferObject nfTokenOffer = (NfTokenOfferObject) this.scanForResult( () -> this.getValidatedAccountObjects(keyPair.publicKey().deriveAddress()), objectsResult -> objectsResult.accountObjects().stream() .anyMatch(object -> NfTokenOfferObject.class.isAssignableFrom(object.getClass()) && ((NfTokenOfferObject) object).owner().equals(keyPair.publicKey().deriveAddress()) ) - ); + ).accountObjects() + .stream() + .filter(object -> NfTokenOfferObject.class.isAssignableFrom(object.getClass()) && + ((NfTokenOfferObject) object).owner().equals(keyPair.publicKey().deriveAddress())) + .findFirst() + .get(); + + assertThat(validatedOfferCreate.metadata().flatMap(TransactionMetadata::offerId)).isNotEmpty().get() + .isEqualTo(nfTokenOffer.index()); logger.info("NFTokenOffer object was found in account's objects."); } @@ -605,14 +625,17 @@ void mintAndCreateOfferThenCancelOffer() throws JsonRpcClientErrorException, Jso assertThat(signedCancel.hash()).isEqualTo(nfTokenCancelOfferSubmitResult.transactionResult().hash()); //verify the offer was created - this.scanForResult( + TransactionResult validatedOfferCancel = this.scanForResult( () -> this.getValidatedTransaction( nfTokenCancelOfferSubmitResult.transactionResult().hash(), - NfTokenCreateOffer.class + NfTokenCancelOffer.class ) ); logger.info("NFT Cancel Offer transaction was validated successfully."); + assertThat(validatedOfferCancel.metadata().map(TransactionMetadata::nfTokenIds)).isNotEmpty().get() + .isEqualTo(Lists.newArrayList(tokenId)); + this.scanForResult( () -> this.getValidatedAccountObjects(wallet.publicKey().deriveAddress()), objectsResult -> objectsResult.accountObjects().stream() diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NftInfoIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NftInfoIT.java new file mode 100644 index 000000000..259a7eae0 --- /dev/null +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NftInfoIT.java @@ -0,0 +1,65 @@ +package org.xrpl.xrpl4j.tests; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.google.common.primitives.UnsignedInteger; +import com.google.common.primitives.UnsignedLong; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; +import org.xrpl.xrpl4j.client.XrplClient; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; +import org.xrpl.xrpl4j.model.client.nft.NftInfoRequestParams; +import org.xrpl.xrpl4j.model.client.nft.NftInfoResult; +import org.xrpl.xrpl4j.model.flags.NfTokenFlags; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; +import org.xrpl.xrpl4j.model.transactions.NfTokenUri; +import org.xrpl.xrpl4j.model.transactions.TransferFee; +import org.xrpl.xrpl4j.tests.environment.ClioMainnetEnvironment; +import org.xrpl.xrpl4j.tests.environment.ReportingMainnetEnvironment; + +import java.math.BigDecimal; + +public class NftInfoIT { + + XrplClient xrplClient = new ClioMainnetEnvironment().getXrplClient(); + + @Test + void getNftInfo() throws JsonRpcClientErrorException { + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("0008138808C4E53F4F6EF5D5B2AF64F96B457F42E0ED9530FE9B131300001178")) + .ledgerSpecifier(LedgerSpecifier.VALIDATED) + .build(); + NftInfoResult nftInfo = xrplClient.nftInfo( + params + ); + + assertThat(nftInfo.nftId()).isEqualTo(params.nfTokenId()); + assertThat(nftInfo.owner()).isEqualTo(Address.of("rLpunkscgfzS8so59bUCJBVqZ3eHZue64r")); + assertThat(nftInfo.burned()).isFalse(); + assertThat(nftInfo.flags()).isEqualTo(NfTokenFlags.TRANSFERABLE); + assertThat(nftInfo.transferFee()).isEqualTo(TransferFee.ofPercent(BigDecimal.valueOf(5))); + assertThat(nftInfo.issuer()).isEqualTo(Address.of("ro4HnG6G1Adz2cWSnZ3Dcr39kmXk4ztA5")); + assertThat(nftInfo.nftTaxon()).isEqualTo(UnsignedLong.ZERO); + assertThat(nftInfo.nftSerial()).isEqualTo(UnsignedInteger.valueOf(4472)); + assertThat(nftInfo.uri()).isNotEmpty().get() + .isEqualTo(NfTokenUri.of("68747470733A2F2F62616679626569656E7662786B756F6C6B3778336333366177686A34346E6F6" + + "F687776613370683568376B746A78616D686D6F63333265733632712E697066732E6E667473746F726167652E6C696E6B2F7" + + "26567756C61725F626972645F6E6F5F323633372E6A7067")); + } + + @Test + void getNftInfoFromReportingModeThrows() throws JsonRpcClientErrorException { + XrplClient client = new ReportingMainnetEnvironment().getXrplClient(); + NftInfoRequestParams params = NftInfoRequestParams.builder() + .nfTokenId(NfTokenId.of("0008138808C4E53F4F6EF5D5B2AF64F96B457F42E0ED9530FE9B131300001178")) + .ledgerSpecifier(LedgerSpecifier.VALIDATED) + .build(); + assertThatThrownBy( + () -> client.nftInfo(params) + ).isInstanceOf(JsonRpcClientErrorException.class) + .hasMessage("Unknown method."); + + } +}