diff --git a/docs/overview.rst b/docs/overview.rst index fe764c7c96..c37373d47f 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -117,7 +117,7 @@ Cryptographic Hashing --------------------- - :meth:`Web3.keccak() ` -- :meth:`Web3.solidityKeccak() ` +- :meth:`Web3.solidity_keccak() ` web3.eth API diff --git a/docs/web3.main.rst b/docs/web3.main.rst index 1161977336..f886fb9cbb 100644 --- a/docs/web3.main.rst +++ b/docs/web3.main.rst @@ -268,7 +268,7 @@ Cryptographic Hashing >>> Web3.keccak(text='txt') HexBytes('0xd7278090a36507640ea6b7a0034b69b0d240766fa3f98e3722be93c613b29d2e') -.. py:classmethod:: Web3.solidityKeccak(abi_types, value) +.. py:classmethod:: Web3.solidity_keccak(abi_types, value) Returns the Keccak-256 as it would be computed by the solidity ``keccak`` function on a *packed* ABI encoding of the ``value`` list contents. The ``abi_types`` @@ -278,19 +278,19 @@ Cryptographic Hashing .. code-block:: python - >>> Web3.solidityKeccak(['bool'], [True]) + >>> Web3.solidity_keccak(['bool'], [True]) HexBytes("0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2") - >>> Web3.solidityKeccak(['uint8', 'uint8', 'uint8'], [97, 98, 99]) + >>> Web3.solidity_keccak(['uint8', 'uint8', 'uint8'], [97, 98, 99]) HexBytes("0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45") - >>> Web3.solidityKeccak(['uint8[]'], [[97, 98, 99]]) + >>> Web3.solidity_keccak(['uint8[]'], [[97, 98, 99]]) HexBytes("0x233002c671295529bcc50b76a2ef2b0de2dac2d93945fca745255de1a9e4017e") - >>> Web3.solidityKeccak(['address'], ["0x49EdDD3769c0712032808D86597B84ac5c2F5614"]) + >>> Web3.solidity_keccak(['address'], ["0x49EdDD3769c0712032808D86597B84ac5c2F5614"]) HexBytes("0x2ff37b5607484cd4eecf6d13292e22bd6e5401eaffcc07e279583bc742c68882") - >>> Web3.solidityKeccak(['address'], ["ethereumfoundation.eth"]) + >>> Web3.solidity_keccak(['address'], ["ethereumfoundation.eth"]) HexBytes("0x913c99ea930c78868f1535d34cd705ab85929b2eaaf70fcd09677ecd6e5d75e9") diff --git a/newsfragments/2702.breaking.rst b/newsfragments/2702.breaking.rst new file mode 100644 index 0000000000..d59b84ac64 --- /dev/null +++ b/newsfragments/2702.breaking.rst @@ -0,0 +1 @@ +Snakecase the solidityKeccak method \ No newline at end of file diff --git a/web3/_utils/module_testing/web3_module.py b/web3/_utils/module_testing/web3_module.py index 936b41a191..197715c584 100644 --- a/web3/_utils/module_testing/web3_module.py +++ b/web3/_utils/module_testing/web3_module.py @@ -219,7 +219,7 @@ def _check_web3_client_version(self, client_version: str) -> NoReturn: ), ), ) - def test_solidityKeccak( + def test_solidity_keccak( self, w3: "Web3", types: Sequence[TypeStr], @@ -228,10 +228,10 @@ def test_solidityKeccak( ) -> None: if isinstance(expected, type) and issubclass(expected, Exception): with pytest.raises(expected): # type: ignore - w3.solidityKeccak(types, values) + w3.solidity_keccak(types, values) return - actual = w3.solidityKeccak(types, values) + actual = w3.solidity_keccak(types, values) assert actual == expected @pytest.mark.parametrize( @@ -253,7 +253,7 @@ def test_solidityKeccak( ), ), ) - def test_solidityKeccak_ens( + def test_solidity_keccak_ens( self, w3: "Web3", types: Sequence[TypeStr], @@ -273,10 +273,10 @@ def test_solidityKeccak_ens( ): # when called as class method, any name lookup attempt will fail with pytest.raises(InvalidAddress): - Web3.solidityKeccak(types, values) + Web3.solidity_keccak(types, values) # when called as instance method, ens lookups can succeed - actual = w3.solidityKeccak(types, values) + actual = w3.solidity_keccak(types, values) assert actual == expected @pytest.mark.parametrize( @@ -287,11 +287,11 @@ def test_solidityKeccak_ens( ([], ["0xA6b759bBbf4B59D24acf7E06e79f3a5D104fdCE5"]), ), ) - def test_solidityKeccak_same_number_of_types_and_values( + def test_solidity_keccak_same_number_of_types_and_values( self, w3: "Web3", types: Sequence[TypeStr], values: Sequence[Any] ) -> None: with pytest.raises(ValueError): - w3.solidityKeccak(types, values) + w3.solidity_keccak(types, values) def test_is_connected(self, w3: "Web3") -> None: assert w3.is_connected() diff --git a/web3/main.py b/web3/main.py index 99fb34360f..f8bc487c0d 100644 --- a/web3/main.py +++ b/web3/main.py @@ -302,7 +302,7 @@ def keccak( ) @combomethod - def solidityKeccak(cls, abi_types: List[TypeStr], values: List[Any]) -> bytes: + def solidity_keccak(cls, abi_types: List[TypeStr], values: List[Any]) -> bytes: """ Executes keccak256 exactly as Solidity does. Takes list of abi_types as inputs -- `[uint24, int8[], bool]`