diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4c7776fa3..1c21f2a93 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -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." }, diff --git a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js index 4e00ebe0c..5cc473f1b 100644 --- a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js +++ b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js @@ -156,6 +156,11 @@ export default function AdvancedGasControls({ ) } + error={ + gasErrors?.gasPrice + ? getGasFormErrorText(gasErrors.gasPrice, t) + : null + } /> )} diff --git a/ui/components/ui/numeric-input/numeric-input.component.js b/ui/components/ui/numeric-input/numeric-input.component.js index cc8e024bf..9aa633692 100644 --- a/ui/components/ui/numeric-input/numeric-input.component.js +++ b/ui/components/ui/numeric-input/numeric-input.component.js @@ -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} diff --git a/ui/helpers/constants/gas.js b/ui/helpers/constants/gas.js index f8552fd65..53ffcf681 100644 --- a/ui/helpers/constants/gas.js +++ b/ui/helpers/constants/gas.js @@ -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 ''; } diff --git a/ui/hooks/useGasFeeInputs.js b/ui/hooks/useGasFeeInputs.js index 4d4f583fc..96e49031a 100644 --- a/ui/hooks/useGasFeeInputs.js +++ b/ui/hooks/useGasFeeInputs.js @@ -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;