From a6bcf13ed83bd53958328236cf03235137f1fc36 Mon Sep 17 00:00:00 2001 From: Lucas Jiang Date: Sun, 5 May 2024 21:23:39 +0800 Subject: [PATCH] fix bug --- .../asset-list/DropdownTransferModal.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/asset-list/components/asset-list/DropdownTransferModal.tsx b/examples/asset-list/components/asset-list/DropdownTransferModal.tsx index 8841ac003..bd5ffdf3d 100644 --- a/examples/asset-list/components/asset-list/DropdownTransferModal.tsx +++ b/examples/asset-list/components/asset-list/DropdownTransferModal.tsx @@ -90,19 +90,19 @@ const OverviewTransferWrapper = ( const { tx } = useTx(sourceChainName); const availableAmount = useMemo((): number => { - if (!isDeposit) { - return transferToken.priceDisplayAmount ?? 0; - } - if (isLoadingBalance) { return 0; } - return new BigNumber( - convertBaseUnitToDisplayUnitByDenom(assetsInRegistry, transferToken.denom || '', balance?.amount || ZERO_AMOUNT, selectedChainName) - ).toNumber(); + if (isDeposit && balance) { + return new BigNumber( + convertBaseUnitToDisplayUnitByDenom(assetsInRegistry, balance.denom, balance.amount || ZERO_AMOUNT, sourceChainName) + ).toNumber(); + } + + return transferToken.available ?? 0; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isDeposit, isLoadingBalance, transferToken]); + }, [isDeposit, isLoadingBalance, transferToken, balance]); useEffect(() => { if (!modalControl.isOpen) return; @@ -200,7 +200,7 @@ const OverviewTransferWrapper = ( return { ...prev, destChainName, token: assetOption }; } - const sourceChainName = getChainNameByDenom(currentAssetLists, assetOption.denom || '') || '' + const sourceChainName = getChainNameByDenom(assetsInRegistry, assetOption.denom || '') || '' const sourceChainAssetDenom = getNativeAssetByChainName(assetsInRegistry, sourceChainName)?.base || '' return { ...prev,