From d907ce53c7d3b327eb6c894ff5cbb256c7a8cfe6 Mon Sep 17 00:00:00 2001 From: Phu Pham Date: Tue, 12 Nov 2024 15:03:15 -0500 Subject: [PATCH] nit changes --- .ci-config/rippled.cfg | 2 +- packages/xrpl/src/sugar/autofill.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.ci-config/rippled.cfg b/.ci-config/rippled.cfg index 6976c24637..ee584f4daa 100644 --- a/.ci-config/rippled.cfg +++ b/.ci-config/rippled.cfg @@ -179,7 +179,7 @@ fixEmptyDID fixXChainRewardRounding fixPreviousTxnID -# # This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode +# This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode [voting] reference_fee = 200 # 200 drops account_reserve = 20000000 # 20 XRP diff --git a/packages/xrpl/src/sugar/autofill.ts b/packages/xrpl/src/sugar/autofill.ts index 05178933b2..9df09576e2 100644 --- a/packages/xrpl/src/sugar/autofill.ts +++ b/packages/xrpl/src/sugar/autofill.ts @@ -233,8 +233,8 @@ export async function setNextValidSequenceNumber( * Fetches the owner reserve fee from the server state using the provided client. * * @param client - The client object used to make the request. - * @returns A Promise that resolves to the account deletion fee as a BigNumber. - * @throws {Error} Throws an error if the account deletion fee cannot be fetched. + * @returns A Promise that resolves to the owner reserve fee as a BigNumber. + * @throws {Error} Throws an error if the owner reserve fee cannot be fetched. */ async function fetchOwnerReserveFee(client: Client): Promise { const response = await client.request({ command: 'server_state' }) @@ -275,10 +275,11 @@ export async function calculateFeePerTransactionType( baseFee = product.dp(0, BigNumber.ROUND_CEIL) } - if ( - tx.TransactionType === 'AccountDelete' || - tx.TransactionType === 'AMMCreate' - ) { + const isSpecialTxCost = ['AccountDelete', 'AMMCreate'].includes( + tx.TransactionType, + ) + + if (isSpecialTxCost) { baseFee = await fetchOwnerReserveFee(client) } @@ -291,12 +292,12 @@ export async function calculateFeePerTransactionType( } const maxFeeDrops = xrpToDrops(client.maxFeeXRP) - const totalFee = ['AccountDelete', 'AMMCreate'].includes(tx.TransactionType) + const totalFee = isSpecialTxCost ? baseFee : BigNumber.min(baseFee, maxFeeDrops) // Round up baseFee and return it as a string - // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-magic-numbers -- param reassign is safe, base 10 magic num + // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-magic-numbers, require-atomic-updates -- safe reassignment. tx.Fee = totalFee.dp(0, BigNumber.ROUND_CEIL).toString(10) }