
    E#i                         S SK Jr  SSKJrJr  SSKJrJrJrJ	r	J
r
  S S.S\S\\   S	\S
\S\4
S jjrS\S\4S jrS\S\4S jrg)    )Sequence   )CONTRACT_ADDRESS_PREFIXL2_ADDRESS_UPPER_BOUND   )
HEX_PREFIX_starknet_keccakcompute_hash_on_elementsencode_uintget_bytes_length)deployer_address
class_hashconstructor_calldatasaltr   returnc                 J    [        US9n[        [        UUU U/S9nU[        -  $ )av  
Computes the contract address in the Starknet network - a unique identifier of the contract.

:param class_hash: class hash of the contract
:param constructor_calldata: calldata for the contract constructor
:param salt: salt used to calculate contract address
:param deployer_address: address of the deployer (if not provided default 0 is used)
:return: Contract's address
)data)r
   r   r   )r   r   r   r   constructor_calldata_hashraw_addresss         h/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/static_dependencies/starknet/hash/address.pycompute_addressr      s<    " !9>R S*#%
K ///    addressc                 L  ^ U R                  5       R                  [        5      (       d  [        U  S35      e[	        U S5      nU SS R                  S5      n[        U[        U5      5      n[        U5      mSR                  U4S j[        U5       5       5      n[         U 3$ )z
Outputs formatted checksum address.

Follows implementation of starknet.js. It is not compatible with EIP55 as it treats hex string as encoded number,
instead of encoding it as ASCII string.

:param address: Address to encode
:return: Checksum address
z$ is not a valid hexadecimal address.   r   N@    c              3      >#    U  HD  u  pUR                  5       (       a&  TS SU-  -
  S-
  -	  S-  (       a  UR                  5       OUv   MF     g7f)      r   N)isalphaupper).0icharaddress_hashs      r   	<genexpr>'get_checksum_address.<locals>.<genexpr>?   sQ       1GA ||~~<3Q;?#Ba"G JJL 1s   AA)lower
startswithr   
ValueErrorintzfillr   r   r	   join	enumerate)r   int_addressstring_addressaddress_in_bytesresultr&   s        @r   get_checksum_addressr4   ,   s     ==?%%j11G9$HIJJgr"KQR[&&r*N";0@0MN#$45LWW  !0 F \&""r   c                     [        U 5      U :H  $ )z<
Checks if provided string is in a checksum address format.
)r4   )r   s    r   is_checksum_addressr6   K   s      (G33r   N)typingr   	constantsr   r   utilsr   r	   r
   r   r   r,   r   strr4   boolr6    r   r   <module>r=      sy     G  00 #3-0 	0
 0 	0>## ## #>4 4 4r   