
    (i                     ~   d dl mZmZ d dlmZ d dlZddlmZ ddlm	Z	 ddl
mZ ddlmZmZ eee   gee   f   Z ed	      d
edef   dedee   deee   ddf   fd       Zdeedef      defdZ ed      dee   dee   deee   ddf   fd       Zdedef   d
edef   dedefdZe		 ddeeef   deeef   ez  dedeeeef   ddf   fd       Z ed      d
edef   dee   deee   ddf   fd       Zdeeedef   edef   f      dedefdZe	deeef   deeef   deeeef   ddf   fd       Zy)    )Callable	Generator)AnyN   )return_arg_type)to_dict)
CamelModel)composecurry   	formatter.at_indexvaluereturnc              #      K   |dz   t        |      kD  rt        dt        |       d|dz          t        |      D ]  \  }}||k(  r | |       |  y w)Nr   z7Not enough values in iterable to apply formatter. Got: z. Need: )len
IndexError	enumerate)r   r   r   indexitems        F/var/www/br/venv/lib/python3.12/site-packages/eth_utils/applicators.pyapply_formatter_at_indexr      su      !|c%j Ec%j\ R\N$
 	
 !' tHD/!J	s   AA
formattersc                      t        j                  t        d      d       t        t              t        fdt        |       D         S )Na  combine_argument_formatters(formatter1, formatter2)([item1, item2])has been deprecated and will be removed in a subsequent major version release of the eth-utils library. Update your calls to use apply_formatters_to_sequence([formatter1, formatter2], [item1, item2]) instead.r   )
stacklevelc              3   6   K   | ]  \  }} ||        y wN ).0r   r   _formatter_at_indexs      r   	<genexpr>z.combine_argument_formatters.<locals>.<genexpr>9   s$      

 y  	51

s   )warningswarnDeprecationWarningr   r   r
   r   )r   r    s    @r   combine_argument_formattersr%   +   sN    MM	
 	   89

$-j$9

     sequencec              #   0  K   t        |       t        |      k(  rt        | |      D ]  \  }} ||        y t        |       t        |      kD  r#t        dt        |        dt        |             t        dt        |        dt        |             w)Nz"Too many formatters for sequence: z formatters for z!Too few formatters for sequence: )r   zipr   repr)r   r'   r   r   s       r   apply_formatters_to_sequencer+   @   s      :#h-'":x8 	"OItD/!	"	Z3x=	(0Z0AAQH~ 
 	

 /J/@@PH~ 
 	
s   BB	conditionc                 &     | |      r ||      S |S r   r   )r,   r   r   s      r   apply_formatter_ifr.   S   s     r&   	unaliasedc              #     K   t        |t              r|j                  |       }|j                         D ]   \  }}|| v r	 | | |   |      f ||f " y# t        $ r+}dt        |       dt        |       }t	        |      |d}~wt        $ r+}dt        |       dt        |       }t        |      |d}~ww xY ww)a  
    Apply formatters to a dictionary of values. If the value is a pydantic model,
    it will be serialized to a dictionary first, taking into account the
    ``unaliased`` parameter.

    :param formatters: The formatters to apply to the dictionary.
    :param value: The dictionary-like object to apply the formatters to.
    :param unaliased: If the model is a ``CamelModel``, whether to turn off
        serialization by alias (camelCase).
    :return: A generator that yields the formatted key-value pairs.
    )by_aliaszCould not format invalid value z
 as field NzCould not format invalid type )
isinstancer	   
model_dumpitems
ValueErrorr*   	TypeError)r   r   r/   keyr   excnew_error_messages          r   apply_formatters_to_dictr:   \   s     " %$  i- 8[[] 	T*<?:c?4000 t)O  =5d4j\DQTI;W " !!23< <4T$ZL
4PS9+V "   12;	<s5   >CA
C	C #&B		C &B;;C  Cc              #   .   K   |D ]  } | |        y wr   r   )r   r   r   s      r   apply_formatter_to_arrayr<      s!       os   formatter_condition_pairsc                 P    | D ]  \  }} ||      s ||      c S  t        d      )NzBThe provided value did not satisfy any of the formatter conditions)r5   )r=   r   r,   r   s       r   apply_one_of_formattersr?      s=     !: 
	9UU##
 P
 	
r&   key_mappingsc              #   >  K   t        j                               j                  | j                               j                  fd| j	                         D              }|rt        d|       j	                         D ]  \  }}|| v r
| |   |f ||f  y w)Nc              3   2   K   | ]  \  }}|v s|  y wr   r   )r   kvr   s      r   r!   z apply_key_map.<locals>.<genexpr>   s     GDAqAJaGs   z3Could not apply key map due to conflicting key(s): )setkeys
differenceintersectionr4   KeyError)r@   r   key_conflictsr7   r   s    `   r   apply_key_maprK      s     
 	EJJL	L%%'	(	GL$6$6$8G	G 
 A-Q
 	
 [[] 	T,s#T))t)O	s   BB)F)collections.abcr   r   typingr   r"   
decoratorsr   
functionalr   pydanticr	   toolzr
   r   list
Formattersintr   r%   r+   boolr.   dicttupler:   r<   r?   rK   r   r&   r   <module>rX      s   
 tCyk49,-
 S!-09=ctCy$$% T(382D-E * * 
S	
%)#Y
tCy$$%
 
$T	"/7S/AJM 	 "S#X"S>J&" " uS#Xd*+	" 	"J S!*.s)tCy$$% 

$U8CH+=xS?Q+Q%RS



 	

 	sCx.)-c3huS#Xd*+ 	r&   