
    ":hz              
          d dl mZmZmZmZmZ ddl mZmZ 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lmZmZmZ  ed	      Ze		 	 	 ddee   dee   dee   defd       Ze		 	 	 ddee   dee   dee   defd       Ze		 	 	 ddee   dee   dee   defd       Ze		 	 	 ddee   dee   dee   defd       Zdedef   deeeef   defdZdedef   deeeef   defdZ y
)    )CallableOptionalTypeVarUnioncast   )HexStr
Primitives   )validate_conversion_arguments)big_endian_to_intint_to_big_endian)add_0x_prefix
decode_hex
encode_hex	is_hexstrremove_0x_prefix)
is_boolean
is_integer	is_stringTN	primitivehexstrtextreturnc                    |"t        t        |j                                     S |t        |j	                  d            S t        |       r| rt        d      S t        d      S t        | t        t        f      rt        |       S t        |       rt        d      t        |       r"t        t        t        t        |                   S t        dt        t!        |              d      )z
    Auto converts any supported value into its hex representation.
    Trims leading zeros, as defined in:
    https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding
    utf-80x10x0zaUnsupported type: The primitive argument must be one of: bytes,bytearray, int or bool and not strzUnsupported type: 'z6'. Must be one of: bool, str, bytes, bytearray or int.)r   r	   lowerr   encoder   
isinstancebytes	bytearrayr   	TypeErrorr   hexr   intreprtyper   r   r   s      m/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/static_dependencies/ethereum/utils/conversions.pyto_hexr,   %   s     VFLLN344$++g.//) )ve}<ve}<)eY/0)$$	9	1
 	

 )c$sI./00

d4	?34 5# 	#     c                     |t        |d      S |t        |      S t        | t        t        f      rt	        |       S t        | t
              rt        d      t        | t         t        f      rt        |       S t        dt        |              )a&  
    Converts value to its integer representation.
    Values are converted this way:

     * primitive:

       * bytes, bytearrays: big-endian integer
       * bool: True => 1, False => 0
     * hexstr: interpret hex as integer
     * text: interpret as string of digits, like '12' => 12
       z+Pass in strings with keyword hexstr or textz@Invalid type. Expected one of int/bool/str/bytes/bytearray. Got )	r'   r"   r#   r$   r   strr%   boolr)   r*   s      r+   to_intr2   J   s    " 62		4y	Iy1	2 ++	Is	#EFF	IT{	+9~NI!
 	
r-   c                 h   t        |       r| rdS dS t        | t              rt        |       S t        | t              r| S t	        |       rt        t        |             S |5t        |      dz  rt        t        dt        |      z         }t        |      S ||j                  d      S t        d      )N       r   r   r   r   zRexpected a bool, int, byte or bytearray in first arg, or keyword of hexstr or text)r   r"   r$   r#   r   to_bytesr,   lenr   r	   r   r   r!   r%   r*   s      r+   r7   r7   l   s     )#w00	Iy	)Y	Iu	%	I	vi011		v;?&%*:6*B"BCF&!!		{{7##
	' r-   c                 >   |t        |      j                  d      S ||S t        | t              rt	        |       S t        | t
        t        f      r| j                  d      S t        |       r$t        t        t        |             }t	        |      S t        d      )Nr6   r   z,Expected an int, bytes, bytearray or hexstr.)r7   decoder"   r0   to_textr#   r$   r   r   r   r'   r%   )r   r   r   byte_encodings       r+   r;   r;      s     v&--g66			Is	#i((	Iy1	2((	I	)$sI*>?}%%
B
CCr-   to_type.text_or_primitivec                 D    t        |t              r	 | |      S  | |      S )a&  
    Convert to a type, assuming that strings can be only unicode text (not a hexstr).

    :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text),
        eg~ to_bytes, to_text, to_hex, to_int, etc
    :param text_or_primitive bytes, str, int: value to convert
    )r   )r"   r0   )r=   r>   s     r+   text_if_strr@      s'     #S)-..())r-   hexstr_or_primitivec                     t        |t              r?t        t        |            r"t	        |      st        dt        |              | |      S  | |      S )a&  
    Convert to a type, assuming that strings can be only hexstr (not unicode text).

    :param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text),
        eg~ to_bytes, to_text, to_hex, to_int, etc
    :param hexstr_or_primitive bytes, str, int: value to convert
    z2when sending a str, it must be a hex string. Got: r6   )r"   r0   r   r	   r   
ValueErrorr(   )r=   rA   s     r+   hexstr_if_strrD      sg     %s+F#678B
 0124  122*++r-   )NNN)!typingr   r   r   r   r   r	   r
   
decoratorsr   encodingr   r   hexadecimalr   r   r   r   r   typesr   r   r   r   r0   r,   r'   r2   r#   r7   r;   r@   rD    r-   r+   <module>rK      s   
   CL &*#!
#!V! 3-! 	! !H &*#

#
V
 3-
 		
 
B &*#
#V 3- 	 2 &*#D
#DVD 3-D 		D D&*c1f*27sC2H** ,c1f,49%c/4J,,r-   