From 14f0d8245bd883b0b9e3ba021d528de38a1f2730 Mon Sep 17 00:00:00 2001 From: Alex Donesky Date: Mon, 27 Sep 2021 09:06:07 -0500 Subject: [PATCH] fix issue where conversionRates aren't shown for tokens stored in non-checksum format (#12206) --- ui/hooks/useTokenFiatAmount.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/hooks/useTokenFiatAmount.js b/ui/hooks/useTokenFiatAmount.js index 1e3974525..dc52a979a 100644 --- a/ui/hooks/useTokenFiatAmount.js +++ b/ui/hooks/useTokenFiatAmount.js @@ -7,6 +7,7 @@ import { } from '../selectors'; import { getTokenFiatAmount } from '../helpers/utils/token-util'; import { getConversionRate } from '../ducks/metamask/metamask'; +import { isEqualCaseInsensitive } from '../helpers/utils/util'; /** * Get the token balance converted to fiat and formatted for display @@ -33,8 +34,13 @@ export function useTokenFiatAmount( const currentCurrency = useSelector(getCurrentCurrency); const userPrefersShownFiat = useSelector(getShouldShowFiat); const showFiat = overrides.showFiat ?? userPrefersShownFiat; + const contractExchangeTokenKey = Object.keys( + contractExchangeRates, + ).find((key) => isEqualCaseInsensitive(key, tokenAddress)); const tokenExchangeRate = - overrides.exchangeRate ?? contractExchangeRates[tokenAddress]; + overrides.exchangeRate ?? + (contractExchangeTokenKey && + contractExchangeRates[contractExchangeTokenKey]); const formattedFiat = useMemo( () => getTokenFiatAmount(