
    (i7&                        d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	m
Z
 erd dlZ G d de      Z G d dee      Z G d d	ee      Z G d
 dee      Z G d dee      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Z G d" d#e      Z  G d$ d%ee       Z! G d& d'ee       Z" G d( d)e      Z# G d* d+e      Z$ G d, d-e      Z% G d. d/e      Z& G d0 d1e&      Z' G d2 d3e      Z( G d4 d5e      Z) G d6 d7e      Z* G d8 d9e      Z+ G d: d;e      Z, G d< d=e      Z- G d> d?e      Z. G d@ dAe      Z/ G dB dCe      Z0 G dD dEe0      Z1 G dF dGe0      Z2 G dH dIe0      Z3 G dJ dKe      Z4 G dL dMe4      Z5 G dN dOe      Z6 G dP dQe      Z7 G dR dSe      Z8 G dT dUe8e      Z9 G dV dWe8      Z: G dX dYe8      Z; G dZ d[e7      Z< G d\ d]e      Z= G d^ d_e=      Z> G d` dae=      Z? G db dce=      Z@ G dd dee=      ZA G df dge=      ZBy)h    N)TYPE_CHECKINGAnyDictOptionalUnion)	BlockDataRPCResponsec                   N     e Zd ZU dZdZee   ed<   dddedee   f fdZ	 xZ
S )Web3Exceptionz
    Exception mixin inherited by all exceptions of web3.py

    This allows::

        try:
            some_call()
        except Web3Exception:
            # deal with web3 exception
        except:
            # deal with other exceptions
    Nuser_messager   argsc                ,    t        |   |  || _        y N)super__init__r   )selfr   r   	__class__s      @/var/www/br/venv/lib/python3.12/site-packages/web3/exceptions.pyr   zWeb3Exception.__init__$   s    
 	$ )    )__name__
__module____qualname____doc__r   r   str__annotations__r   r   __classcell__r   s   @r   r   r      s=     #'L(3-&
 '+)) sm) )r   r   c                       e Zd ZdZy)Web3AssertionErrorzk
    A web3.py exception wrapper for `AssertionError`, for better control over
    exception handling.
    Nr   r   r   r    r   r   r    r    /       r   r    c                       e Zd ZdZy)Web3ValueErrorzg
    A web3.py exception wrapper for `ValueError`, for better control over
    exception handling.
    Nr!   r"   r   r   r%   r%   6   r#   r   r%   c                       e Zd ZdZy)Web3AttributeErrorzk
    A web3.py exception wrapper for `AttributeError`, for better control over
    exception handling.
    Nr!   r"   r   r   r'   r'   =   r#   r   r'   c                       e Zd ZdZy)Web3TypeErrorzf
    A web3.py exception wrapper for `TypeError`, for better control over
    exception handling.
    Nr!   r"   r   r   r)   r)   D   r#   r   r)   c                       e Zd ZdZy)MethodNotSupportedz@
    Raised when a method is not supported by the provider.
    Nr!   r"   r   r   r+   r+   K       r   r+   c                       e Zd ZdZy)BadFunctionCallOutputzH
    We failed to decode ABI output.

    Most likely ABI mismatch.
    Nr!   r"   r   r   r.   r.   Q   s    r   r.   c                       e Zd ZdZy)BlockNumberOutOfRangez=
    block_identifier passed does not match known block.
    Nr!   r"   r   r   r0   r0   Y   r,   r   r0   c                       e Zd ZdZy)ProviderConnectionErrorz5
    Raised when unable to connect to a provider
    Nr!   r"   r   r   r2   r2   _   r,   r   r2   c                       e Zd ZdZy)CannotHandleRequestz
    Raised by a provider to signal that it cannot handle an RPC request and
    that the manager should proceed to the next provider.
    Nr!   r"   r   r   r4   r4   e   r#   r   r4   c                       e Zd ZdZy)TooManyRequestsz]
    Raised by a provider to signal that too many requests have been made consecutively.
    Nr!   r"   r   r   r6   r6   l   r,   r   r6   c                       e Zd ZdZy)MultipleFailedRequestszw
    Raised by a provider to signal that multiple requests to retrieve the same
    (or similar) data have failed.
    Nr!   r"   r   r   r8   r8   r   r#   r   r8   c                       e Zd ZdZy)InvalidAddresszS
    The supplied address does not have a valid checksum, as defined in EIP-55
    Nr!   r"   r   r   r:   r:   y   r,   r   r:   c                       e Zd ZdZy)NameNotFoundzn
    Raised when a caller provides an Ethereum Name Service name that
    does not resolve to an address.
    Nr!   r"   r   r   r<   r<      r#   r   r<   c                   <     e Zd ZdZdededdf fdZdefdZ xZ	S )StaleBlockchainzO
    Raised by the stalecheck_middleware when the latest block is too old.
    blockallowable_delayreturnNc           	          t         j                   j                  |d         j                  d      }d|d    dt        j                         |d   z
   d| d| d	}t        |   |||       y )	N	timestampz%czThe latest block, #numberz, is z( seconds old, but is only allowed to be z- s old. The date of the most recent block is z#. Continue syncing and try again...)datetimefromtimestampstrftimetimer   r   )r   r?   r@   last_block_datemessager   s        r   r   zStaleBlockchain.__init__   s    "++99%:LMVV
 "%/!2%yy{U;//0 1,- .44C3D E'' 	 	%9r   c                      | j                   d   S )Nr   )r   )r   s    r   __str__zStaleBlockchain.__str__   s    yy|r   )
