Skip to content

Commit a9bdc72

Browse files
authored
Merge pull request #85 from fjarri-eth/rpc-layer
Split out lower level RPC API
2 parents 8475c50 + 83eb154 commit a9bdc72

15 files changed

Lines changed: 1214 additions & 1017 deletions

docs/api.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Clients
1313
.. autoclass:: ClientSession()
1414
:members:
1515

16+
.. autoclass:: ClientSessionRPC()
17+
:members:
18+
1619

1720
Providers
1821
---------
@@ -46,14 +49,22 @@ Errors
4649
------
4750

4851
.. autoclass:: pons.ABIDecodingError
49-
50-
.. autoclass:: pons.RemoteError
52+
:show-inheritance:
5153

5254
.. autoclass:: pons.Unreachable
55+
:show-inheritance:
5356

5457
.. autoclass:: pons.ProtocolError
58+
:show-inheritance:
59+
60+
.. autoclass:: pons.HTTPError
61+
:show-inheritance:
5562

5663
.. autoclass:: pons.TransactionFailed
64+
:show-inheritance:
65+
66+
.. autoclass:: pons.BadResponseFormat
67+
:show-inheritance:
5768

5869
.. autoclass:: pons.ProviderError()
5970
:show-inheritance:
@@ -252,11 +263,11 @@ Compiled and deployed contracts
252263
Filter objects
253264
--------------
254265

255-
.. autoclass:: pons._client.BlockFilter()
266+
.. autoclass:: pons._client_rpc.BlockFilter()
256267

257-
.. autoclass:: pons._client.PendingTransactionFilter()
268+
.. autoclass:: pons._client_rpc.PendingTransactionFilter()
258269

259-
.. autoclass:: pons._client.LogFilter()
270+
.. autoclass:: pons._client_rpc.LogFilter()
260271

261272

262273
Solidity types

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Changed
1111
- ``JSON`` removed from the public API, instead we have a more specific ``ABI_JSON``. (PR_82_)
1212
- Renamed ``id_`` fields of ``BlockFilter``, ``PendingTransactionFilter``, and ``LogFilter`` to just ``id``. (PR_82_)
1313
- Split out ``http-provider-server`` feature from ``local-provider``. (PR_82_)
14+
- ``RemoteError`` removed. (PR_82_)
1415

1516

1617
Added
@@ -19,6 +20,7 @@ Added
1920
- Hash methods for ABI types. (PR_81_)
2021
- A base class for bound calls (``BaseBoundMethodCall``). (PR_84_)
2122
- A helper class for interacting with the Multicall contract (``Multicall``). (PR_84_)
23+
- Exporting ``HTTPError`` and ``BadResponseFormat``. (PR_82_)
2224

2325

2426
.. _PR_81: https://github.com/fjarri-eth/pons/pull/81

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ A quick usage example:
9191
signer = AccountSigner(acc)
9292

9393
async with client.session() as session:
94-
my_balance = await session.eth_get_balance(signer.address)
94+
my_balance = await session.get_balance(signer.address)
9595
print("My balance:", my_balance.as_ether(), "ETH")
9696

9797
another_address = Address.from_hex("0x<another_address>")
9898
await session.transfer(signer, another_address, Amount.ether(1.5))
9999

100-
another_balance = await session.eth_get_balance(another_address)
100+
another_balance = await session.get_balance(another_address)
101101
print("Another balance:", another_balance.as_ether(), "ETH")
102102

103103
trio.run(main)

docs/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ Interacting with deployed contracts
178178
A :py:class:`~pons.DeployedContract` object wraps all ABI method objects into "bound" state, similarly to how Python methods are bound to class instances.
179179
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.
180180

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

183183
::
184184

185185
call = deployed_contract.method.getState(1)
186-
result = await session.eth_call(call)
186+
result = await session.call(call)
187187

188188
Note that when the :py:class:`~pons.ContractABI` object is created from the JSON ABI, even if the method returns a single value, it is still represented as a list of one element in the JSON, so the ``result`` will be a list too.
189189
If the ABI is declared programmatically, one can provide a single output value instead of the list, and then ``pons`` will unpack that list.

pons/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
ContractError,
99
ContractLegacyError,
1010
ContractPanic,
11-
ProviderError,
12-
RemoteError,
1311
TransactionFailed,
1412
)
13+
from ._client_rpc import BadResponseFormat, ClientSessionRPC, ProviderError
1514
from ._compiler import EVMVersion, compile_contract_file
1615
from ._contract import (
1716
BaseBoundMethodCall,
@@ -49,14 +48,15 @@
4948
from ._http_provider_server import HTTPProviderServer
5049
from ._local_provider import LocalProvider, SnapshotID
5150
from ._multicall import BoundMultiMethodCall, BoundMultiMethodValueCall, Multicall
52-
from ._provider import HTTPProvider, ProtocolError, Provider, Unreachable
51+
from ._provider import HTTPError, HTTPProvider, ProtocolError, Provider, Unreachable
5352
from ._signer import AccountSigner, Signer
5453
from ._utils import get_create2_address, get_create_address
5554

5655
__all__ = [
5756
"ABI_JSON",
5857
"ABIDecodingError",
5958
"AccountSigner",
59+
"BadResponseFormat",
6060
"BaseBoundMethodCall",
6161
"BoundConstructor",
6262
"BoundConstructorCall",
@@ -68,6 +68,7 @@
6868
"BoundMultiMethodValueCall",
6969
"Client",
7070
"ClientSession",
71+
"ClientSessionRPC",
7172
"CompiledContract",
7273
"Constructor",
7374
"ConstructorCall",
@@ -86,6 +87,7 @@
8687
"FallbackProvider",
8788
"FallbackStrategy",
8889
"FallbackStrategyFactory",
90+
"HTTPError",
8991
"HTTPProvider",
9092
"HTTPProviderServer",
9193
"LocalProvider",
@@ -99,7 +101,6 @@
99101
"Provider",
100102
"ProviderError",
101103
"Receive",
102-
"RemoteError",
103104
"Signer",
104105
"SnapshotID",
105106
"TransactionFailed",

0 commit comments

Comments
 (0)