2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import copyToClipboard from 'copy-to-clipboard';
|
2021-05-19 16:51:47 +02:00
|
|
|
import { getBlockExplorerLink } from '@metamask/etherscan-link';
|
2021-02-04 19:15:23 +01:00
|
|
|
import SenderToRecipient from '../../ui/sender-to-recipient';
|
2021-11-03 16:26:25 +01:00
|
|
|
import { DEFAULT_VARIANT } from '../../ui/sender-to-recipient/sender-to-recipient.constants';
|
2021-12-01 18:22:08 +01:00
|
|
|
import Disclosure from '../../ui/disclosure';
|
2021-02-04 19:15:23 +01:00
|
|
|
import TransactionActivityLog from '../transaction-activity-log';
|
|
|
|
import TransactionBreakdown from '../transaction-breakdown';
|
|
|
|
import Button from '../../ui/button';
|
|
|
|
import Tooltip from '../../ui/tooltip';
|
2021-09-15 17:59:51 +02:00
|
|
|
import CancelButton from '../cancel-button';
|
2021-02-04 19:15:23 +01:00
|
|
|
import Popover from '../../ui/popover';
|
2021-06-10 21:27:03 +02:00
|
|
|
import { SECOND } from '../../../../shared/constants/time';
|
2022-04-22 18:09:10 +02:00
|
|
|
import { EVENT } from '../../../../shared/constants/metametrics';
|
2023-01-18 15:47:29 +01:00
|
|
|
import { TransactionType } from '../../../../shared/constants/transaction';
|
2021-08-25 00:28:16 +02:00
|
|
|
import { getURLHostName } from '../../../helpers/utils/util';
|
2021-12-01 18:22:08 +01:00
|
|
|
import TransactionDecoding from '../transaction-decoding';
|
2022-08-02 23:56:02 +02:00
|
|
|
import { NETWORKS_ROUTE } from '../../../helpers/constants/routes';
|
2018-08-31 21:36:36 +02:00
|
|
|
|
|
|
|
export default class TransactionListItemDetails extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-05-19 16:51:47 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2019-11-01 18:54:00 +01:00
|
|
|
static defaultProps = {
|
|
|
|
recipientEns: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-01 18:54:00 +01:00
|
|
|
|
2018-08-31 21:36:36 +02:00
|
|
|
static propTypes = {
|
2018-09-17 19:34:29 +02:00
|
|
|
onCancel: PropTypes.func,
|
2018-09-15 05:19:13 +02:00
|
|
|
onRetry: PropTypes.func,
|
2018-09-17 19:34:29 +02:00
|
|
|
showCancel: PropTypes.bool,
|
2019-10-28 14:28:46 +01:00
|
|
|
showSpeedUp: PropTypes.bool,
|
2018-08-31 21:36:36 +02:00
|
|
|
showRetry: PropTypes.bool,
|
2019-09-09 21:59:00 +02:00
|
|
|
isEarliestNonce: PropTypes.bool,
|
2020-10-09 22:11:39 +02:00
|
|
|
primaryCurrency: PropTypes.string,
|
2018-12-09 21:48:06 +01:00
|
|
|
transactionGroup: PropTypes.object,
|
2020-05-26 22:49:11 +02:00
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
2019-11-01 18:54:00 +01:00
|
|
|
recipientEns: PropTypes.string,
|
2020-05-28 20:00:51 +02:00
|
|
|
recipientAddress: PropTypes.string,
|
2022-11-08 09:34:21 +01:00
|
|
|
recipientName: PropTypes.string,
|
|
|
|
recipientMetadataName: PropTypes.string,
|
2019-05-09 19:27:14 +02:00
|
|
|
rpcPrefs: PropTypes.object,
|
2019-11-01 18:54:00 +01:00
|
|
|
senderAddress: PropTypes.string.isRequired,
|
|
|
|
tryReverseResolveAddress: PropTypes.func.isRequired,
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname: PropTypes.string.isRequired,
|
2020-05-28 20:00:51 +02:00
|
|
|
recipientNickname: PropTypes.string,
|
2021-12-01 18:22:08 +01:00
|
|
|
transactionStatus: PropTypes.func,
|
2022-08-02 23:56:02 +02:00
|
|
|
isCustomNetwork: PropTypes.bool,
|
|
|
|
history: PropTypes.object,
|
|
|
|
blockExplorerLinkText: PropTypes.object,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2019-02-17 05:30:02 +01:00
|
|
|
state = {
|
|
|
|
justCopied: false,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-17 05:30:02 +01:00
|
|
|
|
2021-05-19 16:51:47 +02:00
|
|
|
handleBlockExplorerClick = () => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
transactionGroup: { primaryTransaction },
|
|
|
|
rpcPrefs,
|
2022-08-02 23:56:02 +02:00
|
|
|
isCustomNetwork,
|
|
|
|
history,
|
|
|
|
onClose,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2021-05-19 16:51:47 +02:00
|
|
|
const blockExplorerLink = getBlockExplorerLink(
|
|
|
|
primaryTransaction,
|
|
|
|
rpcPrefs,
|
|
|
|
);
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2022-08-02 23:56:02 +02:00
|
|
|
if (!rpcPrefs.blockExplorerUrl && isCustomNetwork) {
|
|
|
|
onClose();
|
|
|
|
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
|
|
|
|
} else {
|
|
|
|
this.context.trackEvent({
|
|
|
|
category: EVENT.CATEGORIES.TRANSACTIONS,
|
|
|
|
event: 'Clicked Block Explorer Link',
|
|
|
|
properties: {
|
|
|
|
link_type: 'Transaction Block Explorer',
|
|
|
|
action: 'Transaction Details',
|
|
|
|
block_explorer_domain: getURLHostName(blockExplorerLink),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
global.platform.openTab({
|
|
|
|
url: blockExplorerLink,
|
|
|
|
});
|
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-31 21:36:36 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
handleCancel = (event) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onCancel, onClose } = this.props;
|
|
|
|
onCancel(event);
|
|
|
|
onClose();
|
|
|
|
};
|
2018-09-17 19:34:29 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
handleRetry = (event) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onClose, onRetry } = this.props;
|
|
|
|
onRetry(event);
|
|
|
|
onClose();
|
|
|
|
};
|
2018-09-15 05:19:13 +02:00
|
|
|
|
2019-02-17 05:30:02 +01:00
|
|
|
handleCopyTxId = () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { transactionGroup } = this.props;
|
|
|
|
const { primaryTransaction: transaction } = transactionGroup;
|
|
|
|
const { hash } = transaction;
|
2019-02-17 05:30:02 +01:00
|
|
|
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
2022-04-22 18:09:10 +02:00
|
|
|
category: EVENT.CATEGORIES.NAVIGATION,
|
2022-03-29 15:46:24 +02:00
|
|
|
event: 'Copied Transaction ID',
|
|
|
|
properties: {
|
2019-03-05 16:45:01 +01:00
|
|
|
action: 'Activity Log',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2019-03-05 16:45:01 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-03-05 16:45:01 +01:00
|
|
|
|
2019-02-17 05:30:02 +01:00
|
|
|
this.setState({ justCopied: true }, () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
copyToClipboard(hash);
|
2021-06-10 21:27:03 +02:00
|
|
|
setTimeout(() => this.setState({ justCopied: false }), SECOND);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
};
|
2019-02-17 05:30:02 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentDidMount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { recipientAddress, tryReverseResolveAddress } = this.props;
|
2019-11-01 18:54:00 +01:00
|
|
|
|
2020-05-28 20:00:51 +02:00
|
|
|
if (recipientAddress) {
|
2021-02-04 19:15:23 +01:00
|
|
|
tryReverseResolveAddress(recipientAddress);
|
2020-05-28 20:00:51 +02:00
|
|
|
}
|
2019-11-01 18:54:00 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
|
|
|
const { justCopied } = this.state;
|
2019-03-25 17:25:23 +01:00
|
|
|
const {
|
|
|
|
transactionGroup,
|
2020-10-09 22:11:39 +02:00
|
|
|
primaryCurrency,
|
2019-10-28 14:28:46 +01:00
|
|
|
showSpeedUp,
|
2019-03-25 17:25:23 +01:00
|
|
|
showRetry,
|
2019-11-01 18:54:00 +01:00
|
|
|
recipientEns,
|
|
|
|
recipientAddress,
|
2022-11-08 09:34:21 +01:00
|
|
|
recipientName,
|
|
|
|
recipientMetadataName,
|
2019-11-01 18:54:00 +01:00
|
|
|
senderAddress,
|
2019-09-09 21:59:00 +02:00
|
|
|
isEarliestNonce,
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname,
|
2020-05-26 22:49:11 +02:00
|
|
|
title,
|
|
|
|
onClose,
|
2020-02-11 16:40:15 +01:00
|
|
|
recipientNickname,
|
2021-09-15 17:59:51 +02:00
|
|
|
showCancel,
|
2021-12-01 18:22:08 +01:00
|
|
|
transactionStatus: TransactionStatus,
|
2022-08-02 23:56:02 +02:00
|
|
|
blockExplorerLinkText,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
primaryTransaction: transaction,
|
2021-03-10 21:16:44 +01:00
|
|
|
initialTransaction: { type },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = transactionGroup;
|
|
|
|
const { hash } = transaction;
|
2018-08-31 21:36:36 +02:00
|
|
|
|
|
|
|
return (
|
2020-05-26 22:49:11 +02:00
|
|
|
<Popover title={title} onClose={onClose}>
|
|
|
|
<div className="transaction-list-item-details">
|
2021-12-01 18:22:08 +01:00
|
|
|
<div className="transaction-list-item-details__operations">
|
2020-05-26 22:49:11 +02:00
|
|
|
<div className="transaction-list-item-details__header-buttons">
|
2020-11-03 00:41:28 +01:00
|
|
|
{showSpeedUp && (
|
|
|
|
<Button
|
2021-10-05 21:20:42 +02:00
|
|
|
type="primary"
|
2020-11-03 00:41:28 +01:00
|
|
|
onClick={this.handleRetry}
|
2021-10-05 21:20:42 +02:00
|
|
|
className="transaction-list-item-details__header-button-rounded-button"
|
2023-01-17 16:51:35 +01:00
|
|
|
data-testid="speedup-button"
|
2020-11-03 00:41:28 +01:00
|
|
|
>
|
|
|
|
{t('speedUp')}
|
|
|
|
</Button>
|
|
|
|
)}
|
2021-09-15 17:59:51 +02:00
|
|
|
{showCancel && (
|
|
|
|
<CancelButton
|
|
|
|
transaction={transaction}
|
|
|
|
cancelTransaction={this.handleCancel}
|
|
|
|
detailsModal
|
|
|
|
/>
|
|
|
|
)}
|
2020-11-03 00:41:28 +01:00
|
|
|
{showRetry && (
|
|
|
|
<Tooltip title={t('retryTransaction')}>
|
|
|
|
<Button
|
|
|
|
type="raised"
|
|
|
|
onClick={this.handleRetry}
|
|
|
|
className="transaction-list-item-details__header-button"
|
2023-01-17 16:51:35 +01:00
|
|
|
data-testid="rety-button"
|
2020-11-03 00:41:28 +01:00
|
|
|
>
|
|
|
|
<i className="fa fa-sync"></i>
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
|
|
|
)}
|
2020-05-26 22:49:11 +02:00
|
|
|
</div>
|
2018-12-09 21:48:06 +01:00
|
|
|
</div>
|
2021-12-01 18:22:08 +01:00
|
|
|
<div className="transaction-list-item-details__header">
|
|
|
|
<div className="transaction-list-item-details__tx-status">
|
2022-02-14 16:52:04 +01:00
|
|
|
<div>{t('status')}</div>
|
2021-12-01 18:22:08 +01:00
|
|
|
<div>
|
|
|
|
<TransactionStatus />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="transaction-list-item-details__tx-hash">
|
|
|
|
<div>
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
onClick={this.handleBlockExplorerClick}
|
|
|
|
disabled={!hash}
|
|
|
|
>
|
2022-08-02 23:56:02 +02:00
|
|
|
{blockExplorerLinkText.firstPart === 'addBlockExplorer'
|
|
|
|
? t('addBlockExplorer')
|
|
|
|
: t('viewOnBlockExplorer')}
|
2021-12-01 18:22:08 +01:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Tooltip
|
|
|
|
wrapperClassName="transaction-list-item-details__header-button"
|
|
|
|
containerClassName="transaction-list-item-details__header-button-tooltip-container"
|
|
|
|
title={justCopied ? t('copiedExclamation') : null}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
onClick={this.handleCopyTxId}
|
|
|
|
disabled={!hash}
|
|
|
|
>
|
|
|
|
{t('copyTransactionId')}
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-26 22:49:11 +02:00
|
|
|
<div className="transaction-list-item-details__body">
|
2021-12-01 18:22:08 +01:00
|
|
|
<div className="transaction-list-item-details__sender-to-recipient-header">
|
|
|
|
<div>{t('from')}</div>
|
|
|
|
<div>{t('to')}</div>
|
|
|
|
</div>
|
2020-05-26 22:49:11 +02:00
|
|
|
<div className="transaction-list-item-details__sender-to-recipient-container">
|
|
|
|
<SenderToRecipient
|
2020-05-28 21:20:56 +02:00
|
|
|
warnUserOnAccountMismatch={false}
|
2021-11-03 16:26:25 +01:00
|
|
|
variant={DEFAULT_VARIANT}
|
2020-05-26 22:49:11 +02:00
|
|
|
addressOnly
|
|
|
|
recipientEns={recipientEns}
|
|
|
|
recipientAddress={recipientAddress}
|
|
|
|
recipientNickname={recipientNickname}
|
2022-11-08 09:34:21 +01:00
|
|
|
recipientName={recipientName}
|
|
|
|
recipientMetadataName={recipientMetadataName}
|
2020-05-26 22:49:11 +02:00
|
|
|
senderName={senderNickname}
|
|
|
|
senderAddress={senderAddress}
|
|
|
|
onRecipientClick={() => {
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
2022-04-22 18:09:10 +02:00
|
|
|
category: EVENT.CATEGORIES.NAVIGATION,
|
2022-03-29 15:46:24 +02:00
|
|
|
event: 'Copied "To" Address',
|
|
|
|
properties: {
|
2020-05-26 22:49:11 +02:00
|
|
|
action: 'Activity Log',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2020-05-26 22:49:11 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-05-26 22:49:11 +02:00
|
|
|
}}
|
|
|
|
onSenderClick={() => {
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
2022-04-22 18:09:10 +02:00
|
|
|
category: EVENT.CATEGORIES.NAVIGATION,
|
2022-03-29 15:46:24 +02:00
|
|
|
event: 'Copied "From" Address',
|
|
|
|
properties: {
|
2020-05-26 22:49:11 +02:00
|
|
|
action: 'Activity Log',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2020-05-26 22:49:11 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-05-26 22:49:11 +02:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="transaction-list-item-details__cards-container">
|
|
|
|
<TransactionBreakdown
|
2020-06-02 00:19:49 +02:00
|
|
|
nonce={transactionGroup.initialTransaction.txParams.nonce}
|
2022-07-12 01:32:55 +02:00
|
|
|
isTokenApprove={
|
2023-01-18 15:47:29 +01:00
|
|
|
type === TransactionType.tokenMethodApprove ||
|
|
|
|
type === TransactionType.tokenMethodSetApprovalForAll
|
2022-07-12 01:32:55 +02:00
|
|
|
}
|
2020-05-26 22:49:11 +02:00
|
|
|
transaction={transaction}
|
2020-10-09 22:11:39 +02:00
|
|
|
primaryCurrency={primaryCurrency}
|
2020-05-26 22:49:11 +02:00
|
|
|
className="transaction-list-item-details__transaction-breakdown"
|
|
|
|
/>
|
2021-12-07 16:12:34 +01:00
|
|
|
{transactionGroup.initialTransaction.type !==
|
2023-01-18 15:47:29 +01:00
|
|
|
TransactionType.incoming && (
|
2021-12-07 16:12:34 +01:00
|
|
|
<Disclosure title={t('activityLog')} size="small">
|
|
|
|
<TransactionActivityLog
|
|
|
|
transactionGroup={transactionGroup}
|
|
|
|
className="transaction-list-item-details__transaction-activity-log"
|
|
|
|
onCancel={this.handleCancel}
|
|
|
|
onRetry={this.handleRetry}
|
|
|
|
isEarliestNonce={isEarliestNonce}
|
|
|
|
/>
|
|
|
|
</Disclosure>
|
|
|
|
)}
|
2021-12-01 18:22:08 +01:00
|
|
|
{transactionGroup.initialTransaction?.txParams?.data ? (
|
|
|
|
<Disclosure title="Transaction data" size="small">
|
|
|
|
<TransactionDecoding
|
|
|
|
title={t('transactionData')}
|
|
|
|
to={transactionGroup.initialTransaction.txParams?.to}
|
|
|
|
inputData={
|
|
|
|
transactionGroup.initialTransaction.txParams?.data
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Disclosure>
|
|
|
|
) : null}
|
2020-05-26 22:49:11 +02:00
|
|
|
</div>
|
2018-12-09 21:48:06 +01:00
|
|
|
</div>
|
2018-08-31 21:36:36 +02:00
|
|
|
</div>
|
2020-05-26 22:49:11 +02:00
|
|
|
</Popover>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-08-31 21:36:36 +02:00
|
|
|
}
|
|
|
|
}
|