2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { compose } from 'redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2019-11-20 23:03:49 +01:00
|
|
|
|
2021-04-28 21:53:59 +02:00
|
|
|
import { MESSAGE_TYPE } from '../../../../shared/constants/app';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { goHome } from '../../../store/actions';
|
2019-11-20 23:03:49 +01:00
|
|
|
import {
|
2020-03-06 22:34:56 +01:00
|
|
|
accountsWithSendEtherInfoSelector,
|
2019-11-20 23:03:49 +01:00
|
|
|
conversionRateSelector,
|
2021-01-28 18:59:25 +01:00
|
|
|
getDomainMetadata,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../selectors';
|
|
|
|
import { getAccountByAddress } from '../../../helpers/utils/util';
|
|
|
|
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck';
|
|
|
|
import { getMostRecentOverviewPage } from '../../../ducks/history/history';
|
|
|
|
import SignatureRequestOriginal from './signature-request-original.component';
|
2019-11-20 23:03:49 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2019-11-20 23:03:49 +01:00
|
|
|
return {
|
|
|
|
requester: null,
|
|
|
|
requesterAddress: null,
|
|
|
|
conversionRate: conversionRateSelector(state),
|
2020-06-01 19:54:32 +02:00
|
|
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
2020-03-06 22:34:56 +01:00
|
|
|
// not passed to component
|
|
|
|
allAccounts: accountsWithSendEtherInfoSelector(state),
|
2021-01-28 18:59:25 +01:00
|
|
|
domainMetadata: getDomainMetadata(state),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-20 23:03:49 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapDispatchToProps(dispatch) {
|
2019-11-20 23:03:49 +01:00
|
|
|
return {
|
2020-03-06 22:34:56 +01:00
|
|
|
goHome: () => dispatch(goHome()),
|
2019-11-20 23:03:49 +01:00
|
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-20 23:03:49 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
2019-11-20 23:03:49 +01:00
|
|
|
const {
|
|
|
|
signPersonalMessage,
|
|
|
|
signTypedMessage,
|
|
|
|
cancelPersonalMessage,
|
|
|
|
cancelTypedMessage,
|
|
|
|
signMessage,
|
|
|
|
cancelMessage,
|
|
|
|
txData,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = ownProps;
|
2019-11-20 23:03:49 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const { allAccounts, ...otherStateProps } = stateProps;
|
2020-03-06 22:34:56 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
type,
|
|
|
|
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 = getAccountByAddress(allAccounts, from);
|
2019-11-20 23:03:49 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
let cancel;
|
|
|
|
let sign;
|
2020-06-04 21:22:45 +02:00
|
|
|
if (type === MESSAGE_TYPE.PERSONAL_SIGN) {
|
2021-02-04 19:15:23 +01:00
|
|
|
cancel = cancelPersonalMessage;
|
|
|
|
sign = signPersonalMessage;
|
2020-06-04 21:22:45 +02:00
|
|
|
} else if (type === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA) {
|
2021-02-04 19:15:23 +01:00
|
|
|
cancel = cancelTypedMessage;
|
|
|
|
sign = signTypedMessage;
|
2020-06-04 21:22:45 +02:00
|
|
|
} else if (type === MESSAGE_TYPE.ETH_SIGN) {
|
2021-02-04 19:15:23 +01:00
|
|
|
cancel = cancelMessage;
|
|
|
|
sign = signMessage;
|
2019-11-20 23:03:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...ownProps,
|
2021-02-01 19:02:20 +01:00
|
|
|
...otherStateProps,
|
2019-11-20 23:03:49 +01:00
|
|
|
...dispatchProps,
|
2020-03-06 22:34:56 +01:00
|
|
|
fromAccount,
|
2019-11-20 23:03:49 +01:00
|
|
|
txData,
|
|
|
|
cancel,
|
|
|
|
sign,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-20 23:03:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2020-07-14 17:20:41 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps, mergeProps),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(SignatureRequestOriginal);
|