-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement EIP712 RPC Wrapper Methods and getEncodedEip712Data
Util
#6286
Conversation
Bundle StatsHey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 4.x #6286 +/- ##
==========================================
+ Coverage 88.72% 88.88% +0.16%
==========================================
Files 198 199 +1
Lines 7609 7685 +76
Branches 2094 2110 +16
==========================================
+ Hits 6751 6831 +80
+ Misses 858 854 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Deploying with Cloudflare Pages
|
This is the only documented limitation of the EIP-712 library I copied code from. I've tested it without implementation and it still throws an error, but I've also test with ethers and it throws an error for the same reason: eip712-ethers/node_modules/@ethersproject/logger/lib/index.js:238
var error = new Error(message);
^
Error: circular type reference to "Mail" (argument="types", value={"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"},{"name":"replyTo","type":"Mail"}]}, code=INVALID_ARGUMENT, version=hash/5.7.0)
at Logger.makeError (eip712-ethers/node_modules/@ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (eip712-ethers/node_modules/@ethersproject/logger/lib/index.js:247:20)
at Logger.throwArgumentError (eip712-ethers/node_modules/@ethersproject/logger/lib/index.js:250:21)
at eip712-ethers/node_modules/@ethersproject/hash/lib/typed-data.js:199:28
at Array.forEach (<anonymous>)
at _loop_1 (eip712-ethers/node_modules/@ethersproject/hash/lib/typed-data.js:190:27)
at new TypedDataEncoder (eip712-ethers/node_modules/@ethersproject/hash/lib/typed-data.js:215:13)
at TypedDataEncoder.from (eip712-ethers/node_modules/@ethersproject/hash/lib/typed-data.js:358:16)
at TypedDataEncoder.encode (eip712-ethers/node_modules/@ethersproject/hash/lib/typed-data.js:384:30)
at eip712-ethers/index.js:118:49 {
reason: 'circular type reference to "Mail"',
code: 'INVALID_ARGUMENT',
argument: 'types',
value: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' }
],
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' }
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' },
{ name: 'replyTo', type: 'Mail' }
]
}
}
Node.js v18.16.0 |
packages/web3-rpc-methods/test/unit/eth_rpc_methods/sign_typed_data.test.ts
Outdated
Show resolved
Hide resolved
getEncodedEip712Message
UtilgetEncodedEip712Data
Util
Failing |
packages/web3-eth-abi/src/eip_712.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has a couple places where new Error('...')
is used, I've opted not to wrap these as Web3Error
s as done in the rest of the codebase. I'm choosing to do this so there's some flexibility when this code gets refactored when we implement on own ABI encoder to replace the use of ethers'. I've created #6291 to track this
…eb3#6286) * Add Eip712TypeDetails and Eip712TypedData interfaces * Init signTypedData rpc method and test * Init getEncodedEip712Message and test * Init signTypedData methods and tests * Add return type to signTypedData * Add eth_signTypedData and eth_signTypedData_v4 to web3_eth_execution_api * Add itIf to signTypedData integration test * Replace use of Buffer.from with bytesToHex * Add additional test cases * Rename getEncodedEip712Message to getEncodedEip712Data * Update CHANGELOGs and renamed some files * Update packages/web3-rpc-methods/test/unit/eth_rpc_methods/sign_typed_data.test.ts
…eb3#6286) * Add Eip712TypeDetails and Eip712TypedData interfaces * Init signTypedData rpc method and test * Init getEncodedEip712Message and test * Init signTypedData methods and tests * Add return type to signTypedData * Add eth_signTypedData and eth_signTypedData_v4 to web3_eth_execution_api * Add itIf to signTypedData integration test * Replace use of Buffer.from with bytesToHex * Add additional test cases * Rename getEncodedEip712Message to getEncodedEip712Data * Update CHANGELOGs and renamed some files * Update packages/web3-rpc-methods/test/unit/eth_rpc_methods/sign_typed_data.test.ts
This PR
eth_signTypedData
andeth_signTypedData_v4
toweb3-eth
andweb3-rpc-methods
packagesgetEncodedEip712Message
was added toweb3-eth-abi
4.x
signTypedData
RPC call incase their connected provider doesn't support it (e.g. Geth). The util method requires the use of an abi encoder, so it's using the already importedethersAbiCoder
fromethers_abi_coder.js
inweb3-eth-abi
package. This util methods API is pretty basic so it shouldn't be a problem avoiding a breaking change when web3.js migrates from using Ether's ABI encodercloses #5927