mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
99 lines
3.4 KiB
JavaScript
99 lines
3.4 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { PriorityLevels } from '../../../../shared/constants/gas';
|
|
import { submittedPendingTransactionsSelector } from '../../../selectors';
|
|
import { useGasFeeContext } from '../../../contexts/gasFee';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import { BannerAlert, ButtonLink, Text } from '../../component-library';
|
|
import SimulationErrorMessage from '../../ui/simulation-error-message';
|
|
import { SEVERITIES } from '../../../helpers/constants/design-system';
|
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
|
|
|
import { isSuspiciousResponse } from '../../../../shared/modules/security-provider.utils';
|
|
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
|
|
import BlockaidBannerAlert from '../security-provider-banner-alert/blockaid-banner-alert/blockaid-banner-alert';
|
|
///: END:ONLY_INCLUDE_IN
|
|
import SecurityProviderBannerMessage from '../security-provider-banner-message/security-provider-banner-message';
|
|
|
|
const TransactionAlerts = ({
|
|
userAcknowledgedGasMissing,
|
|
setUserAcknowledgedGasMissing,
|
|
txData,
|
|
}) => {
|
|
const { estimateUsed, hasSimulationError, supportsEIP1559 } =
|
|
useGasFeeContext();
|
|
const pendingTransactions = useSelector(submittedPendingTransactionsSelector);
|
|
const t = useI18nContext();
|
|
|
|
return (
|
|
<div className="transaction-alerts">
|
|
{
|
|
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
|
|
<BlockaidBannerAlert
|
|
securityAlertResponse={txData?.securityAlertResponse}
|
|
/>
|
|
///: END:ONLY_INCLUDE_IN
|
|
}
|
|
{isSuspiciousResponse(txData?.securityProviderResponse) && (
|
|
<SecurityProviderBannerMessage
|
|
securityProviderResponse={txData.securityProviderResponse}
|
|
/>
|
|
)}
|
|
|
|
{supportsEIP1559 && hasSimulationError && (
|
|
<SimulationErrorMessage
|
|
userAcknowledgedGasMissing={userAcknowledgedGasMissing}
|
|
setUserAcknowledgedGasMissing={setUserAcknowledgedGasMissing}
|
|
/>
|
|
)}
|
|
{supportsEIP1559 && pendingTransactions?.length > 0 && (
|
|
<BannerAlert severity={SEVERITIES.WARNING}>
|
|
<Text as="p">
|
|
<strong>
|
|
{pendingTransactions?.length === 1
|
|
? t('pendingTransactionSingle', [pendingTransactions?.length])
|
|
: t('pendingTransactionMultiple', [
|
|
pendingTransactions?.length,
|
|
])}
|
|
</strong>{' '}
|
|
{t('pendingTransactionInfo')}
|
|
{t('learnCancelSpeeedup', [
|
|
<ButtonLink
|
|
key="cancelSpeedUpInfo"
|
|
href={ZENDESK_URLS.SPEEDUP_CANCEL}
|
|
rel="noopener noreferrer"
|
|
target="_blank"
|
|
>
|
|
{t('cancelSpeedUp')}
|
|
</ButtonLink>,
|
|
])}
|
|
</Text>
|
|
</BannerAlert>
|
|
)}
|
|
{estimateUsed === PriorityLevels.low && (
|
|
<BannerAlert
|
|
data-testid="low-gas-fee-alert"
|
|
severity={SEVERITIES.WARNING}
|
|
>
|
|
{t('lowPriorityMessage')}
|
|
</BannerAlert>
|
|
)}
|
|
{/* {supportsEIP1559 && isNetworkBusy ? (
|
|
<BannerAlert severity={SEVERITIES.WARNING}>
|
|
{t('networkIsBusy')}
|
|
</BannerAlert>
|
|
) : null} */}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
TransactionAlerts.propTypes = {
|
|
userAcknowledgedGasMissing: PropTypes.bool,
|
|
setUserAcknowledgedGasMissing: PropTypes.func,
|
|
txData: PropTypes.object,
|
|
};
|
|
|
|
export default TransactionAlerts;
|