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

Fix gas-modal-page-container.container check for custom gas price safety (#11426)

* Fix gas-modal-page-container.container check for custom gas price safety

* Ensure gas price has been fetch before checking for price safety on testnets
This commit is contained in:
Dan J Miller 2021-06-30 15:56:34 -02:30 committed by GitHub
parent ad6715511e
commit 18464793f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -41,6 +41,7 @@ import {
isCustomPriceExcessive,
getIsGasEstimatesFetched,
getShouldShowFiat,
getIsCustomNetworkGasPriceFetched,
} from '../../../../selectors';
import {
@ -137,13 +138,17 @@ const mapStateToProps = (state, ownProps) => {
conversionRate,
});
const isGasEstimate = getIsGasEstimatesFetched(state);
const customNetworkEstimateWasFetched = getIsCustomNetworkGasPriceFetched(
state,
);
let customPriceIsSafe;
let customPriceIsSafe = true;
if ((isMainnet || process.env.IN_TEST) && isGasEstimate) {
customPriceIsSafe = isCustomPriceSafe(state);
} else if (isTestnet) {
customPriceIsSafe = true;
} else {
} else if (
!(isMainnet || process.env.IN_TEST || isTestnet) &&
customNetworkEstimateWasFetched
) {
customPriceIsSafe = isCustomPriceSafeForCustomNetwork(state);
}

View File

@ -105,6 +105,10 @@ export function isCustomPriceSafeForCustomNetwork(state) {
return true;
}
if (!estimatedPrice) {
return false;
}
const customPriceSafe = conversionGreaterThan(
{
value: customGasPrice,
@ -382,6 +386,15 @@ export function getIsEthGasPriceFetched(state) {
);
}
export function getIsCustomNetworkGasPriceFetched(state) {
const gasState = state.gas;
return Boolean(
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 === BASIC_ESTIMATE_STATES.FAILED);