From 9fcd93191b36b08a4e9f79fcd8478d7b8f6cbee3 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 4 Aug 2021 20:14:20 -0230 Subject: [PATCH] Ensure that gas fee minimum errors show when api is down (#11767) * Fix legacy unapproved tx handling * clean up --- ui/hooks/useGasFeeInputs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/hooks/useGasFeeInputs.js b/ui/hooks/useGasFeeInputs.js index 0f2655b4a..7c3195fcd 100644 --- a/ui/hooks/useGasFeeInputs.js +++ b/ui/hooks/useGasFeeInputs.js @@ -414,6 +414,17 @@ export function useGasFeeInputs( gasErrors.gasLimit = GAS_FORM_ERRORS.GAS_LIMIT_OUT_OF_BOUNDS; } + // This ensures these are applied when the api fails to return a fee market type + // It is okay if these errors get overwritten below, as those overwrites can only + // happen when the estimate api is live. + if (networkAndAccountSupports1559) { + if (maxPriorityFeePerGasToUse <= 0) { + gasErrors.maxPriorityFee = GAS_FORM_ERRORS.MAX_PRIORITY_FEE_BELOW_MINIMUM; + } else if (maxPriorityFeePerGasToUse >= maxFeePerGasToUse) { + gasErrors.maxFee = GAS_FORM_ERRORS.MAX_FEE_IMBALANCE; + } + } + switch (gasEstimateType) { case GAS_ESTIMATE_TYPES.FEE_MARKET: if (maxPriorityFeePerGasToUse <= 0) {