
    ":hK                     	   d dl Z d dlZd dlZd dlmZmZmZmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZmZmZ eej&                  eej&                  gef   f   Zeegef   Zee
j0                  gef   Zeeeej4                     f   Zeeee
j8                     f   Z G d	 d
e j<                        Z G d de      Z  G d d      Z! G d de!      Z" G d de!      Z#d Z$d Z%d Z&d Z' G d d      Z( G d dee(      Z) e)       Z*e*jW                   e#d      ejX                  e
jZ                  d       e*jW                   e#d      ej\                  e
j^                  d       e*jW                   e#d      ej`                  e
jb                  d       e*jW                   e#d      ejd                  e
jf                  d       e*jW                   e#d       ejh                  e
jj                  d        e*jW                   e#d!      ejl                  e
jn                  d!       e*jW                   e#d"d#$      ejp                  e
jr                  d%       e*jW                   e#d"d&$      ejt                  e
jv                  d"       e*jW                   e#d'      ejp                  e
jr                  d'       e*jW                   e#d(      ejx                  e
jz                  d(       e*jW                  e$ej|                  e
j~                  d)       e*jW                  e%ej                  e
j                  d*        e)       ZBeBj                   e#d      ej                  d       eBj                   e#d      ej                  d       eBj                   e#d      ej                  d       eBj                   e#d      ej                  d       eBj                   e#d       ej                  d        eBj                   e#d!      ej                  d!       eBj                   e#d"d#$      ej                  d%       eBj                   e#d"d&$      ej                  d"       eBj                   e#d'      ej                  d'       eBj                   e#d(      ej                  d(       eBj                  e$ej                  d)       eBj                  e%ej                  d*       y)+    N)AnyCallableTypeUnion   )abi   )decodingencoding
exceptionsgrammar)	BaseCoder)ABITypeErrorMultipleEntriesFoundNoEntriesFoundc                   <    e Zd Zej                  d        Zd Zd Zy)Copyablec                      y N selfs    h/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/static_dependencies/ethereum/abi/registry.pycopyzCopyable.copy(   s        c                 "    | j                         S r   r   r   s    r   __copy__zCopyable.__copy__,       yy{r   c                 "    | j                         S r   r   )r   argss     r   __deepcopy__zCopyable.__deepcopy__/   r   r   N)__name__
__module____qualname__abcabstractmethodr   r   r"   r   r   r   r   r   '   s$     r   r   c                   B    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zy)PredicateMappingz
    Acts as a mapping from predicate functions to values.  Values are retrieved
    when their corresponding predicate matches a given input.  Predicates can
    also be labeled to facilitate removal from the mapping.
    c                 .    || _         i | _        i | _        y r   )_name_values_labeled_predicates)r   names     r   __init__zPredicateMapping.__init__:   s    
#% r   Nc                 6   || j                   v r.t        dj                  t        |      | j                              |L|| j
                  v r/t        dj                  t        |      || j                              || j
                  |<   || j                   |<   y )NzMatcher {} already exists in {}z/Matcher {} with label '{}' already exists in {})r,   
ValueErrorformatreprr+   r-   )r   	predicatevaluelabels       r   addzPredicateMapping.add?   s    $188OJJ  000 ELLY

  /8D$$U+"'Yr   c           	         t        fd| j                  j                         D              }t        |      dk(  r%t	        dj                  | j                              t        t        |       \  }}t        |      dkD  r>dj                  t        t        |            }t        d d| j                   d| d	      |d   S )
