2023-07-17 19:48:15 +02:00
|
|
|
/* eslint-disable import/no-duplicates */
|
2022-03-14 19:12:38 +01:00
|
|
|
import React, { useMemo, useState, useCallback, useContext } from 'react';
|
2021-02-04 19:15:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useHistory } from 'react-router-dom';
|
2022-01-06 03:47:26 +01:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
import { useTransactionDisplayData } from '../../../hooks/useTransactionDisplayData';
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2021-09-15 17:59:51 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
import TransactionListItemDetails from '../transaction-list-item-details';
|
|
|
|
import { CONFIRM_TRANSACTION_ROUTE } from '../../../helpers/constants/routes';
|
|
|
|
import { useShouldShowSpeedUp } from '../../../hooks/useShouldShowSpeedUp';
|
2023-01-18 15:47:29 +01:00
|
|
|
import TransactionStatusLabel from '../transaction-status-label/transaction-status-label';
|
2021-02-04 19:15:23 +01:00
|
|
|
import TransactionIcon from '../transaction-icon';
|
2023-07-17 19:48:15 +02:00
|
|
|
import {
|
|
|
|
BackgroundColor,
|
|
|
|
Color,
|
|
|
|
Display,
|
|
|
|
FontWeight,
|
|
|
|
Size,
|
|
|
|
TextAlign,
|
|
|
|
TextVariant,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import {
|
|
|
|
AvatarNetwork,
|
|
|
|
BadgeWrapper,
|
|
|
|
BadgeWrapperAnchorElementShape,
|
|
|
|
Box,
|
|
|
|
Text,
|
|
|
|
} from '../../component-library';
|
|
|
|
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
import { IconColor } from '../../../helpers/constants/design-system';
|
|
|
|
import { Icon, IconName, IconSize } from '../../component-library';
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-04-03 17:31:04 +02:00
|
|
|
import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics';
|
2020-11-03 23:57:51 +01:00
|
|
|
import {
|
2023-01-18 15:47:29 +01:00
|
|
|
TransactionGroupCategory,
|
|
|
|
TransactionStatus,
|
2021-04-28 21:53:59 +02:00
|
|
|
} from '../../../../shared/constants/transaction';
|
2023-01-27 19:28:03 +01:00
|
|
|
import { EditGasModes } from '../../../../shared/constants/gas';
|
2022-01-06 03:47:26 +01:00
|
|
|
import {
|
|
|
|
GasFeeContextProvider,
|
|
|
|
useGasFeeContext,
|
|
|
|
} from '../../../contexts/gasFee';
|
|
|
|
import {
|
|
|
|
TransactionModalContextProvider,
|
|
|
|
useTransactionModalContext,
|
|
|
|
} from '../../../contexts/transaction-modal';
|
2023-07-17 19:48:15 +02:00
|
|
|
import {
|
|
|
|
checkNetworkAndAccountSupports1559,
|
|
|
|
getCurrentNetwork,
|
2023-07-18 15:32:00 +02:00
|
|
|
getTestNetworkBackgroundColor,
|
2023-07-17 19:48:15 +02:00
|
|
|
} from '../../../selectors';
|
2022-01-06 03:47:26 +01:00
|
|
|
import { isLegacyTransaction } from '../../../helpers/utils/transactions.util';
|
2023-07-17 19:48:15 +02:00
|
|
|
import { formatDateWithYearContext } from '../../../helpers/utils/util';
|
2021-09-15 17:59:51 +02:00
|
|
|
import Button from '../../ui/button';
|
2022-01-06 03:47:26 +01:00
|
|
|
import AdvancedGasFeePopover from '../advanced-gas-fee-popover';
|
2021-09-15 17:59:51 +02:00
|
|
|
import CancelButton from '../cancel-button';
|
2022-01-06 03:47:26 +01:00
|
|
|
import CancelSpeedupPopover from '../cancel-speedup-popover';
|
|
|
|
import EditGasFeePopover from '../edit-gas-fee-popover';
|
|
|
|
import EditGasPopover from '../edit-gas-popover';
|
2022-04-01 21:11:12 +02:00
|
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
2023-07-17 19:48:15 +02:00
|
|
|
import { ActivityListItem } from '../../multichain';
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2022-01-06 03:47:26 +01:00
|
|
|
function TransactionListItemInner({
|
2020-11-03 00:41:28 +01:00
|
|
|
transactionGroup,
|
2022-01-06 03:47:26 +01:00
|
|
|
setEditGasMode,
|
2020-11-03 00:41:28 +01:00
|
|
|
isEarliestNonce = false,
|
|
|
|
}) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const t = useI18nContext();
|
|
|
|
const history = useHistory();
|
|
|
|
const { hasCancelled } = transactionGroup;
|
|
|
|
const [showDetails, setShowDetails] = useState(false);
|
2022-07-31 20:26:40 +02:00
|
|
|
const [showCancelEditGasPopover, setShowCancelEditGasPopover] =
|
|
|
|
useState(false);
|
2021-09-15 17:59:51 +02:00
|
|
|
const [showRetryEditGasPopover, setShowRetryEditGasPopover] = useState(false);
|
2022-12-08 19:37:06 +01:00
|
|
|
const { supportsEIP1559 } = useGasFeeContext();
|
2022-01-06 03:47:26 +01:00
|
|
|
const { openModal } = useTransactionModalContext();
|
2023-07-18 15:32:00 +02:00
|
|
|
const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
initialTransaction: { id },
|
2020-12-03 00:25:19 +01:00
|
|
|
primaryTransaction: { err, status },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = transactionGroup;
|
2021-09-15 17:59:51 +02:00
|
|
|
|
2022-03-14 19:12:38 +01:00
|
|
|
const trackEvent = useContext(MetaMetricsContext);
|
2021-09-15 17:59:51 +02:00
|
|
|
|
|
|
|
const retryTransaction = useCallback(
|
|
|
|
async (event) => {
|
|
|
|
event.stopPropagation();
|
2022-03-14 19:12:38 +01:00
|
|
|
trackEvent({
|
|
|
|
event: 'Clicked "Speed Up"',
|
2023-04-03 17:31:04 +02:00
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
2022-03-14 19:12:38 +01:00
|
|
|
properties: {
|
|
|
|
action: 'Activity Log',
|
|
|
|
legacy_event: true,
|
|
|
|
},
|
|
|
|
});
|
2022-12-08 19:37:06 +01:00
|
|
|
if (supportsEIP1559) {
|
2023-01-27 19:28:03 +01:00
|
|
|
setEditGasMode(EditGasModes.speedUp);
|
2022-01-06 03:47:26 +01:00
|
|
|
openModal('cancelSpeedUpTransaction');
|
|
|
|
} else {
|
|
|
|
setShowRetryEditGasPopover(true);
|
|
|
|
}
|
2021-09-15 17:59:51 +02:00
|
|
|
},
|
2022-12-08 19:37:06 +01:00
|
|
|
[openModal, setEditGasMode, trackEvent, supportsEIP1559],
|
2021-09-15 17:59:51 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
const cancelTransaction = useCallback(
|
|
|
|
(event) => {
|
|
|
|
event.stopPropagation();
|
2022-03-14 19:12:38 +01:00
|
|
|
trackEvent({
|
|
|
|
event: 'Clicked "Cancel"',
|
2023-04-03 17:31:04 +02:00
|
|
|
category: MetaMetricsEventCategory.Navigation,
|
2022-03-14 19:12:38 +01:00
|
|
|
properties: {
|
|
|
|
action: 'Activity Log',
|
|
|
|
legacy_event: true,
|
|
|
|
},
|
|
|
|
});
|
2022-12-08 19:37:06 +01:00
|
|
|
if (supportsEIP1559) {
|
2023-01-27 19:28:03 +01:00
|
|
|
setEditGasMode(EditGasModes.cancel);
|
2022-01-06 03:47:26 +01:00
|
|
|
openModal('cancelSpeedUpTransaction');
|
|
|
|
} else {
|
|
|
|
setShowCancelEditGasPopover(true);
|
|
|
|
}
|
2021-09-15 17:59:51 +02:00
|
|
|
},
|
2022-12-08 19:37:06 +01:00
|
|
|
[trackEvent, openModal, setEditGasMode, supportsEIP1559],
|
2021-09-15 17:59:51 +02:00
|
|
|
);
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const shouldShowSpeedUp = useShouldShowSpeedUp(
|
|
|
|
transactionGroup,
|
|
|
|
isEarliestNonce,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
|
|
|
const {
|
|
|
|
title,
|
|
|
|
category,
|
|
|
|
primaryCurrency,
|
|
|
|
recipientAddress,
|
|
|
|
secondaryCurrency,
|
2020-10-07 23:59:38 +02:00
|
|
|
displayedStatusKey,
|
2020-05-26 22:49:11 +02:00
|
|
|
isPending,
|
|
|
|
senderAddress,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = useTransactionDisplayData(transactionGroup);
|
2023-07-17 19:48:15 +02:00
|
|
|
const date = formatDateWithYearContext(
|
|
|
|
transactionGroup.primaryTransaction.time,
|
|
|
|
'MMM d, y',
|
|
|
|
'MMM d',
|
|
|
|
);
|
2023-01-18 15:47:29 +01:00
|
|
|
const isSignatureReq = category === TransactionGroupCategory.signatureRequest;
|
|
|
|
const isApproval = category === TransactionGroupCategory.approval;
|
|
|
|
const isUnapproved = status === TransactionStatus.unapproved;
|
|
|
|
const isSwap = category === TransactionGroupCategory.swap;
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const isCustodian = Boolean(transactionGroup.primaryTransaction.custodyId);
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2020-06-10 22:38:34 +02:00
|
|
|
const className = classnames('transaction-list-item', {
|
2020-11-03 00:41:28 +01:00
|
|
|
'transaction-list-item--unconfirmed':
|
|
|
|
isPending ||
|
2020-11-03 23:57:51 +01:00
|
|
|
[
|
2023-01-18 15:47:29 +01:00
|
|
|
TransactionStatus.failed,
|
|
|
|
TransactionStatus.dropped,
|
|
|
|
TransactionStatus.rejected,
|
2020-11-03 23:57:51 +01:00
|
|
|
].includes(displayedStatusKey),
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-07-31 07:03:20 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const toggleShowDetails = useCallback(() => {
|
|
|
|
if (isUnapproved) {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(`${CONFIRM_TRANSACTION_ROUTE}/${id}`);
|
|
|
|
return;
|
2018-07-31 07:03:20 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
setShowDetails((prev) => !prev);
|
|
|
|
}, [isUnapproved, history, id]);
|
2020-05-26 22:49:11 +02:00
|
|
|
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const debugTransactionMeta = {
|
|
|
|
'data-hash': transactionGroup.primaryTransaction.hash,
|
|
|
|
...(isCustodian
|
|
|
|
? {
|
|
|
|
'data-custodiantransactionid':
|
|
|
|
transactionGroup.primaryTransaction.custodyId,
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
};
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const speedUpButton = useMemo(() => {
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
if (isCustodian) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
if (!shouldShowSpeedUp || !isPending || isUnapproved) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return null;
|
2018-08-03 05:20:15 +02:00
|
|
|
}
|
2023-05-24 13:40:58 +02:00
|
|
|
|
2018-07-31 07:03:20 +02:00
|
|
|
return (
|
2020-05-26 22:49:11 +02:00
|
|
|
<Button
|
2021-10-05 21:20:42 +02:00
|
|
|
type="primary"
|
2021-03-12 20:26:07 +01:00
|
|
|
onClick={hasCancelled ? cancelTransaction : retryTransaction}
|
|
|
|
style={hasCancelled ? { width: 'auto' } : null}
|
2020-05-26 22:49:11 +02:00
|
|
|
>
|
2021-03-12 20:26:07 +01:00
|
|
|
{hasCancelled ? t('speedUpCancellation') : t('speedUp')}
|
2020-05-26 22:49:11 +02:00
|
|
|
</Button>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2021-03-12 20:26:07 +01:00
|
|
|
}, [
|
|
|
|
shouldShowSpeedUp,
|
|
|
|
isUnapproved,
|
|
|
|
t,
|
|
|
|
isPending,
|
|
|
|
hasCancelled,
|
2021-09-15 17:59:51 +02:00
|
|
|
retryTransaction,
|
2021-03-12 20:26:07 +01:00
|
|
|
cancelTransaction,
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
isCustodian,
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-03-12 20:26:07 +01:00
|
|
|
]);
|
2023-07-17 19:48:15 +02:00
|
|
|
const currentChain = useSelector(getCurrentNetwork);
|
2023-05-24 13:40:58 +02:00
|
|
|
let showCancelButton = !hasCancelled && isPending && !isUnapproved;
|
|
|
|
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
showCancelButton = showCancelButton && !isCustodian;
|
|
|
|
const PENDING_COLOR = IconColor.iconAlternative;
|
|
|
|
const OK_COLOR = IconColor.primaryDefault;
|
|
|
|
const FAIL_COLOR = IconColor.errorDefault;
|
|
|
|
const getTransactionColor = (tsStatus) => {
|
|
|
|
switch (tsStatus) {
|
|
|
|
case TransactionStatus.signed:
|
|
|
|
return PENDING_COLOR;
|
|
|
|
case TransactionStatus.rejected:
|
|
|
|
case TransactionStatus.failed:
|
|
|
|
case TransactionStatus.dropped:
|
|
|
|
return FAIL_COLOR;
|
|
|
|
default:
|
|
|
|
return OK_COLOR;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-09-15 17:59:51 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
return (
|
|
|
|
<>
|
2023-07-17 19:48:15 +02:00
|
|
|
<ActivityListItem
|
|
|
|
data-testid="activity-list-item"
|
2020-05-26 22:49:11 +02:00
|
|
|
onClick={toggleShowDetails}
|
|
|
|
className={className}
|
|
|
|
title={title}
|
2020-11-03 00:41:28 +01:00
|
|
|
icon={
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
isCustodian ? (
|
2023-07-17 19:48:15 +02:00
|
|
|
<Box style={{ position: 'relative' }} data-testid="custody-icon">
|
2023-05-24 13:40:58 +02:00
|
|
|
<TransactionIcon
|
|
|
|
category={category}
|
|
|
|
status={displayedStatusKey}
|
|
|
|
/>
|
|
|
|
<Icon
|
|
|
|
name={IconName.Custody}
|
|
|
|
className="transaction-list-item__icon-badge"
|
|
|
|
color={getTransactionColor(status)}
|
|
|
|
size={IconSize.Xs}
|
|
|
|
/>
|
2023-07-17 19:48:15 +02:00
|
|
|
</Box>
|
2023-05-24 13:40:58 +02:00
|
|
|
) : (
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-07-17 19:48:15 +02:00
|
|
|
<BadgeWrapper
|
|
|
|
anchorElementShape={BadgeWrapperAnchorElementShape.circular}
|
|
|
|
positionObj={{ top: -4, right: -4 }}
|
|
|
|
display={Display.Block}
|
|
|
|
badge={
|
|
|
|
<AvatarNetwork
|
|
|
|
className="activity-tx__network-badge"
|
|
|
|
data-testid="activity-tx-network-badge"
|
|
|
|
size={Size.XS}
|
|
|
|
name={currentChain?.nickname}
|
|
|
|
src={currentChain?.rpcPrefs?.imageUrl}
|
|
|
|
borderWidth={1}
|
|
|
|
borderColor={BackgroundColor.backgroundDefault}
|
2023-07-18 15:32:00 +02:00
|
|
|
backgroundColor={testNetworkBackgroundColor}
|
2023-07-17 19:48:15 +02:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<TransactionIcon
|
|
|
|
category={category}
|
|
|
|
status={displayedStatusKey}
|
|
|
|
/>
|
|
|
|
</BadgeWrapper>
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
)
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2020-11-03 00:41:28 +01:00
|
|
|
}
|
|
|
|
subtitle={
|
2023-07-17 19:48:15 +02:00
|
|
|
<TransactionStatusLabel
|
|
|
|
statusOnly
|
|
|
|
isPending={isPending}
|
|
|
|
isEarliestNonce={isEarliestNonce}
|
|
|
|
error={err}
|
|
|
|
date={date}
|
|
|
|
status={displayedStatusKey}
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
custodyStatus={transactionGroup.primaryTransaction.custodyStatus}
|
|
|
|
custodyStatusDisplayText={
|
|
|
|
transactionGroup.primaryTransaction.custodyStatusDisplayText
|
|
|
|
}
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
/>
|
2020-11-03 00:41:28 +01:00
|
|
|
}
|
|
|
|
rightContent={
|
|
|
|
!isSignatureReq &&
|
|
|
|
!isApproval && (
|
|
|
|
<>
|
2023-07-17 19:48:15 +02:00
|
|
|
<Text
|
|
|
|
variant={TextVariant.bodyLgMedium}
|
|
|
|
fontWeight={FontWeight.Medium}
|
|
|
|
color={Color.textDefault}
|
2020-11-03 00:41:28 +01:00
|
|
|
title={primaryCurrency}
|
2023-07-17 19:48:15 +02:00
|
|
|
textAlign={TextAlign.Right}
|
|
|
|
data-testid="transaction-list-item-primary-currency"
|
|
|
|
className="activity-list-item__primary-currency"
|
|
|
|
ellipsis
|
2020-11-03 00:41:28 +01:00
|
|
|
>
|
|
|
|
{primaryCurrency}
|
2023-07-17 19:48:15 +02:00
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
variant={TextVariant.bodyMd}
|
|
|
|
color={Color.textAlternative}
|
|
|
|
textAlign={TextAlign.Right}
|
|
|
|
data-testid="transaction-list-item-secondary-currency"
|
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{secondaryCurrency}
|
2023-07-17 19:48:15 +02:00
|
|
|
</Text>
|
2020-11-03 00:41:28 +01:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2020-05-26 22:49:11 +02:00
|
|
|
>
|
2023-07-17 19:48:15 +02:00
|
|
|
<Box paddingTop={4} className="transaction-list-item__pending-actions">
|
2021-09-15 17:59:51 +02:00
|
|
|
{showCancelButton && (
|
|
|
|
<CancelButton
|
|
|
|
transaction={transactionGroup.primaryTransaction}
|
|
|
|
cancelTransaction={cancelTransaction}
|
|
|
|
/>
|
|
|
|
)}
|
2023-07-17 19:48:15 +02:00
|
|
|
{speedUpButton}
|
|
|
|
</Box>
|
2023-05-24 13:40:58 +02:00
|
|
|
{
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
<a {...debugTransactionMeta} className="test-transaction-meta" />
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
}
|
2023-07-17 19:48:15 +02:00
|
|
|
</ActivityListItem>
|
2020-05-26 22:49:11 +02:00
|
|
|
{showDetails && (
|
|
|
|
<TransactionListItemDetails
|
|
|
|
title={title}
|
|
|
|
onClose={toggleShowDetails}
|
|
|
|
transactionGroup={transactionGroup}
|
2020-10-09 22:11:39 +02:00
|
|
|
primaryCurrency={primaryCurrency}
|
2020-05-26 22:49:11 +02:00
|
|
|
senderAddress={senderAddress}
|
|
|
|
recipientAddress={recipientAddress}
|
|
|
|
onRetry={retryTransaction}
|
2023-05-24 13:40:58 +02:00
|
|
|
showRetry={
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
!isCustodian &&
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
status === TransactionStatus.failed &&
|
|
|
|
!isSwap
|
|
|
|
}
|
|
|
|
showSpeedUp={
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
!isCustodian &&
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
shouldShowSpeedUp
|
|
|
|
}
|
2020-05-26 22:49:11 +02:00
|
|
|
isEarliestNonce={isEarliestNonce}
|
|
|
|
onCancel={cancelTransaction}
|
2023-05-24 13:40:58 +02:00
|
|
|
showCancel={
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
!isCustodian &&
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
isPending &&
|
|
|
|
!hasCancelled
|
|
|
|
}
|
2021-12-01 18:22:08 +01:00
|
|
|
transactionStatus={() => (
|
2023-01-18 15:47:29 +01:00
|
|
|
<TransactionStatusLabel
|
2021-12-01 18:22:08 +01:00
|
|
|
isPending={isPending}
|
|
|
|
isEarliestNonce={isEarliestNonce}
|
|
|
|
error={err}
|
|
|
|
date={date}
|
|
|
|
status={displayedStatusKey}
|
|
|
|
statusOnly
|
|
|
|
/>
|
|
|
|
)}
|
2020-05-26 22:49:11 +02:00
|
|
|
/>
|
|
|
|
)}
|
2022-12-08 19:37:06 +01:00
|
|
|
{!supportsEIP1559 && showRetryEditGasPopover && (
|
2021-07-12 21:35:54 +02:00
|
|
|
<EditGasPopover
|
2021-09-15 17:59:51 +02:00
|
|
|
onClose={() => setShowRetryEditGasPopover(false)}
|
2023-01-27 19:28:03 +01:00
|
|
|
mode={EditGasModes.speedUp}
|
2021-09-15 17:59:51 +02:00
|
|
|
transaction={transactionGroup.primaryTransaction}
|
2021-07-12 21:35:54 +02:00
|
|
|
/>
|
|
|
|
)}
|
2022-12-08 19:37:06 +01:00
|
|
|
{!supportsEIP1559 && showCancelEditGasPopover && (
|
2021-07-12 21:35:54 +02:00
|
|
|
<EditGasPopover
|
2021-09-15 17:59:51 +02:00
|
|
|
onClose={() => setShowCancelEditGasPopover(false)}
|
2023-01-27 19:28:03 +01:00
|
|
|
mode={EditGasModes.cancel}
|
2021-09-15 17:59:51 +02:00
|
|
|
transaction={transactionGroup.primaryTransaction}
|
2021-07-12 21:35:54 +02:00
|
|
|
/>
|
|
|
|
)}
|
2020-05-26 22:49:11 +02:00
|
|
|
</>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-05-26 22:49:11 +02:00
|
|
|
}
|
|
|
|
|
2022-01-06 03:47:26 +01:00
|
|
|
TransactionListItemInner.propTypes = {
|
2020-05-26 22:49:11 +02:00
|
|
|
transactionGroup: PropTypes.object.isRequired,
|
|
|
|
isEarliestNonce: PropTypes.bool,
|
2022-01-06 03:47:26 +01:00
|
|
|
setEditGasMode: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
const TransactionListItem = (props) => {
|
|
|
|
const { transactionGroup } = props;
|
|
|
|
const [editGasMode, setEditGasMode] = useState();
|
|
|
|
const transaction = transactionGroup.primaryTransaction;
|
|
|
|
|
|
|
|
const supportsEIP1559 =
|
|
|
|
useSelector(checkNetworkAndAccountSupports1559) &&
|
|
|
|
!isLegacyTransaction(transaction?.txParams);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<GasFeeContextProvider
|
|
|
|
transaction={transactionGroup.primaryTransaction}
|
|
|
|
editGasMode={editGasMode}
|
|
|
|
>
|
2022-02-01 18:53:03 +01:00
|
|
|
<TransactionModalContextProvider>
|
2022-01-06 03:47:26 +01:00
|
|
|
<TransactionListItemInner {...props} setEditGasMode={setEditGasMode} />
|
2022-12-08 19:37:06 +01:00
|
|
|
{supportsEIP1559 && (
|
2022-01-06 03:47:26 +01:00
|
|
|
<>
|
|
|
|
<CancelSpeedupPopover />
|
|
|
|
<EditGasFeePopover />
|
|
|
|
<AdvancedGasFeePopover />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</TransactionModalContextProvider>
|
|
|
|
</GasFeeContextProvider>
|
|
|
|
);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2022-01-06 03:47:26 +01:00
|
|
|
|
|
|
|
TransactionListItem.propTypes = {
|
|
|
|
transactionGroup: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TransactionListItem;
|