From 501302088dda16d573725a6d05dbf955c95cee88 Mon Sep 17 00:00:00 2001
From: David Fuelling Note that a similar field does not exist on {@link EscrowCreate},
* {@link org.xrpl.xrpl4j.model.ledger.EscrowObject}, or
- * {@link org.xrpl.xrpl4j.model.transactions.metadata.MetaEscrowObject} because {@link EscrowCreate}s with
- * malformed conditions will never be included in a ledger by the XRPL. Because of this fact, an
+ * {@link org.xrpl.xrpl4j.model.transactions.metadata.MetaEscrowObject} because {@link EscrowCreate}s with malformed
+ * conditions will never be included in a ledger by the XRPL. Because of this fact, an
* {@link org.xrpl.xrpl4j.model.ledger.EscrowObject} and
- * {@link org.xrpl.xrpl4j.model.transactions.metadata.MetaEscrowObject} will also never contain a malformed
- * crypto condition.
If {@link #condition()} is present but {@link #conditionRawValue()} is empty, we set * {@link #conditionRawValue()} to the underlying value of {@link #condition()}.
*If {@link #condition()} is empty and {@link #conditionRawValue()} is present, we will set - * {@link #condition()} to the {@link Condition} representing the raw condition value, or leave - * {@link #condition()} empty if {@link #conditionRawValue()} is a malformed {@link Condition}.
+ * {@link #condition()} to the {@link Condition} representing the raw condition value, or leave {@link #condition()} + * empty if {@link #conditionRawValue()} is a malformed {@link Condition}. * * @return A normalized {@link EscrowFinish}. */ diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/EscrowFinishTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/EscrowFinishTest.java index 15358b4c6..42a00da31 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/EscrowFinishTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/EscrowFinishTest.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. @@ -22,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.io.BaseEncoding; @@ -30,12 +31,16 @@ import com.ripple.cryptoconditions.CryptoConditionReader; import com.ripple.cryptoconditions.CryptoConditionWriter; import com.ripple.cryptoconditions.Fulfillment; +import com.ripple.cryptoconditions.PrefixSha256Fulfillment; import com.ripple.cryptoconditions.PreimageSha256Condition; import com.ripple.cryptoconditions.PreimageSha256Fulfillment; import com.ripple.cryptoconditions.der.DerEncodingException; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; import org.xrpl.xrpl4j.model.transactions.ImmutableEscrowFinish.Builder; @@ -86,7 +91,8 @@ public void constructWithNoFulfillmentNoCondition() { //////////////////////////////// // normalizeCondition tests - //////////////////////////////// + + /// ///////////////////////////// @Test void normalizeWithNoConditionNoRawValue() { @@ -131,7 +137,7 @@ void normalizeWithConditionAndRawValueNonMatching() { .conditionRawValue("A0258020E3B0C44298FC1C149ABCD4C8996FB92427AE41E4649B934CA495991B7852B855810100") .build() ).isInstanceOf(IllegalStateException.class) - .hasMessage("condition and conditionRawValue should be equivalent if both are present."); + .hasMessage("condition and conditionRawValue should be equivalent if both are present."); } @Test @@ -178,10 +184,9 @@ void normalizeWithNoConditionAndRawValueForMalformedCondition() { } /** - * This tests the case where conditionRawValue is present and is parseable to a Condition but when the - * parsed Condition is written to a byte array, the value differs from the conditionRawValue bytes. This - * can occur if the condition raw value contains a valid condition in the first 32 bytes, but also includes - * extra bytes afterward. + * This tests the case where conditionRawValue is present and is parseable to a Condition but when the parsed + * Condition is written to a byte array, the value differs from the conditionRawValue bytes. This can occur if the + * condition raw value contains a valid condition in the first 32 bytes, but also includes extra bytes afterward. */ @Test void normalizeConditionWithRawValueThatIsParseableButNotValid() { @@ -217,7 +222,8 @@ void normalizeWithNoConditionAndRawValueForBadHexLengthCondition() { //////////////////////////////// // normalizeFulfillment tests - //////////////////////////////// + + /// ///////////////////////////// @Test void normalizeWithNoFulfillmentNoRawValue() { @@ -309,10 +315,10 @@ void normalizeWithNoFulfillmentAndRawValueForMalformedFulfillment() { } /** - * This tests the case where fulfillmentRawValue is present and is parseable to a Fulfillment> but when the - * parsed Fulfillment is written to a byte array, the value differs from the fulfillmentRawValue bytes. This - * can occur if the fulfillment raw value contains a valid fulfillment in the first 32 bytes, but also includes - * extra bytes afterward, such as in transaction 138543329687544CDAFCD3AB0DCBFE9C4F8E710397747BA7155F19426F493C8D. + * This tests the case where fulfillmentRawValue is present and is parseable to a Fulfillment> but when the parsed + * Fulfillment is written to a byte array, the value differs from the fulfillmentRawValue bytes. This can occur if the + * fulfillment raw value contains a valid fulfillment in the first 32 bytes, but also includes extra bytes afterward, + * such as in transaction 138543329687544CDAFCD3AB0DCBFE9C4F8E710397747BA7155F19426F493C8D. */ @Test void normalizeFulfillmentWithRawValueThatIsParseableButNotValid() { @@ -346,8 +352,54 @@ void normalizeWithNoFulfillmentAndRawValueForBadHexLengthFulfillment() { assertThat(actual.fulfillmentRawValue()).isNotEmpty().get().isEqualTo("123"); } - @Test - public void testNormalizeWithVariousFulfillmentSizes() { + @ParameterizedTest + @CsvSource( { + // Simulate 10 drop base fee + "0,10,330", // Standard 10 drop fee, plus 320 drops + "1,10,330", // Standard 10 drop fee, plus 320 drops + "2,10,330", // Standard 10 drop fee, plus 320 drops + "15,10,330", // Standard 10 drop fee, plus 320 drops + "16,10,340", // Standard 10 drop fee, plus 320 drops + 10 drops for 1 chunk of 16 bytes + "17,10,340", // Standard 10 drop fee, plus 320 drops + 10 drops for 1 chunk of 16 bytes + "31,10,340", // Standard 10 drop fee, plus 320 drops + 10 drops for 1 chunk of 16 bytes + "32,10,350", // Standard 10 drop fee, plus 320 drops + 20 drops for 2 chunks of 16 bytes + "33,10,350", // Standard 10 drop fee, plus 320 drops + 20 drops for 2 chunks of 16 bytes + // Simulate 100 drop base fee + "0,100,3300", // Standard 100 drop fee, plus 3200 drops + "1,100,3300", // Standard 100 drop fee, plus 3200 drops + "2,100,3300", // Standard 100 drop fee, plus 3200 drops + "15,100,3300", // Standard 100 drop fee, plus 3200 drops + "16,100,3400", // Standard 100 drop fee, plus 3200 drops + 100 drops for 1 chunk of 16 bytes + "17,100,3400", // Standard 100 drop fee, plus 3200 drops + 100 drops for 1 chunk of 16 bytes + "31,100,3400", // Standard 100 drop fee, plus 3200 drops + 100 drops for 1 chunk of 16 bytes + "32,100,3500", // Standard 100 drop fee, plus 3200 drops + 200 drops for 2 chunks of 16 bytes + "33,100,3500", // Standard 100 drop fee, plus 3200 drops + 200 drops for 2 chunks of 16 bytes + // Simulate 200 drop base fee + "0,200,6600", // Standard 200 drop fee, plus 6400 drops + "1,200,6600", // Standard 200 drop fee, plus 6400 drops + "2,200,6600", // Standard 200 drop fee, plus 6400 drops + "15,200,6600",// Standard 200 drop fee, plus 6400 drops + "16,200,6800",// Standard 200 drop fee, plus 6400 drops + 200 drops for 1 chunk of 16 bytes + "17,200,6800",// Standard 200 drop fee, plus 6400 drops + 200 drops for 1 chunk of 16 bytes + "31,200,6800",// Standard 200 drop fee, plus 6400 drops + 200 drops for 1 chunk of 16 bytes + "32,200,7000",// Standard 200 drop fee, plus 6400 drops + 400 drops for 2 chunks of 16 bytes + "33,200,7000",// Standard 200 drop fee, plus 6400 drops + 400 drops for 2 chunks of 16 bytes + // Simulate 5000 drop base fee + "0,5000,165000", // Standard 5000 drop fee, plus 160000 drops + "1,5000,165000", // Standard 5000 drop fee, plus 160000 drops + "2,5000,165000", // Standard 5000 drop fee, plus 160000 drops + "15,5000,165000",// Standard 5000 drop fee, plus 160000 drops + "16,5000,170000",// Standard 5000 drop fee, plus 160000 drops + 5000 drops for 1 chunk of 16 bytes + "17,5000,170000",// Standard 5000 drop fee, plus 160000 drops + 5000 drops for 1 chunk of 16 bytes + "31,5000,170000",// Standard 5000 drop fee, plus 160000 drops + 5000 drops for 1 chunk of 16 bytes + "32,5000,175000",// Standard 5000 drop fee, plus 160000 drops + 10000 drops for 2 chunks of 16 bytes + "33,5000,175000",// Standard 5000 drop fee, plus 160000 drops + 10000 drops for 2 chunks of 16 bytes + }) + public void testNormalizeWithVariousFulfillmentSizes(int numBytes, int baseFee, int expectedDrops) { + ///////////////// + // Test Normalize + ///////////////// + Builder builder = EscrowFinish.builder() .fee(XrpCurrencyAmount.ofDrops(1)) .account(Address.of("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59Ba")) @@ -355,113 +407,63 @@ public void testNormalizeWithVariousFulfillmentSizes() { .owner(Address.of("rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH")) .offerSequence(UnsignedInteger.ZERO); - // 0 bytes - Fulfillment fulfillment = PreimageSha256Fulfillment.from(new byte[0]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(330)); - - // 1 byte - fulfillment = PreimageSha256Fulfillment.from(new byte[1]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(330)); - - // 2 byte2 - fulfillment = PreimageSha256Fulfillment.from(new byte[2]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(330)); - - // 15 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[15]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(330)); - - // 16 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[16]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops + 10 drops for 16 bytes - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(340)); - - // 17 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[17]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops + 10 drops for 16 bytes - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(340)); - - // 31 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[31]); + Fulfillment> fulfillment = PreimageSha256Fulfillment.from(new byte[numBytes]); builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); + builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(baseFee), fulfillment)); builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops + 10 drops for 16 bytes - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(340)); - - // 32 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[32]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops + 20 drops for 32 bytes + // Standard fee, plus (32 * base-fee) drops, plus one base-fee for every 16 fulfillment bytes. // (see https://xrpl.org/transaction-cost.html#fee-levels) - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(350)); + Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(expectedDrops)); - // 33 bytes - fulfillment = PreimageSha256Fulfillment.from(new byte[33]); - builder.fulfillment(fulfillment); - builder.fee(EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), fulfillment)); - builder.condition(fulfillment.getDerivedCondition()); - // Standard 10 drop fee, plus 320 drops + 20 drops for 32 bytes - Assertions.assertThat(builder.build().fee()).isEqualTo(XrpCurrencyAmount.ofDrops(350)); + /////////////////// + // Test Compute Fee + /////////////////// + final XrpCurrencyAmount computedFee = EscrowFinish.computeFee( + XrpCurrencyAmount.ofDrops(baseFee), PreimageSha256Fulfillment.from(new byte[numBytes]) + ); + assertThat(computedFee).isEqualTo(XrpCurrencyAmount.ofDrops(expectedDrops)); } @Test - public void testComputeFee() { - // 0 bytes - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[0]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(330)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[1]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(330)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[2]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(330)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[15]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(330)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[16]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(340)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[17]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(340)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[31]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(340)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[32]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(350)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[33]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(350)); - assertThat( - EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), PreimageSha256Fulfillment.from(new byte[64]))) - .isEqualTo(XrpCurrencyAmount.ofDrops(370)); + public void testComputeFeeWithWrongFulfillment() { + ////////////////////// + // Invalid Fulfillment + ////////////////////// + + PreimageSha256Fulfillment preimageSha256Fulfillment = PreimageSha256Fulfillment.from(new byte[10]); + PrefixSha256Fulfillment prefixFulfillment = PrefixSha256Fulfillment.from( + new byte[1], 50, preimageSha256Fulfillment + ); + Exception thrownException = assertThrows( + Exception.class, () -> EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), prefixFulfillment) + ); + assertThat(thrownException instanceof RuntimeException).isTrue(); + assertThat(thrownException.getMessage()).isEqualTo("Only PreimageSha256Fulfillment is supported."); } + @Test + public void testComputeFeeWithNullParams() { + PreimageSha256Fulfillment preimageSha256Fulfillment = PreimageSha256Fulfillment.from(new byte[10]); + PrefixSha256Fulfillment prefixFulfillment = PrefixSha256Fulfillment.from( + new byte[1], 50, preimageSha256Fulfillment + ); + + ////////////////////// + // Null Base Fee + ////////////////////// + Exception thrownException = assertThrows( + Exception.class, () -> EscrowFinish.computeFee(null, prefixFulfillment) + ); + assertThat(thrownException instanceof NullPointerException).isTrue(); + assertThat(thrownException.getMessage()).isNull(); + + ////////////////////// + // Null Fulfillment + ////////////////////// + thrownException = assertThrows( + Exception.class, () -> EscrowFinish.computeFee(XrpCurrencyAmount.ofDrops(10), null) + ); + assertThat(thrownException instanceof NullPointerException).isTrue(); + assertThat(thrownException.getMessage()).isNull(); + } } 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 5a3c91f4e..e2036c8ab 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 @@ -87,7 +87,7 @@ void mint() throws JsonRpcClientErrorException, JsonProcessingException { NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keyPair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keyPair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .uri(uri) @@ -174,7 +174,7 @@ void mintFromOtherMinterAccount() throws JsonRpcClientErrorException, JsonProces NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(minterKeyPair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(minterKeyPair.publicKey()) .sequence(minterAccountInfo.accountData().sequence()) .issuer(keyPair.publicKey().deriveAddress()) @@ -215,7 +215,7 @@ void mintAndBurn() throws JsonRpcClientErrorException, JsonProcessingException { NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keyPair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keyPair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .uri(uri) @@ -239,7 +239,7 @@ void mintAndBurn() throws JsonRpcClientErrorException, JsonProcessingException { NfTokenBurn nfTokenBurn = NfTokenBurn.builder() .nfTokenId(tokenId) .account(keyPair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keyPair.publicKey()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.ONE)) .build(); @@ -291,7 +291,7 @@ void mintAndCreateOffer() throws JsonRpcClientErrorException, JsonProcessingExce NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keyPair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keyPair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .uri(uri) @@ -317,7 +317,7 @@ void mintAndCreateOffer() throws JsonRpcClientErrorException, JsonProcessingExce NfTokenCreateOffer nfTokenCreateOffer = NfTokenCreateOffer.builder() .account(keyPair.publicKey().deriveAddress()) .nfTokenId(tokenId) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.ONE)) .amount(XrpCurrencyAmount.ofDrops(1000)) .flags(NfTokenCreateOfferFlags.builder() @@ -382,7 +382,7 @@ void mintAndCreateThenAcceptOffer() throws JsonRpcClientErrorException, JsonProc NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keypair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keypair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .flags(NfTokenMintFlags.builder() @@ -416,7 +416,7 @@ void mintAndCreateThenAcceptOffer() throws JsonRpcClientErrorException, JsonProc .account(wallet2.publicKey().deriveAddress()) .owner(keypair.publicKey().deriveAddress()) .nfTokenId(tokenId) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult2.accountData().sequence()) .amount(XrpCurrencyAmount.ofDrops(1000)) .signingPublicKey(wallet2.publicKey()) @@ -470,7 +470,7 @@ void mintAndCreateThenAcceptOffer() throws JsonRpcClientErrorException, JsonProc NfTokenAcceptOffer nfTokenAcceptOffer = NfTokenAcceptOffer.builder() .account(keypair.publicKey().deriveAddress()) .buyOffer(nftBuyOffersResult.offers().get(0).nftOfferIndex()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.ONE)) .signingPublicKey(keypair.publicKey()) .build(); @@ -530,7 +530,7 @@ void mintAndCreateOfferThenCancelOffer() throws JsonRpcClientErrorException, Jso NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keypair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keypair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .uri(uri) @@ -552,7 +552,7 @@ void mintAndCreateOfferThenCancelOffer() throws JsonRpcClientErrorException, Jso NfTokenCreateOffer nfTokenCreateOffer = NfTokenCreateOffer.builder() .account(keypair.publicKey().deriveAddress()) .nfTokenId(tokenId) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.ONE)) .amount(XrpCurrencyAmount.ofDrops(1000)) .flags(NfTokenCreateOfferFlags.SELL_NFTOKEN) @@ -594,7 +594,7 @@ void mintAndCreateOfferThenCancelOffer() throws JsonRpcClientErrorException, Jso NfTokenCancelOffer nfTokenCancelOffer = NfTokenCancelOffer.builder() .addTokenOffers(nftSellOffersResult.offers().get(0).nftOfferIndex()) .account(keypair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.valueOf(2))) .signingPublicKey(keypair.publicKey()) .build(); @@ -643,7 +643,7 @@ void acceptOfferDirectModeWithBrokerFee() throws JsonRpcClientErrorException, Js NfTokenMint nfTokenMint = NfTokenMint.builder() .tokenTaxon(UnsignedLong.ONE) .account(keypair.publicKey().deriveAddress()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .signingPublicKey(keypair.publicKey()) .sequence(accountInfoResult.accountData().sequence()) .flags(NfTokenMintFlags.builder() @@ -669,7 +669,7 @@ void acceptOfferDirectModeWithBrokerFee() throws JsonRpcClientErrorException, Js NfTokenCreateOffer nfTokenCreateSellOffer = NfTokenCreateOffer.builder() .account(keypair.publicKey().deriveAddress()) .nfTokenId(tokenId) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult.accountData().sequence().plus(UnsignedInteger.ONE)) .amount(XrpCurrencyAmount.ofDrops(1000)) .signingPublicKey(keypair.publicKey()) @@ -719,7 +719,7 @@ void acceptOfferDirectModeWithBrokerFee() throws JsonRpcClientErrorException, Js .account(keypair2.publicKey().deriveAddress()) .owner(keypair.publicKey().deriveAddress()) .nfTokenId(tokenId) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult2.accountData().sequence()) .amount(XrpCurrencyAmount.ofDrops(1000)) .signingPublicKey(keypair2.publicKey()) @@ -767,7 +767,7 @@ void acceptOfferDirectModeWithBrokerFee() throws JsonRpcClientErrorException, Js .account(wallet3.publicKey().deriveAddress()) .buyOffer(nftBuyOffersResult.offers().get(0).nftOfferIndex()) .sellOffer(nftSellOffersResult.offers().get(0).nftOfferIndex()) - .fee(XrpCurrencyAmount.ofDrops(50)) + .fee(FeeUtils.computeNetworkFees(xrplClient.fee()).recommendedFee()) .sequence(accountInfoResult3.accountData().sequence()) .signingPublicKey(wallet3.publicKey()) .build(); From 613339d9f3f6f5401fc59c73f7036da6bf77a8be Mon Sep 17 00:00:00 2001 From: nkramer44