import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import { getIsMainnet, getIsMultiLayerFeeNetwork, getPreferences, getUnapprovedTransactions, getUseCurrencyRateCheck, transactionFeeSelector, txDataSelector, } from '../../../../selectors'; import { PRIMARY, SECONDARY } from '../../../../helpers/constants/common'; import TransactionDetailItem from '../../transaction-detail-item'; import UserPreferencedCurrencyDisplay from '../../user-preferenced-currency-display'; import InfoTooltip from '../../../ui/info-tooltip'; import LoadingHeartBeat from '../../../ui/loading-heartbeat'; import { FONT_STYLE, TextVariant, TextColor, } from '../../../../helpers/constants/design-system'; import { useDraftTransactionWithTxParams } from '../../../../hooks/useDraftTransactionWithTxParams'; import { getNativeCurrency } from '../../../../ducks/metamask/metamask'; import MultilayerFeeMessage from '../../multilayer-fee-message/multi-layer-fee-message'; import { Icon, IconName, Text } from '../../../component-library'; const renderHeartBeatIfNotInTest = () => process.env.IN_TEST ? null : ; const ConfirmLegacyGasDisplay = ({ 'data-testid': dataTestId } = {}) => { const t = useI18nContext(); // state selectors const isMainnet = useSelector(getIsMainnet); const isMultiLayerFeeNetwork = useSelector(getIsMultiLayerFeeNetwork); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); const nativeCurrency = useSelector(getNativeCurrency); const unapprovedTxs = useSelector(getUnapprovedTransactions); const transactionData = useDraftTransactionWithTxParams(); const txData = useSelector((state) => txDataSelector(state)); const { id: transactionId, dappSuggestedGasFees } = txData; const transaction = Object.keys(transactionData).length ? transactionData : unapprovedTxs[transactionId] || {}; const { hexMinimumTransactionFee, hexMaximumTransactionFee } = useSelector( (state) => transactionFeeSelector(state, transaction), ); if (isMultiLayerFeeNetwork) { return [ } detailText={ useCurrencyRateCheck && ( ) } noBold flexWidthValues />, , ]; } return ( {t('transactionDetailGasHeading')} > ) : ( <> {t('transactionDetailGasHeading')} {t('transactionDetailGasTooltipIntro', [ isMainnet ? t('networkNameEthereum') : '', ])} {t('transactionDetailGasTooltipExplanation')} {t('transactionDetailGasTooltipConversion')} > } position="top" > > ) } detailText={ useCurrencyRateCheck && ( {renderHeartBeatIfNotInTest()} ) } detailTotal={ {renderHeartBeatIfNotInTest()} } subText={ <> {t('editGasSubTextFeeLabel')} {renderHeartBeatIfNotInTest()} > } subTitle={ <> {dappSuggestedGasFees && ( {t('transactionDetailDappGasMoreInfo')} )} > } /> ); }; ConfirmLegacyGasDisplay.propTypes = { 'data-testid': PropTypes.string, }; export default ConfirmLegacyGasDisplay;
{t('transactionDetailGasTooltipIntro', [ isMainnet ? t('networkNameEthereum') : '', ])}
{t('transactionDetailGasTooltipExplanation')}
{t('transactionDetailGasTooltipConversion')}