diff --git a/shared/constants/gas.js b/shared/constants/gas.js
index 161751b60..004e0919b 100644
--- a/shared/constants/gas.js
+++ b/shared/constants/gas.js
@@ -29,3 +29,12 @@ export const GAS_RECOMMENDATIONS = {
MEDIUM: 'medium',
HIGH: 'high',
};
+
+/**
+ * These represent the different edit modes presented in the UI
+ */
+export const EDIT_GAS_MODES = {
+ SPEED_UP: 'speed-up',
+ CANCEL: 'cancel',
+ MODIFY_IN_PLACE: 'modify-in-place',
+};
diff --git a/ui/components/app/edit-gas-display/edit-gas-display.component.js b/ui/components/app/edit-gas-display/edit-gas-display.component.js
index cf3bb72e6..a51cd8a0d 100644
--- a/ui/components/app/edit-gas-display/edit-gas-display.component.js
+++ b/ui/components/app/edit-gas-display/edit-gas-display.component.js
@@ -1,7 +1,10 @@
-import React, { useState, useContext } from 'react';
+import React, { useContext } from 'react';
import PropTypes from 'prop-types';
-import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas';
+import {
+ GAS_RECOMMENDATIONS,
+ EDIT_GAS_MODES,
+} from '../../../../shared/constants/gas';
import Button from '../../ui/button';
import Typography from '../../ui/typography/typography';
@@ -19,55 +22,48 @@ import AdvancedGasControls from '../advanced-gas-controls/advanced-gas-controls.
import ActionableMessage from '../../ui/actionable-message/actionable-message';
import { I18nContext } from '../../../contexts/i18n';
-import { useGasFeeInputs } from '../../../hooks/useGasFeeInputs';
export default function EditGasDisplay({
- alwaysShowForm,
- type,
- showEducationButton,
+ mode = EDIT_GAS_MODES.MODIFY_IN_PLACE,
+ alwaysShowForm = false,
+ showEducationButton = false,
onEducationClick,
- dappSuggestedGasFee,
- dappOrigin,
- defaultEstimateToUse = 'medium',
+ dappSuggestedGasFee = 0,
+ dappOrigin = '',
+ defaultEstimateToUse,
+ maxPriorityFeePerGas,
+ setMaxPriorityFeePerGas,
+ maxPriorityFeePerGasFiat,
+ maxFeePerGas,
+ setMaxFeePerGas,
+ maxFeePerGasFiat,
+ estimatedMaximumNative,
+ isGasEstimatesLoading,
+ gasFeeEstimates,
+ gasEstimateType,
+ gasPrice,
+ setGasPrice,
+ gasLimit,
+ setGasLimit,
+ estimateToUse,
+ setEstimateToUse,
+ estimatedMinimumFiat,
+ estimatedMaximumFiat,
+ isMaxFeeError,
+ isMaxPriorityFeeError,
+ isGasTooLow,
+ dappSuggestedGasFeeAcknowledged,
+ setDappSuggestedGasFeeAcknowledged,
+ showAdvancedForm,
+ setShowAdvancedForm,
+ warning,
}) {
const t = useContext(I18nContext);
- const [warning] = useState(null);
-
- const [showAdvancedForm, setShowAdvancedForm] = useState(false);
- const [
- dappSuggestedGasFeeAcknowledged,
- setDappSuggestedGasFeeAcknowledged,
- ] = useState(false);
-
const requireDappAcknowledgement = Boolean(
dappSuggestedGasFee && !dappSuggestedGasFeeAcknowledged,
);
- const {
- maxPriorityFeePerGas,
- setMaxPriorityFeePerGas,
- maxPriorityFeePerGasFiat,
- maxFeePerGas,
- setMaxFeePerGas,
- maxFeePerGasFiat,
- estimatedMaximumNative,
- isGasEstimatesLoading,
- gasFeeEstimates,
- gasEstimateType,
- gasPrice,
- setGasPrice,
- gasLimit,
- setGasLimit,
- estimateToUse,
- setEstimateToUse,
- estimatedMinimumFiat,
- estimatedMaximumFiat,
- isMaxFeeError,
- isMaxPriorityFeeError,
- isGasTooLow,
- } = useGasFeeInputs(defaultEstimateToUse);
-
return (
@@ -88,7 +84,7 @@ export default function EditGasDisplay({
/>
)}
- {type === 'speed-up' && (
+ {mode === EDIT_GAS_MODES.SPEED_UP && (
)}
- {!requireDappAcknowledgement && (
-
- )}
+ {!requireDappAcknowledgement &&
+ ![EDIT_GAS_MODES.SPEED_UP, EDIT_GAS_MODES.CANCEL].includes(mode) && (
+
+ )}
{!alwaysShowForm && (
@@ -123,15 +226,8 @@ EditGasPopover.propTypes = {
popoverTitle: PropTypes.string,
editGasDisplayProps: PropTypes.object,
confirmButtonText: PropTypes.string,
- showEducationButton: PropTypes.bool,
onClose: PropTypes.func,
transaction: PropTypes.object,
- mode: PropTypes.oneOf(Object.values(EDIT_GAS_MODE)),
-};
-
-EditGasPopover.defaultProps = {
- popoverTitle: '',
- editGasDisplayProps: {},
- confirmButtonText: '',
- showEducationButton: false,
+ mode: PropTypes.oneOf(Object.values(EDIT_GAS_MODES)),
+ defaultEstimateToUse: PropTypes.string,
};
diff --git a/ui/components/app/transaction-list-item/transaction-list-item.component.js b/ui/components/app/transaction-list-item/transaction-list-item.component.js
index 01cd5cbb7..5065ae957 100644
--- a/ui/components/app/transaction-list-item/transaction-list-item.component.js
+++ b/ui/components/app/transaction-list-item/transaction-list-item.component.js
@@ -18,8 +18,8 @@ import {
TRANSACTION_GROUP_CATEGORIES,
TRANSACTION_STATUSES,
} from '../../../../shared/constants/transaction';
+import { EDIT_GAS_MODES } from '../../../../shared/constants/gas';
import EditGasPopover from '../edit-gas-popover';
-import { EDIT_GAS_MODE } from '../edit-gas-popover/edit-gas-popover.component';
export default function TransactionListItem({
transactionGroup,
@@ -212,17 +212,15 @@ export default function TransactionListItem({
)}
{process.env.SHOW_EIP_1559_UI && showRetryEditGasPopover && (
)}
{process.env.SHOW_EIP_1559_UI && showCancelEditGasPopover && (
)}