2018-09-18 03:32:35 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import Modal from '../../modal'
|
|
|
|
import TransactionListItemDetails from '../../transaction-list-item-details'
|
|
|
|
import { hexToDecimal } from '../../../helpers/conversions.util'
|
|
|
|
|
|
|
|
export default class TransactionConfirmed extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
hideModal: PropTypes.func,
|
|
|
|
transaction: PropTypes.object,
|
|
|
|
onRetry: PropTypes.func,
|
|
|
|
showRetry: PropTypes.bool,
|
|
|
|
onCancel: PropTypes.func,
|
|
|
|
showCancel: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
2018-09-21 04:35:45 +02:00
|
|
|
handleSubmit = () => {
|
|
|
|
this.props.hideModal()
|
|
|
|
}
|
|
|
|
|
2018-09-26 23:58:27 +02:00
|
|
|
handleRetry = () => {
|
|
|
|
const { onRetry, hideModal } = this.props
|
|
|
|
|
|
|
|
Promise.resolve(onRetry()).then(() => hideModal())
|
|
|
|
}
|
|
|
|
|
2018-09-18 03:32:35 +02:00
|
|
|
render () {
|
|
|
|
const { t } = this.context
|
2018-09-26 23:58:27 +02:00
|
|
|
const { transaction, showRetry, onCancel, showCancel } = this.props
|
2018-09-18 03:32:35 +02:00
|
|
|
const { txParams: { nonce } = {} } = transaction
|
|
|
|
const decimalNonce = nonce && hexToDecimal(nonce)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
2018-09-21 04:35:45 +02:00
|
|
|
onSubmit={this.handleSubmit}
|
|
|
|
onClose={this.handleSubmit}
|
2018-09-18 03:32:35 +02:00
|
|
|
submitText={t('ok')}
|
|
|
|
headerText={t('transactionWithNonce', [`#${decimalNonce}`])}
|
|
|
|
>
|
|
|
|
<TransactionListItemDetails
|
|
|
|
transaction={transaction}
|
2018-09-26 23:58:27 +02:00
|
|
|
onRetry={this.handleRetry}
|
2018-09-18 03:32:35 +02:00
|
|
|
showRetry={showRetry}
|
|
|
|
onCancel={() => onCancel()}
|
|
|
|
showCancel={showCancel}
|
|
|
|
/>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|