You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
856 B
28 lines
856 B
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { unconfirmedTransactionsListSelector } from '../../selectors';
|
||
|
import ConfirmTransactionSwitch from './confirm-transaction-switch.component';
|
||
7 years ago
|
|
||
6 years ago
|
const mapStateToProps = (state, ownProps) => {
|
||
4 years ago
|
const {
|
||
|
metamask: { unapprovedTxs },
|
||
4 years ago
|
} = state;
|
||
4 years ago
|
const {
|
||
|
match: { params = {}, url },
|
||
4 years ago
|
} = ownProps;
|
||
|
const urlId = url?.match(/\d+/u) && url?.match(/\d+/u)[0];
|
||
|
const { id: paramsId } = params;
|
||
|
const transactionId = paramsId || urlId;
|
||
6 years ago
|
|
||
4 years ago
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state);
|
||
|
const totalUnconfirmed = unconfirmedTransactions.length;
|
||
6 years ago
|
const transaction = totalUnconfirmed
|
||
5 years ago
|
? unapprovedTxs[transactionId] || unconfirmedTransactions[0]
|
||
4 years ago
|
: {};
|
||
7 years ago
|
|
||
7 years ago
|
return {
|
||
6 years ago
|
txData: transaction,
|
||
4 years ago
|
};
|
||
|
};
|
||
7 years ago
|
|
||
4 years ago
|
export default connect(mapStateToProps)(ConfirmTransactionSwitch);
|