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.
69 lines
1.6 KiB
69 lines
1.6 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck';
|
||
|
import { accountsWithSendEtherInfoSelector } from '../../../selectors';
|
||
|
import { getAccountByAddress } from '../../../helpers/utils/util';
|
||
4 years ago
|
import { MESSAGE_TYPE } from '../../../../shared/constants/app';
|
||
4 years ago
|
import SignatureRequest from './signature-request.component';
|
||
5 years ago
|
|
||
4 years ago
|
function mapStateToProps(state) {
|
||
5 years ago
|
return {
|
||
5 years ago
|
// not forwarded to component
|
||
|
allAccounts: accountsWithSendEtherInfoSelector(state),
|
||
4 years ago
|
};
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
function mapDispatchToProps(dispatch) {
|
||
5 years ago
|
return {
|
||
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
||
4 years ago
|
};
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
||
4 years ago
|
const { allAccounts } = stateProps;
|
||
5 years ago
|
const {
|
||
|
signPersonalMessage,
|
||
|
signTypedMessage,
|
||
|
cancelPersonalMessage,
|
||
|
cancelTypedMessage,
|
||
|
signMessage,
|
||
|
cancelMessage,
|
||
|
txData,
|
||
4 years ago
|
} = ownProps;
|
||
5 years ago
|
|
||
4 years ago
|
const {
|
||
|
type,
|
||
|
msgParams: { from },
|
||
4 years ago
|
} = txData;
|
||
5 years ago
|
|
||
4 years ago
|
const fromAccount = getAccountByAddress(allAccounts, from);
|
||
5 years ago
|
|
||
4 years ago
|
let cancel;
|
||
|
let sign;
|
||
5 years ago
|
|
||
5 years ago
|
if (type === MESSAGE_TYPE.PERSONAL_SIGN) {
|
||
4 years ago
|
cancel = cancelPersonalMessage;
|
||
|
sign = signPersonalMessage;
|
||
5 years ago
|
} else if (type === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA) {
|
||
4 years ago
|
cancel = cancelTypedMessage;
|
||
|
sign = signTypedMessage;
|
||
5 years ago
|
} else if (type === MESSAGE_TYPE.ETH_SIGN) {
|
||
4 years ago
|
cancel = cancelMessage;
|
||
|
sign = signMessage;
|
||
5 years ago
|
}
|
||
|
|
||
|
return {
|
||
|
...ownProps,
|
||
5 years ago
|
...dispatchProps,
|
||
|
fromAccount,
|
||
5 years ago
|
txData,
|
||
|
cancel,
|
||
|
sign,
|
||
4 years ago
|
};
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
export default connect(
|
||
|
mapStateToProps,
|
||
|
mapDispatchToProps,
|
||
|
mergeProps,
|
||
4 years ago
|
)(SignatureRequest);
|