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.
61 lines
2.0 KiB
61 lines
2.0 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { compose } from 'redux';
|
||
|
import { withRouter } from 'react-router-dom';
|
||
6 years ago
|
import {
|
||
|
setTransactionToConfirm,
|
||
|
clearConfirmTransaction,
|
||
4 years ago
|
} from '../../ducks/confirm-transaction/confirm-transaction.duck';
|
||
|
import { isTokenMethodAction } from '../../helpers/utils/transactions.util';
|
||
|
import { fetchBasicGasEstimates } from '../../ducks/gas/gas.duck';
|
||
6 years ago
|
|
||
4 years ago
|
import { getContractMethodData, getTokenParams } from '../../store/actions';
|
||
|
import { unconfirmedTransactionsListSelector } from '../../selectors';
|
||
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||
|
import ConfirmTransaction from './confirm-transaction.component';
|
||
7 years ago
|
|
||
6 years ago
|
const mapStateToProps = (state, ownProps) => {
|
||
5 years ago
|
const {
|
||
4 years ago
|
metamask: { send, unapprovedTxs },
|
||
4 years ago
|
} = state;
|
||
4 years ago
|
const {
|
||
|
match: { params = {} },
|
||
4 years ago
|
} = ownProps;
|
||
|
const { id } = params;
|
||
6 years ago
|
|
||
4 years ago
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state);
|
||
|
const totalUnconfirmed = unconfirmedTransactions.length;
|
||
6 years ago
|
const transaction = totalUnconfirmed
|
||
5 years ago
|
? unapprovedTxs[id] || unconfirmedTransactions[0]
|
||
4 years ago
|
: {};
|
||
4 years ago
|
const { id: transactionId, type } = transaction;
|
||
5 years ago
|
|
||
7 years ago
|
return {
|
||
6 years ago
|
totalUnapprovedCount: totalUnconfirmed,
|
||
7 years ago
|
send,
|
||
6 years ago
|
unapprovedTxs,
|
||
|
id,
|
||
5 years ago
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||
6 years ago
|
paramsTransactionId: id && String(id),
|
||
5 years ago
|
transactionId: transactionId && String(transactionId),
|
||
6 years ago
|
transaction,
|
||
4 years ago
|
isTokenMethodAction: isTokenMethodAction(type),
|
||
4 years ago
|
};
|
||
|
};
|
||
7 years ago
|
|
||
5 years ago
|
const mapDispatchToProps = (dispatch) => {
|
||
7 years ago
|
return {
|
||
5 years ago
|
setTransactionToConfirm: (transactionId) => {
|
||
4 years ago
|
dispatch(setTransactionToConfirm(transactionId));
|
||
6 years ago
|
},
|
||
6 years ago
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
||
4 years ago
|
fetchBasicGasEstimates: () => dispatch(fetchBasicGasEstimates()),
|
||
6 years ago
|
getContractMethodData: (data) => dispatch(getContractMethodData(data)),
|
||
5 years ago
|
getTokenParams: (tokenAddress) => dispatch(getTokenParams(tokenAddress)),
|
||
4 years ago
|
};
|
||
|
};
|
||
7 years ago
|
|
||
|
export default compose(
|
||
|
withRouter,
|
||
7 years ago
|
connect(mapStateToProps, mapDispatchToProps),
|
||
4 years ago
|
)(ConfirmTransaction);
|