1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

fix issue where conversionRates aren't shown for tokens stored in non-checksum format (#12206)

This commit is contained in:
Alex Donesky 2021-09-27 09:06:07 -05:00 committed by GitHub
parent c076faeb8f
commit 14f0d8245b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(