Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx committed Oct 10, 2024
1 parent a9f788c commit 6675fd2
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export function TransferPanel() {
isBatchTransferSupported &&
Number(amount2) > 0

let nativeCurrencyToApprove = amountBigNumber
let approvalAmountIncrease: BigNumber | undefined = undefined

// Eth transfers to a custom destination use retryables
// In the case of native currency we need to also approve native currency used for gas
Expand All @@ -622,20 +622,26 @@ export function TransferPanel() {
retryableGasEstimates?.estimatedParentChainGas.mul(parentGasPrice)

if (parentRetryableGas) {
nativeCurrencyToApprove = nativeCurrencyToApprove.add(
percentIncrease(parentRetryableGas, BigNumber.from(30))
approvalAmountIncrease = percentIncrease(
parentRetryableGas,
BigNumber.from(30)
)
}
}

if (isCustomNativeTokenAmount2) {
approvalAmountIncrease = utils.parseUnits(
amount2,
nativeCurrency.decimals
)
}

const isNativeCurrencyApprovalRequired =
await bridgeTransferStarter.requiresNativeCurrencyApproval({
signer,
amount: nativeCurrencyToApprove,
amount: amountBigNumber,
options: {
approvalAmountIncrease: isCustomNativeTokenAmount2
? utils.parseUnits(amount2, nativeCurrency.decimals)
: undefined
approvalAmountIncrease
}
})

Expand All @@ -646,11 +652,9 @@ export function TransferPanel() {

const approvalTx = await bridgeTransferStarter.approveNativeCurrency({
signer,
amount: nativeCurrencyToApprove,
amount: amountBigNumber,
options: {
approvalAmountIncrease: isCustomNativeTokenAmount2
? utils.parseUnits(amount2, nativeCurrency.decimals)
: undefined
approvalAmountIncrease
}
})

Expand Down

0 comments on commit 6675fd2

Please sign in to comment.