pytonapi 0.3.4__tar.gz → 0.3.6__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 (71) hide show
  1. {pytonapi-0.3.4 → pytonapi-0.3.6}/PKG-INFO +1 -1
  2. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/sse.py +22 -2
  3. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/events.py +8 -0
  4. pytonapi-0.3.6/pytonapi/tonapi/methods/sse.py +103 -0
  5. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi.egg-info/PKG-INFO +1 -1
  6. {pytonapi-0.3.4 → pytonapi-0.3.6}/setup.py +1 -1
  7. pytonapi-0.3.4/pytonapi/tonapi/methods/sse.py +0 -72
  8. {pytonapi-0.3.4 → pytonapi-0.3.6}/LICENSE +0 -0
  9. {pytonapi-0.3.4 → pytonapi-0.3.6}/README.md +0 -0
  10. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/__init__.py +0 -0
  11. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/__init__.py +0 -0
  12. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/client.py +0 -0
  13. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/__init__.py +0 -0
  14. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/accounts.py +0 -0
  15. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/blockchain.py +0 -0
  16. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/dns.py +0 -0
  17. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/emulate.py +0 -0
  18. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/events.py +0 -0
  19. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/inscriptions.py +0 -0
  20. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/jettons.py +0 -0
  21. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/liteserver.py +0 -0
  22. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/nft.py +0 -0
  23. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/rates.py +0 -0
  24. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/staking.py +0 -0
  25. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/storage.py +0 -0
  26. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/tonconnect.py +0 -0
  27. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/traces.py +0 -0
  28. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/wallet.py +0 -0
  29. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/async_tonapi/methods/websocket.py +0 -0
  30. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/exceptions.py +0 -0
  31. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/py.typed +0 -0
  32. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/__init__.py +0 -0
  33. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/_address.py +0 -0
  34. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/_balance.py +0 -0
  35. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/accounts.py +0 -0
  36. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/blockchain.py +0 -0
  37. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/dns.py +0 -0
  38. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/domains.py +0 -0
  39. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/inscriptions.py +0 -0
  40. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/jettons.py +0 -0
  41. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/liteserver.py +0 -0
  42. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/nft.py +0 -0
  43. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/rates.py +0 -0
  44. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/staking.py +0 -0
  45. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/storage.py +0 -0
  46. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/tonconnect.py +0 -0
  47. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/schema/traces.py +0 -0
  48. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/__init__.py +0 -0
  49. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/client.py +0 -0
  50. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/__init__.py +0 -0
  51. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/accounts.py +0 -0
  52. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/blockchain.py +0 -0
  53. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/dns.py +0 -0
  54. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/emulate.py +0 -0
  55. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/events.py +0 -0
  56. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/inscriptions.py +0 -0
  57. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/jettons.py +0 -0
  58. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/liteserver.py +0 -0
  59. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/nft.py +0 -0
  60. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/rates.py +0 -0
  61. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/staking.py +0 -0
  62. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/storage.py +0 -0
  63. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/tonconnect.py +0 -0
  64. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/traces.py +0 -0
  65. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/tonapi/methods/wallet.py +0 -0
  66. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi/utils.py +0 -0
  67. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi.egg-info/SOURCES.txt +0 -0
  68. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi.egg-info/dependency_links.txt +0 -0
  69. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi.egg-info/requires.txt +0 -0
  70. {pytonapi-0.3.4 → pytonapi-0.3.6}/pytonapi.egg-info/top_level.txt +0 -0
  71. {pytonapi-0.3.4 → pytonapi-0.3.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytonapi
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Provide access to indexed TON blockchain.
5
5
  Home-page: https://github.com/tonkeeper/pytonapi/
6
6
  Author: nessshon
@@ -1,8 +1,8 @@
1
1
  import json
2
- from typing import List, Callable, Any, Awaitable, Tuple, Optional
2
+ from typing import List, Callable, Any, Awaitable, Tuple, Optional, Union
3
3
 
4
4
  from pytonapi.async_tonapi.client import AsyncTonapiClient
5
- from pytonapi.schema.events import TransactionEventData, TraceEventData, MempoolEventData
5
+ from pytonapi.schema.events import TransactionEventData, TraceEventData, MempoolEventData, BlockEventData
6
6
 
7
7
 
8
8
  class SSEMethod(AsyncTonapiClient):
@@ -81,3 +81,23 @@ class SSEMethod(AsyncTonapiClient):
81
81
  result = await handler(event, *args)
82
82
  if result is not None:
83
83
  return result
84
+
85
+ async def subscribe_to_blocks(
86
+ self,
87
+ workchain: Optional[Union[int, None]],
88
+ handler: Callable[[BlockEventData, Any], Awaitable[Any]],
89
+ args: Tuple = (),
90
+ ) -> Any:
91
+ """
92
+ Subscribes to blocks SSE events for the specified workchains.
93
+
94
+ :handler: A callable function to handle the SSEEvent
95
+ :workchain: The ID of the workchain to subscribe to. If None, subscribes to all workchains.
96
+ """
97
+ method = "v2/sse/blocks"
98
+ params = {} if workchain is None else {'workchain': workchain}
99
+ async for data in self._subscribe(method=method, params=params):
100
+ event = BlockEventData(**json.loads(data))
101
+ result = await handler(event, *args)
102
+ if result is not None:
103
+ return result
@@ -261,6 +261,14 @@ class TransactionEventData(BaseModel):
261
261
  tx_hash: str
262
262
 
263
263
 
264
+ class BlockEventData(BaseModel):
265
+ workchain: int
266
+ shard: str
267
+ seqno: int
268
+ root_hash: str
269
+ file_hash: str
270
+
271
+
264
272
  class Risk(BaseModel):
265
273
  description: Optional[str] = None
266
274
  transfer_all_remaining_balance: bool
@@ -0,0 +1,103 @@
1
+ import json
2
+ from typing import List, Callable, Any, Tuple, Optional, Union
3
+
4
+ from pytonapi.schema.events import TransactionEventData, TraceEventData, MempoolEventData, BlockEventData
5
+ from pytonapi.tonapi import TonapiClient
6
+
7
+
8
+ class SSEMethod(TonapiClient):
9
+
10
+ def subscribe_to_transactions(
11
+ self,
12
+ accounts: List[str],
13
+ handler: Callable[[TransactionEventData, Any], Any],
14
+ operations: Optional[List[str]] = None,
15
+ args: Tuple = (),
16
+ ) -> None:
17
+ """
18
+ Subscribes to transactions SSE events for the specified accounts.
19
+
20
+ :param handler: A callable function to handle the SSEEvent
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>`_.
32
+ :param args: Additional arguments to pass to the handler
33
+ """
34
+ method = "v2/sse/accounts/transactions"
35
+ params = {'accounts': ",".join(accounts)}
36
+ if operations:
37
+ params['operations'] = ",".join(operations)
38
+
39
+ for data in self._subscribe(method=method, params=params):
40
+ event = TransactionEventData(**json.loads(data))
41
+ result = handler(event, *args)
42
+ if result is not None:
43
+ return result
44
+
45
+ def subscribe_to_traces(
46
+ self,
47
+ accounts: List[str],
48
+ handler: Callable[[TraceEventData, Any], Any],
49
+ args: Tuple = (),
50
+ ) -> None:
51
+ """
52
+ Subscribes to traces SSE events for the specified accounts.
53
+
54
+ :handler: A callable function to handle the SSEEvent
55
+ :accounts: A list of account addresses to subscribe to
56
+ """
57
+ method = "v2/sse/accounts/traces"
58
+ params = {'accounts': accounts}
59
+ for data in self._subscribe(method=method, params=params):
60
+ event = TraceEventData(**json.loads(data))
61
+ result = handler(event, *args)
62
+ if result is not None:
63
+ return result
64
+
65
+ def subscribe_to_mempool(
66
+ self,
67
+ accounts: List[str],
68
+ handler: Callable[[MempoolEventData, Any], Any],
69
+ args: Tuple = (),
70
+ ) -> None:
71
+ """
72
+ Subscribes to mempool SSE events for the specified accounts.
73
+
74
+ :handler: A callable function to handle the SSEEvent
75
+ :accounts: A list of account addresses to subscribe to
76
+ """
77
+ method = "v2/sse/mempool"
78
+ params = {'accounts': ",".join(accounts)}
79
+ for data in self._subscribe(method=method, params=params):
80
+ event = MempoolEventData(**json.loads(data))
81
+ result = handler(event, *args)
82
+ if result is not None:
83
+ return result
84
+
85
+ def subscribe_to_blocks(
86
+ self,
87
+ workchain: Optional[Union[int, None]],
88
+ handler: Callable[[BlockEventData, Any], Any],
89
+ args: Tuple = (),
90
+ ) -> Any:
91
+ """
92
+ Subscribes to blocks SSE events for the specified workchains.
93
+
94
+ :handler: A callable function to handle the SSEEvent
95
+ :workchain: The ID of the workchain to subscribe to. If None, subscribes to all workchains.
96
+ """
97
+ method = "v2/sse/blocks"
98
+ params = {} if workchain is None else {'workchain': workchain}
99
+ for data in self._subscribe(method=method, params=params):
100
+ event = BlockEventData(**json.loads(data))
101
+ result = handler(event, *args)
102
+ if result is not None:
103
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytonapi
3
- Version: 0.3.4
3
+ Version: 0.3.6
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.3.4",
8
+ version="0.3.6",
9
9
  author="nessshon",
10
10
  description="Provide access to indexed TON blockchain.",
11
11
  long_description=long_description,
@@ -1,72 +0,0 @@
1
- import json
2
- from typing import List, Callable, Any, Tuple
3
-
4
- from pytonapi.schema.events import TransactionEventData, TraceEventData, MempoolEventData
5
- from pytonapi.tonapi import TonapiClient
6
-
7
-
8
- class SSEMethod(TonapiClient):
9
-
10
- def subscribe_to_transactions(
11
- self,
12
- accounts: List[str],
13
- handler: Callable[[TransactionEventData, List[Any]], Any],
14
- args: Tuple[Any, ...] = (),
15
- ) -> None:
16
- """
17
- Subscribes to transactions SSE events for the specified accounts.
18
-
19
- :param handler: A callable function to handle the SSEEvent
20
- :param accounts: A list of account addresses to subscribe to
21
- :param args: Additional arguments to pass to the handler
22
- """
23
- method = "v2/sse/accounts/transactions"
24
- params = {'accounts': accounts}
25
- for data in self._subscribe(method=method, params=params):
26
- event = TransactionEventData(**json.loads(data))
27
- result = handler(event, *args)
28
- if result is not None:
29
- return result
30
-
31
- def subscribe_to_traces(
32
- self,
33
- accounts: List[str],
34
- handler: Callable[[TraceEventData, List[Any]], Any],
35
- args: Tuple[Any, ...] = (),
36
- ) -> None:
37
- """
38
- Subscribes to traces SSE events for the specified accounts.
39
-
40
- :handler: A callable function to handle the SSEEvent
41
- :accounts: A list of account addresses to subscribe to
42
-
43
- Returns:
44
- None
45
- """
46
- method = "v2/sse/accounts/traces"
47
- params = {'accounts': accounts}
48
- for data in self._subscribe(method=method, params=params):
49
- event = TraceEventData(**json.loads(data))
50
- result = handler(event, *args)
51
- if result is not None:
52
- return result
53
-
54
- def subscribe_to_mempool(
55
- self,
56
- accounts: List[str],
57
- handler: Callable[[MempoolEventData, List[Any]], Any],
58
- args: Tuple[Any, ...] = (),
59
- ) -> None:
60
- """
61
- Subscribes to mempool SSE events for the specified accounts.
62
-
63
- :handler: A callable function to handle the SSEEvent
64
- :accounts: A list of account addresses to subscribe to
65
- """
66
- method = "v2/sse/mempool"
67
- params = {'accounts': accounts}
68
- for data in self._subscribe(method=method, params=params):
69
- event = MempoolEventData(**json.loads(data))
70
- result = handler(event, *args)
71
- if result is not None:
72
- return result
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes