2021-11-23 19:18:44 +01:00
|
|
|
import React from 'react';
|
2021-11-24 18:02:53 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2021-11-23 19:18:44 +01:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
2021-11-24 18:02:53 +01:00
|
|
|
import { PRIORITY_LEVELS } from '../../../../shared/constants/gas';
|
2021-11-23 19:18:44 +01:00
|
|
|
import { submittedPendingTransactionsSelector } from '../../../selectors/transactions';
|
|
|
|
import { useGasFeeContext } from '../../../contexts/gasFee';
|
2021-11-24 18:02:53 +01:00
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2021-11-23 19:18:44 +01:00
|
|
|
import ActionableMessage from '../../../components/ui/actionable-message/actionable-message';
|
2021-11-24 18:02:53 +01:00
|
|
|
import Typography from '../../../components/ui/typography';
|
2021-12-03 16:59:48 +01:00
|
|
|
import { TYPOGRAPHY } from '../../../helpers/constants/design-system';
|
2022-08-23 16:19:31 +02:00
|
|
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
2021-11-23 19:18:44 +01:00
|
|
|
|
2021-11-24 18:02:53 +01:00
|
|
|
const TransactionAlerts = ({
|
|
|
|
userAcknowledgedGasMissing,
|
|
|
|
setUserAcknowledgedGasMissing,
|
|
|
|
}) => {
|
2022-11-09 16:36:21 +01:00
|
|
|
const { estimateUsed, hasSimulationError, supportsEIP1559V2, isNetworkBusy } =
|
|
|
|
useGasFeeContext();
|
2021-11-23 19:18:44 +01:00
|
|
|
const pendingTransactions = useSelector(submittedPendingTransactionsSelector);
|
2021-11-24 18:02:53 +01:00
|
|
|
const t = useI18nContext();
|
2021-11-23 19:18:44 +01:00
|
|
|
|
2022-01-06 23:56:51 +01:00
|
|
|
if (!supportsEIP1559V2) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-11-29 17:08:24 +01:00
|
|
|
|
2021-11-23 19:18:44 +01:00
|
|
|
return (
|
|
|
|
<div className="transaction-alerts">
|
2021-11-24 18:02:53 +01:00
|
|
|
{hasSimulationError && (
|
|
|
|
<ActionableMessage
|
2022-07-12 15:59:38 +02:00
|
|
|
message={t('simulationErrorMessageV2')}
|
2021-11-24 18:02:53 +01:00
|
|
|
useIcon
|
2022-03-25 23:15:31 +01:00
|
|
|
iconFillColor="var(--color-error-default)"
|
2021-11-24 18:02:53 +01:00
|
|
|
type="danger"
|
|
|
|
primaryActionV2={
|
|
|
|
userAcknowledgedGasMissing === true
|
|
|
|
? undefined
|
|
|
|
: {
|
|
|
|
label: t('proceedWithTransaction'),
|
|
|
|
onClick: setUserAcknowledgedGasMissing,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2021-11-23 19:18:44 +01:00
|
|
|
{pendingTransactions?.length > 0 && (
|
|
|
|
<ActionableMessage
|
|
|
|
message={
|
2021-11-24 18:02:53 +01:00
|
|
|
<Typography
|
|
|
|
align="left"
|
2021-12-03 16:59:48 +01:00
|
|
|
className="transaction-alerts__pending-transactions"
|
2022-07-20 22:47:51 +02:00
|
|
|
margin={0}
|
2021-12-03 16:59:48 +01:00
|
|
|
tag={TYPOGRAPHY.Paragraph}
|
|
|
|
variant={TYPOGRAPHY.H7}
|
2021-11-24 18:02:53 +01:00
|
|
|
>
|
2021-11-23 19:18:44 +01:00
|
|
|
<strong>
|
2022-07-12 15:59:38 +02:00
|
|
|
{pendingTransactions?.length === 1
|
|
|
|
? t('pendingTransactionSingle', [pendingTransactions?.length])
|
|
|
|
: t('pendingTransactionMultiple', [
|
|
|
|
pendingTransactions?.length,
|
|
|
|
])}
|
2021-11-23 19:18:44 +01:00
|
|
|
</strong>{' '}
|
2022-07-12 15:59:38 +02:00
|
|
|
{t('pendingTransactionInfo')}
|
|
|
|
{t('learnCancelSpeeedup', [
|
|
|
|
<a
|
|
|
|
key="cancelSpeedUpInfo"
|
2022-08-23 16:19:31 +02:00
|
|
|
href={ZENDESK_URLS.SPEEDUP_CANCEL}
|
2022-07-12 15:59:38 +02:00
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
{t('cancelSpeedUp')}
|
|
|
|
</a>,
|
|
|
|
])}
|
2021-11-24 18:02:53 +01:00
|
|
|
</Typography>
|
2021-11-23 19:18:44 +01:00
|
|
|
}
|
|
|
|
useIcon
|
2022-03-25 23:15:31 +01:00
|
|
|
iconFillColor="var(--color-warning-default)"
|
2021-11-23 19:18:44 +01:00
|
|
|
type="warning"
|
|
|
|
/>
|
|
|
|
)}
|
2021-11-24 18:02:53 +01:00
|
|
|
{estimateUsed === PRIORITY_LEVELS.LOW && (
|
|
|
|
<ActionableMessage
|
2022-01-19 19:34:43 +01:00
|
|
|
dataTestId="low-gas-fee-alert"
|
2021-11-24 18:02:53 +01:00
|
|
|
message={
|
2021-12-03 16:59:48 +01:00
|
|
|
<Typography
|
|
|
|
align="left"
|
2022-07-20 22:47:51 +02:00
|
|
|
margin={0}
|
2021-12-03 16:59:48 +01:00
|
|
|
tag={TYPOGRAPHY.Paragraph}
|
|
|
|
variant={TYPOGRAPHY.H7}
|
|
|
|
>
|
2022-07-12 15:59:38 +02:00
|
|
|
{t('lowPriorityMessage')}
|
2021-11-24 18:02:53 +01:00
|
|
|
</Typography>
|
|
|
|
}
|
|
|
|
useIcon
|
2022-03-25 23:15:31 +01:00
|
|
|
iconFillColor="var(--color-warning-default)"
|
2021-11-24 18:02:53 +01:00
|
|
|
type="warning"
|
|
|
|
/>
|
2021-11-23 19:18:44 +01:00
|
|
|
)}
|
2022-01-07 20:18:02 +01:00
|
|
|
{isNetworkBusy ? (
|
|
|
|
<ActionableMessage
|
2022-01-22 01:23:02 +01:00
|
|
|
message={
|
|
|
|
<Typography
|
|
|
|
align="left"
|
2022-07-20 22:47:51 +02:00
|
|
|
margin={0}
|
2022-01-22 01:23:02 +01:00
|
|
|
tag={TYPOGRAPHY.Paragraph}
|
|
|
|
variant={TYPOGRAPHY.H7}
|
|
|
|
>
|
2022-07-12 15:59:38 +02:00
|
|
|
{t('networkIsBusy')}
|
2022-01-22 01:23:02 +01:00
|
|
|
</Typography>
|
|
|
|
}
|
2022-03-25 23:15:31 +01:00
|
|
|
iconFillColor="var(--color-warning-default)"
|
2022-01-07 20:18:02 +01:00
|
|
|
type="warning"
|
2022-01-22 01:23:02 +01:00
|
|
|
useIcon
|
2022-01-07 20:18:02 +01:00
|
|
|
/>
|
|
|
|
) : null}
|
2021-11-23 19:18:44 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-11-24 18:02:53 +01:00
|
|
|
TransactionAlerts.propTypes = {
|
|
|
|
userAcknowledgedGasMissing: PropTypes.bool,
|
|
|
|
setUserAcknowledgedGasMissing: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
2021-11-23 19:18:44 +01:00
|
|
|
export default TransactionAlerts;
|