2018-07-31 07:03:20 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
import { compose } from 'recompose'
|
2018-08-03 05:20:15 +02:00
|
|
|
import withMethodData from '../../higher-order-components/with-method-data'
|
2018-07-31 07:03:20 +02:00
|
|
|
import TransactionListItem from './transaction-list-item.component'
|
2018-08-03 05:20:15 +02:00
|
|
|
import { setSelectedToken, retryTransaction } from '../../actions'
|
2018-08-16 04:18:01 +02:00
|
|
|
import { hexToDecimal } from '../../helpers/conversions.util'
|
2018-09-07 22:59:05 +02:00
|
|
|
import { getTokenData } from '../../helpers/transactions.util'
|
2018-08-07 10:57:46 +02:00
|
|
|
import { formatDate } from '../../util'
|
2018-07-31 07:03:20 +02:00
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2018-09-07 22:59:05 +02:00
|
|
|
const { transaction: { txParams: { value, nonce, data } = {}, time } = {} } = ownProps
|
2018-07-31 07:03:20 +02:00
|
|
|
|
2018-09-07 22:59:05 +02:00
|
|
|
const tokenData = data && getTokenData(data)
|
2018-08-07 10:57:46 +02:00
|
|
|
const nonceAndDate = nonce ? `#${hexToDecimal(nonce)} - ${formatDate(time)}` : formatDate(time)
|
|
|
|
|
2018-07-31 07:03:20 +02:00
|
|
|
return {
|
2018-08-16 04:18:01 +02:00
|
|
|
value,
|
2018-08-07 10:57:46 +02:00
|
|
|
nonceAndDate,
|
2018-09-07 22:59:05 +02:00
|
|
|
tokenData,
|
2018-07-31 07:03:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 05:20:15 +02:00
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
setSelectedToken: tokenAddress => dispatch(setSelectedToken(tokenAddress)),
|
|
|
|
retryTransaction: transactionId => dispatch(retryTransaction(transactionId)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-31 07:03:20 +02:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2018-08-03 05:20:15 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps),
|
|
|
|
withMethodData,
|
2018-07-31 07:03:20 +02:00
|
|
|
)(TransactionListItem)
|