import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import { useGasFeeContext } from '../../../contexts/gasFee'; import InfoTooltip from '../../ui/info-tooltip/info-tooltip'; import Typography from '../../ui/typography/typography'; import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component'; import { COLORS } from '../../../helpers/constants/design-system'; const GasLevelIconMap = { low: '🐢', medium: '🦊', high: '🦍', dappSuggested: '🌐', custom: '⚙', }; export default function TransactionDetail({ rows = [], onEdit }) { // eslint-disable-next-line prefer-destructuring const EIP_1559_V2 = process.env.EIP_1559_V2; const t = useContext(I18nContext); const { estimateToUse, gasLimit, gasPrice, isUsingDappSuggestedGasFees, maxFeePerGas, maxPriorityFeePerGas, transaction, supportsEIP1559, } = useGasFeeContext(); const estimateUsed = isUsingDappSuggestedGasFees ? 'dappSuggested' : estimateToUse; if (EIP_1559_V2 && estimateUsed) { return (
{estimateUsed === 'custom' && onEdit && ( )} {estimateUsed === 'dappSuggested' && ( {t('dappSuggestedTooltip', [transaction.origin])} {supportsEIP1559 ? ( <> {t('maxBaseFee')} {maxFeePerGas} {t('maxPriorityFee')} {maxPriorityFeePerGas} ) : ( {t('gasPriceLabel')} {gasPrice} )} {t('gasLimit')} {gasLimit}
} position="top" /> )}
{rows}
); } return (
{onEdit && (
)}
{rows}
); } TransactionDetail.propTypes = { rows: PropTypes.arrayOf(TransactionDetailItem).isRequired, onEdit: PropTypes.func, };