import React, { useState, useContext } from 'react'; import PropTypes from 'prop-types'; import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas'; import Button from '../../ui/button'; import Typography from '../../ui/typography/typography'; import { COLORS, TYPOGRAPHY, FONT_WEIGHT, TEXT_ALIGN, } from '../../../helpers/constants/design-system'; import InfoTooltip from '../../ui/info-tooltip'; import TransactionTotalBanner from '../transaction-total-banner/transaction-total-banner.component'; import RadioGroup from '../../ui/radio-group/radio-group.component'; import AdvancedGasControls from '../advanced-gas-controls/advanced-gas-controls.component'; 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, onEducationClick, dappSuggestedGasFee, dappOrigin, defaultEstimateToUse = 'medium', }) { 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 (