import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { getMaximumGasTotalInHexWei } from '../../../../../shared/modules/gas.utils'; import { PRIORITY_LEVEL_ICON_MAP } from '../../../../helpers/constants/gas'; import { PRIMARY } from '../../../../helpers/constants/common'; import { decGWEIToHexWEI, decimalToHex, } from '../../../../helpers/utils/conversions.util'; import { toHumanReadableTime } from '../../../../helpers/utils/util'; import { useGasFeeContext } from '../../../../contexts/gasFee'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import I18nValue from '../../../ui/i18n-value'; import InfoTooltip from '../../../ui/info-tooltip'; import UserPreferencedCurrencyDisplay from '../../user-preferenced-currency-display'; const EditGasItem = ({ estimateType, onClose }) => { const { estimateUsed, gasFeeEstimates, gasLimit, setEstimateToUse, updateTransaction, } = useGasFeeContext(); const t = useI18nContext(); const { minWaitTimeEstimate, suggestedMaxFeePerGas } = gasFeeEstimates[estimateType] || {}; const hexMaximumTransactionFee = suggestedMaxFeePerGas ? getMaximumGasTotalInHexWei({ gasLimit: decimalToHex(gasLimit), maxFeePerGas: decGWEIToHexWEI(suggestedMaxFeePerGas), }) : null; const onOptionSelect = () => { setEstimateToUse(estimateType); updateTransaction(estimateType); onClose(); }; return (
{PRIORITY_LEVEL_ICON_MAP[estimateType]} {minWaitTimeEstimate && toHumanReadableTime(t, minWaitTimeEstimate)}
); }; EditGasItem.propTypes = { estimateType: PropTypes.string, onClose: PropTypes.func, }; export default EditGasItem;