import React from 'react'; import PropTypes from 'prop-types'; import { PRIORITY_LEVELS } from '../../../../../shared/constants/gas'; import { COLORS, FONT_WEIGHT, TYPOGRAPHY, } from '../../../../helpers/constants/design-system'; import Typography from '../../../ui/typography'; import { useGasFeeContext } from '../../../../contexts/gasFee'; const EditGasToolTip = ({ priorityLevel, // maxFeePerGas & maxPriorityFeePerGas are derived from conditional logic // related to the source of the estimates. We pass these values from the // the parent component (edit-gas-item) rather than recalculate them maxFeePerGas, maxPriorityFeePerGas, t, }) => { const { gasLimit, maxFeePerGas: maxFeePerGasValue, maxPriorityFeePerGas: maxPriorityFeePerGasValue, transaction, } = useGasFeeContext(); const toolTipMessage = () => { switch (priorityLevel) { case PRIORITY_LEVELS.LOW: return t('lowGasSettingToolTipMessage', [ {t('low')} , ]); case PRIORITY_LEVELS.MEDIUM: return t('mediumGasSettingToolTipMessage', [ {t('medium')} , ]); case PRIORITY_LEVELS.HIGH: return t('highGasSettingToolTipMessage', [ {t('high')} , ]); case PRIORITY_LEVELS.CUSTOM: return t('customGasSettingToolTipMessage', [ {t('custom')} , ]); case PRIORITY_LEVELS.DAPP_SUGGESTED: return transaction?.origin ? t('dappSuggestedGasSettingToolTipMessage', [ {transaction?.origin}, ]) : null; default: return ''; } }; return (
{priorityLevel !== PRIORITY_LEVELS.CUSTOM && priorityLevel !== PRIORITY_LEVELS.DAPP_SUGGESTED ? ( ) : null} {priorityLevel === PRIORITY_LEVELS.HIGH ? (
{t('highGasSettingToolTipDialog')}
) : null}
{toolTipMessage()}
{priorityLevel === PRIORITY_LEVELS.CUSTOM ? null : (
{t('maxBaseFee')} {maxFeePerGas ?? maxFeePerGasValue}
{t('priorityFeeProperCase')} {maxPriorityFeePerGas ?? maxPriorityFeePerGasValue}
{t('gasLimit')} {gasLimit}
)}
); }; EditGasToolTip.propTypes = { priorityLevel: PropTypes.string, maxFeePerGas: PropTypes.string, maxPriorityFeePerGas: PropTypes.string, t: PropTypes.func, }; export default EditGasToolTip;