
    ":h                        d dl Z d dlmZmZmZ ddlmZmZmZmZm	Z	 ddl
mZ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 j0                  de j2                  e j4                  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e e!f   defdZ"dedefdZ#deee e!f   defdZ$dedefdZ%dededefdZ&deee e!f   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Unioncast   )Address
AnyAddressChecksumAddress
HexAddressHexStr   )hexstr_if_strto_hexto_bytes   )SHA3)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    i/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/static_dependencies/ethereum/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                 `    t        |       rt        |       rt        |       S yt        |       ryy)zE
    Is the given string an address in any of the known formats?
    TF)r   _is_checksum_formattedis_checksum_addressr$   r   s    r   
is_addressr(   ;   s0     e!%(&u--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_addressr1   J   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(   r1   r   boolr   is_equals     r   is_normalized_addressr6   [   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   r1   )r7   s    r   to_canonical_addressr9   f   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#   r9   r   r3   )r7   r5   s     r   is_canonical_addressr;   m   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.   r3   r1   )r<   r=   s     r   is_same_addressr?   w   s;     d:e#4>??)$/3H3OOPPr    c                    t        |       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   *   )r1   r   keccakr   r   r   r   joinranger	   r
   )r   checksum_addressrJ   rK   s     @@r   to_checksum_addressrR      su     )/LfX3CF<DX3Y%Z[\L$GG  q" 		
 :&6788r    c                 n    t        |       syt        |       sy| t        |       k(  }t        t        |      S )NF)r   r   rR   r   r3   r4   s     r   r'   r'      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   r&   r&      sI    '.$$&& 	- ((**	- **,,r    c                 2    t        |       xr t        |       S rU   )r   r&   r   s    r   is_checksum_formatted_addressr[      s    % B%;E%BBr    )+retypingr   r   r   r   r   r	   r
   r   conversionsr   r   r   rN   r   hexadecimalr   r   r   r   typesr   r   compile
IGNORECASEASCIIr   r3   r   r$   r(   strbytesr1   r6   r9   r;   r?   rR   r'   r&   r[    r    r   <module>rg      ss   	   
 
 !bjj!4bmmbhh6NO <# <$ <	S 	T 	c d 
z3'=!> 
: 
"$ $ $?%
C(>"? ?G ? #  $  Q* QZ QD Q9uZe%;< 9 9, s  t  # $ C C Cr    