Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
Browse files Browse the repository at this point in the history
…e into token-query-params
  • Loading branch information
brtkx committed Jul 22, 2024
2 parents 059a969 + 6cb1eea commit 976617c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/arb-token-bridge-ui/src/hooks/useBalance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useMemo } from 'react'
import { BigNumber } from 'ethers'
import { BigNumber, utils } from 'ethers'
import useSWR, {
useSWRConfig,
unstable_serialize,
Expand Down Expand Up @@ -40,10 +40,13 @@ const merge: Middleware = (useSWRNext: SWRHook) => {
}

const useBalance = ({ chainId, walletAddress }: UseBalanceProps) => {
const walletAddressLowercased = useMemo(
() => walletAddress?.toLowerCase(),
[walletAddress]
)
const walletAddressLowercased = useMemo(() => {
// use balances for the wallet address only if it's valid
if (!walletAddress || !utils.isAddress(walletAddress)) {
return undefined
}
return walletAddress.toLowerCase()
}, [walletAddress])

const queryKey = useCallback(
(type: 'eth' | 'erc20') => {
Expand Down

0 comments on commit 976617c

Please sign in to comment.