diff --git a/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index d85d07c72618..4dbbeec22256 100644 --- a/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -38,6 +38,7 @@ import { getSendMaxModeState, getAveragePriceEstimateInHexWEI, isCustomPriceExcessive, + getIsGasEstimatesFetched, } from '../../../../selectors'; import { @@ -132,7 +133,7 @@ const mapStateToProps = (state, ownProps) => { balance, conversionRate, }); - + const isGasEstimate = getIsGasEstimatesFetched(state); return { hideBasic, isConfirm: isConfirm(state), @@ -142,7 +143,10 @@ const mapStateToProps = (state, ownProps) => { customGasLimit: calcCustomGasLimit(customModalGasLimitInHex), customGasTotal, newTotalFiat, - customPriceIsSafe: isCustomPriceSafe(state), + customPriceIsSafe: + (isMainnet || process.env.IN_TEST) && isGasEstimate + ? isCustomPriceSafe(state) + : true, customPriceIsExcessive: isCustomPriceExcessive(state), maxModeOn, gasPriceButtonGroupProps: { diff --git a/ui/ducks/gas/gas.duck.js b/ui/ducks/gas/gas.duck.js index 863d726faca2..e991e5e73ca1 100644 --- a/ui/ducks/gas/gas.duck.js +++ b/ui/ducks/gas/gas.duck.js @@ -11,13 +11,13 @@ import { import { getIsMainnet, getCurrentChainId } from '../../selectors'; import fetchWithCache from '../../helpers/utils/fetch-with-cache'; -const BASIC_ESTIMATE_STATES = { +export const BASIC_ESTIMATE_STATES = { LOADING: 'LOADING', FAILED: 'FAILED', READY: 'READY', }; -const GAS_SOURCE = { +export const GAS_SOURCE = { METASWAPS: 'MetaSwaps', ETHGASPRICE: 'eth_gasprice', }; diff --git a/ui/selectors/custom-gas.js b/ui/selectors/custom-gas.js index ea64bcbe6a89..4485c2086bed 100644 --- a/ui/selectors/custom-gas.js +++ b/ui/selectors/custom-gas.js @@ -9,6 +9,7 @@ import { formatETHFee } from '../helpers/utils/formatters'; import { calcGasTotal } from '../pages/send/send.utils'; import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common'; +import { BASIC_ESTIMATE_STATES, GAS_SOURCE } from '../ducks/gas/gas.duck'; import { getCurrentCurrency, getIsMainnet, @@ -361,13 +362,21 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) { export function getIsEthGasPriceFetched(state) { const gasState = state.gas; return Boolean( - gasState.estimateSource === 'eth_gasprice' && - gasState.basicEstimateStatus === 'READY' && + gasState.estimateSource === GAS_SOURCE.ETHGASPRICE && + gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.READY && getIsMainnet(state), ); } export function getNoGasPriceFetched(state) { const gasState = state.gas; - return Boolean(gasState.basicEstimateStatus === 'FAILED'); + return Boolean(gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.FAILED); +} + +export function getIsGasEstimatesFetched(state) { + const gasState = state.gas; + return Boolean( + gasState.estimateSource === GAS_SOURCE.METASWAPS && + gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.READY, + ); }