mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import { connect } from 'react-redux'
|
|
import { withRouter } from 'react-router-dom'
|
|
import { compose } from 'recompose'
|
|
import withMethodData from '../../higher-order-components/with-method-data'
|
|
import TransactionListItem from './transaction-list-item.component'
|
|
import { setSelectedToken, retryTransaction, showModal } from '../../actions'
|
|
import { hexToDecimal } from '../../helpers/conversions.util'
|
|
import { getTokenData } from '../../helpers/transactions.util'
|
|
import { formatDate } from '../../util'
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
const { transaction: { txParams: { value, nonce, data } = {}, time } = {} } = ownProps
|
|
|
|
const tokenData = data && getTokenData(data)
|
|
const nonceAndDate = nonce ? `#${hexToDecimal(nonce)} - ${formatDate(time)}` : formatDate(time)
|
|
|
|
return {
|
|
value,
|
|
nonceAndDate,
|
|
tokenData,
|
|
}
|
|
}
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
return {
|
|
setSelectedToken: tokenAddress => dispatch(setSelectedToken(tokenAddress)),
|
|
retryTransaction: transactionId => dispatch(retryTransaction(transactionId)),
|
|
showCancelModal: (transactionId, originalGasPrice) => {
|
|
return dispatch(showModal({ name: 'CANCEL_TRANSACTION', transactionId, originalGasPrice }))
|
|
},
|
|
showTransactionDetailsModal: ({ transaction, onRetry, showRetry, onCancel, showCancel }) => {
|
|
return dispatch(showModal({
|
|
name: 'TRANSACTION_DETAILS',
|
|
transaction,
|
|
onRetry,
|
|
showRetry,
|
|
onCancel,
|
|
showCancel,
|
|
}))
|
|
},
|
|
}
|
|
}
|
|
|
|
export default compose(
|
|
withRouter,
|
|
connect(mapStateToProps, mapDispatchToProps),
|
|
withMethodData,
|
|
)(TransactionListItem)
|