From 16a68e1b216670a6d79b910d170594551dfd7421 Mon Sep 17 00:00:00 2001 From: Tiffany McKenzie <25855566+tmckenzie51@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:46:28 -0500 Subject: [PATCH] snakecase listStorageKeys --- newsfragments/1944.feature.rst | 1 + web3/_utils/module_testing/parity_module.py | 16 +++++++++++++++- web3/parity.py | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 newsfragments/1944.feature.rst diff --git a/newsfragments/1944.feature.rst b/newsfragments/1944.feature.rst new file mode 100644 index 0000000000..c129cfa59d --- /dev/null +++ b/newsfragments/1944.feature.rst @@ -0,0 +1 @@ +Add list_storage_keys deprecate listStorageKeys diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index dea5b96002..d04630ee74 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -135,7 +135,21 @@ def test_add_reserved_peer(self, web3: "Web3") -> None: def test_list_storage_keys_no_support( self, web3: "Web3", emitter_contract_address: ChecksumAddress ) -> None: - keys = web3.parity.listStorageKeys(emitter_contract_address, 10, None) + keys = web3.parity.list_storage_keys(emitter_contract_address, 10, None) + assert keys == [] + + def test_list_storage_keys( + self, web3: "Web3", emitter_contract_address: ChecksumAddress + ) -> None: + keys = web3.parity.list_storage_keys(emitter_contract_address, 10, None) + assert keys == [] + + def test_listStorageKeys_deprecated( + self, web3: "Web3", emitter_contract_address: ChecksumAddress + ) -> None: + with pytest.warns(DeprecationWarning, + match='listStorageKeys is deprecated in favor of list_storage_keys'): + keys = web3.parity.listStorageKeys(emitter_contract_address, 10, None) assert keys == [] def test_mode(self, web3: "Web3") -> None: diff --git a/web3/parity.py b/web3/parity.py index 945f45ae37..eb8465e83b 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -41,6 +41,7 @@ RPC, ) from web3.method import ( + DeprecatedMethod, Method, default_root_munger, ) @@ -133,7 +134,7 @@ def list_storage_keys_munger( block_identifier = self.default_block return (address, quantity, hash_, block_identifier) - listStorageKeys: Method[Callable[..., List[Hash32]]] = Method( + list_storage_keys: Method[Callable[..., List[Hash32]]] = Method( RPC.parity_listStorageKeys, mungers=[list_storage_keys_munger], ) @@ -218,3 +219,6 @@ def trace_transactions_munger( RPC.parity_mode, mungers=None ) + + # Deprecated Methods + listStorageKeys = DeprecatedMethod(list_storage_keys, 'listStorageKeys', 'list_storage_keys')