
    (i                     F   d dl mZ d dlZd dlZd dlmZmZ ddlmZ  ed      Z	 G d d      Z
d	e	d
e	defdZd	e	d
e	ddfdZd
e	defdZd
e	ddfdZd
eddfdZdede	f   dede	f   fdZdededede	f   f   fdZdeee   ee   f   deede	f   gede	f   f   fdZy)    )CallableN)AnyTypeVar   is_textTc            	       Z    e Zd Zdedef   ddfdZ	 d	dedz  dee   dz  dedef   fdZy)
combomethodmethod.returnNc                     || _         y Nr   )selfr   s     E/var/www/br/venv/lib/python3.12/site-packages/eth_utils/decorators.py__init__zcombomethod.__init__   s	        objobjtypec                      t        j                   j                        dt        dt        dt        f fd       }|S )Nargskwargsr   c                  `     j                   g| i |S  j                   g| i |S r   r   )r   r   r   r   r   s     r   _wrapperz%combomethod.__get__.<locals>._wrapper   s>    "t{{38888"t{{7<T<V<<r   )	functoolswrapsr   r   )r   r   r   r   s   ``` r   __get__zcombomethod.__get__   s@     
	%	=C 	=3 	=3 	= 
&	= r   )NN)	__name__
__module____qualname__r   r   r   r	   typer    r   r   r   r      sV    xS1 d  ?C
t8
-1!Wt^
	#s(	
r   r   r   r   r   c                      t        j                  | |j                               }t        t	        d |            }t        |      dk(  S )Nc                 
    | d uS r   r#   )vals    r   <lambda>z_has_one_val.<locals>.<lambda>%   s
    4 r   r   )	itertoolschainvalueslistfilterlen)r   r   vals	not_noness       r   _has_one_valr0   #   s9    ??41DV7>?Iy>Qr   c                  `    t        | i |s#t        dt        |        dt        |             y )NzIExactly one of the passed values can be specified. Instead, values were: z, )r0   	TypeErrorrepr)r   r   s     r   _assert_one_valr4   )   s?    ((%%)$ZL4<.B
 	
 )r   c                  4    d| v r| d   n| d   }t        |      S )Nhexstrtextr   )r   values     r   "_hexstr_or_text_kwarg_is_text_typer9   1   s#     (F 2F8vE5>r   c                      t        di | s@t        dt        t        t	        t        | j                                                        y )NzMArguments passed as hexstr or text must be of text type. Instead, value was: r#   )r9   r2   r3   nextiterr+   r*   r   s    r   )_assert_hexstr_or_text_kwarg_is_text_typer>   6   sJ    -77#$(d43H.I)J$K"MO
 	
 8r   c           
          t        t        |             dvr)t        dt        t        t        |                          y )N)	primitiver6   r7   zDKwarg must be 'primitive', 'hexstr', or 'text'. Instead, kwarg was: )r;   r<   r2   r3   r=   s    r   _validate_supported_kwargrA   >   sE    DL!@@##'T&\(:#;"<>
 	
 Ar   to_wrap.c                 h     t        j                         dt        dt        dt        f fd       }|S )z
    Validates arguments for conversion functions.
    - Only a single argument is present
    - Kwarg must be 'primitive' 'hexstr' or 'text'
    - If it is 'hexstr' or 'text' that it is a text type
    r   r   r   c                  ~    t        | i | |rt        |       t        |       dk(  rd|vrt        di |  | i |S )Nr   r@   r#   )r4   rA   r-   r>   )r   r   rB   s     r   wrapperz.validate_conversion_arguments.<locals>.wrapperN   sH    ((%f-t9>k75??'''r   r   r   r   r	   )rB   rE   s   ` r   validate_conversion_argumentsrG   F   s<     __W(s (c (a ( ( Nr   at_positionc                 P     dt         dt        f   dt         dt        f   f fd}|S )zM
    Wrap the return value with the result of `type(args[at_position])`.
    rB   .r   c                 l     t        j                         dt        dt        dt        f fd       }|S )Nr   r   r   c                  @     | i |}t        |          } ||      S r   )r"   )r   r   result
ReturnTyperH   rB   s       r   rE   z3return_arg_type.<locals>.decorator.<locals>.wrappera   s,    d-f-Fd;/0Jf%%r   rF   )rB   rE   rH   s   ` r   	decoratorz"return_arg_type.<locals>.decorator`   s:    		!	&3 	&# 	&! 	& 
"	&
 r   )r   r   r	   )rH   rN   s   ` r   return_arg_typerO   [   s0    
8CH- (362B  r   old_to_new_exceptionsc                      t         j                               dt        dt        f   dt        dt        f   f fd}|S )zR
    Replaces old exceptions with new exceptions to be raised in their place.
    rB   .r   c                 n     t        j                         dt        dt        dt        f fd       }|S )Nr   r   r   c                      	  | i |S # $ r@}	  t        |         |      |# t        $ r t        dt        |             |w xY wd }~ww xY w)Nz+could not look up new exception to use for )r"   KeyErrorr2   r3   )r   r   errold_exceptionsrP   rB   s      r   wrappedz6replace_exceptions.<locals>.decorator.<locals>.wrappedu   sr    ///! :/S	:3?SH #Ed3i[Qs    A&"AAArF   )rB   rW   rV   rP   s   ` r   rN   z%replace_exceptions.<locals>.decoratort   s:    		!		3 		# 		! 		 
"		 r   )tuplekeysr   r	   )rP   rN   rV   s   ` @r   replace_exceptionsrZ   l   sF     05578N8CF+ a0@  r   )collections.abcr   r   r(   typingr   r   typesr   r	   r   boolr0   r4   r9   r>   rA   rG   intrO   dictr"   BaseExceptionrZ   r#   r   r   <module>rb      s1    
 CL " Q 4 
1 
 
d 
 t 

 
d 

c 
d 
8CF+; a@P * #xQ7G2G)H "] 3T-5H HIxQ (36"223r   