2018-06-23 08:52:45 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { compose } from 'recompose'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
2018-07-06 20:58:41 +02:00
|
|
|
import {
|
|
|
|
setTransactionToConfirm,
|
|
|
|
clearConfirmTransaction,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
2018-09-13 10:47:05 +02:00
|
|
|
import {
|
2018-11-13 17:36:52 +01:00
|
|
|
fetchBasicGasAndTimeEstimates,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../ducks/gas/gas.duck'
|
2019-06-18 14:17:14 +02:00
|
|
|
|
|
|
|
import {
|
|
|
|
getContractMethodData,
|
|
|
|
} from '../../store/actions'
|
2018-06-23 08:52:45 +02:00
|
|
|
import ConfirmTransaction from './confirm-transaction.component'
|
2019-03-22 00:03:30 +01:00
|
|
|
import { unconfirmedTransactionsListSelector } from '../../selectors/confirm-transaction'
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2019-06-18 14:17:14 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
const { metamask: { send, unapprovedTxs }, confirmTransaction } = state
|
|
|
|
const { match: { params = {} } } = ownProps
|
|
|
|
const { id } = params
|
|
|
|
|
|
|
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state)
|
|
|
|
const totalUnconfirmed = unconfirmedTransactions.length
|
|
|
|
const transaction = totalUnconfirmed
|
|
|
|
? unapprovedTxs[id] || unconfirmedTransactions[totalUnconfirmed - 1]
|
|
|
|
: {}
|
2018-06-23 08:52:45 +02:00
|
|
|
|
|
|
|
return {
|
2019-06-18 14:17:14 +02:00
|
|
|
totalUnapprovedCount: totalUnconfirmed,
|
2018-06-23 08:52:45 +02:00
|
|
|
send,
|
2018-06-25 21:06:57 +02:00
|
|
|
confirmTransaction,
|
2019-06-18 14:17:14 +02:00
|
|
|
unapprovedTxs,
|
|
|
|
id,
|
|
|
|
paramsTransactionId: id && String(id),
|
|
|
|
transactionId: transaction.id && String(transaction.id),
|
|
|
|
unconfirmedTransactions,
|
|
|
|
transaction,
|
2018-06-25 21:06:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
2019-06-18 14:17:14 +02:00
|
|
|
setTransactionToConfirm: transactionId => {
|
|
|
|
dispatch(setTransactionToConfirm(transactionId))
|
|
|
|
},
|
2018-07-06 20:58:41 +02:00
|
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
2018-11-13 17:36:52 +01:00
|
|
|
fetchBasicGasAndTimeEstimates: () => dispatch(fetchBasicGasAndTimeEstimates()),
|
2019-06-18 14:17:14 +02:00
|
|
|
getContractMethodData: (data) => dispatch(getContractMethodData(data)),
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2018-06-25 21:06:57 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps),
|
2018-06-23 08:52:45 +02:00
|
|
|
)(ConfirmTransaction)
|