r   r   r   r   r   intr   r   rL   r   r   s   @r   r>   r>      s.    :i :# :$ : r   r>   c                       e Zd ZdZy)MismatchedABIz
    Raised when an ABI does not match with supplied parameters, or when an
    attempt is made to access a function/event that does not exist in the ABI.
    Nr!   r"   r   r   rO   rO      r#   r   rO   c                       e Zd ZdZy)ABIEventNotFoundz_
    Raised when an attempt is made to access an event
    that does not exist in the ABI.
    Nr!   r"   r   r   rQ   rQ      r#   r   rQ   c                       e Zd ZdZy)ABIFunctionNotFoundza
    Raised when an attempt is made to access a function
    that does not exist in the ABI.
    Nr!   r"   r   r   rS   rS      r#   r   rS   c                       e Zd ZdZy)ABIConstructorNotFoundzG
    Raised when a constructor function doesn't exist in contract.
    Nr!   r"   r   r   rU   rU      r,   r   rU   c                       e Zd ZdZy)ABIFallbackNotFoundzD
    Raised when a fallback function doesn't exist in contract.
    Nr!   r"   r   r   rW   rW      r,   r   rW   c                       e Zd ZdZy)ABIReceiveNotFoundzC
    Raised when a receive function doesn't exist in contract.
    Nr!   r"   r   r   rY   rY      r,   r   rY   c                       e Zd ZdZy)Web3ValidationErrorz2
    Raised when a supplied value is invalid.
    Nr!   r"   r   r   r[   r[      r,   r   r[   c                       e Zd ZdZy)ExtraDataLengthErrorzA
    Raised when an RPC call returns >32 bytes of extraData.
    Nr!   r"   r   r   r]   r]      r,   r   r]   c                       e Zd ZdZy)NoABIFunctionsFoundzK
    Raised when an ABI is present, but doesn't contain any functions.
    Nr!   r"   r   r   r_   r_      r,   r   r_   c                       e Zd ZdZy)
NoABIFoundz(
    Raised when no ABI is present.
    Nr!   r"   r   r   ra   ra      r,   r   ra   c                       e Zd ZdZy)NoABIEventsFoundz8
    Raised when an ABI doesn't contain any events.
    Nr!   r"   r   r   rc   rc      r,   r   rc   c                       e Zd ZdZy)InsufficientDatazV
    Raised when there are insufficient data points to
    complete a calculation
    Nr!   r"   r   r   re   re      r#   r   re   c                       e Zd ZdZy)TimeExhaustedzc
    Raised when a method has not retrieved the desired
    result within a specified timeout.
    Nr!   r"   r   r   rg   rg      r#   r   rg   c                       e Zd ZdZy)InfuraProjectIdNotFoundz8
    Raised when there is no Infura Project Id set.
    Nr!   r"   r   r   ri   ri      r,   r   ri   c                       e Zd ZdZy)LogTopicErrorz=
    Raised when the number of log topics is mismatched.
    Nr!   r"   r   r   rk   rk      r,   r   rk   c                       e Zd ZdZy)InvalidEventABIz/
    Raised when the event ABI is invalid.
    Nr!   r"   r   r   rm   rm      r,   r   rm   c            
       R     e Zd ZdZ	 	 ddee   deeeeeef   f      f fdZ xZ	S )ContractLogicErrorz+
    Raised on a contract revert error
    rJ   datac                 B    t         |   ||       || _        || _        y r   )r   r   rJ   rp   )r   rJ   rp   r   s      r   r   zContractLogicError.__init__  s"    
 	$'	r   NN)
r   r   r   r   r   r   r   r   r   r   r   s   @r   ro   ro     sG     "&59# uS$sCx.012 r   ro   c                       e Zd ZdZy)ContractCustomErrorz2
    Raised on a contract revert custom error
    Nr!   r"   r   r   rt   rt     r,   r   rt   c                       e Zd ZdZy)ContractPanicErrorzI
    Raised when a contract reverts with Panic, as of Solidity 0.8.0
    Nr!   r"   r   r   rv   rv     r,   r   rv   c                   B     e Zd ZdZddeeef   dee   ddf fdZ xZ	S )OffchainLookupzU
    Raised when a contract reverts with OffchainLookup as described in EIP-3668
    Npayloadrp   rA   c                 B    || _         || _        t        |   |       y )N)rp   )ry   rp   r   r   )r   ry   rp   r   s      r   r   zOffchainLookup.__init__!  s!    	d#r   r   )
