mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
3747ace06b
* make use of getTokenStandardAndDetails method exposed on assetsContractController to determine how to represent the contract being interacted with in token contract method calls
65 lines
2.0 KiB
JavaScript
65 lines
2.0 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 } 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 totalUnconfirmed = unconfirmedTransactions.length;
|
|
const transaction = totalUnconfirmed
|
|
? unapprovedTxs[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);
|