import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { getBlockExplorerLink } from '@metamask/etherscan-link'; import { formatDate, getURLHostName } from '../../../helpers/utils/util'; import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics'; import { getValueFromWeiHex } from '../../../../shared/modules/conversion.utils'; import TransactionActivityLogIcon from './transaction-activity-log-icon'; import { CONFIRMED_STATUS } from './transaction-activity-log.constants'; export default class TransactionActivityLog extends PureComponent { static contextTypes = { t: PropTypes.func, trackEvent: PropTypes.func, }; static propTypes = { activities: PropTypes.array, className: PropTypes.string, conversionRate: PropTypes.number, inlineRetryIndex: PropTypes.number, inlineCancelIndex: PropTypes.number, nativeCurrency: PropTypes.string, onCancel: PropTypes.func, onRetry: PropTypes.func, primaryTransaction: PropTypes.object, isEarliestNonce: PropTypes.bool, rpcPrefs: PropTypes.object, }; handleActivityClick = (activity) => { const { rpcPrefs } = this.props; const etherscanUrl = getBlockExplorerLink(activity, rpcPrefs); this.context.trackEvent({ category: MetaMetricsEventCategory.Transactions, event: 'Clicked Block Explorer Link', properties: { link_type: 'Transaction Block Explorer', action: 'Activity Details', block_explorer_domain: getURLHostName(etherscanUrl), }, }); global.platform.openTab({ url: etherscanUrl }); }; renderInlineRetry(index) { const { t } = this.context; const { inlineRetryIndex, primaryTransaction = {}, onRetry, isEarliestNonce, } = this.props; const { status } = primaryTransaction; return isEarliestNonce && status !== CONFIRMED_STATUS && index === inlineRetryIndex ? (