Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
}