-
Notifications
You must be signed in to change notification settings - Fork 150
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
Support eth_signTypedData #136
Comments
The 0x team implements this logic in their subprovider: https://github.com/0xProject/0x-monorepo/blob/master/packages/subproviders/src/subproviders/private_key_wallet.ts#L99 They intercept the call and serialize the typed data so it can be sent through |
Here is an example object: 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: 'wallet', type: 'address' }
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person' },
{ name: 'contents', type: 'string' }
],
},
primaryType: 'Mail',
domain: {
name: 'Ether Mail',
version: '1',
chainId: 1,
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
message: {
from: {
name: 'Cow',
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
},
to: {
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
},
contents: 'Hello, Bob!',
},
}; From: https://github.com/ethereum/EIPs/blob/master/assets/eip-712/Example.js#L5 |
A simple test of the functionality can be done with the following bash command: curl -X POST --url http://127.0.0.1:1248 --data '{"jsonrpc":"2.0","method":"eth_signTypedData","params":["0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", {"types":{"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"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}],"id":1}' |
This is how it looks like in https://github.com/MetaMask/metamask-extension/: From here: https://app.kovan.radarrelay.com/ZRX/WETH The rendered JSON is not interactable. |
Real-world example of EIP-712: https://dicether.com/ |
It seems like eth_signTypedData is not available in Trezor nor Ledger at the moment. It also doesn't work in MetaMask:
There is a WIP pull-request in the Trezor-firmware repo: And a stale issue in the Ledger repo: So I think, we can close this issue for now since #183 add support for hot wallets and just wait for the native hardware wallet support. |
@schmidsi the latest trezor update has EIP712 which implemented eth_signTypedData, but frame doesn't recognize it, are there ways we can help test/debug? |
Similar to #129 , there is another JSON RPC command that needs to be intercepted:
eth_signTypedData
as described in: EIP-712The text was updated successfully, but these errors were encountered: