1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/ui/app/pages/confirm-transaction/confirm-transaction.container.js

61 lines
2.0 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router-dom';
2018-07-06 20:58:41 +02:00
import {
setTransactionToConfirm,
clearConfirmTransaction,
} from '../../ducks/confirm-transaction/confirm-transaction.duck';
import { isTokenMethodAction } from '../../helpers/utils/transactions.util';
import { fetchBasicGasEstimates } from '../../ducks/gas/gas.duck';
import { getContractMethodData, getTokenParams } from '../../store/actions';
import { unconfirmedTransactionsListSelector } from '../../selectors';
import { getMostRecentOverviewPage } from '../../ducks/history/history';
import ConfirmTransaction from './confirm-transaction.component';
const mapStateToProps = (state, ownProps) => {
const {
2020-11-03 00:41:28 +01:00
metamask: { send, unapprovedTxs },
} = state;
2020-11-03 00:41:28 +01:00
const {
match: { params = {} },
} = ownProps;
const { id } = params;
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state);
const totalUnconfirmed = unconfirmedTransactions.length;
const transaction = totalUnconfirmed
? unapprovedTxs[id] || unconfirmedTransactions[0]
: {};
const { id: transactionId, type } = transaction;
return {
totalUnapprovedCount: totalUnconfirmed,
send,
unapprovedTxs,
id,
mostRecentOverviewPage: getMostRecentOverviewPage(state),
paramsTransactionId: id && String(id),
transactionId: transactionId && String(transactionId),
transaction,
isTokenMethodAction: isTokenMethodAction(type),
};
};
2020-02-15 21:34:12 +01:00
const mapDispatchToProps = (dispatch) => {
return {
2020-02-15 21:34:12 +01:00
setTransactionToConfirm: (transactionId) => {
dispatch(setTransactionToConfirm(transactionId));
},
2018-07-06 20:58:41 +02:00
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
fetchBasicGasEstimates: () => dispatch(fetchBasicGasEstimates()),
getContractMethodData: (data) => dispatch(getContractMethodData(data)),
getTokenParams: (tokenAddress) => dispatch(getTokenParams(tokenAddress)),
};
};
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(ConfirmTransaction);