From c6ed6437ee2e1e777d7d8e73ba72b01be86d656f Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 4 Aug 2023 10:49:25 -0400 Subject: [PATCH] pr feedback --- .../org/xrpl/xrpl4j/model/client/nft/NftInfoResult.java | 2 +- .../org/xrpl/xrpl4j/model/transactions/Wrappers.java | 9 +++++++++ .../xrpl/xrpl4j/model/client/nft/NftInfoResultTest.java | 4 ++-- .../xrpl/xrpl4j/model/transactions/TransferFeeTest.java | 6 ++++++ .../src/test/java/org/xrpl/xrpl4j/tests/NftInfoIT.java | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) 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 index a1cdfd6da..fea5eca55 100644 --- 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 @@ -39,7 +39,7 @@ static ImmutableNftInfoResult.Builder builder() { * @return An {@link NfTokenId}. */ @JsonProperty("nft_id") - NfTokenId nfTokenId(); + NfTokenId nftId(); /** * The ledger index of the most recent ledger version where the state of this NFT was modified, as in the NFT was 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 4cc4a6fd9..fd8716df7 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 @@ -51,6 +51,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 +335,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,10 +354,14 @@ 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} */ public static TransferFee ofPercent(BigDecimal percent) { + Objects.requireNonNull(percent); Preconditions.checkArgument( Math.max(0, percent.stripTrailingZeros().scale()) <= 3, "Percent value should have a maximum of 3 decimal places." 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 index fdeaa2760..b2dc295f0 100644 --- 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 @@ -18,7 +18,7 @@ class NftInfoResultTest extends AbstractJsonTest { @Test void testJsonWithUri() throws JSONException, JsonProcessingException { NftInfoResult result = NftInfoResult.builder() - .nfTokenId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) + .nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269))) .owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk")) .burned(false) @@ -51,7 +51,7 @@ void testJsonWithUri() throws JSONException, JsonProcessingException { @Test void testJsonWithoutUri() throws JSONException, JsonProcessingException { NftInfoResult result = NftInfoResult.builder() - .nfTokenId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) + .nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000")) .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269))) .owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk")) .burned(false) 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 d2b7996c8..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 @@ -55,6 +55,12 @@ void ofPercent() { 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)); 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 index 6d2b76b88..259a7eae0 100644 --- 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 @@ -35,7 +35,7 @@ void getNftInfo() throws JsonRpcClientErrorException { params ); - assertThat(nftInfo.nfTokenId()).isEqualTo(params.nfTokenId()); + assertThat(nftInfo.nftId()).isEqualTo(params.nfTokenId()); assertThat(nftInfo.owner()).isEqualTo(Address.of("rLpunkscgfzS8so59bUCJBVqZ3eHZue64r")); assertThat(nftInfo.burned()).isFalse(); assertThat(nftInfo.flags()).isEqualTo(NfTokenFlags.TRANSFERABLE);