|
|
|
@ -50,6 +50,7 @@ const seedPhraseVerifier = require('./lib/seed-phrase-verifier') |
|
|
|
|
const log = require('loglevel') |
|
|
|
|
const TrezorKeyring = require('eth-trezor-keyring') |
|
|
|
|
const LedgerBridgeKeyring = require('eth-ledger-bridge-keyring') |
|
|
|
|
const HW_WALLETS_KEYRINGS = [TrezorKeyring.type, LedgerBridgeKeyring.type] |
|
|
|
|
const EthQuery = require('eth-query') |
|
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
|
const sigUtil = require('eth-sig-util') |
|
|
|
@ -1025,9 +1026,12 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
const cleanMsgParams = await this.typedMessageManager.approveMessage(msgParams) |
|
|
|
|
const address = sigUtil.normalize(cleanMsgParams.from) |
|
|
|
|
const keyring = await this.keyringController.getKeyringForAccount(address) |
|
|
|
|
let signature |
|
|
|
|
// HW Wallet keyrings don't expose private keys
|
|
|
|
|
// so we need to handle it separately
|
|
|
|
|
if (!HW_WALLETS_KEYRINGS.includes(keyring.type)) { |
|
|
|
|
const wallet = keyring._getWalletForAccount(address) |
|
|
|
|
const privKey = ethUtil.toBuffer(wallet.getPrivateKey()) |
|
|
|
|
let signature |
|
|
|
|
switch (version) { |
|
|
|
|
case 'V1': |
|
|
|
|
signature = sigUtil.signTypedDataLegacy(privKey, { data: cleanMsgParams.data }) |
|
|
|
@ -1036,6 +1040,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
signature = sigUtil.signTypedData(privKey, { data: JSON.parse(cleanMsgParams.data) }) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
signature = await keyring.signTypedData(address, cleanMsgParams.data) |
|
|
|
|
} |
|
|
|
|
this.typedMessageManager.setMsgStatusSigned(msgId, signature) |
|
|
|
|
return this.getState() |
|
|
|
|
} catch (error) { |
|
|
|
|