Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaaawscodepipelinedeploy committed May 5, 2024
1 parent 1d856e6 commit a6bcf13
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a6bcf13

Please sign in to comment.