mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
This reverts commit f09ab8889148c406551dea1643966e3331fde4aa, reversing changes made to effc761e0ee4ea7ffb77f275b5ed650a7098d6f8. This is being temporarily reverted to make it easier to release an urgent fix for v10.15.1.
102 lines
2.6 KiB
JavaScript
102 lines
2.6 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { compose } from 'redux';
|
|
import { withRouter } from 'react-router-dom';
|
|
|
|
import { MESSAGE_TYPE } from '../../../../shared/constants/app';
|
|
import { goHome } from '../../../store/actions';
|
|
import {
|
|
accountsWithSendEtherInfoSelector,
|
|
conversionRateSelector,
|
|
getSubjectMetadata,
|
|
doesAddressRequireLedgerHidConnection,
|
|
} from '../../../selectors';
|
|
import { getAccountByAddress } from '../../../helpers/utils/util';
|
|
import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck';
|
|
import { getMostRecentOverviewPage } from '../../../ducks/history/history';
|
|
import {
|
|
isAddressLedger,
|
|
getNativeCurrency,
|
|
} from '../../../ducks/metamask/metamask';
|
|
import SignatureRequestOriginal from './signature-request-original.component';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const {
|
|
msgParams: { from },
|
|
} = ownProps.txData;
|
|
|
|
const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(
|
|
state,
|
|
from,
|
|
);
|
|
const isLedgerWallet = isAddressLedger(state, from);
|
|
|
|
return {
|
|
requester: null,
|
|
requesterAddress: null,
|
|
conversionRate: conversionRateSelector(state),
|
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
|
hardwareWalletRequiresConnection,
|
|
isLedgerWallet,
|
|
nativeCurrency: getNativeCurrency(state),
|
|
// not passed to component
|
|
allAccounts: accountsWithSendEtherInfoSelector(state),
|
|
subjectMetadata: getSubjectMetadata(state),
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
goHome: () => dispatch(goHome()),
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
|
};
|
|
}
|
|
|
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
|
const {
|
|
signPersonalMessage,
|
|
signTypedMessage,
|
|
cancelPersonalMessage,
|
|
cancelTypedMessage,
|
|
signMessage,
|
|
cancelMessage,
|
|
txData,
|
|
} = ownProps;
|
|
|
|
const { allAccounts, ...otherStateProps } = stateProps;
|
|
|
|
const {
|
|
type,
|
|
msgParams: { from },
|
|
} = txData;
|
|
|
|
const fromAccount = getAccountByAddress(allAccounts, from);
|
|
|
|
let cancel;
|
|
let sign;
|
|
if (type === MESSAGE_TYPE.PERSONAL_SIGN) {
|
|
cancel = cancelPersonalMessage;
|
|
sign = signPersonalMessage;
|
|
} else if (type === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA) {
|
|
cancel = cancelTypedMessage;
|
|
sign = signTypedMessage;
|
|
} else if (type === MESSAGE_TYPE.ETH_SIGN) {
|
|
cancel = cancelMessage;
|
|
sign = signMessage;
|
|
}
|
|
|
|
return {
|
|
...ownProps,
|
|
...otherStateProps,
|
|
...dispatchProps,
|
|
fromAccount,
|
|
txData,
|
|
cancel,
|
|
sign,
|
|
};
|
|
}
|
|
|
|
export default compose(
|
|
withRouter,
|
|
connect(mapStateToProps, mapDispatchToProps, mergeProps),
|
|
)(SignatureRequestOriginal);
|