2018-07-31 07:03:20 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
import { compose } from 'recompose'
|
|
|
|
import TransactionList from './transaction-list.component'
|
|
|
|
import {
|
|
|
|
pendingTransactionsSelector,
|
2018-08-07 07:39:54 +02:00
|
|
|
submittedPendingTransactionsSelector,
|
2018-07-31 07:03:20 +02:00
|
|
|
completedTransactionsSelector,
|
|
|
|
} from '../../selectors/transactions'
|
2018-08-30 18:51:57 +02:00
|
|
|
import { getSelectedAddress, getAssetImages } from '../../selectors'
|
2018-08-06 07:25:58 +02:00
|
|
|
import { selectedTokenSelector } from '../../selectors/tokens'
|
2018-08-12 06:12:30 +02:00
|
|
|
import { getLatestSubmittedTxWithNonce } from '../../helpers/transactions.util'
|
|
|
|
import { updateNetworkNonce } from '../../actions'
|
2018-07-31 07:03:20 +02:00
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
2018-08-03 05:20:15 +02:00
|
|
|
const pendingTransactions = pendingTransactionsSelector(state)
|
2018-08-07 07:39:54 +02:00
|
|
|
const submittedPendingTransactions = submittedPendingTransactionsSelector(state)
|
2018-08-12 06:12:30 +02:00
|
|
|
const networkNonce = state.appState.networkNonce
|
2018-08-03 05:20:15 +02:00
|
|
|
|
2018-07-31 07:03:20 +02:00
|
|
|
return {
|
|
|
|
completedTransactions: completedTransactionsSelector(state),
|
2018-08-03 05:20:15 +02:00
|
|
|
pendingTransactions,
|
2018-08-12 06:12:30 +02:00
|
|
|
transactionToRetry: getLatestSubmittedTxWithNonce(submittedPendingTransactions, networkNonce),
|
2018-08-06 07:25:58 +02:00
|
|
|
selectedToken: selectedTokenSelector(state),
|
2018-08-12 06:12:30 +02:00
|
|
|
selectedAddress: getSelectedAddress(state),
|
2018-08-30 18:51:57 +02:00
|
|
|
assetImages: getAssetImages(state),
|
2018-08-12 06:12:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
updateNetworkNonce: address => dispatch(updateNetworkNonce(address)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
|
|
|
const { selectedAddress, ...restStateProps } = stateProps
|
|
|
|
const { updateNetworkNonce, ...restDispatchProps } = dispatchProps
|
|
|
|
|
|
|
|
return {
|
|
|
|
...restStateProps,
|
|
|
|
...restDispatchProps,
|
|
|
|
...ownProps,
|
|
|
|
updateNetworkNonce: () => updateNetworkNonce(selectedAddress),
|
2018-07-31 07:03:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2018-08-12 06:12:30 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps, mergeProps)
|
2018-07-31 07:03:20 +02:00
|
|
|
)(TransactionList)
|