
    (i                     p    d dl mZmZmZmZmZ d dlmZmZm	Z	 erd dl
mZ d dlmZ d dlmZ  G d d      Zy)	    )TYPE_CHECKINGAnyDictUnioncast) FormattedEthSubscriptionResponseRPCEndpointRPCResponse)	AsyncWeb3)_AsyncPersistentMessageStream)PersistentConnectionProviderc                   ~    e Zd ZdZddZedeeef   fd       Z	de
dedefdZde
deddfd	Zdeeef   fd
ZddZy)PersistentConnectionz
    A class that houses the public API for interacting with the persistent connection
    via a `AsyncWeb3` instance instantiated with a `PersistentConnectionProvider` class.
    c                 p    |j                   | _        t        d| j                  j                        | _        y )Nr   )manager_managerr   provider)selfw3s     `/var/www/br/venv/lib/python3.12/site-packages/web3/providers/persistent/persistent_connection.py__init__zPersistentConnection.__init__!   s&    

;T]]=S=ST    returnc                 B    | j                   j                  j                  S )z
        Return the active subscriptions on the persistent connection.

        :return: The active subscriptions on the persistent connection.
        :rtype: Dict[str, Any]
        )r   _request_processoractive_subscriptionsr   s    r   subscriptionsz"PersistentConnection.subscriptions%   s     }}//DDDr   methodparamsc                 V   K   | j                   j                  ||       d{   S 7 w)a  
        Make a request to the persistent connection and return the response. This method
        does not process the response as it would when invoking a method via the
        appropriate module on the `AsyncWeb3` instance,
        e.g. `w3.eth.get_block("latest")`.

        :param method: The RPC method, e.g. `eth_getBlockByNumber`.
        :param params: The RPC method parameters, e.g. `["0x1337", False]`.

        :return: The unprocessed response from the persistent connection.
        :rtype: RPCResponse
        N)r   make_requestr   r   r    s      r   r"   z!PersistentConnection.make_request/   s%      ]]//????s    )')Nc                 X   K   | j                   j                  ||       d{    y7 w)z
        Send a raw, unprocessed message to the persistent connection.

        :param method: The RPC method, e.g. `eth_getBlockByNumber`.
        :param params: The RPC method parameters, e.g. `["0x1337", False]`.

        :return: None
        N)r   sendr#   s      r   r%   zPersistentConnection.send>   s"      mm  000s    *(*c                 R   K   | j                   j                          d{   S 7 w)a!  
        Receive the next unprocessed response for a request from the persistent
        connection.

        :return: The next unprocessed response for a request from the persistent
                 connection.
        :rtype: Union[RPCResponse, FormattedEthSubscriptionResponse]
        N)r   recvr   s    r   r'   zPersistentConnection.recvI   s!      ]]''))))s   '%'c                 6    | j                   j                         S )z
        Asynchronous iterator that yields messages from the subscription message stream.

        :return: The subscription message stream.
        :rtype: _AsyncPersistentMessageStream
        )r   _persistent_message_streamr   s    r   process_subscriptionsz*PersistentConnection.process_subscriptionsT   s     }}7799r   )r   zAsyncWeb3[Any])r   r   )__name__
__module____qualname____doc__r   propertyr   strr   r   r	   r
   r"   r%   r   r   r'   r*    r   r   r   r      s    
U EtCH~ E E@ @c @k @	1 	1c 	1d 	1	*E+/O"OP 	*:r   r   N)typingr   r   r   r   r   
web3.typesr   r	   r
   	web3.mainr   web3.managerr   web3.providers.persistentr   r   r1   r   r   <module>r7      s9      
@: @:r   