mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Show warning when network request for fee market estimates fails (#11724)
This commit is contained in:
parent
d34bf92fd0
commit
8481c4b6be
@ -901,6 +901,9 @@
|
|||||||
"message": "This gas fee has been suggested by $1. Overriding this may cause a problem with your transaction. Please reach out to $1 if you have questions.",
|
"message": "This gas fee has been suggested by $1. Overriding this may cause a problem with your transaction. Please reach out to $1 if you have questions.",
|
||||||
"description": "$1 represents the Dapp's origin"
|
"description": "$1 represents the Dapp's origin"
|
||||||
},
|
},
|
||||||
|
"gasEstimatesUnavailableWarning": {
|
||||||
|
"message": "Our low, medium and high estimates are not available."
|
||||||
|
},
|
||||||
"gasFee": {
|
"gasFee": {
|
||||||
"message": "Gas Fee"
|
"message": "Gas Fee"
|
||||||
},
|
},
|
||||||
|
@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|||||||
import {
|
import {
|
||||||
GAS_RECOMMENDATIONS,
|
GAS_RECOMMENDATIONS,
|
||||||
EDIT_GAS_MODES,
|
EDIT_GAS_MODES,
|
||||||
|
GAS_ESTIMATE_TYPES,
|
||||||
} from '../../../../shared/constants/gas';
|
} from '../../../../shared/constants/gas';
|
||||||
|
|
||||||
import Button from '../../ui/button';
|
import Button from '../../ui/button';
|
||||||
@ -62,6 +63,7 @@ export default function EditGasDisplay({
|
|||||||
onManualChange,
|
onManualChange,
|
||||||
minimumGasLimit,
|
minimumGasLimit,
|
||||||
balanceError,
|
balanceError,
|
||||||
|
estimatesUnavailableWarning,
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
const supportsEIP1559 = useSelector(isEIP1559Network);
|
const supportsEIP1559 = useSelector(isEIP1559Network);
|
||||||
@ -78,16 +80,19 @@ export default function EditGasDisplay({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const networkSupports1559 = useSelector(isEIP1559Network);
|
const networkSupports1559 = useSelector(isEIP1559Network);
|
||||||
const showTopError = balanceError;
|
const showTopError = balanceError || estimatesUnavailableWarning;
|
||||||
|
|
||||||
const showRadioButtons =
|
const showRadioButtons =
|
||||||
networkSupports1559 &&
|
networkSupports1559 &&
|
||||||
|
gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET &&
|
||||||
!requireDappAcknowledgement &&
|
!requireDappAcknowledgement &&
|
||||||
![EDIT_GAS_MODES.SPEED_UP, EDIT_GAS_MODES.CANCEL].includes(mode);
|
![EDIT_GAS_MODES.SPEED_UP, EDIT_GAS_MODES.CANCEL].includes(mode);
|
||||||
|
|
||||||
let errorKey;
|
let errorKey;
|
||||||
if (balanceError) {
|
if (balanceError) {
|
||||||
errorKey = 'insufficientFunds';
|
errorKey = 'insufficientFunds';
|
||||||
|
} else if (estimatesUnavailableWarning) {
|
||||||
|
errorKey = 'gasEstimatesUnavailableWarning';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -275,4 +280,5 @@ EditGasDisplay.propTypes = {
|
|||||||
onManualChange: PropTypes.func,
|
onManualChange: PropTypes.func,
|
||||||
minimumGasLimit: PropTypes.number,
|
minimumGasLimit: PropTypes.number,
|
||||||
balanceError: PropTypes.bool,
|
balanceError: PropTypes.bool,
|
||||||
|
estimatesUnavailableWarning: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -82,6 +82,7 @@ export default function EditGasPopover({
|
|||||||
gasErrors,
|
gasErrors,
|
||||||
onManualChange,
|
onManualChange,
|
||||||
balanceError,
|
balanceError,
|
||||||
|
estimatesUnavailableWarning,
|
||||||
} = useGasFeeInputs(defaultEstimateToUse, transaction, minimumGasLimit, mode);
|
} = useGasFeeInputs(defaultEstimateToUse, transaction, minimumGasLimit, mode);
|
||||||
|
|
||||||
const [showAdvancedForm, setShowAdvancedForm] = useState(
|
const [showAdvancedForm, setShowAdvancedForm] = useState(
|
||||||
@ -241,6 +242,7 @@ export default function EditGasPopover({
|
|||||||
onManualChange={onManualChange}
|
onManualChange={onManualChange}
|
||||||
minimumGasLimit={minimumGasLimitDec}
|
minimumGasLimit={minimumGasLimitDec}
|
||||||
balanceError={balanceError}
|
balanceError={balanceError}
|
||||||
|
estimatesUnavailableWarning={estimatesUnavailableWarning}
|
||||||
{...editGasDisplayProps}
|
{...editGasDisplayProps}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -349,6 +349,8 @@ export function useGasFeeInputs(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let estimatesUnavailableWarning = null;
|
||||||
|
|
||||||
// Separating errors from warnings so we can know which value problems
|
// Separating errors from warnings so we can know which value problems
|
||||||
// are blocking or simply useful information for the users
|
// are blocking or simply useful information for the users
|
||||||
const gasErrors = {};
|
const gasErrors = {};
|
||||||
@ -399,6 +401,13 @@ export function useGasFeeInputs(
|
|||||||
gasWarnings.maxFee = GAS_FORM_ERRORS.MAX_FEE_HIGH_WARNING;
|
gasWarnings.maxFee = GAS_FORM_ERRORS.MAX_FEE_HIGH_WARNING;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GAS_ESTIMATE_TYPES.LEGACY:
|
||||||
|
case GAS_ESTIMATE_TYPES.ETH_GASPRICE:
|
||||||
|
case GAS_ESTIMATE_TYPES.NONE:
|
||||||
|
if (networkSupportsEIP1559) {
|
||||||
|
estimatesUnavailableWarning = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -477,5 +486,6 @@ export function useGasFeeInputs(
|
|||||||
setMaxPriorityFeePerGas(maxPriorityFeePerGasToUse);
|
setMaxPriorityFeePerGas(maxPriorityFeePerGasToUse);
|
||||||
},
|
},
|
||||||
balanceError,
|
balanceError,
|
||||||
|
estimatesUnavailableWarning,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user