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

update eth-sig-util signTypedData call #460

Merged
merged 2 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ StateManager.prototype.signTypedData = function(address, typedDataToSign) {
throw new Error("cannot sign data; message missing");
}

return sigUtil.signTypedData(account.secretKey, { data: typedDataToSign });
return sigUtil.signTypedData_v4(account.secretKey, { data: typedDataToSign });
};

StateManager.prototype.printTransactionReceipt = function(txHash, error, callback) {
Expand Down
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clone": "2.1.2",
"debug": "3.2.6",
"encoding-down": "5.0.4",
"eth-sig-util": "2.2.0",
"eth-sig-util": "2.3.0",
"ethereumjs-abi": "0.6.7",
"ethereumjs-account": "3.0.0",
"ethereumjs-block": "2.2.0",
Expand Down
56 changes: 56 additions & 0 deletions test/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,62 @@ const tests = function(web3) {
);
});

it("should produce a signature whose signer can be recovered (for arrays)", async function() {
const typedData = {
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" }
],
Person: [{ name: "name", type: "string" }, { name: "wallets", type: "address[]" }],
Mail: [
{ name: "from", type: "Person" },
{ name: "to", type: "Person[]" },
{ name: "contents", type: "string" }
],
Group: [{ name: "name", type: "string" }, { name: "members", type: "Person[]" }]
},
domain: {
name: "Ether Mail",
version: "1",
chainId: 1,
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
},
primaryType: "Mail",
message: {
from: {
name: "Cow",
wallets: ["0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", "0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"]
},
to: [
{
name: "Bob",
wallets: [
"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57",
"0xB0B0b0b0b0b0B000000000000000000000000000"
]
}
],
contents: "Hello, Bob!"
}
};

const response = await pify(signingWeb3.currentProvider.send)({
jsonrpc: "2.0",
method: "eth_signTypedData",
params: [accounts[0], typedData],
id: new Date().getTime()
});
assert.strictEqual(
response.result,
"0x65cbd956f2fae28a601bebc9b906cea0191744bd4c4247bcd27cd08f8eb6b71c" +
"78efdf7a31dc9abee78f492292721f362d296cf86b4538e07b51303b67f749061b"
);
});

after("shutdown", async function() {
let provider = signingWeb3._provider;
signingWeb3.setProvider();
Expand Down