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

feat: add validator for eth addresses #383

Merged
merged 10 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .github/workflows/pycqa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ jobs:
cache: "pip"
# testing
- name: Install 'testing' dependencies
run: pip install pytest
run: pip install -r package/requirements.testing.txt
- name: Testing
run: pytest .
3 changes: 0 additions & 3 deletions docs/api/btc_address.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/api/btc_address.rst

This file was deleted.

4 changes: 4 additions & 0 deletions docs/api/crypto_addresses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# crypto_addresses

::: validators.crypto_addresses.btc_address
::: validators.crypto_addresses.eth_address
6 changes: 6 additions & 0 deletions docs/api/crypto_addresses.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
crypto_addresses
----------------

.. module:: validators.crypto_addresses
.. autofunction:: btc_address
.. autofunction:: eth_address
2 changes: 1 addition & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ nav:
- Install and Use: install_and_use.md
- API:
- api/between.md
- api/btc_address.md
- api/crypto_addresses.md
- api/card.md
- api/country.md
- api/cron.md
Expand Down
49 changes: 49 additions & 0 deletions package/requirements.testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This file is @generated by PDM.
# Please do not edit it manually.

colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
eth-hash==0.7.0 \
--hash=sha256:b8d5a230a2b251f4a291e3164a23a14057c4a6de4b0aa4a16fa4dc9161b57e2f \
--hash=sha256:bacdc705bfd85dadd055ecd35fd1b4f846b671add101427e089a4ca2e8db310a
exceptiongroup==1.2.1; python_version < "3.11" \
--hash=sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad \
--hash=sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16
iniconfig==2.0.0 \
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
packaging==24.1 \
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
pluggy==1.5.0 \
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
pycryptodome==3.20.0 \
--hash=sha256:09609209ed7de61c2b560cc5c8c4fbf892f8b15b1faf7e4cbffac97db1fffda7 \
--hash=sha256:210ba1b647837bfc42dd5a813cdecb5b86193ae11a3f5d972b9a0ae2c7e9e4b4 \
--hash=sha256:2ab6ab0cb755154ad14e507d1df72de9897e99fd2d4922851a276ccc14f4f1a5 \
--hash=sha256:405002eafad114a2f9a930f5db65feef7b53c4784495dd8758069b89baf68eab \
--hash=sha256:4401564ebf37dfde45d096974c7a159b52eeabd9969135f0426907db367a652a \
--hash=sha256:49a4c4dc60b78ec41d2afa392491d788c2e06edf48580fbfb0dd0f828af49d25 \
--hash=sha256:6e0e4a987d38cfc2e71b4a1b591bae4891eeabe5fa0f56154f576e26287bfdea \
--hash=sha256:76658f0d942051d12a9bd08ca1b6b34fd762a8ee4240984f7c06ddfb55eaf15a \
--hash=sha256:76cb39afede7055127e35a444c1c041d2e8d2f1f9c121ecef573757ba4cd2c3c \
--hash=sha256:8d6b98d0d83d21fb757a182d52940d028564efe8147baa9ce0f38d057104ae72 \
--hash=sha256:9b3ae153c89a480a0ec402e23db8d8d84a3833b65fa4b15b81b83be9d637aab9 \
--hash=sha256:a60fedd2b37b4cb11ccb5d0399efe26db9e0dd149016c1cc6c8161974ceac2d6 \
--hash=sha256:ac1c7c0624a862f2e53438a15c9259d1655325fc2ec4392e66dc46cdae24d044 \
--hash=sha256:acae12b9ede49f38eb0ef76fdec2df2e94aad85ae46ec85be3648a57f0a7db04 \
--hash=sha256:acc2614e2e5346a4a4eab6e199203034924313626f9620b7b4b38e9ad74b7e0c \
--hash=sha256:acf6e43fa75aca2d33e93409f2dafe386fe051818ee79ee8a3e21de9caa2ac9e \
--hash=sha256:c18b381553638414b38705f07d1ef0a7cf301bc78a5f9bc17a957eb19446834b \
--hash=sha256:ec1f93feb3bb93380ab0ebf8b859e8e5678c0f010d2d78367cf6bc30bfeb148e \
--hash=sha256:f35d6cee81fa145333137009d9c8ba90951d7d77b67c79cbe5f03c7eb74d8fe2 \
--hash=sha256:f47888542a0633baff535a04726948e876bf1ed880fddb7c10a736fa99146ab3 \
--hash=sha256:fb3b87461fa35afa19c971b0a2b7456a7b1db7b4eba9a8424666104925b78128
pytest==8.2.2 \
--hash=sha256:c434598117762e2bd304e526244f67bf66bbd7b5d6cf22138be51ff661980343 \
--hash=sha256:de4bb8104e201939ccdc688b27a89a7be2079b22e2bd2b07f806b6ba71117977
tomli==2.0.1; python_version < "3.11" \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
25 changes: 25 additions & 0 deletions package/requirements.tooling.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ click==8.1.7 \
colorama==0.4.6 \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
eth-hash==0.7.0 \
--hash=sha256:b8d5a230a2b251f4a291e3164a23a14057c4a6de4b0aa4a16fa4dc9161b57e2f \
--hash=sha256:bacdc705bfd85dadd055ecd35fd1b4f846b671add101427e089a4ca2e8db310a
exceptiongroup==1.2.1; python_version < "3.11" \
--hash=sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad \
--hash=sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16
Expand All @@ -54,6 +57,28 @@ platformdirs==4.2.2 \
pluggy==1.5.0 \
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
pycryptodome==3.20.0 \
--hash=sha256:09609209ed7de61c2b560cc5c8c4fbf892f8b15b1faf7e4cbffac97db1fffda7 \
--hash=sha256:210ba1b647837bfc42dd5a813cdecb5b86193ae11a3f5d972b9a0ae2c7e9e4b4 \
--hash=sha256:2ab6ab0cb755154ad14e507d1df72de9897e99fd2d4922851a276ccc14f4f1a5 \
--hash=sha256:405002eafad114a2f9a930f5db65feef7b53c4784495dd8758069b89baf68eab \
--hash=sha256:4401564ebf37dfde45d096974c7a159b52eeabd9969135f0426907db367a652a \
--hash=sha256:49a4c4dc60b78ec41d2afa392491d788c2e06edf48580fbfb0dd0f828af49d25 \
--hash=sha256:6e0e4a987d38cfc2e71b4a1b591bae4891eeabe5fa0f56154f576e26287bfdea \
--hash=sha256:76658f0d942051d12a9bd08ca1b6b34fd762a8ee4240984f7c06ddfb55eaf15a \
--hash=sha256:76cb39afede7055127e35a444c1c041d2e8d2f1f9c121ecef573757ba4cd2c3c \
--hash=sha256:8d6b98d0d83d21fb757a182d52940d028564efe8147baa9ce0f38d057104ae72 \
--hash=sha256:9b3ae153c89a480a0ec402e23db8d8d84a3833b65fa4b15b81b83be9d637aab9 \
--hash=sha256:a60fedd2b37b4cb11ccb5d0399efe26db9e0dd149016c1cc6c8161974ceac2d6 \
--hash=sha256:ac1c7c0624a862f2e53438a15c9259d1655325fc2ec4392e66dc46cdae24d044 \
--hash=sha256:acae12b9ede49f38eb0ef76fdec2df2e94aad85ae46ec85be3648a57f0a7db04 \
--hash=sha256:acc2614e2e5346a4a4eab6e199203034924313626f9620b7b4b38e9ad74b7e0c \
--hash=sha256:acf6e43fa75aca2d33e93409f2dafe386fe051818ee79ee8a3e21de9caa2ac9e \
--hash=sha256:c18b381553638414b38705f07d1ef0a7cf301bc78a5f9bc17a957eb19446834b \
--hash=sha256:ec1f93feb3bb93380ab0ebf8b859e8e5678c0f010d2d78367cf6bc30bfeb148e \
--hash=sha256:f35d6cee81fa145333137009d9c8ba90951d7d77b67c79cbe5f03c7eb74d8fe2 \
--hash=sha256:f47888542a0633baff535a04726948e876bf1ed880fddb7c10a736fa99146ab3 \
--hash=sha256:fb3b87461fa35afa19c971b0a2b7456a7b1db7b4eba9a8424666104925b78128
pypandoc-binary==1.13 \
--hash=sha256:11a2497320eb3dccb74de3c67b6df3e5d3f66cdc2a36a67e9a871708f7e48412 \
--hash=sha256:21ef0345726d36fc45a50211320614daf2caede684b0d0963ce8738292809746 \
Expand Down
4 changes: 3 additions & 1 deletion package/roll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ $ErrorActionPreference = "Stop"
# Check if CI environment variable is set to "false"
if ($null -eq $env:CI || "false" -eq $env:CI) {
# tooling
pdm export --group tooling -f requirements -o package/requirements.tooling.txt
pdm export --group tooling,crypto-eth-addresses -f requirements -o package/requirements.tooling.txt
# testing
pdm export --group testing,crypto-eth-addresses -f requirements -o package/requirements.testing.txt
# mkdocs
pdm export --group docs-online -f requirements -o package/requirements.mkdocs.txt
# sphinx
Expand Down
4 changes: 3 additions & 1 deletion package/roll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ set -e
# Using the wrong way see: https://stackoverflow.com/a/13864829
if [ -z "$CI" ] || [ "$CI" = "false" ]; then
# tooling
pdm export --group tooling -f requirements -o package/requirements.tooling.txt
pdm export --group tooling,crypto-eth-addresses -f requirements -o package/requirements.tooling.txt
# testing
pdm export --group testing,crypto-eth-addresses -f requirements -o package/requirements.testing.txt
# mkdocs
pdm export --group docs-online -f requirements -o package/requirements.mkdocs.txt
# sphinx
Expand Down
75 changes: 66 additions & 9 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Changelog = "https://github.com/python-validators/validators/blob/master/CHANGES
# Development Dependencies #
##############################

[project.optional-dependencies]
crypto-eth-addresses = [
"eth-hash[pycryptodome]>=0.7.0",
]
[tool.pdm.dev-dependencies]
docs-offline = [
"myst-parser>=3.0.1",
Expand Down Expand Up @@ -81,6 +85,9 @@ tooling = [
####################
# Configurations #
####################
testing = [
"pytest>=8.2.2",
]

[tool.setuptools.packages.find]
where = ["src"]
Expand Down Expand Up @@ -176,6 +183,7 @@ deps =
pyright
pypandoc-binary
pytest
.[crypto-eth-addresses]
commands = pyright .

[testenv:format]
Expand All @@ -193,5 +201,6 @@ commands = bandit -c pyproject.toml -r .
description = unit tests
deps =
pytest
.[crypto-eth-addresses]
commands = pytest .
"""
6 changes: 2 additions & 4 deletions src/validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# local
from .between import between
from .btc_address import btc_address
from .card import amex, card_number, diners, discover, jcb, mastercard, unionpay, visa
from .country import calling_code, country_code, currency
from .cron import cron
from .crypto_addresses import btc_address, eth_address
from .domain import domain
from .email import email
from .encoding import base58, base64
Expand Down Expand Up @@ -33,13 +33,11 @@
from .utils import ValidationError, validator
from .uuid import uuid

# from .crypto_addresses import eth_address

__all__ = (
# ...
"between",
# crypto_addresses
"btc_address",
"eth_address",
# cards
"amex",
"card_number",
Expand Down
7 changes: 7 additions & 0 deletions src/validators/crypto_addresses/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Crypto addresses."""

# local
from .btc_address import btc_address
from .eth_address import eth_address

__all__ = ("btc_address", "eth_address")
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re

# local
from .utils import validator
from validators.utils import validator


def _decode_base58(addr: str):
Expand Down
Loading
Loading