mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
EIP-1559 - Provide better validation for gas price and gas limit (#11736)
This commit is contained in:
parent
f9a4f177b8
commit
29072a0cf0
@ -683,6 +683,9 @@
|
||||
"editGasMedium": {
|
||||
"message": "Medium"
|
||||
},
|
||||
"editGasPriceTooLow": {
|
||||
"message": "Gas price must be greater than 0"
|
||||
},
|
||||
"editGasPriceTooltip": {
|
||||
"message": "This network requires a “Gas price” field when submitting a transaction. Gas price is the amount you will pay pay per unit of gas."
|
||||
},
|
||||
|
@ -156,6 +156,11 @@ export default function AdvancedGasControls({
|
||||
</>
|
||||
)
|
||||
}
|
||||
error={
|
||||
gasErrors?.gasPrice
|
||||
? getGasFormErrorText(gasErrors.gasPrice, t)
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
@ -25,7 +25,7 @@ export default function NumericInput({
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
onChange?.(parseFloat(e.target.value, 10));
|
||||
onChange?.(parseFloat(e.target.value || 0, 10));
|
||||
}}
|
||||
min="0"
|
||||
autoFocus={autoFocus}
|
||||
|
@ -6,6 +6,7 @@ export const GAS_FORM_ERRORS = {
|
||||
MAX_PRIORITY_FEE_HIGH_WARNING: 'editGasMaxPriorityFeeHigh',
|
||||
MAX_FEE_HIGH_WARNING: 'editGasMaxFeeHigh',
|
||||
MAX_FEE_IMBALANCE: 'editGasMaxFeeImbalance',
|
||||
GAS_PRICE_TOO_LOW: 'editGasPriceTooLow',
|
||||
};
|
||||
|
||||
export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
|
||||
@ -24,6 +25,8 @@ export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
|
||||
return t('editGasMaxFeeHigh');
|
||||
case GAS_FORM_ERRORS.MAX_FEE_IMBALANCE:
|
||||
return t('editGasMaxFeePriorityImbalance');
|
||||
case GAS_FORM_ERRORS.GAS_PRICE_TOO_LOW:
|
||||
return t('editGasPriceTooLow');
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@ -425,6 +425,9 @@ export function useGasFeeInputs(
|
||||
if (networkAndAccountSupports1559) {
|
||||
estimatesUnavailableWarning = true;
|
||||
}
|
||||
if (gasPriceToUse <= 0) {
|
||||
gasErrors.gasPrice = GAS_FORM_ERRORS.GAS_PRICE_TOO_LOW;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user