mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
consider hw wallets
This commit is contained in:
parent
a7b3750a3e
commit
3abf9ec7db
@ -1021,13 +1021,17 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
log.info('MetaMaskController - eth_signTypedData')
|
||||
const msgId = msgParams.metamaskId
|
||||
const version = msgParams.version
|
||||
const HW_WALLETS_KEYRINGS = [TrezorKeyring.type, LedgerBridgeKeyring.type]
|
||||
try {
|
||||
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.indexOf(keyring.type) === -1) {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user