1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02: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": { "editGasMaxFeeLow": {
"message": "Max fee too low for network conditions" "message": "Max fee too low for network conditions"
}, },
"editGasMaxFeePriorityImbalance": {
"message": "Max fee cannot be lower than max priority fee"
},
"editGasMaxFeeTooltip": { "editGasMaxFeeTooltip": {
"message": "The max fee is the most youll pay (base fee + priority fee)." "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_ZERO: 'editGasMaxPriorityFeeZeroError',
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',
}; };
export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) { export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
@ -21,6 +22,8 @@ export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
return t('editGasMaxPriorityFeeHigh'); return t('editGasMaxPriorityFeeHigh');
case GAS_FORM_ERRORS.MAX_FEE_HIGH_WARNING: case GAS_FORM_ERRORS.MAX_FEE_HIGH_WARNING:
return t('editGasMaxFeeHigh'); return t('editGasMaxFeeHigh');
case GAS_FORM_ERRORS.MAX_FEE_IMBALANCE:
return t('editGasMaxFeePriorityImbalance');
default: default:
return ''; return '';
} }

View File

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