tonutils 2.0.1b2__py3-none-any.whl → 2.0.1b4__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 (91) hide show
  1. tonutils/__init__.py +0 -2
  2. tonutils/__meta__.py +1 -1
  3. tonutils/cli.py +111 -0
  4. tonutils/clients/__init__.py +7 -11
  5. tonutils/clients/adnl/__init__.py +7 -3
  6. tonutils/clients/adnl/balancer.py +362 -168
  7. tonutils/clients/adnl/client.py +203 -67
  8. tonutils/clients/adnl/provider/config.py +24 -25
  9. tonutils/clients/adnl/provider/models.py +4 -0
  10. tonutils/clients/adnl/provider/provider.py +203 -160
  11. tonutils/clients/adnl/provider/transport.py +44 -33
  12. tonutils/clients/adnl/provider/workers/base.py +0 -2
  13. tonutils/clients/adnl/provider/workers/pinger.py +1 -1
  14. tonutils/clients/adnl/provider/workers/reader.py +3 -2
  15. tonutils/clients/adnl/{provider/builder.py → utils.py} +62 -2
  16. tonutils/clients/http/__init__.py +11 -8
  17. tonutils/clients/http/balancer.py +75 -63
  18. tonutils/clients/http/clients/__init__.py +13 -0
  19. tonutils/clients/http/clients/chainstack.py +48 -0
  20. tonutils/clients/http/clients/quicknode.py +47 -0
  21. tonutils/clients/http/clients/tatum.py +56 -0
  22. tonutils/clients/http/{tonapi/client.py → clients/tonapi.py} +31 -31
  23. tonutils/clients/http/{toncenter/client.py → clients/toncenter.py} +59 -48
  24. tonutils/clients/http/providers/__init__.py +4 -0
  25. tonutils/clients/http/providers/base.py +201 -0
  26. tonutils/clients/http/providers/response.py +85 -0
  27. tonutils/clients/http/providers/tonapi/__init__.py +3 -0
  28. tonutils/clients/http/{tonapi → providers/tonapi}/models.py +1 -0
  29. tonutils/clients/http/providers/tonapi/provider.py +125 -0
  30. tonutils/clients/http/providers/toncenter/__init__.py +3 -0
  31. tonutils/clients/http/{toncenter → providers/toncenter}/models.py +1 -0
  32. tonutils/clients/http/providers/toncenter/provider.py +119 -0
  33. tonutils/clients/http/utils.py +140 -0
  34. tonutils/clients/limiter.py +115 -0
  35. tonutils/contracts/__init__.py +4 -0
  36. tonutils/contracts/base.py +33 -20
  37. tonutils/contracts/dns/methods.py +2 -2
  38. tonutils/contracts/jetton/methods.py +2 -2
  39. tonutils/contracts/nft/methods.py +2 -2
  40. tonutils/contracts/nft/tlb.py +1 -1
  41. tonutils/{protocols/contract.py → contracts/protocol.py} +29 -29
  42. tonutils/contracts/telegram/methods.py +2 -2
  43. tonutils/contracts/vanity/vanity.py +1 -1
  44. tonutils/contracts/wallet/__init__.py +2 -0
  45. tonutils/contracts/wallet/base.py +3 -3
  46. tonutils/contracts/wallet/messages.py +1 -1
  47. tonutils/contracts/wallet/methods.py +2 -2
  48. tonutils/{protocols/wallet.py → contracts/wallet/protocol.py} +35 -35
  49. tonutils/contracts/wallet/versions/v5.py +3 -3
  50. tonutils/exceptions.py +146 -228
  51. tonutils/tonconnect/__init__.py +0 -0
  52. tonutils/tools/__init__.py +6 -0
  53. tonutils/tools/block_scanner/__init__.py +26 -0
  54. tonutils/tools/block_scanner/annotations.py +23 -0
  55. tonutils/tools/block_scanner/dispatcher.py +141 -0
  56. tonutils/tools/block_scanner/events.py +31 -0
  57. tonutils/tools/block_scanner/scanner.py +315 -0
  58. tonutils/tools/block_scanner/traversal.py +96 -0
  59. tonutils/tools/block_scanner/where.py +151 -0
  60. tonutils/tools/status_monitor/__init__.py +3 -0
  61. tonutils/tools/status_monitor/console.py +157 -0
  62. tonutils/tools/status_monitor/models.py +27 -0
  63. tonutils/tools/status_monitor/monitor.py +295 -0
  64. tonutils/types.py +125 -2
  65. tonutils/utils.py +3 -3
  66. {tonutils-2.0.1b2.dist-info → tonutils-2.0.1b4.dist-info}/METADATA +2 -5
  67. tonutils-2.0.1b4.dist-info/RECORD +108 -0
  68. tonutils-2.0.1b4.dist-info/entry_points.txt +2 -0
  69. tonutils/clients/adnl/provider/limiter.py +0 -56
  70. tonutils/clients/adnl/stack.py +0 -64
  71. tonutils/clients/http/chainstack/__init__.py +0 -4
  72. tonutils/clients/http/chainstack/client.py +0 -63
  73. tonutils/clients/http/chainstack/provider.py +0 -44
  74. tonutils/clients/http/quicknode/__init__.py +0 -4
  75. tonutils/clients/http/quicknode/client.py +0 -60
  76. tonutils/clients/http/quicknode/provider.py +0 -42
  77. tonutils/clients/http/tatum/__init__.py +0 -4
  78. tonutils/clients/http/tatum/client.py +0 -66
  79. tonutils/clients/http/tatum/provider.py +0 -53
  80. tonutils/clients/http/tonapi/__init__.py +0 -4
  81. tonutils/clients/http/tonapi/provider.py +0 -150
  82. tonutils/clients/http/tonapi/stack.py +0 -71
  83. tonutils/clients/http/toncenter/__init__.py +0 -4
  84. tonutils/clients/http/toncenter/provider.py +0 -145
  85. tonutils/clients/http/toncenter/stack.py +0 -73
  86. tonutils/protocols/__init__.py +0 -9
  87. tonutils-2.0.1b2.dist-info/RECORD +0 -98
  88. /tonutils/{protocols/client.py → clients/protocol.py} +0 -0
  89. {tonutils-2.0.1b2.dist-info → tonutils-2.0.1b4.dist-info}/WHEEL +0 -0
  90. {tonutils-2.0.1b2.dist-info → tonutils-2.0.1b4.dist-info}/licenses/LICENSE +0 -0
  91. {tonutils-2.0.1b2.dist-info → tonutils-2.0.1b4.dist-info}/top_level.txt +0 -0
