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.
Files changed (69) hide show
  1. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/PKG-INFO +1 -1
  2. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/client.py +8 -3
  3. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/sse.py +18 -4
  4. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/exceptions.py +5 -1
  5. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/PKG-INFO +1 -1
  6. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/setup.py +1 -1
  7. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/LICENSE +0 -0
  8. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/README.md +0 -0
  9. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/__init__.py +0 -0
  10. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/__init__.py +0 -0
  11. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/__init__.py +0 -0
  12. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/accounts.py +0 -0
  13. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/blockchain.py +0 -0
  14. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/dns.py +0 -0
  15. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/emulate.py +0 -0
  16. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/events.py +0 -0
  17. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/inscriptions.py +0 -0
  18. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/jettons.py +0 -0
  19. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/liteserver.py +0 -0
  20. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/nft.py +0 -0
  21. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/rates.py +0 -0
  22. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/staking.py +0 -0
  23. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/storage.py +0 -0
  24. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/tonconnect.py +0 -0
  25. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/traces.py +0 -0
  26. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/wallet.py +0 -0
  27. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/async_tonapi/methods/websocket.py +0 -0
  28. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/__init__.py +0 -0
  29. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/_address.py +0 -0
  30. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/_balance.py +0 -0
  31. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/accounts.py +0 -0
  32. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/blockchain.py +0 -0
  33. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/dns.py +0 -0
  34. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/domains.py +0 -0
  35. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/events.py +0 -0
  36. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/inscriptions.py +0 -0
  37. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/jettons.py +0 -0
  38. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/liteserver.py +0 -0
  39. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/nft.py +0 -0
  40. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/rates.py +0 -0
  41. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/staking.py +0 -0
  42. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/storage.py +0 -0
  43. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/tonconnect.py +0 -0
  44. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/schema/traces.py +0 -0
  45. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/__init__.py +0 -0
  46. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/client.py +0 -0
  47. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/__init__.py +0 -0
  48. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/accounts.py +0 -0
  49. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/blockchain.py +0 -0
  50. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/dns.py +0 -0
  51. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/emulate.py +0 -0
  52. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/events.py +0 -0
  53. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/inscriptions.py +0 -0
  54. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/jettons.py +0 -0
  55. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/liteserver.py +0 -0
  56. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/nft.py +0 -0
  57. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/rates.py +0 -0
  58. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/sse.py +0 -0
  59. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/staking.py +0 -0
  60. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/storage.py +0 -0
  61. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/tonconnect.py +0 -0
  62. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/traces.py +0 -0
  63. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/tonapi/methods/wallet.py +0 -0
  64. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi/utils.py +0 -0
  65. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/SOURCES.txt +0 -0
  66. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/dependency_links.txt +0 -0
  67. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/requires.txt +0 -0
  68. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/pytonapi.egg-info/top_level.txt +0 -0
  69. {pytonapi-0.2.4b2 → pytonapi-0.2.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytonapi
3
- Version: 0.2.4b2
3
+ Version: 0.2.5
4
4
  Summary: Provide access to indexed TON blockchain.
5
5
  Home-page: https://github.com/tonkeeper/pytonapi/
6
6
  Author: nessshon
@@ -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
- if response.status_code != 200:
122
- await self.__process_response(response)
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 addresses to subscribe to
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 TONAPISSELimitReachedError(TONAPIClientError):
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytonapi
3
- Version: 0.2.4b2
3
+ Version: 0.2.5
4
4
  Summary: Provide access to indexed TON blockchain.
5
5
  Home-page: https://github.com/tonkeeper/pytonapi/
6
6
  Author: nessshon
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="pytonapi",
8
- version="0.2.4b2",
8
+ version="0.2.5",
9
9
  author="nessshon",
10
10
  description="Provide access to indexed TON blockchain.",
11
11
  long_description=long_description,
File without changes
File without changes
File without changes
File without changes