import React from 'react'; 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 { Text } from '../../../component-library/text'; import { FONT_STYLE, TextVariant, TextColor, } from '../../../../helpers/constants/design-system'; import { useDraftTransactionGasValues } from '../../../../hooks/useDraftTransactionGasValues'; import { getNativeCurrency } from '../../../../ducks/metamask/metamask'; import MultilayerFeeMessage from '../../multilayer-fee-message/multi-layer-fee-message'; const renderHeartBeatIfNotInTest = () => process.env.IN_TEST ? null : ; const ConfirmLegacyGasDisplay = () => { 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 } = useDraftTransactionGasValues(); 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')} )} } /> ); }; export default ConfirmLegacyGasDisplay;