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,
|
isCustomPriceExcessive,
|
||||||
getIsGasEstimatesFetched,
|
getIsGasEstimatesFetched,
|
||||||
getShouldShowFiat,
|
getShouldShowFiat,
|
||||||
|
getIsCustomNetworkGasPriceFetched,
|
||||||
} from '../../../../selectors';
|
} from '../../../../selectors';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -137,13 +138,17 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
});
|
});
|
||||||
const isGasEstimate = getIsGasEstimatesFetched(state);
|
const isGasEstimate = getIsGasEstimatesFetched(state);
|
||||||
|
const customNetworkEstimateWasFetched = getIsCustomNetworkGasPriceFetched(
|
||||||
|
state,
|
||||||
|
);
|
||||||
|
|
||||||
let customPriceIsSafe;
|
let customPriceIsSafe = true;
|
||||||
if ((isMainnet || process.env.IN_TEST) && isGasEstimate) {
|
if ((isMainnet || process.env.IN_TEST) && isGasEstimate) {
|
||||||
customPriceIsSafe = isCustomPriceSafe(state);
|
customPriceIsSafe = isCustomPriceSafe(state);
|
||||||
} else if (isTestnet) {
|
} else if (
|
||||||
customPriceIsSafe = true;
|
!(isMainnet || process.env.IN_TEST || isTestnet) &&
|
||||||
} else {
|
customNetworkEstimateWasFetched
|
||||||
|
) {
|
||||||
customPriceIsSafe = isCustomPriceSafeForCustomNetwork(state);
|
customPriceIsSafe = isCustomPriceSafeForCustomNetwork(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,10 @@ export function isCustomPriceSafeForCustomNetwork(state) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!estimatedPrice) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const customPriceSafe = conversionGreaterThan(
|
const customPriceSafe = conversionGreaterThan(
|
||||||
{
|
{
|
||||||
value: customGasPrice,
|
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) {
|
export function getNoGasPriceFetched(state) {
|
||||||
const gasState = state.gas;
|
const gasState = state.gas;
|
||||||
return Boolean(gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.FAILED);
|
return Boolean(gasState.basicEstimateStatus === BASIC_ESTIMATE_STATES.FAILED);
|
||||||
|
Loading…
Reference in New Issue
Block a user