import React, { useContext } from 'react'; import { useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import InfoTooltip from '../../../components/ui/info-tooltip'; import { CHAIN_IDS } from '../../../../shared/constants/network'; import TransactionDetail from '../../../components/app/transaction-detail/transaction-detail.component'; import TransactionDetailItem from '../../../components/app/transaction-detail-item/transaction-detail-item.component'; import { TextColor, TextVariant, FontWeight, } from '../../../helpers/constants/design-system'; import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics'; import { getUseCurrencyRateCheck } from '../../../selectors'; import { Text } from '../../../components/component-library'; const GAS_FEES_LEARN_MORE_URL = 'https://community.metamask.io/t/what-is-gas-why-do-transactions-take-so-long/3172'; export default function FeeCard({ primaryFee, secondaryFee, hideTokenApprovalRow, tokenApprovalSourceTokenSymbol, onTokenApprovalClick, metaMaskFee, numberOfQuotes, onQuotesClick, chainId, isBestQuote, }) { const t = useContext(I18nContext); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); /* istanbul ignore next */ const getTranslatedNetworkName = () => { switch (chainId) { case CHAIN_IDS.MAINNET: return t('networkNameEthereum'); case CHAIN_IDS.BSC: return t('networkNameBSC'); case CHAIN_IDS.POLYGON: return t('networkNamePolygon'); case CHAIN_IDS.LOCALHOST: return t('networkNameTestnet'); case CHAIN_IDS.GOERLI: return t('networkNameGoerli'); case CHAIN_IDS.AVALANCHE: return t('networkNameAvalanche'); case CHAIN_IDS.OPTIMISM: return t('networkNameOptimism'); case CHAIN_IDS.ARBITRUM: return t('networkNameArbitrum'); default: throw new Error('This network is not supported for token swaps'); } }; const trackEvent = useContext(MetaMetricsContext); const tokenApprovalTextComponent = ( {t('enableToken', [tokenApprovalSourceTokenSymbol])} ); return (
{t('swapGasFeesSummary', [ getTranslatedNetworkName(), ])}
{t('swapGasFeesDetails')}
> } containerClassName="fee-card__info-tooltip-content-container" wrapperClassName="fee-card__row-label fee-card__info-tooltip-container" /> > } detailText={primaryFee.fee} detailTotal={useCurrencyRateCheck && secondaryFee.fee} subText={ (secondaryFee?.maxFee !== undefined || primaryFee?.maxFee !== undefined) && ( <>