From a2320c76fef084b7ec01839ab9c17b474839b3c0 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Tue, 26 Feb 2019 10:30:41 -0800 Subject: Show/Hide Fiat on Testnets based on User Preference (#6153) --- .../gas-modal-page-container.container.js | 7 ++- .../gas-modal-page-container-container.test.js | 63 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) (limited to 'ui/app/components/gas-customization/gas-modal-page-container') diff --git a/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index 1671f95fa..6692fb363 100644 --- a/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -63,6 +63,7 @@ import { } from '../../send/send.utils' import { addHexPrefix } from 'ethereumjs-util' import { getAdjacentGasPrices, extrapolateY } from '../gas-price-chart/gas-price-chart.utils' +import {getIsMainnet, preferencesSelector} from '../../../selectors' const mapStateToProps = (state, ownProps) => { const { transaction = {} } = ownProps @@ -91,6 +92,10 @@ const mapStateToProps = (state, ownProps) => { const estimatedTimes = getEstimatedGasTimes(state) const balance = getCurrentEthBalance(state) + const { showFiatInTestnets } = preferencesSelector(state) + const isMainnet = getIsMainnet(state) + const showFiat = Boolean(isMainnet || showFiatInTestnets) + const insufficientBalance = !isBalanceSufficient({ amount: value, gasTotal, @@ -124,7 +129,7 @@ const mapStateToProps = (state, ownProps) => { infoRowProps: { originalTotalFiat: addHexWEIsToRenderableFiat(value, gasTotal, currentCurrency, conversionRate), originalTotalEth: addHexWEIsToRenderableEth(value, gasTotal), - newTotalFiat, + newTotalFiat: showFiat ? newTotalFiat : '', newTotalEth: addHexWEIsToRenderableEth(value, customGasTotal), transactionFee: addHexWEIsToRenderableEth('0x0', customGasTotal), sendAmount: addHexWEIsToRenderableEth(value, '0x0'), diff --git a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index 077ec471d..fb6a01fff 100644 --- a/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -71,6 +71,12 @@ describe('gas-modal-page-container container', () => { }, currentCurrency: 'abc', conversionRate: 50, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'mainnet', + }, }, gas: { basicEstimates: { @@ -152,6 +158,63 @@ describe('gas-modal-page-container container', () => { }), expectedResult: Object.assign({}, baseExpectedResult, { isSpeedUp: true }), }, + { + mockState: Object.assign({}, baseMockState, { + metamask: { + ...baseMockState.metamask, + preferences: { + ...baseMockState.metamask.preferences, + showFiatInTestnets: false, + }, + provider: { + ...baseMockState.metamask.provider, + type: 'rinkeby', + }, + }, + }), + mockOwnProps: baseMockOwnProps, + expectedResult: { + ...baseExpectedResult, + infoRowProps: { + ...baseExpectedResult.infoRowProps, + newTotalFiat: '', + }, + }, + }, + { + mockState: Object.assign({}, baseMockState, { + metamask: { + ...baseMockState.metamask, + preferences: { + ...baseMockState.metamask.preferences, + showFiatInTestnets: true, + }, + provider: { + ...baseMockState.metamask.provider, + type: 'rinkeby', + }, + }, + }), + mockOwnProps: baseMockOwnProps, + expectedResult: baseExpectedResult, + }, + { + mockState: Object.assign({}, baseMockState, { + metamask: { + ...baseMockState.metamask, + preferences: { + ...baseMockState.metamask.preferences, + showFiatInTestnets: true, + }, + provider: { + ...baseMockState.metamask.provider, + type: 'mainnet', + }, + }, + }), + mockOwnProps: baseMockOwnProps, + expectedResult: baseExpectedResult, + }, ] let result -- cgit v1.2.3