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,
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: {

View File

@ -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',
};

View File

@ -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,
);
}