2018-06-23 08:52:45 +02:00
|
|
|
import { connect } from 'react-redux'
|
2020-05-02 21:41:17 +02:00
|
|
|
import { unconfirmedTransactionsListSelector } from '../../selectors'
|
2020-08-18 21:18:25 +02:00
|
|
|
import ConfirmTransactionSwitch from './confirm-transaction-switch.component'
|
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
|
2020-08-14 13:48:42 +02:00
|
|
|
const urlId = url && url.match(/\d+/u) && url.match(/\d+/u)[0]
|
2019-06-18 14:17:14 +02:00
|
|
|
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)
|