-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@embark/rpc-manager): fix eth_signTypedData method + tests
The signTypedData rpc method was broken, because it didn't check for the node accounts, meaning that if you wanted to sign with a node account that was unlocked, like in the tests, it would throw
- Loading branch information
1 parent
67581ce
commit b29998e
Showing
5 changed files
with
147 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Web3 from "web3"; | ||
|
||
export function isNodeAccount(nodeAccounts, fromAddr) { | ||
const account = nodeAccounts.find(acc => ( | ||
Web3.utils.toChecksumAddress(acc) === | ||
Web3.utils.toChecksumAddress(fromAddr) | ||
)); | ||
return !!account; | ||
} | ||
|
||
export function handleSignRequest(nodeAccounts, params, callback) { | ||
try { | ||
const [fromAddr] = params.request.params; | ||
|
||
// If it's not a node account, we don't send it to the Node as it won't understand it | ||
if (!isNodeAccount(nodeAccounts, fromAddr)) { | ||
params.sendToNode = false; | ||
} | ||
} catch (err) { | ||
return callback(err); | ||
} | ||
callback(null, params); | ||
} |