diff --git a/ui/app/components/app/wallet-overview/token-overview.js b/ui/app/components/app/wallet-overview/token-overview.js index af765409e..1d499e1b4 100644 --- a/ui/app/components/app/wallet-overview/token-overview.js +++ b/ui/app/components/app/wallet-overview/token-overview.js @@ -38,8 +38,9 @@ const TokenOverview = ({ className, token }) => { const keyring = useSelector(getCurrentKeyring) const usingHardwareWallet = keyring.type.search('Hardware') !== -1 const { tokensWithBalances } = useTokenTracker([token]) - const balance = tokensWithBalances[0]?.string - const formattedFiatBalance = useTokenFiatAmount(token.address, balance, token.symbol) + const balanceToRender = tokensWithBalances[0]?.string + const balance = tokensWithBalances[0]?.balance + const formattedFiatBalance = useTokenFiatAmount(token.address, balanceToRender, token.symbol) const networkId = useSelector(getCurrentNetworkId) const enteredSwapsEvent = useNewMetricEvent({ event: 'Swaps Opened', properties: { source: 'Token View', active_currency: token.symbol }, category: 'swaps' }) const swapsEnabled = useSelector(getSwapsFeatureLiveness) @@ -50,7 +51,7 @@ const TokenOverview = ({ className, token }) => {
{ @@ -87,7 +88,12 @@ const TokenOverview = ({ className, token }) => { onClick={() => { if (networkId === MAINNET_NETWORK_ID) { enteredSwapsEvent() - dispatch(setSwapsFromToken({ ...token, iconUrl: assetImages[token.address] })) + dispatch(setSwapsFromToken({ + ...token, + iconUrl: assetImages[token.address], + balance, + string: balanceToRender, + })) if (usingHardwareWallet) { global.platform.openExtensionInBrowser(BUILD_QUOTE_ROUTE) } else { diff --git a/ui/app/pages/swaps/build-quote/build-quote.js b/ui/app/pages/swaps/build-quote/build-quote.js index 89f9152f9..1a03c7831 100644 --- a/ui/app/pages/swaps/build-quote/build-quote.js +++ b/ui/app/pages/swaps/build-quote/build-quote.js @@ -24,7 +24,7 @@ import { getTopAssets, getFetchParams, } from '../../../ducks/swaps/swaps' -import { getValueFromWeiHex } from '../../../helpers/utils/conversions.util' +import { getValueFromWeiHex, hexToDecimal } from '../../../helpers/utils/conversions.util' import { calcTokenAmount } from '../../../helpers/utils/token-util' import { usePrevious } from '../../../hooks/usePrevious' import { useTokenTracker } from '../../../hooks/useTokenTracker' @@ -167,7 +167,11 @@ export default function BuildQuote ({ // If the eth balance changes while on build quote, we update the selected from token useEffect(() => { if (fromToken?.address === ETH_SWAPS_TOKEN_OBJECT.address && (fromToken?.balance !== ethBalance)) { - dispatch(setSwapsFromToken({ ...fromToken, balance: ethBalance, string: getValueFromWeiHex({ value: ethBalance, numberOfDecimals: 4, toDenomination: 'ETH' }) })) + dispatch(setSwapsFromToken({ + ...fromToken, + balance: hexToDecimal(ethBalance), + string: getValueFromWeiHex({ value: ethBalance, numberOfDecimals: 4, toDenomination: 'ETH' }), + })) } }, [dispatch, fromToken, ethBalance])