Nc              3   <   K   | ]  \  }} |      r||f  y wr   r   ).0r4   r5   type_strs      r   	<genexpr>z(PredicateMapping.find.<locals>.<genexpr>W   s*      
 	5" 
s   r   z"No matching entries for '{}' in {}r	   z, zMultiple matching entries for 'z' in z: z. This occurs when two registrations match the same type string. You may need to delete one of the registrations or modify its matching behavior to ensure it doesn't collide with other registrations. See the "Registry" documentation for more information.)tupler,   itemslenr   r2   r+   zipjoinmapr3   r   )r   r;   results
predicatesvaluespredicate_reprss    `    r   findzPredicateMapping.findV   s     
$(LL$6$6$8
 
 w<1 4;;JJ  #3=1
Fw<!"iiD*(=>O&1(5B"# $66  ayr   c                     	 | j                   |= 	 | j                  |      }| j                  |= y # t        $ r/ t        dj                  t        |      | j                              w xY w# t        $ r Y y w xY w)NzMatcher {} not found in {})r,   KeyErrorr2   r3   r+   _label_for_predicater-   r1   )r   r4   r6   s      r   remove_by_equalityz#PredicateMapping.remove_by_equalityt   s    	Y'	0--i8E ((/  	,33OJJ 	  		s   / A* 8A'*	A65A6c                     | j                   j                         D ]  \  }}||u s|c S  t        dj                  t	        |      | j
                              )Nz-Matcher {} not referred to by any label in {})r-   r>   r1   r2   r3   r+   )r   r4   keyr5   s       r   rJ   z%PredicateMapping._label_for_predicate   s^     2288: 	JC	!
	 ;BBY


 	
r   c                     	 | j                   |   }| j                   |= | j                  |= y # t        $ r& t        dj                  || j                              w xY w)NzLabel '{}' not found in {})r-   rI   r2   r+   r,   )r   r6   r4   s      r   remove_by_labelz PredicateMapping.remove_by_label   sd    	S007I $$U+LL#	  	S7>>udjjQRR	Ss	   , /Ac                     t        |      r| j                  |       y t        |t              r| j	                  |       y t        dj                  t        |                  )Nz4Key to be removed must be callable or string: got {})callablerK   
isinstancestrrO   	TypeErrorr2   type)r   predicate_or_labels     r   removezPredicateMapping.remove   sX    &'##$67*C0  !34FMM+, r   c                      t        |       | j                        }t        j                  | j                        |_        t        j                  | j                        |_        |S r   )rU   r+   r   r,   r-   r   cpys     r   r   zPredicateMapping.copy   sF    d4j$ii-"&))D,D,D"E
r   r   )r#   r$   r%   __doc__r/   r7   rG   rK   rJ   rO   rW   r   r   r   r   r)   r)   3   s/    &
(.<0(
$
r   r)   c                   B    e Zd ZdZ e       Zd Zd Zd Zd Z	d Z
d Zy)		Predicatez^
    Represents a predicate function to be used for type matching in
    ``ABIRegistry``.
    c                     t        d      )NzMust implement `__call__`NotImplementedError)r   r!   kwargss      r   __call__zPredicate.__call__   s    !"=>>r   c                     t        d      )NzMust implement `__str__`r_   r   s    r   __str__zPredicate.__str__   s    !"<==r   c                 L    dj                  t        |       j                  |       S )Nz<{} {}>)r2   rU   r#   r   s    r   __repr__zPredicate.__repr__   s    T
 3 3T::r   c              #   J   K   | j                   D ]  }t        | |        y wr   )	__slots__getattr)r   attrs     r   __iter__zPredicate.__iter__   s&     NN 	&D$%%	&s   !#c                 *    t        t        |             S r   )hashr=   r   s    r   __hash__zPredicate.__hash__   s    E$K  r   c                 `    t        |       t        |      u xr t        |       t        |      k(  S r   )rU   r=   r   others     r   __eq__zPredicate.__eq__   s'    DzT%[(HU4[E%L-HHr   N)r#   r$   r%   r[   r=   rh   rb   rd   rf   rk   rn   rr   r   r   r   r]   r]      s/    
 I?>;&!Ir   r]   c                   &    e Zd ZdZdZd Zd Zd Zy)Equalsz>
    A predicate that matches any input equal to `value`.
    r5   c                     || _         y r   ru   )r   r5   s     r   r/   zEquals.__init__   s	    
