import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import InfoTooltip from '../../../components/ui/info-tooltip'; import { useNewMetricEvent } from '../../../hooks/useMetricEvent'; import { MAINNET_CHAIN_ID, BSC_CHAIN_ID, LOCALHOST_CHAIN_ID, POLYGON_CHAIN_ID, RINKEBY_CHAIN_ID, AVALANCHE_CHAIN_ID, } 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 Typography from '../../../components/ui/typography'; import { COLORS, TYPOGRAPHY, FONT_WEIGHT, } from '../../../helpers/constants/design-system'; import GasDetailsItemTitle from '../../../components/app/gas-details-item/gas-details-item-title'; 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, onFeeCardMaxRowClick, tokenApprovalSourceTokenSymbol, onTokenApprovalClick, metaMaskFee, numberOfQuotes, onQuotesClick, chainId, smartTransactionsOptInStatus, smartTransactionsEnabled, isBestQuote, supportsEIP1559V2 = false, }) { const t = useContext(I18nContext); const getTranslatedNetworkName = () => { switch (chainId) { case MAINNET_CHAIN_ID: return t('networkNameEthereum'); case BSC_CHAIN_ID: return t('networkNameBSC'); case POLYGON_CHAIN_ID: return t('networkNamePolygon'); case LOCALHOST_CHAIN_ID: return t('networkNameTestnet'); case RINKEBY_CHAIN_ID: return t('networkNameRinkeby'); case AVALANCHE_CHAIN_ID: return t('networkNameAvalanche'); default: throw new Error('This network is not supported for token swaps'); } }; const gasFeesLearnMoreLinkClickedEvent = useNewMetricEvent({ category: 'Swaps', event: 'Clicked "Gas Fees: Learn More" Link', }); 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" wide /> > ) } detailText={primaryFee.fee} detailTotal={secondaryFee.fee} subText={ secondaryFee?.maxFee !== undefined && ( <>