Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export some specialized classes #56

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Clients
.. autoclass:: Client
:members:

.. autoclass:: pons._client.ClientSession()
.. autoclass:: ClientSession()
:members:


Expand Down Expand Up @@ -119,34 +119,37 @@ Contract ABI
Secondary classes
-----------------

.. autoclass:: pons._contract_abi.ConstructorCall()
The instances of these classes are not created by the user directly, but rather found as return values, or attributes of other objects.


.. autoclass:: ConstructorCall()
:members:

.. autoclass:: pons._contract_abi.MethodCall()
.. autoclass:: MethodCall()
:members:

.. autoclass:: pons._contract_abi.EventFilter()
.. autoclass:: EventFilter()
:members:

.. autoclass:: pons._contract.BoundConstructor()
.. autoclass:: BoundConstructor()
:members:
:special-members: __call__

.. autoclass:: pons._contract.BoundConstructorCall()
.. autoclass:: BoundConstructorCall()
:members:

.. autoclass:: pons._contract.BoundMethod()
.. autoclass:: BoundMethod()
:members:
:special-members: __call__

.. autoclass:: pons._contract.BoundMethodCall()
.. autoclass:: BoundMethodCall()
:members:

.. autoclass:: pons._contract.BoundEvent()
.. autoclass:: BoundEvent()
:members:
:special-members: __call__

.. autoclass:: pons._contract.BoundEventFilter()
.. autoclass:: BoundEventFilter()
:members:


Expand Down
4 changes: 3 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Changelog
Added
^^^^^

- `Client.transact()` takes an optional `return_events` argument, allowing one to get "return values" from the transaction via events. (PR_52_)
- ``Client.transact()`` takes an optional ``return_events`` argument, allowing one to get "return values" from the transaction via events. (PR_52_)
- Exposed ``ClientSession``, ``ConstructorCall``, ``MethodCall``, ``EventFilter``, ``BoundConstructor``, ``BoundConstructorCall``, ``BoundMethod``, ``BoundMethodCall``, ``BoundEvent``, ``BoundEventFilter`` from the top level. (PR_56_)


Fixed
Expand All @@ -19,6 +20,7 @@ Fixed

.. _PR_51: https://github.com/fjarri/pons/pull/51
.. _PR_52: https://github.com/fjarri/pons/pull/52
.. _PR_56: https://github.com/fjarri/pons/pull/56


0.7.0 (09-07-2023)
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All calls to the provider in ``pons`` happen within a session.
It translates to the usage of a single session in the backend HTTP request library, so the details are implementation-dependent, but in general it means that multiple requests will happen faster.
For example, in a session an SSL handshake only happens once, and it is a somewhat slow process.

Correspondingly, all the main functionality of the library is concentrated in the :py:class:`~pons._client.ClientSession` class.
Correspondingly, all the main functionality of the library is concentrated in the :py:class:`~pons.ClientSession` class.


Signers
Expand Down Expand Up @@ -156,7 +156,7 @@ Deploying contracts

In order to deploy a contract one needs its ABI and bytecode.
At the moment ``pons`` does not expose the compiler interface, so it has to come from a third party library, for example `py-solcx <https://solcx.readthedocs.io/en/latest/>`_.
With that, create a :py:class:`~pons.CompiledContract` object and use :py:meth:`~pons._client.ClientSession.deploy`:
With that, create a :py:class:`~pons.CompiledContract` object and use :py:meth:`~pons.ClientSession.deploy`:

::

Expand All @@ -178,7 +178,7 @@ Interacting with deployed contracts
A :py:class:`~pons.DeployedContract` object wraps all ABI method objects into "bound" state, similarly to how Python methods are bound to class instances.
It means that all the method calls created from this object have the contract address inside them, so that it does not need to be provided every time.

For example, to call a non-mutating contract method via :py:meth:`~pons._client.ClientSession.eth_call`:
For example, to call a non-mutating contract method via :py:meth:`~pons.ClientSession.eth_call`:

::

Expand Down
63 changes: 62 additions & 1 deletion pons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ._abi_types import ABIDecodingError
from ._client import (
Client,
ClientSession,
RemoteError,
ContractPanic,
ContractLegacyError,
Expand All @@ -12,15 +13,27 @@
from ._contract_abi import (
ContractABI,
Constructor,
ConstructorCall,
Method,
MethodCall,
Event,
EventFilter,
Error,
Fallback,
Receive,
Either,
Mutability,
)
from ._contract import CompiledContract, DeployedContract
from ._contract import (
BoundConstructor,
BoundConstructorCall,
BoundMethod,
BoundMethodCall,
BoundEvent,
BoundEventFilter,
CompiledContract,
DeployedContract,
)
from ._entities import (
Amount,
Address,
Expand All @@ -37,3 +50,51 @@
)
from ._provider import HTTPProvider, Unreachable, JSON
from ._signer import Signer, AccountSigner

__all__ = [
"ABIDecodingError",
"AccountSigner",
"Address",
"Amount",
"Block",
"BlockHash",
"BoundConstructor",
"BoundConstructorCall",
"BoundEvent",
"BoundEventFilter",
"BoundMethod",
"BoundMethodCall",
"Client",
"ClientSession",
"CompiledContract",
"Constructor",
"ConstructorCall",
"ContractABI",
"ContractError",
"ContractLegacyError",
"ContractPanic",
"CycleFallback",
"DeployedContract",
"Either",
"Error",
"Event",
"EventFilter",
"Fallback",
"FallbackProvider",
"FallbackStrategy",
"FallbackStrategyFactory",
"HTTPProvider",
"JSON",
"Method",
"MethodCall",
"Mutability",
"PriorityFallback",
"ProviderError",
"Receive",
"RemoteError",
"Signer",
"TransactionFailed",
"TxHash",
"Unreachable",
"abi",
]
3 changes: 1 addition & 2 deletions pons/_contract_abi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from abc import ABC, abstractmethod
from enum import Enum
from functools import cached_property
import inspect
Expand Down Expand Up @@ -309,7 +308,7 @@ def mutating(self) -> bool:

class Method:
"""
A non-mutating contract method.
A contract method.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion pons/_fallback_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from contextlib import asynccontextmanager, AsyncExitStack
from typing import Any, AsyncIterator, Optional, Iterable, List, Tuple, Union
from typing import AsyncIterator, Optional, Iterable, List, Tuple

from ._provider import Provider, ProviderSession, JSON, RPCError, UnexpectedResponse

Expand Down