Skip to content

Commit

Permalink
Avoid showing "Gas price extremely low" warning in advanced tab for t…
Browse files Browse the repository at this point in the history
…estnets (#11111)
  • Loading branch information
NiranjanaBinoy authored May 20, 2021
1 parent 978f11b commit 2972e78
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
getSendMaxModeState,
getAveragePriceEstimateInHexWEI,
isCustomPriceExcessive,
getIsGasEstimatesFetched,
} from '../../../../selectors';

import {
Expand Down Expand Up @@ -132,7 +133,7 @@ const mapStateToProps = (state, ownProps) => {
balance,
conversionRate,
});

const isGasEstimate = getIsGasEstimatesFetched(state);
return {
hideBasic,
isConfirm: isConfirm(state),
Expand All @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions ui/ducks/gas/gas.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
Expand Down
15 changes: 12 additions & 3 deletions ui/selectors/custom-gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
);
}

0 comments on commit 2972e78

Please sign in to comment.