
    ei                        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 j        de j        e j        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*dS )    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                 \    t          |           sdS t                              |           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    m/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/static_dependencies/ethereum/utils/address.pyis_hex_addressr   &   s0     5>> u((//t;;    c                 R    t          |           sdS t          |           dk    rdS dS )zE
    Checks if the given string is an address in raw bytes form.
    F   T)r   lenr   s    r   is_binary_addressr$   /   s2     E?? u	Ur		utr    c                     t          |           r t          |           rt          |           S dS t          |           rdS dS )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(   ;   sQ     e !%(( 	.&u---t t5r    c                 b   	 t          t          |                                           }n-# t          $ r  t	          dt          |                      w xY wt          |          rt          t          |                    S t          dt          |            dt          |                     )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288:: U U USd5kkSSTTTU+ 
&--...#d5kk # #K  # #
 
 	
s	   '* *Ac                 t    t          |           sdS | 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 $u1%888D(###r    addressc                 T    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                     t          |           rt          |           dk    rdS | 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   sL     G G 2 2u.w7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   sY     d Q:e#4#4 Q>???)$//3H3O3OOPPPr    c                 x   t          |           t          t          t          t	          t                                                            t          t          d                    fdt          dd          D                                           }t          t          |                    S )z<
    Makes a checksum address given a supported format.
    )text c              3      K   | ]@}t          |         d           dk    r|                                         n|         V  AdS )      N)intupper).0iaddress_hashnorm_addresss     r   	<genexpr>z&to_checksum_address.<locals>.<genexpr>   sn          <?B//!33 !O))+++%a	     r    r   *   )r1   r   keccakr   r   r   r   joinranger	   r
   )r   checksum_addressrJ   rK   s     @@r   to_checksum_addressrR      s     )//LfX3CF<DXDX3Y3Y%Z%Z%Z[[\\L$GG      q"    		
 		
  :&677888r    c                     t          |           sdS t          |           sdS | t          |           k    }t          t          |          S )NF)r   r   rR   r   r3   r4   s     r   r'   r'      sM    5>> u%   u+E222Hhr    c                     t          |           }|                                 o)|                                 o|                                 S N)r   islowerisupper	isnumeric)r   unprefixed_values     r   r&   r&      sU    '..$$&&& 	- ((***	- **,,,r    c                 >    t          |           ot          |           S rU   )r   r&   r   s    r   is_checksum_formatted_addressr[      s    %  B%;E%B%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      s6   				                               
                       
 !bj!4bmbh6NOO <# <$ < < < <	S 	T 	 	 	 	c d    
z3'=!> 
: 
 
 
 
"$ $ $ $ $ $?%
C(>"? ?G ? ? ? ? #  $        Q* QZ QD Q Q Q Q9uZe%;< 9 9 9 9 9, s  t        # $    C C C C C C C Cr    