
    ":h                         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y)    )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                 V    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         h/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/static_dependencies/starknet/hash/address.pycompute_addressr      s<    " !9>R S*#%
K ///    addressc                 @   | j                         j                  t              st        |  d      t	        | d      }| dd j                  d      }t        |t        |            }t        |      dj                  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   | ]:  \  }}|j                         r!d d|z  z
  dz
  z	  dz  r|j                         n| < yw)      r   N)isalphaupper).0icharaddress_hashs      r   	<genexpr>z'get_checksum_address.<locals>.<genexpr>?   sP       At ||~<3Q;?#Ba"G JJLs   A A)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G9$HIJJgr"KQR[&&r*N";0@0MN#$45LWW  !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<      sy     G  00 #3-0 	0
 0 	0>## ## #>4 4 4r   