UNPKG

@lifi/widget

Version:

LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.

18 lines 722 B
import { useMemo } from 'react'; import { useTokenBalances } from './useTokenBalances.js'; export const useTokenAddressBalance = (chainId, tokenAddress) => { const { tokens, tokensWithBalance, chain, isBalanceLoading, refetch } = useTokenBalances(chainId); const token = useMemo(() => { if (tokenAddress && chainId) { const token = (tokensWithBalance ?? tokens)?.find((token) => token.address === tokenAddress && token.chainId === chainId); return token; } }, [chainId, tokenAddress, tokens, tokensWithBalance]); return { token, chain, isLoading: isBalanceLoading, refetch, }; }; //# sourceMappingURL=useTokenAddressBalance.js.map