From 455dfd97bbcec86ed1e992b04d9e1c9bc31e1ea1 Mon Sep 17 00:00:00 2001 From: Bhargavasomu Date: Mon, 8 Apr 2019 21:15:42 +0530 Subject: [PATCH] Add support for eth_signTypedData, personal_signTypedData RPC call --- docs/web3.eth.rst | 21 ++- docs/web3.geth.rst | 13 +- docs/web3.parity.rst | 19 +- tests/integration/go_ethereum/common.py | 16 ++ tests/integration/parity/common.py | 16 ++ tests/integration/parity/test_parity_http.py | 2 + tests/integration/parity/test_parity_ipc.py | 2 + tests/integration/parity/test_parity_ws.py | 2 + tests/integration/test_ethereum_tester.py | 1 + web3/_utils/module_testing/eth_module.py | 97 ++++++++++ web3/_utils/module_testing/personal_module.py | 171 ++++++++++++++++++ web3/_utils/personal.py | 6 + web3/_utils/rpc_abi.py | 2 + web3/eth.py | 5 + web3/geth.py | 2 + web3/middleware/exception_retry_request.py | 4 +- web3/middleware/pythonic.py | 2 + web3/parity.py | 2 + 18 files changed, 373 insertions(+), 10 deletions(-) diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 6646f6abe5..ceb3b912de 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -654,6 +654,19 @@ The following methods are available on the ``web3.eth`` namespace. '0x1a8bbe6eab8c72a219385681efefe565afd3accee35f516f8edf5ae82208fbd45a58f9f9116d8d88ba40fcd29076d6eada7027a3b412a9db55a0164547810cc401' +.. py:method:: Eth.signTypedData(account, jsonMessage) + + * Delegates to ``eth_signTypedData`` RPC Method + + Please note that the ``jsonMessage`` argument is the loaded JSON Object + and **NOT** the JSON String itself. + + Signs the ``Structured Data`` (or ``Typed Data``) with the private key of the given ``account``. + The account must be unlocked. + + ``account`` may be a hex address or an ENS name + + .. py:method:: Eth.call(transaction, block_identifier=web3.eth.defaultBlock) * Delegates to ``eth_call`` RPC Method @@ -864,8 +877,8 @@ with the filtering API. * Delegates to ``eth_submitHashrate`` RPC Method .. code-block:: python - - >>> node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' + + >>> node_id = '59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' >>> web3.eth.submitHashrate(5000, node_id) True @@ -875,14 +888,14 @@ with the filtering API. * Delegates to ``eth_submitWork`` RPC Method. .. code-block:: python - + >>> web3.eth.submitWork( 1, '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000', ) True - + Contracts --------- diff --git a/docs/web3.geth.rst b/docs/web3.geth.rst index 181a66c718..e234a92fb3 100644 --- a/docs/web3.geth.rst +++ b/docs/web3.geth.rst @@ -251,6 +251,7 @@ The following methods are available on the ``web3.geth.personal`` namespace. >>> web3.geth.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'the-passphrase') True + .. py:method:: sendTransaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method @@ -258,6 +259,16 @@ The following methods are available on the ``web3.geth.personal`` namespace. Sends the transaction. +.. py:method:: signTypedData(self, jsonMessage, account, passphrase) + + * Delegates to ``personal_signTypedData`` RPC Method + + Please note that the ``jsonMessage`` argument is the loaded JSON Object + and **NOT** the JSON String itself. + + Signs the ``Structured Data`` (or ``Typed Data``) with the passphrase of the given ``account`` + + .. py:module:: web3.geth.txpool GethTxPool API @@ -502,7 +513,7 @@ Full documentation for Geth-supported endpoints can be found `here >> web3.parity.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'the-passphrase') True + .. py:method:: sendTransaction(self, transaction, passphrase) * Delegates to ``personal_sendTransaction`` RPC Method @@ -71,6 +72,16 @@ The following methods are available on the ``web3.parity.personal`` namespace. Sends the transaction. +.. py:method:: signTypedData(self, jsonMessage, account, passphrase) + + * Delegates to ``personal_signTypedData`` RPC Method + + Please note that the ``jsonMessage`` argument is the loaded JSON Object + and **NOT** the JSON String itself. + + Signs the ``Structured Data`` (or ``Typed Data``) with the passphrase of the given ``account`` + + ParityShh --------- @@ -121,14 +132,14 @@ Full documentation for Parity-supported endpoints can be found `here