Skip to content

Commit

Permalink
nit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 committed Nov 12, 2024
1 parent 80a6d1f commit d907ce5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions packages/xrpl/src/sugar/autofill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BigNumber> {
const response = await client.request({ command: 'server_state' })
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit d907ce5

Please sign in to comment.