
    ei                         d dl mZ ddlmZmZ ddlmZmZmZm	Z	m
Z
 d ddedee         d	ed
edef
dZdedefdZdedefdZdS )    )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    t          |          }t          t          ||| |g          }|t          z  S )a  
    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         l/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/static_dependencies/starknet/hash/address.pycompute_addressr      sL    " !9>R S S S*#%
  K ///    addressc                    |                                                      t                    st          |  d          t	          | d          }| dd                             d          }t          |t          |                    }t          |          d	                    fdt          |          D                       }t           | S )a  
    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      K   | ]B\  }}|                                 r%d d|z  z
  dz
  z	  dz  r|                                n|V  CdS )      r   N)isalphaupper).0icharaddress_hashs      r   	<genexpr>z'get_checksum_address.<locals>.<genexpr>?   sw         At ||~~#/3Q;?#Ba"GDJJLLL	     r   )lower
startswithr   
ValueErrorintzfillr   r   r	   join	enumerate)r   int_addressstring_addressaddress_in_bytesresultr&   s        @r   get_checksum_addressr3   ,   s     ==??%%j11 KGIIIJJJgr""KQRR[&&r**N";0@0M0MNN#$455LWW     !00    F "&"""r   c                 (    t          |           | k    S )zD
    Checks if provided string is in a checksum address format.
    )r3   )r   s    r   is_checksum_addressr5   K   s      ((G33r   N)typingr   	constantsr   r   utilsr   r	   r
   r   r   r+   r   strr3   boolr5    r   r   <module>r<      s         G G G G G G G G              0 0 00 #3-0 	0
 0 	0 0 0 0>## ## # # # #>4 4 4 4 4 4 4 4r   