pytonapi 0.2.4b2__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/PKG-INFO +1 -1
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/client.py +8 -3
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/sse.py +18 -4
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/exceptions.py +5 -1
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/PKG-INFO +1 -1
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/setup.py +1 -1
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/LICENSE +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/README.md +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/accounts.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/blockchain.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/dns.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/emulate.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/events.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/inscriptions.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/jettons.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/liteserver.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/nft.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/rates.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/staking.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/storage.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/tonconnect.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/traces.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/wallet.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/websocket.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/_address.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/_balance.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/accounts.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/blockchain.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/dns.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/domains.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/events.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/inscriptions.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/jettons.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/liteserver.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/nft.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/rates.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/staking.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/storage.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/tonconnect.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/traces.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/client.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/__init__.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/accounts.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/blockchain.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/dns.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/emulate.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/events.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/inscriptions.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/jettons.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/liteserver.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/nft.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/rates.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/sse.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/staking.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/storage.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/tonconnect.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/traces.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/wallet.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/utils.py +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/SOURCES.txt +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/dependency_links.txt +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/requires.txt +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/top_level.txt +0 -0
- {pytonapi-0.2.4b2 → pytonapi-0.2.5}/setup.cfg +0 -0
|
@@ -13,7 +13,8 @@ from pytonapi.exceptions import (
|
|
|
13
13
|
TONAPINotFoundError,
|
|
14
14
|
TONAPIUnauthorizedError,
|
|
15
15
|
TONAPITooManyRequestsError,
|
|
16
|
-
TONAPINotImplementedError
|
|
16
|
+
TONAPINotImplementedError,
|
|
17
|
+
TONAPISSEError,
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
|
|
@@ -68,6 +69,8 @@ class AsyncTonapiClient:
|
|
|
68
69
|
content = data.decode()
|
|
69
70
|
except httpx.ResponseNotRead:
|
|
70
71
|
content = {"error": response.text}
|
|
72
|
+
except httpx.ReadError as read_error:
|
|
73
|
+
content = {"error": f"Read error occurred: {read_error}"}
|
|
71
74
|
except Exception as e:
|
|
72
75
|
raise TONAPIError(f"Failed to read response content: {e}")
|
|
73
76
|
|
|
@@ -118,8 +121,8 @@ class AsyncTonapiClient:
|
|
|
118
121
|
try:
|
|
119
122
|
async with client.stream("GET", url=url, **data) as response:
|
|
120
123
|
response: httpx.Response
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
response.raise_for_status()
|
|
125
|
+
|
|
123
126
|
async for line in response.aiter_lines():
|
|
124
127
|
try:
|
|
125
128
|
key, value = line.split(": ", 1)
|
|
@@ -131,6 +134,8 @@ class AsyncTonapiClient:
|
|
|
131
134
|
yield value
|
|
132
135
|
except httpx.LocalProtocolError:
|
|
133
136
|
raise TONAPIUnauthorizedError
|
|
137
|
+
except httpx.HTTPStatusError as e:
|
|
138
|
+
raise TONAPISSEError(e)
|
|
134
139
|
|
|
135
140
|
async def _subscribe_websocket(
|
|
136
141
|
self,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from typing import List, Callable, Any, Awaitable, Tuple
|
|
2
|
+
from typing import List, Callable, Any, Awaitable, Tuple, Optional
|
|
3
3
|
|
|
4
4
|
from pytonapi.async_tonapi.client import AsyncTonapiClient
|
|
5
5
|
from pytonapi.schema.events import TransactionEventData, TraceEventData, MempoolEventData
|
|
@@ -9,19 +9,33 @@ class SSEMethod(AsyncTonapiClient):
|
|
|
9
9
|
|
|
10
10
|
async def subscribe_to_transactions(
|
|
11
11
|
self,
|
|
12
|
-
accounts: List[str],
|
|
13
12
|
handler: Callable[[TransactionEventData, ...], Awaitable[Any]],
|
|
13
|
+
accounts: List[str],
|
|
14
|
+
operations: Optional[List[str]] = None,
|
|
14
15
|
args: Tuple[Any, ...] = (),
|
|
15
16
|
) -> Any:
|
|
16
17
|
"""
|
|
17
18
|
Subscribes to transactions SSE events for the specified accounts.
|
|
18
19
|
|
|
19
20
|
:param handler: A callable function to handle the SSEEvent
|
|
20
|
-
:param accounts: A list of account
|
|
21
|
+
:param accounts: A comma-separated list of account IDs.
|
|
22
|
+
A special value of "accounts" is ALL. TonAPI will stream transactions for all accounts in this case.
|
|
23
|
+
:param operations: A comma-separated list of operations, which makes it possible
|
|
24
|
+
to get transactions based on the `first 4 bytes of a message body of an inbound message(opens in a new tab)
|
|
25
|
+
<https://docs.ton.org/develop/smart-contracts/guidelines/internal-messages#internal-message-body>`_.
|
|
26
|
+
Each operation is a string containing either one of the supported names or a hex string
|
|
27
|
+
representing a message operation opcode which is an unsigned 32-bit integer.
|
|
28
|
+
A hex string must start with "0x" prefix and have exactly 8 hex digits.
|
|
29
|
+
An example of "operations" is &operations=JettonTransfer,0x0524c7ae,StonfiSwap.
|
|
30
|
+
The advantage of using hex strings is that it's possible to get transactions for operations
|
|
31
|
+
that are not yet present on `the list <https://github.com/tonkeeper/tongo/blob/master/abi/messages.md>`_.
|
|
21
32
|
:param args: Additional arguments to pass to the handler
|
|
22
33
|
"""
|
|
23
34
|
method = "v2/sse/accounts/transactions"
|
|
24
|
-
params = {'accounts': accounts}
|
|
35
|
+
params = {'accounts': ",".join(accounts)}
|
|
36
|
+
if operations:
|
|
37
|
+
params['operations'] = ",".join(operations)
|
|
38
|
+
|
|
25
39
|
async for data in self._subscribe(method=method, params=params):
|
|
26
40
|
event = TransactionEventData(**json.loads(data))
|
|
27
41
|
result = await handler(event, *args)
|
|
@@ -29,7 +29,11 @@ class TONAPIUnauthorizedError(TONAPIClientError):
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
class
|
|
32
|
+
class TONAPISSEError(TONAPIServerError):
|
|
33
|
+
"""Raised when the server encounters an error (HTTP 4xx)."""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TONAPISSELimitReachedError(TONAPISSEError):
|
|
33
37
|
"""Raises when the limit of streaming connections is reached (HTTP 401)."""
|
|
34
38
|
|
|
35
39
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|