import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { I18nContext } from '../../../contexts/i18n'; import Typography from '../../ui/typography/typography'; import { FONT_WEIGHT, TYPOGRAPHY, COLORS, } from '../../../helpers/constants/design-system'; import FormField from '../../ui/form-field'; import { GAS_ESTIMATE_TYPES, GAS_RECOMMENDATIONS, } from '../../../../shared/constants/gas'; import { getGasFormErrorText } from '../../../helpers/constants/gas'; import { checkNetworkAndAccountSupports1559 } from '../../../selectors'; export default function AdvancedGasControls({ estimateToUse, gasFeeEstimates, gasEstimateType, maxPriorityFee, maxFee, setMaxPriorityFee, setMaxFee, onManualChange, gasLimit, setGasLimit, gasPrice, setGasPrice, maxPriorityFeeFiat, maxFeeFiat, gasErrors, minimumGasLimit, }) { const t = useContext(I18nContext); const networkAndAccountSupport1559 = useSelector( checkNetworkAndAccountSupports1559, ); const suggestedValues = {}; if (networkAndAccountSupport1559) { suggestedValues.maxFeePerGas = gasFeeEstimates?.[estimateToUse]?.suggestedMaxFeePerGas || gasFeeEstimates?.gasPrice; suggestedValues.maxPriorityFeePerGas = gasFeeEstimates?.[estimateToUse]?.suggestedMaxPriorityFeePerGas || suggestedValues.maxFeePerGas; } else { switch (gasEstimateType) { case GAS_ESTIMATE_TYPES.LEGACY: suggestedValues.gasPrice = gasFeeEstimates?.[estimateToUse]; break; case GAS_ESTIMATE_TYPES.ETH_GASPRICE: suggestedValues.gasPrice = gasFeeEstimates?.gasPrice; break; default: break; } } const showFeeMarketFields = networkAndAccountSupport1559 && (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET || gasEstimateType === GAS_ESTIMATE_TYPES.ETH_GASPRICE); return (