2018-08-31 21:36:36 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import SenderToRecipient from '../sender-to-recipient'
|
|
|
|
import { CARDS_VARIANT } from '../sender-to-recipient/sender-to-recipient.constants'
|
|
|
|
import TransactionActivityLog from '../transaction-activity-log'
|
|
|
|
import TransactionBreakdown from '../transaction-breakdown'
|
|
|
|
import Button from '../button'
|
2018-10-16 01:02:57 +02:00
|
|
|
import Tooltip from '../tooltip'
|
2018-08-31 21:36:36 +02:00
|
|
|
import prefixForNetwork from '../../../lib/etherscan-prefix-for-network'
|
|
|
|
|
|
|
|
export default class TransactionListItemDetails extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2018-08-31 21:36:36 +02:00
|
|
|
showRetry: PropTypes.bool,
|
2018-09-15 05:19:13 +02:00
|
|
|
transaction: PropTypes.object,
|
2018-08-31 21:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleEtherscanClick = () => {
|
|
|
|
const { hash, metamaskNetworkId } = this.props.transaction
|
|
|
|
|
|
|
|
const prefix = prefixForNetwork(metamaskNetworkId)
|
|
|
|
const etherscanUrl = `https://${prefix}etherscan.io/tx/${hash}`
|
|
|
|
global.platform.openWindow({ url: etherscanUrl })
|
|
|
|
this.setState({ showTransactionDetails: true })
|
|
|
|
}
|
|
|
|
|
2018-09-17 19:34:29 +02:00
|
|
|
handleCancel = event => {
|
|
|
|
const { onCancel } = this.props
|
|
|
|
|
|
|
|
event.stopPropagation()
|
|
|
|
onCancel()
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:19:13 +02:00
|
|
|
handleRetry = event => {
|
|
|
|
const { onRetry } = this.props
|
|
|
|
|
|
|
|
event.stopPropagation()
|
|
|
|
onRetry()
|
|
|
|
}
|
|
|
|
|
2018-08-31 21:36:36 +02:00
|
|
|
render () {
|
|
|
|
const { t } = this.context
|
2018-09-17 19:34:29 +02:00
|
|
|
const { transaction, showCancel, showRetry } = this.props
|
2018-08-31 21:36:36 +02:00
|
|
|
const { txParams: { to, from } = {} } = transaction
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="transaction-list-item-details">
|
|
|
|
<div className="transaction-list-item-details__header">
|
|
|
|
<div>Details</div>
|
|
|
|
<div className="transaction-list-item-details__header-buttons">
|
|
|
|
{
|
|
|
|
showRetry && (
|
|
|
|
<Button
|
|
|
|
type="raised"
|
2018-09-15 05:19:13 +02:00
|
|
|
onClick={this.handleRetry}
|
2018-08-31 21:36:36 +02:00
|
|
|
className="transaction-list-item-details__header-button"
|
|
|
|
>
|
|
|
|
{ t('speedUp') }
|
|
|
|
</Button>
|
|
|
|
)
|
2018-09-17 19:34:29 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
showCancel && (
|
|
|
|
<Button
|
|
|
|
type="raised"
|
|
|
|
onClick={this.handleCancel}
|
|
|
|
className="transaction-list-item-details__header-button"
|
|
|
|
>
|
|
|
|
{ t('cancel') }
|
|
|
|
</Button>
|
|
|
|
)
|
2018-08-31 21:36:36 +02:00
|
|
|
}
|
2018-10-16 01:02:57 +02:00
|
|
|
<Tooltip title={t('viewOnEtherscan')}>
|
|
|
|
<Button
|
|
|
|
type="raised"
|
|
|
|
onClick={this.handleEtherscanClick}
|
|
|
|
className="transaction-list-item-details__header-button"
|
|
|
|
>
|
|
|
|
<img src="/images/arrow-popout.svg" />
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
2018-08-31 21:36:36 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="transaction-list-item-details__sender-to-recipient-container">
|
|
|
|
<SenderToRecipient
|
|
|
|
variant={CARDS_VARIANT}
|
|
|
|
addressOnly
|
|
|
|
recipientAddress={to}
|
|
|
|
senderAddress={from}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="transaction-list-item-details__cards-container">
|
|
|
|
<TransactionBreakdown
|
|
|
|
transaction={transaction}
|
|
|
|
className="transaction-list-item-details__transaction-breakdown"
|
|
|
|
/>
|
|
|
|
<TransactionActivityLog
|
|
|
|
transaction={transaction}
|
|
|
|
className="transaction-list-item-details__transaction-activity-log"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|