2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { compose } from 'redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2020-02-19 19:24:16 +01:00
|
|
|
|
|
|
|
import {
|
2020-03-06 22:34:56 +01:00
|
|
|
goHome,
|
|
|
|
decryptMsg,
|
|
|
|
cancelDecryptMsg,
|
|
|
|
decryptMsgInline,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../store/actions';
|
2020-03-06 22:34:56 +01:00
|
|
|
import {
|
|
|
|
getTargetAccountWithSendEtherInfo,
|
2021-02-17 21:47:01 +01:00
|
|
|
unconfirmedTransactionsListSelector,
|
2020-02-19 19:24:16 +01:00
|
|
|
conversionRateSelector,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../selectors';
|
|
|
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
|
|
|
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
|
|
|
import ConfirmDecryptMessage from './confirm-decrypt-message.component';
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2020-08-19 18:27:05 +02:00
|
|
|
const {
|
2020-02-19 19:24:16 +01:00
|
|
|
metamask: { domainMetadata = {} },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = state;
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2021-02-17 21:47:01 +01:00
|
|
|
const unconfirmedTransactions = unconfirmedTransactionsListSelector(state);
|
|
|
|
|
|
|
|
const txData = unconfirmedTransactions[0];
|
2020-02-19 19:24:16 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
msgParams: { from },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = txData;
|
2020-03-06 22:34:56 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const fromAccount = getTargetAccountWithSendEtherInfo(state, from);
|
2020-03-06 22:34:56 +01:00
|
|
|
|
2020-02-19 19:24:16 +01:00
|
|
|
return {
|
2020-08-19 18:27:05 +02:00
|
|
|
txData,
|
2020-03-06 22:34:56 +01:00
|
|
|
domainMetadata,
|
|
|
|
fromAccount,
|
2020-02-19 19:24:16 +01:00
|
|
|
requester: null,
|
|
|
|
requesterAddress: null,
|
|
|
|
conversionRate: conversionRateSelector(state),
|
2020-06-01 19:54:32 +02:00
|
|
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapDispatchToProps(dispatch) {
|
2020-02-19 19:24:16 +01:00
|
|
|
return {
|
|
|
|
goHome: () => dispatch(goHome()),
|
|
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
|
|
|
decryptMessage: (msgData, event) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const params = msgData.msgParams;
|
|
|
|
params.metamaskId = msgData.id;
|
|
|
|
event.stopPropagation(event);
|
|
|
|
return dispatch(decryptMsg(params));
|
2020-02-19 19:24:16 +01:00
|
|
|
},
|
|
|
|
cancelDecryptMessage: (msgData, event) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
event.stopPropagation(event);
|
|
|
|
return dispatch(cancelDecryptMsg(msgData));
|
2020-02-19 19:24:16 +01:00
|
|
|
},
|
|
|
|
decryptMessageInline: (msgData, event) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const params = msgData.msgParams;
|
|
|
|
params.metamaskId = msgData.id;
|
|
|
|
event.stopPropagation(event);
|
|
|
|
return dispatch(decryptMsgInline(params));
|
2020-02-19 19:24:16 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-02-19 19:24:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2020-07-14 17:20:41 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(ConfirmDecryptMessage);
|