Skip to content

Commit

Permalink
fix: show correct balance for batch transfers (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx committed Sep 17, 2024
1 parent 25a41ec commit 9fad7f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { useTransferReadiness } from '../useTransferReadiness'
import { useIsBatchTransferSupported } from '../../../hooks/TransferPanel/useIsBatchTransferSupported'
import { Button } from '../../common/Button'
import { useSelectedTokenDecimals } from '../../../hooks/TransferPanel/useSelectedTokenDecimals'
import { useBalanceOnSourceChain } from '../../../hooks/useBalanceOnSourceChain'
import { useNativeCurrencyBalances } from './useNativeCurrencyBalances'

function Amount2ToggleButton({
onClick
Expand Down Expand Up @@ -91,7 +91,7 @@ export function SourceNetworkBox({
const isBatchTransferSupported = useIsBatchTransferSupported()
const decimals = useSelectedTokenDecimals()
const { errorMessages } = useTransferReadiness()
const ethBalanceSourceChain = useBalanceOnSourceChain(null)
const nativeCurrencyBalances = useNativeCurrencyBalances()

const isMaxAmount = amount === AmountQueryParamEnum.MAX
const isMaxAmount2 = amount2 === AmountQueryParamEnum.MAX
Expand Down Expand Up @@ -142,11 +142,11 @@ export function SourceNetworkBox({
() => ({
symbol: nativeCurrency.symbol,
disabled: true,
balance: ethBalanceSourceChain
? Number(utils.formatEther(ethBalanceSourceChain))
balance: nativeCurrencyBalances.sourceBalance
? Number(utils.formatEther(nativeCurrencyBalances.sourceBalance))
: undefined
}),
[ethBalanceSourceChain, nativeCurrency.symbol]
[nativeCurrencyBalances, nativeCurrency.symbol]
)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ function SourceChainTokenBalance({
balanceOverride ??
(selectedToken ? tokenBalance : nativeCurrencyBalances.sourceBalance)

const formattedBalance = balance
? formatAmount(balance, {
decimals: selectedToken?.decimals ?? nativeCurrency.decimals
})
: null
const formattedBalance =
balance !== null
? formatAmount(balance, {
decimals: selectedToken?.decimals ?? nativeCurrency.decimals
})
: null

if (formattedBalance) {
return (
Expand Down

0 comments on commit 9fad7f1

Please sign in to comment.