tonutils 2.0.1b5__py3-none-any.whl → 2.0.1b7__py3-none-any.whl

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 (58) hide show
  1. tonutils/__meta__.py +1 -1
  2. tonutils/clients/__init__.py +10 -10
  3. tonutils/clients/adnl/balancer.py +135 -361
  4. tonutils/clients/adnl/client.py +35 -208
  5. tonutils/clients/adnl/mixin.py +268 -0
  6. tonutils/clients/adnl/provider/config.py +22 -7
  7. tonutils/clients/adnl/provider/provider.py +61 -16
  8. tonutils/clients/adnl/provider/transport.py +13 -4
  9. tonutils/clients/adnl/provider/workers/pinger.py +1 -1
  10. tonutils/clients/adnl/utils.py +5 -5
  11. tonutils/clients/base.py +61 -95
  12. tonutils/clients/http/__init__.py +11 -11
  13. tonutils/clients/http/balancer.py +103 -100
  14. tonutils/clients/http/clients/__init__.py +10 -10
  15. tonutils/clients/http/clients/chainstack.py +3 -3
  16. tonutils/clients/http/clients/quicknode.py +2 -3
  17. tonutils/clients/http/clients/tatum.py +4 -3
  18. tonutils/clients/http/clients/tonapi.py +20 -33
  19. tonutils/clients/http/clients/toncenter.py +64 -55
  20. tonutils/clients/http/{providers → provider}/__init__.py +4 -1
  21. tonutils/clients/http/{providers → provider}/base.py +140 -61
  22. tonutils/clients/http/{providers/toncenter → provider}/models.py +44 -2
  23. tonutils/clients/http/{providers/tonapi/provider.py → provider/tonapi.py} +8 -13
  24. tonutils/clients/http/{providers/toncenter/provider.py → provider/toncenter.py} +25 -21
  25. tonutils/clients/limiter.py +61 -59
  26. tonutils/clients/protocol.py +8 -8
  27. tonutils/contracts/base.py +32 -32
  28. tonutils/contracts/protocol.py +9 -9
  29. tonutils/contracts/wallet/base.py +7 -8
  30. tonutils/contracts/wallet/messages.py +4 -8
  31. tonutils/contracts/wallet/versions/v5.py +2 -2
  32. tonutils/exceptions.py +29 -13
  33. tonutils/tonconnect/bridge/__init__.py +0 -0
  34. tonutils/tonconnect/events.py +0 -0
  35. tonutils/tonconnect/models/__init__.py +0 -0
  36. tonutils/tonconnect/storage.py +0 -0
  37. tonutils/tonconnect/tonconnect.py +0 -0
  38. tonutils/tools/block_scanner/__init__.py +2 -5
  39. tonutils/tools/block_scanner/events.py +48 -7
  40. tonutils/tools/block_scanner/scanner.py +316 -222
  41. tonutils/tools/block_scanner/storage.py +11 -0
  42. tonutils/tools/status_monitor/monitor.py +6 -6
  43. tonutils/types.py +2 -2
  44. tonutils/utils.py +0 -48
  45. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/METADATA +3 -18
  46. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/RECORD +50 -51
  47. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/WHEEL +1 -1
  48. tonutils/clients/http/providers/response.py +0 -85
  49. tonutils/clients/http/providers/tonapi/__init__.py +0 -3
  50. tonutils/clients/http/providers/tonapi/models.py +0 -47
  51. tonutils/clients/http/providers/toncenter/__init__.py +0 -3
  52. tonutils/tools/block_scanner/annotations.py +0 -23
  53. tonutils/tools/block_scanner/dispatcher.py +0 -141
  54. tonutils/tools/block_scanner/traversal.py +0 -97
  55. tonutils/tools/block_scanner/where.py +0 -53
  56. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/entry_points.txt +0 -0
  57. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/licenses/LICENSE +0 -0
  58. {tonutils-2.0.1b5.dist-info → tonutils-2.0.1b7.dist-info}/top_level.txt +0 -0
