2018-06-23 08:52:45 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import ConfirmTransactionSwitch from './confirm-transaction-switch.component'
|
2020-05-02 21:41:17 +02:00
|
|
|
import { unconfirmedTransactionsListSelector } from '../../selectors'
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2019-06-18 14:17:14 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
const { metamask: { unapprovedTxs } } = state
|
|
|
|
const { match: { params = {}, url } } = ownProps
|
|
|
|
const urlId = url && url.match(/\d+/) && url.match(/\d+/)[0]
|
|
|
|
const { id: paramsId } = params
|
|
|
|
const transactionId = paramsId || urlId
|
|
|
|
|
|
|
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state)
|
|
|
|
const totalUnconfirmed = unconfirmedTransactions.length
|
|
|
|
const transaction = totalUnconfirmed
|
2020-01-10 15:34:02 +01:00
|
|
|
? unapprovedTxs[transactionId] || unconfirmedTransactions[0]
|
2019-06-18 14:17:14 +02:00
|
|
|
: {}
|
2018-06-25 21:06:57 +02:00
|
|
|
|
2018-06-23 08:52:45 +02:00
|
|
|
return {
|
2019-06-18 14:17:14 +02:00
|
|
|
txData: transaction,
|
2018-06-23 08:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(ConfirmTransactionSwitch)
|