tonutils/__init__.py CHANGED
@@ -1,7 +1,6 @@
1
1
  from . import (
2
2
  clients,
3
3
  contracts,
4
- protocols,
5
4
  exceptions,
6
5
  types,
7
6
  utils,
@@ -12,7 +11,6 @@ __all__ = [
12
11
  "__version__",
13
12
  "clients",
14
13
  "contracts",
15
- "protocols",
16
14
  "exceptions",
17
15
  "types",
18
16
  "utils",
tonutils/__meta__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.0.1b2"
1
+ __version__ = "2.0.1b4"
tonutils/cli.py ADDED
@@ -0,0 +1,111 @@
1
+ import argparse
2
+ import asyncio
3
+ import typing as t
4
+
5
+ from tonutils.__meta__ import __version__
6
+ from tonutils.clients.adnl.provider.config import (
7
+ get_mainnet_global_config,
8
+ get_testnet_global_config,
9
+ load_global_config,
10
+ )
11
+ from tonutils.tools.status_monitor import LiteServerMonitor
12
+ from tonutils.types import NetworkGlobalID
13
+
14
+ NETWORK_MAP: t.Dict[str, NetworkGlobalID] = {
15
+ "mainnet": NetworkGlobalID.MAINNET,
16
+ "testnet": NetworkGlobalID.TESTNET,
17
+ }
18
+
19
+
20
+ def parse_network(value: str) -> NetworkGlobalID:
21
+ value = value.lower().strip()
22
+ if value not in NETWORK_MAP:
23
+ raise argparse.ArgumentTypeError(f"Unknown network: {value}")
24
+ return NETWORK_MAP[value]
25
+
26
+
27
+ def cmd_status(args: argparse.Namespace) -> None:
28
+ if args.config:
29
+ config = load_global_config(args.config)
30
+ else:
31
+ config_getter = {
32
+ NetworkGlobalID.MAINNET: get_mainnet_global_config,
33
+ NetworkGlobalID.TESTNET: get_testnet_global_config,
34
+ }
35
+ config = config_getter[args.network]()
36
+
37
+ async def _run() -> None:
38
+ monitor = LiteServerMonitor.from_config(
39
+ config=config,
40
+ network=args.network,
41
+ rps_limit=args.rps,
42
+ )
43
+ try:
44
+ await monitor.run()
45
+ finally:
46
+ await monitor.stop()
47
+
48
+ try:
49
+ asyncio.run(_run())
50
+ except KeyboardInterrupt:
51
+ pass
52
+
53
+
54
+ def _create_parser() -> argparse.ArgumentParser:
55
+ parser = argparse.ArgumentParser(
56
+ prog="tonutils",
57
+ description="Tonutils CLI.",
58
+ )
59
+ parser.add_argument(
60
+ "-v",
61
+ "--version",
62
+ action="version",
63
+ version=f"tonutils {__version__}",
64
+ )
65
+
66
+ subs = parser.add_subparsers(dest="command", metavar="command")
67
+
68
+ status = subs.add_parser(
69
+ "status",
70
+ help="Monitor lite-servers status.",
71
+ )
72
+ status.add_argument(
73
+ "-n",
74
+ "--network",
75
+ type=parse_network,
76
+ metavar="NET",
77
+ default=NetworkGlobalID.MAINNET,
78
+ help="mainnet (default) or testnet",
79
+ )
80
+ status.add_argument(
81
+ "-c",
82
+ "--config",
83
+ type=str,
84
+ metavar="PATH",
85
+ help="Config file path or URL",
86
+ )
87
+ status.add_argument(
88
+ "-r",
89
+ "--rps",
90
+ type=int,
91
+ metavar="N",
92
+ default=100,
93
+ help="Requests per second (default: 100)",
94
+ )
95
+ status.set_defaults(func=cmd_status)
96
+
97
+ return parser
98
+
99
+
100
+ def main() -> None:
101
+ parser = _create_parser()
102
+ args = parser.parse_args()
103
+
104
+ if hasattr(args, "func"):
105
+ args.func(args)
106
+ else:
107
+ parser.print_help()
108
+
109
+
110
+ if __name__ == "__main__":
111
+ main()
@@ -1,13 +1,13 @@
1
- from .adnl import AdnlBalancer, AdnlClient, AdnlProvider
2
- from .base import BaseClient
1
+ from .adnl import (
2
+ LiteBalancer,
3
+ LiteClient,
4
+ AdnlProvider,
5
+ )
3
6
  from .http import (
4
7
  HttpBalancer,
5
8
  ChainstackHttpClient,
6
- ChainstackHttpProvider,
7
9
  QuicknodeHttpClient,
8
- QuicknodeHttpProvider,
9
10
  TatumHttpClient,
10
- TatumHttpProvider,
11
11
  TonapiHttpClient,
12
12
  TonapiHttpProvider,
13
13
  ToncenterHttpClient,
@@ -15,17 +15,13 @@ from .http import (
15
15
  )
16
16
 
17
17
  __all__ = [
18
- "BaseClient",
19
- "AdnlBalancer",
20
- "AdnlClient",
18
+ "LiteBalancer",
19
+ "LiteClient",
21
20
  "AdnlProvider",
22
21
  "HttpBalancer",
23
22
  "ChainstackHttpClient",
24
- "ChainstackHttpProvider",
25
23
  "QuicknodeHttpClient",
26
- "QuicknodeHttpProvider",
27
24
  "TatumHttpClient",
28
- "TatumHttpProvider",
29
25
  "TonapiHttpClient",
30
26
  "TonapiHttpProvider",
31
27
  "ToncenterHttpClient",
@@ -1,5 +1,9 @@
1
- from .balancer import AdnlBalancer
2
- from .client import AdnlClient
1
+ from .balancer import LiteBalancer
2
+ from .client import LiteClient
3
3
  from .provider import AdnlProvider
4
4
 
5
- __all__ = ["AdnlBalancer", "AdnlClient", "AdnlProvider"]
5
+ __all__ = [
6
+ "LiteBalancer",
7
+ "LiteClient",
8
+ "AdnlProvider",
9
+ ]