1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Fix #11695 - Prevent maxFee and maxPriorityFee imbalance (#11700)

This commit is contained in:
David Walsh 2021-08-02 09:07:29 -05:00 committed by GitHub
parent 38ff2c937f
commit 4ce6994a6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -662,6 +662,9 @@
"editGasMaxFeeLow": {
"message": "Max fee too low for network conditions"
},
"editGasMaxFeePriorityImbalance": {
"message": "Max fee cannot be lower than max priority fee"
},
"editGasMaxFeeTooltip": {
"message": "The max fee is the most youll pay (base fee + priority fee)."
},

View File

@ -5,6 +5,7 @@ export const GAS_FORM_ERRORS = {
MAX_PRIORITY_FEE_ZERO: 'editGasMaxPriorityFeeZeroError',
MAX_PRIORITY_FEE_HIGH_WARNING: 'editGasMaxPriorityFeeHigh',
MAX_FEE_HIGH_WARNING: 'editGasMaxFeeHigh',
MAX_FEE_IMBALANCE: 'editGasMaxFeeImbalance',
};
export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
@ -21,6 +22,8 @@ export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
return t('editGasMaxPriorityFeeHigh');
case GAS_FORM_ERRORS.MAX_FEE_HIGH_WARNING:
return t('editGasMaxFeeHigh');
case GAS_FORM_ERRORS.MAX_FEE_IMBALANCE:
return t('editGasMaxFeePriorityImbalance');
default:
return '';
}

View File

@ -384,6 +384,8 @@ export function useGasFeeInputs(
gasFeeEstimates?.low?.suggestedMaxPriorityFeePerGas
) {
gasErrors.maxPriorityFee = GAS_FORM_ERRORS.MAX_PRIORITY_FEE_TOO_LOW;
} else if (maxPriorityFeePerGasToUse >= maxFeePerGasToUse) {
gasErrors.maxFee = GAS_FORM_ERRORS.MAX_FEE_IMBALANCE;
} else if (
gasFeeEstimates?.high &&
maxPriorityFeePerGasToUse >
@ -419,8 +421,8 @@ export function useGasFeeInputs(
// and errors into one object for easier use within the UI. This object should have
// no effect on whether or not the user can submit the form
const errorsAndWarnings = {
...gasErrors,
...gasWarnings,
...gasErrors,
};
const minimumTxCostInHexWei = addHexes(