
    eiz              
       P   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 d
S )    )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                 p   |.t          t          |                                                    S |"t          |                    d                    S t          |           r | rt          d          n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
    N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      q/var/www/html/volatility/venv/lib/python3.11/site-packages/ccxt/static_dependencies/ethereum/utils/conversions.pyto_hexr,   %   s'    VFLLNN33444$++g..///) = )<ve}}}ve}}<)eY/00 
)$$$	9		 
1
 
 	

 ) 1c$sI..//000
	#d4	??33 	# 	# 	#      c                 z   |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
    N   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		4yy	Iy1	2	2 

 +++	Is	#	# 
EFFF	IT{	+	+ 
9~~!I! !
 
 	
r-   c                    t          |           r| rdndS t          | t                    rt          |           S t          | t                    r| S t	          |           rt          t          |                     S |Ft          |          dz  r%t          t          dt          |          z             }t          |          S ||                    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     ) $#0ww0	Iy	)	) $Y	Iu	%	% 	$	I		 $vi001111		v;;? 	D&%*:6*B*B"BCCF&!!!		{{7###
	'  r-   c                    |#t          |                              d          S ||S t          | t                    rt	          |           S t          | t
          t          f          r|                     d          S t          |           r1t          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6			Is	#	# &i((((	Iy1	2	2 &(((	I		 &)$sI*>*>??}%%%
B
C
CCr-   to_type.text_or_primitivec                 Z    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)) *w-....w()))r-   hexstr_or_primitivec                     t          |t                    rVt          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      s     %s++ 
,F#67788 	B
 B
 	 40114 4   w12222w*+++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      sY                      
                                   GCLL &*#! !
#!V! 3-! 	! ! ! !H &*#
 

#
V
 3-
 		
 
 
 
B &*# 
#V 3- 	   2 &*#D D
#DVD 3-D 		D D D D&*c1f*27sC2H** * * * ,c1f,49%c/4J,, , , , , ,r-   