Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Add support for eth_signTypedData v3 & v4 (#333)
Browse files Browse the repository at this point in the history
* Add support for newer eth_signTypedData methods

* Handle different order of parameters
  • Loading branch information
brunobar79 authored Apr 15, 2020
1 parent 55b882b commit 58f5a0e
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions subproviders/hooked-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module.exports = HookedWalletSubprovider
// eth_sendTransaction
// eth_sign
// eth_signTypedData
// eth_signTypedData_v3
// eth_signTypedData_v4
// personal_sign
// eth_decryptMessage
// encryption_public_key
Expand Down Expand Up @@ -253,19 +255,32 @@ HookedWalletSubprovider.prototype.handleRequest = function(payload, next, end){
})()

case 'eth_signTypedData':
// process normally
message = payload.params[0]
address = payload.params[1]
extraParams = payload.params[2] || {}
msgParams = extend(extraParams, {
from: address,
data: message,
})
waterfall([
(cb) => self.validateTypedMessage(msgParams, cb),
(cb) => self.processTypedMessage(msgParams, cb),
], end)
return
case 'eth_signTypedData_v3':
case 'eth_signTypedData_v4':
return (function(){
// process normally

const first = payload.params[0]
const second = payload.params[1]

if (resemblesAddress(first)) {
address = first
message = second
} else {
message = first
address = second
}

extraParams = payload.params[2] || {}
msgParams = extend(extraParams, {
from: address,
data: message,
})
waterfall([
(cb) => self.validateTypedMessage(msgParams, cb),
(cb) => self.processTypedMessage(msgParams, cb),
], end)
})()

case 'parity_postTransaction':
txParams = payload.params[0]
Expand Down

0 comments on commit 58f5a0e

Please sign in to comment.