r   c                      | j                   |k(  S r   ru   rp   s     r   rb   zEquals.__call__   s    zzU""r   c                 J    dj                  t        | j                              S )Nz(== {}))r2   r3   r5   r   s    r   rd   zEquals.__str__   s    TZZ 011r   Nr#   r$   r%   r[   rh   r/   rb   rd   r   r   r   rt   rt      s     I#2r   rt   c                   ,    e Zd ZdZdZdddZd Zd Zy)
BaseEqualsal  
    A predicate that matches a basic type string with a base component equal to
    `value` and no array component.  If `with_sub` is `True`, the type string
    must have a sub component to match.  If `with_sub` is `False`, the type
    string must *not* have a sub component to match.  If `with_sub` is None,
    the type string's sub component is ignored.
    basewith_subNr~   c                     || _         || _        y r   r|   )r   r}   r~   s      r   r/   zBaseEquals.__init__   s    	 r   c                 ^   	 t        j                  |      }t	        |t         j
                        rd|j                  y| j                  2| j                  r|j                  y| j                  s|j                  y|j                  | j                  k(  S y# t        j                  $ r Y yw xY w)NF)
r   parser   
ParseErrorrR   	BasicTypearrlistr~   subr}   )r   r;   abi_types      r   rb   zBaseEquals.__call__   s    	}}X.H h 1 12+}}(==X\\%9 }})A ==DII-- # $$ 		s   B B,+B,c                     dj                  t        | j                        | j                  d      S | j                  rd      S d      S )Nz(base == {}{}) z and sub is not Nonez and sub is None)r2   r3   r}   r~   r   s    r   rd   zBaseEquals.__str__  sV    &&O}}$ 
 	
 -1MM(	
 	
 @R	
 	
r   ry   r   r   r   r{   r{      s      %I)- !,
r   r{   c                 |    	 t        j                  |       }|j                  duS # t        j                  $ r Y yw xY w)zN
    A predicate that matches a type string with an array dimension list.
    FN)r   r   r   r   r   r;   r   s     r   has_arrlistr     sB    ==* 4''    s   % ;;c                     	 t        j                  |       }t	        |t         j
                        xr |j                  du S # t        j                  $ r Y yw xY w)zM
    A predicate that matches a tuple type with no array dimension list.
    FN)r   r   r   r   rR   	TupleTyper   r   s     r   is_base_tupler     sT    ==* h 1 12Ox7G7G47OO    s   A AAc                 B     t        j                          fd       }|S )Nc                 P    | j                   j                           | g|i |S r   )get_encodercache_clearr   r!   ra   
