
    ":h                         d dl mZmZmZ d dl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 dd	lmZ dd
lmZ  G d d      Z G d de      Z G d de      Z G d dee      Zy)    )AnyIterableTupleN   )	DecodableTypeStr)is_bytes   )ContextFramesBytesIOTupleDecoder)TupleEncoder)EncodingError)ABIRegistryc                       e Zd ZdZdefdZy)BaseABICoderz
    Base class for porcelain coding APIs.  These are classes which wrap
    instances of :class:`~.registry.ABIRegistry` to provide last-mile
    coding functionality.
    registryc                     || _         y)z
        Constructor.

        :param registry: The registry providing the encoders to be used when
            encoding values.
        N)	_registry)selfr   s     e/var/www/html/turnos/venv/lib/python3.12/site-packages/ccxt/static_dependencies/ethereum/abi/codec.py__init__zBaseABICoder.__init__&   s     "    N)__name__
__module____qualname____doc__r   r    r   r   r   r      s    " "r   r   c                   n    e Zd ZdZdededefdZdee   dee   defdZ	d	 Z
dededefd
ZdedefdZy)
ABIEncoderzG
    Wraps a registry to provide last-mile encoding functionality.
    typargreturnc                 ~    t        j                  dt               | j                  j	                  |      } ||      S )a  
        Encodes the python value ``arg`` as a binary value of the ABI type
        ``typ``.

        :param typ: The string representation of the ABI type that will be used
            for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
            etc.
        :param arg: The python value to be encoded.

        :returns: The binary representation of the python value ``arg`` as a
            value of the ABI type ``typ``.
        zabi.encode_single() and abi.encode_single_packed() are deprecated and will be removed in version 4.0.0 in favor of abi.encode() and abi.encode_packed(), respectivelycategory)warningswarnDeprecationWarningr   get_encoderr   r    r!   encoders       r   encode_singlezABIEncoder.encode_single5   s:     	0 (		
 ..,,S1s|r   typesargsc                 \    t        j                  dt               | j                  ||      S )a"  
        Encodes the python values in ``args`` as a sequence of binary values of
        the ABI types in ``types`` via the head-tail mechanism.

        :param types: An iterable of string representations of the ABI types
            that will be used for encoding e.g.  ``('uint256', 'bytes[]',
            '(int,int)')``
        :param args: An iterable of python values to be encoded.

        :returns: The head-tail encoded binary representation of the python
            values in ``args`` as values of the ABI types in ``types``.
        zabi.encode_abi() and abi.encode_abi_packed() are deprecated and will be removed in version 4.0.0 in favor of abi.encode() and abi.encode_packed(), respectivelyr$   )r&   r'   r(   encode)r   r-   r.   s      r   
encode_abizABIEncoder.encode_abiM   s-     	0 (		
 {{5$''r   c                     |D cg c]  }| j                   j                  |       }}t        |      } ||      S c c}w )N)encoders)r   r)   r   )r   r-   r.   type_strr3   r+   s         r   r0   zABIEncoder.encodeb   s>    INOXDNN..x8OO1t}	 Ps   "=c                     | j                   j                  |      }	 |j                  |       y# t        $ r Y yt        $ r 	  ||       Y y# t        $ r Y Y yw xY ww xY w)a  
        Determines if the python value ``arg`` is encodable as a value of the
        ABI type ``typ``.

        :param typ: A string representation for the ABI type against which the
            python value ``arg`` will be checked e.g. ``'uint256'``,
            ``'bytes[]'``, ``'(int,int)'``, etc.
        :param arg: The python value whose encodability should be checked.

        :returns: ``True`` if ``arg`` is encodable as a value of the ABI type
            ``typ``.  Otherwise, ``False``.
        FT)r   r)   validate_valuer   AttributeErrorr*   s       r   is_encodablezABIEncoder.is_encodablei   sq     ..,,S1	""3'   	 	  ! 	s,   / 	AAA	AAAAc                 8    | j                   j                  |      S )a  
        Returns ``True`` if values for the ABI type ``typ`` can be encoded by
        this codec.

        :param typ: A string representation for the ABI type that will be
            checked for encodability e.g. ``'uint256'``, ``'bytes[]'``,
            ``'(int,int)'``, etc.

        :returns: ``True`` if values for ``typ`` can be encoded by this codec.
            Otherwise, ``False``.
        )r   has_encoder)r   r    s     r   is_encodable_typezABIEncoder.is_encodable_type   s     ~~))#..r   N)r   r   r   r   r   r   bytesr,   r   r1   r0   boolr8   r;   r   r   r   r   r   0   sv     s u 0( 1 (# (5 (* c d 6/W / /r   r   c                   R    e Zd ZdZeZdededefdZ	de
e   dedeedf   fdZd	 Zy
)
ABIDecoderzG
    Wraps a registry to provide last-mile decoding functionality.
    r    datar"   c                     t        j                  dt               t        |      s#t	        dj                  t        |                  | j                  j                  |      }| j                  |      } ||      S )a  
        Decodes the binary value ``data`` of the ABI type ``typ`` into its
        equivalent python value.

        :param typ: The string representation of the ABI type that will be used for
            decoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``, etc.
        :param data: The binary value to be decoded.

        :returns: The equivalent python value of the ABI value represented in
            ``data``.
        z_abi.decode_single() is deprecated and will be removed in version 4.0.0 in favor of abi.decode()r$   z0The `data` value must be of bytes type.  Got {0})
r&   r'   r(   r	   	TypeErrorformattyper   get_decoderstream_class)r   r    r@   decoderstreams        r   decode_singlezABIDecoder.decode_single   sp     	''	
 ~BII$t*U  ..,,S1""4(vr   r-   .c                 \    t        j                  dt               | j                  ||      S )a	  
        Decodes the binary value ``data`` as a sequence of values of the ABI types
        in ``types`` via the head-tail mechanism into a tuple of equivalent python
        values.

        :param types: An iterable of string representations of the ABI types that
            will be used for decoding e.g. ``('uint256', 'bytes[]', '(int,int)')``
        :param data: The binary value to be decoded.

        :returns: A tuple of equivalent python values for the ABI values
            represented in ``data``.
        z\abi.decode_abi() is deprecated and will be removed in version 4.0.0 in favor of abi.decode()r$   )r&   r'   r(   decode)r   r-   r@   s      r   
decode_abizABIDecoder.decode_abi   s+     	$'	

 {{5$''r   c                     t        |      st        dt        |             |D cg c]  }| j                  j	                  |       }}t        |      }| j                  |      } ||      S c c}w )Nz-The `data` value must be of bytes type.  Got )decoders)r	   rB   rD   r   rE   r   rF   )r   r-   r@   r4   rN   rG   rH   s          r   rK   zABIDecoder.decode   st    ~?T
|L  JOOXDNN..x8OO1""4(v Ps   "A0N)r   r   r   r   r   rF   r   r   r   rI   r   r   rL   rK   r   r   r   r?   r?      sU     (L 	 c 8( 1 ( (uSRUX ((r   r?   c                       e Zd Zy)ABICodecN)r   r   r   r   r   r   rP   rP      s    r   rP   )typingr   r   r   r&   
typing.abir   r   utilsr	   decodingr   r   encodingr   
exceptionsr   r   r   r   r   r?   rP   r   r   r   <module>rW      sh    
 
" ""`/ `/FB BJ	z: 	r   