mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 12:56:01 +01:00
a323a5fe59
* Background clears confirmations on popup close * [WIP] Remove clearing confirmations through UI * Confirmations are now rejected instead of cleared * Erased commented out code * Fix linter errors * Changes after code review * Moved metrics events from onWindowUnload to background * PR review fixes * Added abillity to add reason to rejection of messages * Fix prettier * Added type metrics event to signature cancel * Fix test * The uncofirmed transactions are now cleared even if Metamask is locked
80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
accountsWithSendEtherInfoSelector,
|
|
doesAddressRequireLedgerHidConnection,
|
|
} from '../../../selectors';
|
|
import { isAddressLedger } from '../../../ducks/metamask/metamask';
|
|
import { getAccountByAddress } from '../../../helpers/utils/util';
|
|
import { MESSAGE_TYPE } from '../../../../shared/constants/app';
|
|
import SignatureRequest from './signature-request.component';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const { txData } = ownProps;
|
|
const {
|
|
msgParams: { from },
|
|
} = txData;
|
|
const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(
|
|
state,
|
|
from,
|
|
);
|
|
const isLedgerWallet = isAddressLedger(state, from);
|
|
|
|
return {
|
|
isLedgerWallet,
|
|
hardwareWalletRequiresConnection,
|
|
// not forwarded to component
|
|
allAccounts: accountsWithSendEtherInfoSelector(state),
|
|
};
|
|
}
|
|
|
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
|
const {
|
|
allAccounts,
|
|
isLedgerWallet,
|
|
hardwareWalletRequiresConnection,
|
|
} = stateProps;
|
|
const {
|
|
signPersonalMessage,
|
|
signTypedMessage,
|
|
cancelPersonalMessage,
|
|
cancelTypedMessage,
|
|
signMessage,
|
|
cancelMessage,
|
|
txData,
|
|
} = ownProps;
|
|
|
|
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,
|
|
...dispatchProps,
|
|
fromAccount,
|
|
txData,
|
|
cancel,
|
|
sign,
|
|
isLedgerWallet,
|
|
hardwareWalletRequiresConnection,
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps, null, mergeProps)(SignatureRequest);
|