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:
parent
ad6715511e
commit
18464793f5
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user