1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00

Hide token fiat amounts on testnets (#8792)

The token amount is no longer shown in fiat on testnets, unless the
user has enabled the "Show fiat on testnets" setting.
This commit is contained in:
Mark Stacey 2020-06-12 15:47:23 -03:00 committed by GitHub
parent 2f50e9fd72
commit a100c55e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,12 @@ describe('Token Cell', function () {
'0xAnotherToken': 0.015, '0xAnotherToken': 0.015,
}, },
conversionRate: 7.00, conversionRate: 7.00,
preferences: {},
provider: {
chainId: '1',
ticker: 'ETH',
type: 'mainnet',
},
}, },
appState: { appState: {
sidebar: { sidebar: {

View File

@ -1,6 +1,6 @@
import { useMemo } from 'react' import { useMemo } from 'react'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
import { getTokenExchangeRates, getConversionRate, getCurrentCurrency } from '../selectors' import { getTokenExchangeRates, getConversionRate, getCurrentCurrency, getShouldShowFiat } from '../selectors'
import { getFormattedTokenFiatAmount } from '../helpers/utils/token-util' import { getFormattedTokenFiatAmount } from '../helpers/utils/token-util'
/** /**
@ -15,6 +15,7 @@ export function useTokenFiatAmount (tokenAddress, tokenAmount, tokenSymbol) {
const contractExchangeRates = useSelector(getTokenExchangeRates) const contractExchangeRates = useSelector(getTokenExchangeRates)
const conversionRate = useSelector(getConversionRate) const conversionRate = useSelector(getConversionRate)
const currentCurrency = useSelector(getCurrentCurrency) const currentCurrency = useSelector(getCurrentCurrency)
const showFiat = useSelector(getShouldShowFiat)
const tokenExchangeRate = contractExchangeRates[tokenAddress] const tokenExchangeRate = contractExchangeRates[tokenAddress]
@ -29,7 +30,7 @@ export function useTokenFiatAmount (tokenAddress, tokenAmount, tokenSymbol) {
[tokenExchangeRate, conversionRate, currentCurrency, tokenAmount, tokenSymbol] [tokenExchangeRate, conversionRate, currentCurrency, tokenAmount, tokenSymbol]
) )
if (currentCurrency.toUpperCase() === tokenSymbol) { if (!showFiat || currentCurrency.toUpperCase() === tokenSymbol) {
return undefined return undefined
} }