mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-22 19:26:13 +02:00
EIP-1559 - Provide better validation for gas price and gas limit (#11736)
This commit is contained in:
parent
9ccb91f47b
commit
fba662ca2b
@ -683,6 +683,9 @@
|
|||||||
"editGasMedium": {
|
"editGasMedium": {
|
||||||
"message": "Medium"
|
"message": "Medium"
|
||||||
},
|
},
|
||||||
|
"editGasPriceTooLow": {
|
||||||
|
"message": "Gas price must be greater than 0"
|
||||||
|
},
|
||||||
"editGasPriceTooltip": {
|
"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."
|
"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={(e) => {
|
||||||
onChange?.(parseFloat(e.target.value, 10));
|
onChange?.(parseFloat(e.target.value || 0, 10));
|
||||||
}}
|
}}
|
||||||
min="0"
|
min="0"
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
|
@ -6,6 +6,7 @@ export const GAS_FORM_ERRORS = {
|
|||||||
MAX_PRIORITY_FEE_HIGH_WARNING: 'editGasMaxPriorityFeeHigh',
|
MAX_PRIORITY_FEE_HIGH_WARNING: 'editGasMaxPriorityFeeHigh',
|
||||||
MAX_FEE_HIGH_WARNING: 'editGasMaxFeeHigh',
|
MAX_FEE_HIGH_WARNING: 'editGasMaxFeeHigh',
|
||||||
MAX_FEE_IMBALANCE: 'editGasMaxFeeImbalance',
|
MAX_FEE_IMBALANCE: 'editGasMaxFeeImbalance',
|
||||||
|
GAS_PRICE_TOO_LOW: 'editGasPriceTooLow',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
|
export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
|
||||||
@ -24,6 +25,8 @@ export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
|
|||||||
return t('editGasMaxFeeHigh');
|
return t('editGasMaxFeeHigh');
|
||||||
case GAS_FORM_ERRORS.MAX_FEE_IMBALANCE:
|
case GAS_FORM_ERRORS.MAX_FEE_IMBALANCE:
|
||||||
return t('editGasMaxFeePriorityImbalance');
|
return t('editGasMaxFeePriorityImbalance');
|
||||||
|
case GAS_FORM_ERRORS.GAS_PRICE_TOO_LOW:
|
||||||
|
return t('editGasPriceTooLow');
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -425,6 +425,9 @@ export function useGasFeeInputs(
|
|||||||
if (networkAndAccountSupports1559) {
|
if (networkAndAccountSupports1559) {
|
||||||
estimatesUnavailableWarning = true;
|
estimatesUnavailableWarning = true;
|
||||||
}
|
}
|
||||||
|
if (gasPriceToUse <= 0) {
|
||||||
|
gasErrors.gasPrice = GAS_FORM_ERRORS.GAS_PRICE_TOO_LOW;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user