@@ -1,97 +0,0 @@
1
- import typing as t
2
-
3
- from pytoniq_core.tl import BlockIdExt
4
- from pytoniq_core.tlb.block import ExtBlkRef
5
-
6
-
7
- class ShardTraversal:
8
-
9
- @staticmethod
10
- def shard_key(blk: BlockIdExt) -> t.Tuple[int, int]:
11
- return blk.workchain, blk.shard
12
-
13
- @staticmethod
14
- def simulate_overflow(x: int) -> int:
15
- return (x + 2**63) % 2**64 - 2**63
16
-
17
- @staticmethod
18
- def lower_bit64(num: int) -> int:
19
- return num & (~num + 1)
20
-
21
- def get_child_shard(self, shard: int, *, left: bool) -> int:
22
- x = self.lower_bit64(shard) >> 1
23
- if left:
24
- return self.simulate_overflow(shard - x)
25
- return self.simulate_overflow(shard + x)
26
-
27
- def get_parent_shard(self, shard: int) -> int:
28
- x = self.lower_bit64(shard)
29
- return self.simulate_overflow((shard - x) | (x << 1))
30
-
31
- async def walk_unseen(
32
- self,
33
- *,
34
- root: BlockIdExt,
35
- seen_seqno: t.Dict[t.Tuple[int, int], int],
36
- get_header: t.Callable[[BlockIdExt], t.Awaitable[t.Any]],
37
- out: t.Optional[t.List[BlockIdExt]] = None,
38
- ) -> t.List[BlockIdExt]:
39
- """Recursively walk from root block back to seen blocks."""
40
- if out is None:
41
- out = []
42
-
43
- key = self.shard_key(root)
44
- if seen_seqno.get(key, -1) >= root.seqno:
45
- return out
46
-
47
- _, header = await get_header(root)
48
- prev_ref = header.info.prev_ref
49
-
50
- if prev_ref.type_ == "prev_blk_info":
51
- prev: ExtBlkRef = prev_ref.prev
52
- prev_shard = (
53
- self.get_parent_shard(root.shard)
54
- if header.info.after_split
55
- else root.shard
56
- )
57
- await self.walk_unseen(
58
- root=BlockIdExt(
59
- workchain=root.workchain,
60
- shard=prev_shard,
61
- seqno=prev.seqno,
62
- root_hash=prev.root_hash,
63
- file_hash=prev.file_hash,
64
- ),
65
- seen_seqno=seen_seqno,
66
- get_header=get_header,
67
- out=out,
68
- )
69
- else:
70
- prev1, prev2 = prev_ref.prev1, prev_ref.prev2
71
- await self.walk_unseen(
72
- root=BlockIdExt(
73
- workchain=root.workchain,
74
- shard=self.get_child_shard(root.shard, left=True),
75
- seqno=prev1.seqno,
76
- root_hash=prev1.root_hash,
77
- file_hash=prev1.file_hash,
78
- ),
79
- seen_seqno=seen_seqno,
80
- get_header=get_header,
81
- out=out,
82
- )
83
- await self.walk_unseen(
84
- root=BlockIdExt(
85
- workchain=root.workchain,
86
- shard=self.get_child_shard(root.shard, left=False),
87
- seqno=prev2.seqno,
88
- root_hash=prev2.root_hash,
89
- file_hash=prev2.file_hash,
90
- ),
91
- seen_seqno=seen_seqno,
92
- get_header=get_header,
93
- out=out,
94
- )
95
-
96
- out.append(root)
97
- return out
@@ -1,53 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing as t
4
-
5
- from tonutils.tools.block_scanner.annotations import TEvent
6
-
7
-
8
- class Where(t.Generic[TEvent]):
9
- __slots__ = ()
10
-
11
- def __call__(self, event: TEvent) -> bool:
12
- raise NotImplementedError
13
-
14
- def __and__(self, other: Where[TEvent]) -> _And[TEvent]:
15
- return _And(self, other)
16
-
17
- def __or__(self, other: Where[TEvent]) -> _Or[TEvent]:
18
- return _Or(self, other)
19
-
20
- def __invert__(self) -> _Not[TEvent]:
21
- return _Not(self)
22
-
23
-
24
- class _And(Where[TEvent]):
25
- __slots__ = ("_a", "_b")
26
-
27
- def __init__(self, a: Where[TEvent], b: Where[TEvent]) -> None:
28
- self._a = a
29
- self._b = b
30
-
31
- def __call__(self, event: TEvent) -> bool:
32
- return self._a(event) and self._b(event)
33
-
34
-
35
- class _Or(Where[TEvent]):
36
- __slots__ = ("_a", "_b")
37
-
38
- def __init__(self, a: Where[TEvent], b: Where[TEvent]) -> None:
39
- self._a = a
40
- self._b = b
41
-
42
- def __call__(self, event: TEvent) -> bool:
43
- return self._a(event) or self._b(event)
44
-
45
-
46
- class _Not(Where[TEvent]):
47
- __slots__ = ("_f",)
48
-
49
- def __init__(self, f: Where[TEvent]) -> None:
50
- self._f = f
51
-
52
- def __call__(self, event: TEvent) -> bool:
53
- return not self._f(event)