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

Avoid showing "Gas price extremely low" warning in advanced tab for testnets (#11111)

This commit is contained in:
Niranjana Binoy 2021-05-20 11:32:55 -04:00 committed by GitHub
parent 978f11b89b
commit 2972e78444
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -38,6 +38,7 @@ import {
getSendMaxModeState, getSendMaxModeState,
getAveragePriceEstimateInHexWEI, getAveragePriceEstimateInHexWEI,
isCustomPriceExcessive, isCustomPriceExcessive,
getIsGasEstimatesFetched,
} from '../../../../selectors'; } from '../../../../selectors';
import { import {
@ -132,7 +133,7 @@ const mapStateToProps = (state, ownProps) => {
balance, balance,
conversionRate, conversionRate,
}); });
const isGasEstimate = getIsGasEstimatesFetched(state);
return { return {
hideBasic, hideBasic,
isConfirm: isConfirm(state), isConfirm: isConfirm(state),
@ -142,7 +143,10 @@ const mapStateToProps = (state, ownProps) => {
customGasLimit: calcCustomGasLimit(customModalGasLimitInHex), customGasLimit: calcCustomGasLimit(customModalGasLimitInHex),
customGasTotal, customGasTotal,
newTotalFiat, newTotalFiat,
customPriceIsSafe: isCustomPriceSafe(state), customPriceIsSafe:
(isMainnet || process.env.IN_TEST) && isGasEstimate
? isCustomPriceSafe(state)
: true,
customPriceIsExcessive: isCustomPriceExcessive(state), customPriceIsExcessive: isCustomPriceExcessive(state),
maxModeOn, maxModeOn,
gasPriceButtonGroupProps: { gasPriceButtonGroupProps: {

View File

@ -11,13 +11,13 @@ import {
import { getIsMainnet, getCurrentChainId } from '../../selectors'; import { getIsMainnet, getCurrentChainId } from '../../selectors';
import fetchWithCache from '../../helpers/utils/fetch-with-cache'; import fetchWithCache from '../../helpers/utils/fetch-with-cache';
const BASIC_ESTIMATE_STATES = { export const BASIC_ESTIMATE_STATES = {
LOADING: 'LOADING', LOADING: 'LOADING',
FAILED: 'FAILED', FAILED: 'FAILED',
READY: 'READY', READY: 'READY',
}; };
const GAS_SOURCE = { export const GAS_SOURCE = {
METASWAPS: 'MetaSwaps', METASWAPS: 'MetaSwaps',
ETHGASPRICE: 'eth_gasprice', ETHGASPRICE: 'eth_gasprice',
}; };

View File

@ -9,6 +9,7 @@ import { formatETHFee } from '../helpers/utils/formatters';
import { calcGasTotal } from '../pages/send/send.utils'; import { calcGasTotal } from '../pages/send/send.utils';
import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common'; import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common';
import { BASIC_ESTIMATE_STATES, GAS_SOURCE } from '../ducks/gas/gas.duck';
import { import {
getCurrentCurrency, getCurrentCurrency,
getIsMainnet, getIsMainnet,
@ -361,13 +362,21 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI(state) {
export function getIsEthGasPriceFetched(state) { export function getIsEthGasPriceFetched(state) {
const gasState = state.gas; const gasState = state.gas;
return Boolean( return Boolean(
gasState.estimateSource === 'eth_gasprice' && gasState.estimateSource === GAS_SOURCE.ETHGASPRICE &&
gasState.basicEstimateStatus === 'READY' && gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.READY &&
getIsMainnet(state), getIsMainnet(state),
); );
} }
export function getNoGasPriceFetched(state) { export function getNoGasPriceFetched(state) {
const gasState = state.gas; 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,
);
} }