o
    7D©iº  ã                   @   sh   d Z ddlZddlmZ dZzddlmZ W n ey!   dZY nw defdd	„Z	ed
efdd„ƒZ
dS )zETH Address.é    N)Ú	validatorT)ÚkeccakFÚaddrc                 C   sž   |   dd¡} t |  ¡  d¡¡ ¡  ¡ }t| ƒdkrdS tddƒD ]+}t	|| dƒdkr6| |  
¡ | | ksIt	|| dƒdkrL| |  ¡ | | krL dS q!d	S )
z#Validate ETH type checksum address.Ú0xÚ Úasciié(   Fr   é   é   T)Úreplacer   ÚnewÚlowerÚencodeÚdigestÚhexÚlenÚrangeÚintÚupper)r   Ú	addr_hashÚi© r   ú`/var/www/Datamplify/venv/lib/python3.10/site-packages/validators/crypto_addresses/eth_address.pyÚ_validate_eth_checksum_address   s   &&€r   Úvaluec                C   s,   t stdƒ‚| s
dS t d¡ | ¡pt| ƒS )al  Return whether or not given value is a valid ethereum address.

    Full validation is implemented for ERC20 addresses.

    Examples:
        >>> eth_address('0x9cc14ba4f9f68ca159ea4ebf2c292a808aaeb598')
        True
        >>> eth_address('0x8Ba1f109551bD432803012645Ac136ddd64DBa72')
        ValidationError(func=eth_address, args={'value': '0x8Ba1f109551bD432803012645Ac136ddd64DBa72'})

    Args:
        value:
            Ethereum address string to validate.

    Returns:
        (Literal[True]): If `value` is a valid ethereum address.
        (ValidationError): If `value` is an invalid ethereum address.
    zVDo `pip install validators[crypto-eth-addresses]` to perform `eth_address` validation.Fz!^0x[0-9a-f]{40}$|^0x[0-9A-F]{40}$)Ú_keccak_flagÚImportErrorÚreÚcompileÚmatchr   )r   r   r   r   Úeth_address!   s   ÿ
ÿþr    )Ú__doc__r   Úvalidators.utilsr   r   Úeth_hash.autor   r   Ústrr   r    r   r   r   r   Ú<module>   s    ÿ