
    E#i                         S SK JrJrJr  S SKrSSKJrJr  SSKJ	r	  SSK
JrJr  SSKJr  SS	KJr  SS
KJr   " S S5      r " S S\5      r " S S\5      r " S S\\5      rg)    )AnyIterableTupleN   )	DecodableTypeStr)is_bytes   )ContextFramesBytesIOTupleDecoder)TupleEncoder)EncodingError)ABIRegistryc                   &    \ rS rSrSrS\4S jrSrg)BaseABICoder   z
Base class for porcelain coding APIs.  These are classes which wrap
instances of :class:`~.registry.ABIRegistry` to provide last-mile
coding functionality.
registryc                     Xl         g)zi
Constructor.

:param registry: The registry providing the encoders to be used when
    encoding values.
N	_registry)selfr   s     e/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/static_dependencies/ethereum/abi/codec.py__init__BaseABICoder.__init__&   s	     "    r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    " "r   r   c                   ~    \ rS rSrSrS\S\S\4S jrS\	\   S\	\   S\4S	 jr
S
 rS\S\S\4S jrS\S\4S jrSrg)
ABIEncoder0   z?
Wraps a registry to provide last-mile encoding functionality.
typargreturnc                 z    [         R                  " S[        S9  U R                  R	                  U5      nU" U5      $ )ay  
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_singleABIEncoder.encode_single5   s:     	0 (		
 ..,,S1s|r   typesargsc                 V    [         R                  " S[        S9  U R                  X5      $ )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   r4   r5   s      r   
encode_abiABIEncoder.encode_abiM   s+     	0 (		
 {{5''r   c                     U Vs/ s H  o0R                   R                  U5      PM     nn[        US9nU" U5      $ s  snf )N)encoders)r   r/   r   )r   r4   r5   type_strr;   r1   s         r   r7   ABIEncoder.encodeb   s=    INOXNN..x8O1t}	 Ps   $<c                     U R                   R                  U5      n UR                  U5        g! [         a     g[         a     U" U5         g! [         a      gf = ff = f)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   AttributeErrorr0   s       r   is_encodableABIEncoder.is_encodablei   sq     ..,,S1	""3'   	 	  ! 	s,   / 
A!	A!A
AA!AA!c                 8    U R                   R                  U5      $ )aR  
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_typeABIEncoder.is_encodable_type   s     ~~))#..r   r"   N)r   r   r   r   r    r   r   bytesr2   r   r8   r7   boolrA   rE   r!   r"   r   r   r$   r$   0   sv     s u 0( 1 (# (5 (* c d 6/W / /r   r$   c                   ^    \ rS rSrSr\rS\S\S\	4S jr
S\\   S\S\\	S4   4S	 jrS
 rSrg)
ABIDecoder   z?
Wraps a registry to provide last-mile decoding functionality.
r&   datar(   c                    [         R                  " S[        S9  [        U5      (       d#  [	        SR                  [        U5      5      5      eU R                  R                  U5      nU R                  U5      nU" U5      $ )ar  
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&   rL   decoderstreams        r   decode_singleABIDecoder.decode_single   sr     	''	
 ~~BII$t*U  ..,,S1""4(vr   r4   .c                 V    [         R                  " S[        S9  U R                  X5      $ )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   r4   rL   s      r   
decode_abiABIDecoder.decode_abi   s)     	$'	

 {{5''r   c                     [        U5      (       d  [        S[        U5       35      eU Vs/ s H  o0R                  R	                  U5      PM     nn[        US9nU R                  U5      nU" U5      $ s  snf )Nz-The `data` value must be of bytes type.  Got )decoders)r	   rN   rP   r   rQ   r   rR   )r   r4   rL   r<   r\   rS   rT   s          r   rX   ABIDecoder.decode   su    ~~?T
|L  JOOXNN..x8O1""4(v Ps   $A4r"   N)r   r   r   r   r    r   rR   r   r   r   rU   r   r   rY   rX   r!   r"   r   r   rJ   rJ      sU     (L 	 c 8( 1 ( (uSRUX ((r   rJ   c                       \ rS rSrSrg)ABICodec   r"   N)r   r   r   r   r!   r"   r   r   r_   r_      s    r   r_   )typingr   r   r   r,   
typing.abir   r   utilsr	   decodingr   r   encodingr   
exceptionsr   r   r   r   r$   rJ   r_   r"   r   r   <module>rg      sh    
 
" ""`/ `/FB BJ	z: 	r   