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

Snakecase address helpers #2708

Merged
merged 4 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ Encoding and Decoding Helpers
Address Helpers
---------------

- :meth:`Web3.isAddress() <web3.Web3.isAddress>`
- :meth:`Web3.isChecksumAddress() <web3.Web3.isChecksumAddress>`
- :meth:`Web3.toChecksumAddress() <web3.Web3.toChecksumAddress>`
- :meth:`Web3.is_address() <web3.Web3.is_address>`
- :meth:`Web3.is_checksum_address() <web3.Web3.is_checksum_address>`
- :meth:`Web3.to_checksum_address() <web3.Web3.to_checksum_address>`


Currency Conversions
Expand Down
14 changes: 7 additions & 7 deletions docs/web3.main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Currency Conversions
Addresses
~~~~~~~~~

.. py:method:: Web3.isAddress(value)
.. py:method:: Web3.is_address(value)

Returns ``True`` if the value is one of the recognized address formats.

Expand All @@ -218,31 +218,31 @@ Addresses

.. code-block:: python

>>> Web3.isAddress('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')
>>> Web3.is_address('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')
True


.. py:method:: Web3.isChecksumAddress(value)
.. py:method:: Web3.is_checksum_address(value)

Returns ``True`` if the value is a valid `EIP55`_ checksummed address


.. code-block:: python

>>> Web3.isChecksumAddress('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')
>>> Web3.is_checksum_address('0xd3CdA913deB6f67967B99D67aCDFa1712C293601')
True
>>> Web3.isChecksumAddress('0xd3cda913deb6f67967b99d67acdfa1712c293601')
>>> Web3.is_checksum_address('0xd3cda913deb6f67967b99d67acdfa1712c293601')
False


.. py:method:: Web3.toChecksumAddress(value)
.. py:method:: Web3.to_checksum_address(value)

Returns the given address with an `EIP55`_ checksum.


.. code-block:: python

>>> Web3.toChecksumAddress('0xd3cda913deb6f67967b99d67acdfa1712c293601')
>>> Web3.to_checksum_address('0xd3cda913deb6f67967b99d67acdfa1712c293601')
'0xd3CdA913deB6f67967B99D67aCDFa1712C293601'

.. _EIP55: https://github.com/ethereum/EIPs/issues/55
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2708.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Snakecase the toAddress, isChecksumAddress, and toChecksumAddress methods
2 changes: 1 addition & 1 deletion web3/_utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def validate_address(value: Any) -> None:
"The software that gave you this non-checksum address should be "
"considered unsafe, please file it as a bug on their platform. "
"Try using an ENS name instead. Or, if you must accept lower safety, "
"use Web3.toChecksumAddress(lower_case_address).",
"use Web3.to_checksum_address(lower_case_address).",
value,
)
else:
Expand Down
6 changes: 3 additions & 3 deletions web3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ def from_wei(number: int, unit: str) -> Union[int, decimal.Decimal]:
# Address Utility
@staticmethod
@wraps(is_address)
def isAddress(value: Any) -> bool:
def is_address(value: Any) -> bool:
return is_address(value)

@staticmethod
@wraps(is_checksum_address)
def isChecksumAddress(value: Any) -> bool:
def is_checksum_address(value: Any) -> bool:
return is_checksum_address(value)

@staticmethod
@wraps(to_checksum_address)
def toChecksumAddress(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress:
def to_checksum_address(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress:
return to_checksum_address(value)

# mypy Types
Expand Down