import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import copyToClipboard from 'copy-to-clipboard' import SenderToRecipient from '../sender-to-recipient' import { FLAT_VARIANT } from '../sender-to-recipient/sender-to-recipient.constants' import TransactionActivityLog from '../transaction-activity-log' import TransactionBreakdown from '../transaction-breakdown' import Button from '../button' import Tooltip from '../tooltip' import prefixForNetwork from '../../../lib/etherscan-prefix-for-network' export default class TransactionListItemDetails extends PureComponent { static contextTypes = { t: PropTypes.func, } static propTypes = { onCancel: PropTypes.func, onRetry: PropTypes.func, showCancel: PropTypes.bool, showRetry: PropTypes.bool, transactionGroup: PropTypes.object, } state = { justCopied: false, } handleEtherscanClick = () => { const { transactionGroup: { primaryTransaction } } = this.props const { hash, metamaskNetworkId } = primaryTransaction const prefix = prefixForNetwork(metamaskNetworkId) const etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}` global.platform.openWindow({ url: etherscanUrl }) } handleCancel = event => { const { transactionGroup: { initialTransaction: { id } = {} } = {}, onCancel } = this.props event.stopPropagation() onCancel(id) } handleRetry = event => { const { transactionGroup: { initialTransaction: { id } = {} } = {}, onRetry } = this.props event.stopPropagation() onRetry(id) } handleCopyTxId = () => { const { transactionGroup} = this.props const { primaryTransaction: transaction } = transactionGroup const { hash } = transaction this.setState({ justCopied: true }, () => { copyToClipboard(hash) setTimeout(() => this.setState({ justCopied: false }), 1000) }) } render () { const { t } = this.context const { justCopied } = this.state const { transactionGroup, showCancel, showRetry, onCancel, onRetry } = this.props const { primaryTransaction: transaction } = transactionGroup const { txParams: { to, from } = {} } = transaction return (
{ t('details') }
{ showRetry && ( ) } { showCancel && ( ) }
) } }