Skip to content
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

Closed
schmidsi opened this issue Feb 13, 2019 · 8 comments
Closed

Support eth_signTypedData #136

schmidsi opened this issue Feb 13, 2019 · 8 comments
Milestone

Comments

@schmidsi
Copy link
Contributor

schmidsi commented Feb 13, 2019

Similar to #129 , there is another JSON RPC command that needs to be intercepted: eth_signTypedData as described in: EIP-712

@schmidsi
Copy link
Contributor Author

screen shot 2019-02-13 at 16 53 35

I think this screenshot actually makes the point ;)

@schmidsi
Copy link
Contributor Author

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 eth_signMessage finally.

@schmidsi
Copy link
Contributor Author

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

@schmidsi
Copy link
Contributor Author

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}'

@floating floating added this to the v0.3.0 milestone Jul 30, 2019
@schmidsi
Copy link
Contributor Author

This is how it looks like in https://github.com/MetaMask/metamask-extension/:

Screenshot 2019-08-13 at 11 49 17

From here: https://app.kovan.radarrelay.com/ZRX/WETH

The rendered JSON is not interactable.

@schmidsi
Copy link
Contributor Author

Real-world example of EIP-712: https://dicether.com/

@schmidsi
Copy link
Contributor Author

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:
trezor/trezor-firmware#148

And a stale issue in the Ledger repo:
LedgerHQ/ledgerjs#86

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.

@mohamedmansour
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants