import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { PRIORITY_LEVELS } from '../../../../shared/constants/gas'; import { submittedPendingTransactionsSelector } from '../../../selectors/transactions'; import { useGasFeeContext } from '../../../contexts/gasFee'; import { useI18nContext } from '../../../hooks/useI18nContext'; import ActionableMessage from '../../../components/ui/actionable-message/actionable-message'; import I18nValue from '../../../components/ui/i18n-value'; import Button from '../../../components/ui/button'; import Typography from '../../../components/ui/typography'; import { TYPOGRAPHY } from '../../../helpers/constants/design-system'; import { TRANSACTION_TYPES } from '../../../../shared/constants/transaction'; import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network'; const TransactionAlerts = ({ userAcknowledgedGasMissing, setUserAcknowledgedGasMissing, chainId, nativeCurrency, networkName, showBuyModal, type, }) => { const { balanceError, estimateUsed, hasSimulationError, supportsEIP1559V2, isNetworkBusy, } = useGasFeeContext(); const pendingTransactions = useSelector(submittedPendingTransactionsSelector); const t = useI18nContext(); if (!supportsEIP1559V2) { return null; } return (
{hasSimulationError && ( } useIcon iconFillColor="#d73a49" type="danger" primaryActionV2={ userAcknowledgedGasMissing === true ? undefined : { label: t('proceedWithTransaction'), onClick: setUserAcknowledgedGasMissing, } } /> )} {pendingTransactions?.length > 0 && ( {' '} {' '} , ]} /> } useIcon iconFillColor="#f8c000" type="warning" /> )} {balanceError && chainId === MAINNET_CHAIN_ID && type === TRANSACTION_TYPES.DEPLOY_CONTRACT ? ( {t('insufficientCurrency', [nativeCurrency, networkName])}{' '} {' '} {t('orDeposit')} } useIcon iconFillColor="#d73a49" type="danger" /> ) : null} {balanceError && chainId !== MAINNET_CHAIN_ID && type === TRANSACTION_TYPES.DEPLOY_CONTRACT ? ( {t('insufficientCurrency', [nativeCurrency, networkName])} {t('buyOther', [nativeCurrency])} } useIcon iconFillColor="#d73a49" type="danger" /> ) : null} {estimateUsed === PRIORITY_LEVELS.LOW && ( } useIcon iconFillColor="#f8c000" type="warning" /> )} {isNetworkBusy ? ( } iconFillColor="#f8c000" type="warning" useIcon /> ) : null}
); }; TransactionAlerts.propTypes = { userAcknowledgedGasMissing: PropTypes.bool, setUserAcknowledgedGasMissing: PropTypes.func, chainId: PropTypes.string, nativeCurrency: PropTypes.string, networkName: PropTypes.string, showBuyModal: PropTypes.func, type: PropTypes.string, }; export default TransactionAlerts;