1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/pages/confirm-transaction/confirm-transaction.container.js
Vladimir Saric 8aa3263b82
Added navigation between multiple sign prompts and reject all sign prompts (#17093)
* Fixed navigation through multiple unapproved transactions for ERC20 tokens

* Fixed tx details activity-log currency

* Fixed e2e test failure

* Added navigation between multiple sign prompts and reject all sign prompts

* Resolving conflicts

* Creating SignatureRequestNavigation component and extracting the UI rendering part into a single component

* Fixing e2e tests and updating snapshot

* Using single component for navigation which shows both messages and transactions requests

* Fixing test-unit-jest-main

* Added more unit tests

* Fixing test-storybook

* Fixing test-storybook

---------

Co-authored-by: Filip Sekulic <filip.sekulic@consensys.net>
2023-01-31 16:29:23 +01:00

69 lines
2.1 KiB
JavaScript

import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router-dom';
import {
setTransactionToConfirm,
clearConfirmTransaction,
} from '../../ducks/confirm-transaction/confirm-transaction.duck';
import { isTokenMethodAction } from '../../helpers/utils/transactions.util';
import {
getContractMethodData,
setDefaultHomeActiveTabName,
} from '../../store/actions';
import {
unconfirmedTransactionsListSelector,
unconfirmedTransactionsHashSelector,
} from '../../selectors';
import { getMostRecentOverviewPage } from '../../ducks/history/history';
import { getSendTo } from '../../ducks/send';
import ConfirmTransaction from './confirm-transaction.component';
const mapStateToProps = (state, ownProps) => {
const {
metamask: { unapprovedTxs },
} = state;
const {
match: { params = {} },
} = ownProps;
const { id } = params;
const sendTo = getSendTo(state);
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state);
const unconfirmedMessages = unconfirmedTransactionsHashSelector(state);
const totalUnconfirmed = unconfirmedTransactions.length;
const transaction = totalUnconfirmed
? unapprovedTxs[id] || unconfirmedMessages[id] || unconfirmedTransactions[0]
: {};
const { id: transactionId, type } = transaction;
return {
totalUnapprovedCount: totalUnconfirmed,
sendTo,
unapprovedTxs,
id,
mostRecentOverviewPage: getMostRecentOverviewPage(state),
paramsTransactionId: id && String(id),
transactionId: transactionId && String(transactionId),
transaction,
isTokenMethodAction: isTokenMethodAction(type),
};
};
const mapDispatchToProps = (dispatch) => {
return {
setTransactionToConfirm: (transactionId) => {
dispatch(setTransactionToConfirm(transactionId));
},
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
getContractMethodData: (data) => dispatch(getContractMethodData(data)),
setDefaultHomeActiveTabName: (tabName) =>
dispatch(setDefaultHomeActiveTabName(tabName)),
};
};
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(ConfirmTransaction);