
    E#i                        S SK r S SKJrJrJr  SSKJrJrJrJrJ	r	  SSK
JrJrJr  SSKJr  SS	KJrJrJrJr  SS
KJrJr  \ R0                  " S\ R2                  \ R4                  -  5      rS\S\4S jrS\S\4S jrS\S\4S jrS\\\ \!4   S\4S jr"S\S\4S jr#S\\\ \!4   S\4S jr$S\S\4S jr%S\S\S\4S jr&S\\\ \!4   S\4S jr'S\S\4S jr(S\S\4S jr)S\S\4S jr*g)    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                 R    [        U 5      (       d  g[        R                  U 5      SL$ )zT
Checks if the given string of text type is an address in hexadecimal encoded form.
FN)r   _HEX_ADDRESS_REGEXP	fullmatchr   s    i/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/static_dependencies/ethereum/utils/address.pyis_hex_addressr   &   s&     5>>((/t;;    c                 F    [        U 5      (       d  g[        U 5      S:w  a  gg)z=
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                 ~    [        U 5      (       a  [        U 5      (       a  [        U 5      $ g[        U 5      (       a  gg)z=
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(   ;   s9     e!%((&u--r    c                     [        [        U 5      R                  5       n[        U5      (       a  [        [        U5      5      $ [        S[        U 5       S[        U5       35      e! [         a    [	        S[        U 5       35      ef = f)zC
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                 `    [        U 5      (       d  gU [        U 5      :H  n[        [        U5      $ )zJ
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                 <    [        [        [        U 5      5      5      $ )zB
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                 ~    [        U 5      (       a  [        U 5      S:w  a  gU [        U 5      :H  n[        [        U5      $ )zD
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   s:     GG 2.w77Hhr    leftrightc                     [        U 5      (       a  [        U5      (       d  [        S5      e[        [        U 5      [        U5      :H  5      $ )z+
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   sA     d:e#4#4>??)$/3H3OOPPr    c                   ^^ [        U 5      m[        [        [        [	        [        T5      5      S95      5      m[        [        SR                  UU4S j[        SS5       5       5      5      5      n[        [        U5      5      $ )z4
Makes a checksum address given a supported format.
)text c              3   z   >#    U  H0  n[        TU   S 5      S:  a  TU   R                  5       OTU   v   M2     g7f)      N)intupper).0iaddress_hashnorm_addresss     r   	<genexpr>&to_checksum_address.<locals>.<genexpr>   sJ       &A <?B/!3 !O))+%a) &s   8;r   *   )r1   r   keccakr   r   r   r   joinranger	   r
   )r   checksum_addressrJ   rK   s     @@r   to_checksum_addressrS      su     )/LfX3CF<DX3Y%Z[\L$GG  q" 		
 :&6788r    c                     [        U 5      (       d  g[        U 5      (       d  gU [        U 5      :H  n[        [        U5      $ )NF)r   r   rS   r   r3   r4   s     r   r'   r'      s9    5>>%  +E22Hhr    c                     [        U 5      nUR                  5       (       + =(       a1    UR                  5       (       + =(       a    UR                  5       (       + $ N)r   islowerisupper	isnumeric)r   unprefixed_values     r   r&   r&      sI    '.$$&& 	- ((**	- **,,r    c                 <    [        U 5      =(       a    [        U 5      $ rV   )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   rO   r   hexadecimalr   r   r   r   typesr   r   compile
IGNORECASEASCIIr   r3   r   r$   r(   strbytesr1   r6   r9   r;   r?   rS   r'   r&   r\    r    r   <module>rh      sq   	   
 
 jj!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    