
    (i                        d dl Z d dlmZmZ d dlmZmZmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZmZmZmZ ddlmZmZ  e j.                  d	e j0                  e j2                  z        Zd
edefdZd
edefdZd
edefdZd
eez  e z  defdZ!d
edefdZ"deez  e z  defdZ#dedefdZ$deez  e z  deez  e z  defdZ%d
eez  e z  defdZ&d
edefdZ'd
edefdZ(d
edefdZ)y)    N)Anycast)Address
AnyAddressChecksumAddress
HexAddressHexStr   )hexstr_if_strto_hex)keccak)add_0x_prefix
decode_hex
encode_hexremove_0x_prefix)is_bytesis_textz(0x)?[0-9a-f]{40}valuereturnc                 H    t        |       syt        j                  |       duS )z\
    Checks if the given string of text type is an address in hexadecimal encoded form.
    FN)r   _HEX_ADDRESS_REGEXP	fullmatchr   s    B/var/www/br/venv/lib/python3.12/site-packages/eth_utils/address.pyis_hex_addressr   $   s$     5>((/t;;    c                 :    t        |       syt        |       dk7  ryy)zE
    Checks if the given string is an address in raw bytes form.
    F   T)r   lenr   s    r   is_binary_addressr    -   s      E?	Ur	r   c                 2    t        |       st        |       ryy)zE
    Is the given string an address in any of the known formats?
    TF)r   r    r   s    r   
is_addressr"   9   s     e 1% 8r   c                    	 t        t        |       j                         }t        |      rt        t        |            S t        dt        |        dt        |             # t        $ r t	        dt        |              w xY w)zK
    Converts an address to its normalized hexadecimal representation.
    z+Value must be any string, instead got type zUnknown format z, attempted to normalize to )r   r   lowerAttributeError	TypeErrortyper"   r   r	   
ValueErrorrepr)r   hex_addresss     r   to_normalized_addressr+   C   s    U#FE288: +&-..d5k]*FK !#
 	
  UEd5k]STTUs   A" "!Bc                 V    t        |       sy| t        |       k(  }t        t        |      S )zR
    Returns whether the provided value is an address in its normalized form.
    F)r"   r+   r   boolr   is_equals     r   is_normalized_addressr0   T   s,     e1%88D(##r   addressc                 <    t        t        t        |                   S )zJ
    Convert a valid address to its canonical form (20-length bytes).
    )r   r   r+   )r1   s    r   to_canonical_addressr3   _   s     :3G<=>>r   c                 r    t        |       rt        |       dk7  ry| t        |       k(  }t        t        |      S )zL
    Returns `True` if the `value` is an address in its canonical form.
    r   F)r   r   r3   r   r-   )r1   r/   s     r   is_canonical_addressr5   f   s7     GG 2.w77Hhr   leftrightc                     t        |       rt        |      st        d      t        t        |       t        |      k(        S )z3
    Checks if both addresses are same or not.
    z#Both values must be valid addresses)r"   r(   r-   r+   )r6   r7   s     r   is_same_addressr9   p   s;     d:e#4>??)$/3H3OOPPr   c                     t        |       t        t        t        t	                                t        t	        dj                  fdt        dd      D                          }t        t        |            S )z<
    Makes a checksum address given a supported format.
    )text c              3   r   K   | ].  }t        |   d       dkD  r|   j                         n|    0 yw)      N)intupper).0iaddress_hashnorm_addresss     r   	<genexpr>z&to_checksum_address.<locals>.<genexpr>   sI        <?B/!3 !O))+%a)s   47   *   )
r+   r   r   r   r	   r   joinranger   r   )r   checksum_addressrD   rE   s     @@r   to_checksum_addressrL   |   sp     )/Lf*:6,;O*PQRL$GG  q" 		
 :&6788r   c                 n    t        |       syt        |       sy| t        |       k(  }t        t        |      S )NF)r   r   rL   r   r-   r.   s     r   is_checksum_addressrN      s4    5>% +E22Hhr   c                     t        |       }|j                          xr$ |j                          xr |j                          S N)r   islowerisupper	isnumeric)r   unprefixed_values     r   _is_checksum_formattedrU      sI    '.$$&& 	- ((**	- **,,r   c                 2    t        |       xr t        |       S rP   )r   rU   r   s    r   is_checksum_formatted_addressrW      s    % B%;E%BBr   )*retypingr   r   
eth_typingr   r   r   r   r	   conversionsr   r   cryptor   hexadecimalr   r   r   r   typesr   r   compile
IGNORECASEASCIIr   r-   r   r    r"   strbytesr+   r0   r3   r5   r9   rL   rN   rU   rW    r   r   <module>re      sz   	
  
 !bjj!4bmmbhh6NO <# <$ <	S 	T 	c d 
c!1E!9 
j 
"$ $ $?*s"2U": ?w ? #  $  	Q
s
U
"	Q+5+;e+C	Q		Q9zC/%7 9O 9, s  t  # $ C C Cr   