Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx committed Sep 11, 2024
1 parent 55efce0 commit 01bc4dd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export function TransferPanelSummary({ token }: TransferPanelSummaryProps) {
{isBatchTransferSupported && Number(amount2) > 0 && (
<span>
{' '}
+ {amount2} {childChainNativeCurrency.symbol}
and {amount2} {childChainNativeCurrency.symbol}
</span>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,26 @@ export function useTransferReadiness(): UseTransferReadinessResult {
}

// Check amount against custom fee token balance
if (Number(amount) > customFeeTokenBalanceFloat) {
if (
Number(amount) > customFeeTokenBalanceFloat ||
(sendsAmount2 && notEnoughAmount2)
) {
return notReady({
errorMessages: {
inputAmount1: getInsufficientFundsErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name
})
inputAmount1:
Number(amount) > customFeeTokenBalanceFloat
? getInsufficientFundsErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name
})
: undefined,
inputAmount2:
sendsAmount2 && notEnoughAmount2
? getInsufficientFundsErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name
})
: undefined
}
})
}
Expand Down Expand Up @@ -410,29 +423,55 @@ export function useTransferReadiness(): UseTransferReadinessResult {
}

// We have to check if there's enough ETH to cover L1 gas
if (estimatedL1GasFees > ethBalanceFloat) {
if (
estimatedL1GasFees > ethBalanceFloat ||
(sendsAmount2 && notEnoughAmount2)
) {
return notReady({
errorMessages: {
inputAmount1: getInsufficientFundsForGasFeesErrorMessage({
asset: ether.symbol,
chain: networks.sourceChain.name,
balance: formatAmount(ethBalanceFloat),
requiredBalance: formatAmount(estimatedL1GasFees)
})
inputAmount1:
estimatedL1GasFees > ethBalanceFloat
? getInsufficientFundsForGasFeesErrorMessage({
asset: ether.symbol,
chain: networks.sourceChain.name,
balance: formatAmount(ethBalanceFloat),
requiredBalance: formatAmount(estimatedL1GasFees)
})
: undefined,
inputAmount2:
sendsAmount2 && notEnoughAmount2
? getInsufficientFundsErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name
})
: undefined
}
})
}

// We have to check if there's enough of the custom fee token to cover L2 gas
if (estimatedL2GasFees > customFeeTokenL1BalanceFloat) {
if (
estimatedL2GasFees > customFeeTokenL1BalanceFloat ||
(sendsAmount2 && notEnoughAmount2)
) {
return notReady({
errorMessages: {
inputAmount1: getInsufficientFundsForGasFeesErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name,
balance: formatAmount(customFeeTokenL1BalanceFloat),
requiredBalance: formatAmount(estimatedL2GasFees)
})
inputAmount1:
estimatedL2GasFees > customFeeTokenL1BalanceFloat
? getInsufficientFundsForGasFeesErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name,
balance: formatAmount(customFeeTokenL1BalanceFloat),
requiredBalance: formatAmount(estimatedL2GasFees)
})
: undefined,
inputAmount2:
sendsAmount2 && notEnoughAmount2
? getInsufficientFundsErrorMessage({
asset: nativeCurrency.symbol,
chain: networks.sourceChain.name
})
: undefined
}
})
}
Expand Down

0 comments on commit 01bc4dd

Please sign in to comment.