r   r   r   r   r   r   r   r   r   r   r   s   @r   rx   rx     s3    $S#X $hsm $t $ $r   rx   c                   ,     e Zd ZdZdeddf fdZ xZS )InvalidTransactionzQ
    Raised when a transaction includes an invalid combination of arguments.
    rJ   rA   Nc                 $    t         |   |       y r   r   r   r   rJ   r   s     r   r   zInvalidTransaction.__init__,  s    !r   )r   r   r   r   r   r   r   r   s   @r   r|   r|   '  s     " " " "r   r|   c                   $     e Zd ZdZd fdZ xZS )TransactionTypeMismatchzq
    Raised when legacy transaction values are used alongside dynamic
    fee (EIP-1559) transaction values.
    c                 (    d}t         |   |       y )Nz-Found legacy and EIP 1559 transaction values.r~   r   s     r   r   z TransactionTypeMismatch.__init__6  s    A!r   )rA   N)r   r   r   r   r   r   r   s   @r   r   r   0  s    
" "r   r   c                       e Zd ZdZy)BadResponseFormatzL
    Raised when a JSON-RPC response comes back in an unexpected format
    Nr!   r"   r   r   r   r   ;  r,   r   r   c                   :     e Zd ZdZ	 ddddee   ddf fdZ xZS )	TaskNotRunningzq
    Used to signal between asyncio contexts that a task that is being awaited
    is not currently running.
    Ntaskzasyncio.Task[Any]rJ   rA   c                 P    || _         |d| d}|| _        t        |   |       y )NzTask z is not running.)r   rJ   r   r   )r   r   rJ   r   s      r   r   zTaskNotRunning.__init__G  s4     	?dV#34G!r   r   )r   r   r   r   r   r   r   r   r   s   @r   r   r   A  s5     CG"'"2:3-"	" "r   r   c                       e Zd ZdZy)PersistentConnectionErrorzB
    Raised when a persistent connection encounters an error.
    Nr!   r"   r   r   r   r   Q  r,   r   r   c                       e Zd ZdZy)ReadBufferLimitReachedzk
    Raised when the read buffer limit is reached while reading data from a persistent
    connection.
    Nr!   r"   r   r   r   r   W  r#   r   r   c                       e Zd ZdZy)PersistentConnectionClosedOKzQ
    Raised when a persistent connection is closed gracefully by the server.
    Nr!   r"   r   r   r   r   ^  r,   r   r   c                       e Zd ZdZy)SubscriptionProcessingFinishedzi
    Raised to alert the subscription manager that the processing of subscriptions
    has finished.
    Nr!   r"   r   r   r   r   d  r#   r   r   c                       e Zd ZdZy) SubscriptionHandlerTaskExceptionzv
    Raised to alert the subscription manager that an exception occurred in the
    subscription processing task.
    Nr!   r"   r   r   r   r   k  r#   r   r   c            	       F     e Zd ZdZ	 	 ddedee   dee   ddf fdZ xZS )	Web3RPCErrorzB
    Raised when a JSON-RPC response contains an error field.
    NrJ   rpc_responser   rA   c                 L    |d}t         |   ||       || _        || _        y )Nz{An RPC error was returned by the node. Check the message provided in the error and any available logs for more information.r   )r   r   rJ   r   )r   rJ   r   r   r   s       r   r   zWeb3RPCError.__init__w  sA     I 
 	% 	 	
 (r   rr   )	r   r   r   r   r   r   r	   r   r   r   s   @r   r   r   r  sI     /3&*	)) {+) sm	)
 
) )r   r   c                       e Zd ZdZy)MethodUnavailablez=
    Raised when the method is not available on the node
    Nr!   r"   r   r   r   r     r,   r   r   c                       e Zd ZdZy)RequestTimedOutz6
    Raised when a request to the node times out.
    Nr!   r"   r   r   r   r     r,   r   r   c                       e Zd ZdZy)TransactionNotFoundzW
    Raised when a tx hash used to look up a tx in a jsonrpc call cannot be found.
    Nr!   r"   r   r   r   r     r,   r   r   c                       e Zd ZdZy)TransactionIndexingInProgresszy
    Raised when a transaction receipt is not yet available due to transaction indexing
    still being in progress.
    Nr!   r"   r   r   r   r     r#   r   r   c                       e Zd ZdZy)BlockNotFoundz]
    Raised when the block id used to look up a block in a jsonrpc call cannot be found.
    Nr!   r"   r   r   r   r     r,   r   r   )CrE   rH   typingr   r   r   r   r   
web3.typesr   r	   asyncio	Exceptionr   AssertionErrorr    
ValueErrorr%   AttributeErrorr'   	TypeErrorr)   r+   r.   r0   r2   r4   r6   r8   r:   r<   r>   rO   rQ   rS   rU   rW   rY   r[   r]   r_   ra   rc   re   rg   ri   rk   rm   ro   rt   rv   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r   r   <module>r      s     
 )I )6 ]J  M9  M M m - m ] ] = m ,M ~} .- ] -  - . -  } } M m M m  , + $' $" ""0 " "] "  6 #< %> ~ )= )2 l , L L r   