
    E#iz              
          S SK JrJrJrJrJr  SSK JrJr  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KJrJrJr  \" S	5      r\	   SS\\   S\\   S\\   S\4S jj5       r\	   SS\\   S\\   S\\   S\4S jj5       r\	   SS\\   S\\   S\\   S\4S jj5       r\	   SS\\   S\\   S\\   S\4S jj5       rS\S\4   S\\\\4   S\4S jrS\S\4   S\\\\4   S\4S jr g
)    )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                    Ub"  [        [        UR                  5       5      5      $ Ub  [        UR	                  S5      5      $ [        U 5      (       a  U (       a  [        S5      $ [        S5      $ [        U [        [        45      (       a  [        U 5      $ [        U 5      (       a  [        S5      e[        U 5      (       a"  [        [        [        [        U 5      5      5      $ [        S[        [!        U 5      5       S35      e)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/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/static_dependencies/ethereum/utils/conversions.pyto_hexr,   %   s     VFLLN344$++g.//) )ve}<ve}<)eY/00)$$	9		1
 	

 )c$sI./00

d4	?34 5# 	#     c                 B   Ub  [        US5      $ Ub  [        U5      $ [        U [        [        45      (       a  [	        U 5      $ [        U [
        5      (       a  [        S5      e[        U [         [        45      (       a  [        U 5      $ [        S[        U 5       35      e)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	2 ++	Is	#	#EFF	IT{	+	+9~NI!
 	
r-   c                    [        U 5      (       a  U (       a  S$ S$ [        U [        5      (       a  [        U 5      $ [        U [        5      (       a  U $ [	        U 5      (       a  [        [        U 5      S9$ Ub:  [        U5      S-  (       a  [        [        S[        U5      -   5      n[        U5      $ Ub  UR                  S5      $ [        S5      e)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   Ub  [        US9R                  S5      $ Ub  U$ [        U [        5      (       a	  [	        U S9$ [        U [
        [        45      (       a  U R                  S5      $ [        U 5      (       a$  [        [        [        U 5      5      n[	        U5      $ [        S5      e)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	2((	I		)$sI*>?}%%
B
CCr-   to_type.text_or_primitivec                 H    [        U[        5      (       a  U " US9$ U " U5      $ )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                     [        U[        5      (       aF  [        [        U5      5      (       a'  [	        U5      (       d  [        S[        U5       35      eU " US9$ U " U5      $ )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      ss     %s++F#6788B
 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-   