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

        :param registry: The registry providing the encoders to be used when
            encoding values.
        N)	_registry)selfr   s     i/var/www/html/volatility/venv/lib/python3.11/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      s9         " " " " " " "r   r   c                   |    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dS )
ABIEncoderzG
    Wraps a registry to provide last-mile encoding functionality.
    typargreturnc                     t          j        dt                     | 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   sL     	0 (		
 	
 	
 	
 .,,S11ws||r   typesargsc                 d    t          j        dt                     |                     ||          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                 V      fd|D             }t          |          } ||          S )Nc                 D    g | ]}j                             |          S r   )r   r*   .0type_strr   s     r   
<listcomp>z%ABIEncoder.encode.<locals>.<listcomp>c   )    OOOXDN..x88OOOr   )encodersr   )r   r.   r/   r:   r,   s   `    r   r1   zABIEncoder.encodeb   s:    OOOOOOO111wt}}r   c                     | j                             |          }	 |                    |           n;# t          $ r Y dS t          $ r" 	  ||           n# t          $ r Y Y dS w xY wY nw xY wdS )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   s     .,,S11	""3'''' 	 	 	55 	 	 	    uuu 	 ts8   2 
A*	A*	AA*
A$A*#A$$A*)A*c                 6    | 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   r2   r1   boolr>   rA   r   r   r   r    r    0   s          s u    0( 1 (# (5 ( ( ( (*   c d    6/W / / / / / / /r   r    c                   `    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d
S )
ABIDecoderzG
    Wraps a registry to provide last-mile decoding functionality.
    r!   datar#   c                 (   t          j        dt                     t          |          s/t	          d                    t          |                              | 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!   rF   decoderstreams        r   decode_singlezABIDecoder.decode_single   s     	''	
 	
 	
 	
 ~~ 	BII$t**UU   .,,S11""4((wvr   r.   .c                 d    t          j        dt                     |                     ||          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.   rF   s      r   
decode_abizABIDecoder.decode_abi   s;     	$'	
 	
 	
 	

 {{5$'''r   c                      t          |          st          dt          |                      fd|D             }t          |          }                     |          } ||          S )Nz-The `data` value must be of bytes type.  Got c                 D    g | ]}j                             |          S r   )r   rK   r5   s     r   r8   z%ABIDecoder.decode.<locals>.<listcomp>   r9   r   )decoders)r	   rH   rJ   r   rL   )r   r.   rF   rU   rM   rN   s   `     r   rQ   zABIDecoder.decode   s    ~~ 	LT

LL   POOOOOO111""4((wvr   N)r   r   r   r   r   rL   r   r   r   rO   r   r   rR   rQ   r   r   r   rE   rE      s          (L 	 c    8( 1 ( (uSRUX ( ( ( ((    r   rE   c                       e Zd ZdS )ABICodecN)r   r   r   r   r   r   rW   rW      s        Dr   rW   )typingr   r   r   r'   
typing.abir   r   utilsr	   decodingr   r   encodingr   
exceptionsr   r   r   r   r    rE   rW   r   r   r   <module>r^      s           
                                   
" " " " " " " ""`/ `/ `/ `/ `/ `/ `/ `/FB B B B B B B BJ	 	 	 	 	z: 	 	 	 	 	r   