old_methods      r   
new_methodz(_clear_encoder_cache.<locals>.new_method(  *    $$&$0000r   	functoolswrapsr   r   s   ` r   _clear_encoder_cacher   '  &    __Z 1 !1 r   c                 B     t        j                          fd       }|S )Nc                 P    | j                   j                           | g|i |S r   )get_decoderr   r   s      r   r   z(_clear_decoder_cache.<locals>.new_method1  r   r   r   r   s   ` r   _clear_decoder_cacher   0  r   r   c                   >    e Zd Zedd       Zed        Zed        Zy)BaseRegistryNc                     t        |      r| j                  |||       y t        |t              r| j                  t	        |      ||       y t        dj                  t        |                  )Nz:Lookup must be a callable or a value of type `str`: got {})rQ   r7   rR   rS   rt   rT   r2   r3   )mappinglookupr5   r6   s       r   	_registerzBaseRegistry._register:  s`    FKKu-fc"KKvv6HOOV
 	
r   c                     t        |      r| j                  |       y t        |t              r| j	                  |       y t        dj                  t        |                  )Nz@Lookup/label must be a callable or a value of type `str`: got {})rQ   rK   rR   rS   rO   rT   r2   r3   )r   lookup_or_labels     r   _unregisterzBaseRegistry._unregisterJ  sY    O$&&7os+##O4NUU_%
 	
r   c                     	 | j                  |      }|S # t        $ r,}d|j                  d   v rt        j                  |        d }~ww xY w)NzNo matchingr   )rG   r1   r!   r   r   )r   r;   r5   es       r   _get_registrationzBaseRegistry._get_registrationZ  sO    	LL*E   	q	) h'	s    	A
'AA
r   )r#   r$   r%   staticmethodr   r   r   r   r   r   r   r   9  s<    
 
 
 
  r   r   c                   b    e Zd Zd Z fdZe	 ddedededdfd       Z	ed	eddfd
       Z
e	 ddedededdfd       Zed	eddfd       Z	 ddededededdf
dZdeddfdZ ej$                  d      d        Zdej*                  defdZ ej$                  d      d        Zd Z xZS )ABIRegistryc                 D    t        d      | _        t        d      | _        y )Nzencoder registryzdecoder registry)r)   	_encoders	_decodersr   s    r   r/   zABIRegistry.__init__j  s    )*<=)*<=r   c                     t         |   ||      }t        |t              r"t	        |t
              r|j                  ||       S |S r   )superr   rR   rU   
issubclassr   from_type_str)r   r   r;   coder	__class__s       r   r   zABIRegistry._get_registrationn  s?    )'8<eT"z%'C&&x66r   Nr   encoderr6   returnc                 B    | j                  | j                  |||       y)a  
        Registers the given ``encoder`` under the given ``lookup``.  A unique
        string label may be optionally provided that can be used to refer to
        the registration by name.  For more information about arguments, refer
        to :any:`register`.
        r6   N)r   r   )r   r   r   r6   s       r   register_encoderzABIRegistry.register_encoderv       	t~~vweDr   r   c                 <    | j                  | j                  |       y)aG  
        Unregisters an encoder in the registry with the given lookup or label.
        If ``lookup_or_label`` is a string, the encoder with the label
        ``lookup_or_label`` will be unregistered.  If it is an function, the
        encoder with the lookup function ``lookup_or_label`` will be
        unregistered.
        N)r   r   r   r   s     r   unregister_encoderzABIRegistry.unregister_encoder       	9r   decoderc                 B    | j                  | j                  |||       y)a  
        Registers the given ``decoder`` under the given ``lookup``.  A unique
        string label may be optionally provided that can be used to refer to
        the registration by name.  For more information about arguments, refer
        to :any:`register`.
        r   N)r   r   )r   r   r   r6   s       r   register_decoderzABIRegistry.register_decoder  r   r   c                 <    | j                  | j                  |       y)aF  
        Unregisters a decoder in the registry with the given lookup or label.
        If ``lookup_or_label`` is a string, the decoder with the label
        ``lookup_or_label`` will be unregistered.  If it is an function, the
        decoder with the lookup function ``lookup_or_label`` will be
        unregistered.
        N)r   r   r   s     r   unregister_decoderzABIRegistry.unregister_decoder  r   r   c                 T    | j                  |||       | j                  |||       y)a  
        Registers the given ``encoder`` and ``decoder`` under the given
        ``lookup``.  A unique string label may be optionally provided that can
        be used to refer to the registration by name.

        :param lookup: A type string or type string matcher function
            (predicate).  When the registry is queried with a type string
            ``query`` to determine which encoder or decoder to use, ``query``
            will be checked against every registration in the registry.  If a
            registration was created with a type string for ``lookup``, it will
            be considered a match if ``lookup == query``.  If a registration
            was created with a matcher function for ``lookup``, it will be
            considered a match if ``lookup(query) is True``.  If more than one
            registration is found to be a match, then an exception is raised.

        :param encoder: An encoder callable or class to use if ``lookup``
            matches a query.  If ``encoder`` is a callable, it must accept a
            python value and return a ``bytes`` value.  If ``encoder`` is a
            class, it must be a valid subclass of :any:`encoding.BaseEncoder`
            and must also implement the :any:`from_type_str` method on
            :any:`base.BaseCoder`.

        :param decoder: A decoder callable or class to use if ``lookup``
            matches a query.  If ``decoder`` is a callable, it must accept a
            stream-like object of bytes and return a python value.  If
            ``decoder`` is a class, it must be a valid subclass of
            :any:`decoding.BaseDecoder` and must also implement the
            :any:`from_type_str` method on :any:`base.BaseCoder`.

        :param label: An optional label that can be used to refer to this
            registration by name.  This label can be used to unregister an
            entry in the registry via the :any:`unregister` method and its
            variants.
        r   N)r   r   )r   r   r   r   r6   s        r   registerzABIRegistry.register  s/    J 	fgU;fgU;r   c                 H    | j                  |       | j                  |       y)zw
        Unregisters the entries in the encoder and decoder registries which
        have the label ``label``.
        N)r   r   )r   r6   s     r   
unregisterzABIRegistry.unregister  s     
 	&&r   )maxsizec                 :    | j                  | j                  |      S r   )r   r   r   r;   s     r   r   zABIRegistry.get_encoder      %%dnnh??r   r;   c                 R    	 | j                  |       y# t        t        f$ r Y yw xY w)z
        Returns ``True`` if an encoder is found for the given type string
        ``type_str``.  Otherwise, returns ``False``.  Raises
        :class:`~eth_abi.exceptions.MultipleEntriesFound` if multiple encoders
        are found.
        TF)r   r   r   r   s     r   has_encoderzABIRegistry.has_encoder  s3    	X&  n- 		s    &&c                 :    | j                  | j                  |      S r   )r   r   r   s     r   r   zABIRegistry.get_decoder  r   r   c                      t        |              }t        j                  | j                        |_        t        j                  | j                        |_        |S )a  
        Copies a registry such that new registrations can be made or existing
        registrations can be unregistered without affecting any instance from
        which a copy was obtained.  This is useful if an existing registry
        fulfills most of a user's needs but requires one or two modifications.
        In that case, a copy of that registry can be obtained and the necessary
        changes made without affecting the original registry.
        )rU   r   r   r   rY   s     r   r   zABIRegistry.copy  s>     d4jl		$..1		$..1
r   r   )r#   r$   r%   r/   r   r   LookupEncoderrS   r   r   r   Decoderr   r   r   r   r   	lru_cacher   r   TypeStrboolr   r   r   __classcell__)r   s   @r   r   r   i  su   > =A	E	E'.	E7:	E		E 	E :& :T : : =A	E	E'.	E7:	E		E 	E :& :T : : PT&<&<'.&<9@&<IL&<	&<P' ' ' Y&@ '@CKK D  Y&@ '@r   r   uintr   intaddressr   ufixedfixedbytesTr   zbytes<M>Ffunctionstringr   r   )Nr&   r   r   typingr   r   r   r   r   r   r
   r   r   r   r}   r   r   r   r   r   r   r   r   EncoderCallableContextFramesBytesIODecoderCallableBaseEncoderr   BaseDecoderr   ABCr   r)   r]   rt   r{   r   r   r   r   r   r   registryr   UnsignedIntegerEncoderUnsignedIntegerDecoderSignedIntegerEncoderSignedIntegerDecoderAddressEncoderAddressDecoderBooleanEncoderBooleanDecoderUnsignedFixedEncoderUnsignedFixedDecoderSignedFixedEncoderSignedFixedDecoderBytesEncoderBytesDecoderByteStringEncoderByteStringDecoderTextStringEncoderStringDecoderBaseArrayEncoderBaseArrayDecoderTupleEncoderTupleDecoderregistry_packedr   PackedUnsignedIntegerEncoderPackedSignedIntegerEncoderPackedAddressEncoderPackedBooleanEncoderPackedUnsignedFixedEncoderPackedSignedFixedEncoderPackedBytesEncoderPackedByteStringEncoderPackedTextStringEncoderPackedArrayEncoderr   r   r   <module>r     sr   
      
s{{Hckk]D%899	:C5%<(H99:C?@
h&:&:!;;
<
h&:&:!;;
<	sww 	~x ~BI I82Y 2"+
 +
\	(	P- -`O(L Od =   v####
	   	  u!!!!
	   	  y
	   	  v
	   	  x!!!!
	   	  w
	   	  w&
	   	  w'
	   	  z
	   	  x
	   	  
	   	  
	   -     v))
 ! 
     u''
 ! 
     y!!
 ! 
     v!!
 ! 
     x''
 ! 
     w%%
 ! 
     w&
 ! 
     w'$$
 ! 
     z
 ! 
     x$$
 ! 
     
 ! 
     
 ! r   