tonutils 2.0.1b1__py3-none-any.whl → 2.0.1b3__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.
- tonutils/__init__.py +0 -2
- tonutils/__meta__.py +1 -1
- tonutils/clients/__init__.py +5 -9
- tonutils/clients/adnl/__init__.py +5 -1
- tonutils/clients/adnl/balancer.py +319 -125
- tonutils/clients/adnl/client.py +187 -51
- tonutils/clients/adnl/provider/config.py +19 -25
- tonutils/clients/adnl/provider/models.py +4 -0
- tonutils/clients/adnl/provider/provider.py +191 -145
- tonutils/clients/adnl/provider/transport.py +38 -32
- tonutils/clients/adnl/provider/workers/base.py +0 -2
- tonutils/clients/adnl/provider/workers/pinger.py +1 -1
- tonutils/clients/adnl/provider/workers/reader.py +3 -2
- tonutils/clients/adnl/{provider/builder.py → utils.py} +62 -2
- tonutils/clients/http/__init__.py +11 -8
- tonutils/clients/http/balancer.py +75 -63
- tonutils/clients/http/clients/__init__.py +13 -0
- tonutils/clients/http/clients/chainstack.py +48 -0
- tonutils/clients/http/clients/quicknode.py +47 -0
- tonutils/clients/http/clients/tatum.py +56 -0
- tonutils/clients/http/{tonapi/client.py → clients/tonapi.py} +31 -31
- tonutils/clients/http/{toncenter/client.py → clients/toncenter.py} +59 -48
- tonutils/clients/http/providers/__init__.py +4 -0
- tonutils/clients/http/providers/base.py +201 -0
- tonutils/clients/http/providers/response.py +85 -0
- tonutils/clients/http/providers/tonapi/__init__.py +3 -0
- tonutils/clients/http/{tonapi → providers/tonapi}/models.py +1 -0
- tonutils/clients/http/providers/tonapi/provider.py +125 -0
- tonutils/clients/http/providers/toncenter/__init__.py +3 -0
- tonutils/clients/http/{toncenter → providers/toncenter}/models.py +1 -0
- tonutils/clients/http/providers/toncenter/provider.py +119 -0
- tonutils/clients/http/utils.py +140 -0
- tonutils/clients/limiter.py +115 -0
- tonutils/contracts/__init__.py +18 -0
- tonutils/contracts/base.py +33 -20
- tonutils/contracts/dns/methods.py +2 -2
- tonutils/contracts/jetton/methods.py +2 -2
- tonutils/contracts/nft/methods.py +2 -2
- tonutils/contracts/nft/tlb.py +1 -1
- tonutils/{protocols/contract.py → contracts/protocol.py} +29 -29
- tonutils/contracts/telegram/methods.py +2 -2
- tonutils/contracts/vanity/__init__.py +17 -0
- tonutils/contracts/vanity/models.py +39 -0
- tonutils/contracts/vanity/tlb.py +40 -0
- tonutils/contracts/vanity/vanity.py +40 -0
- tonutils/contracts/wallet/__init__.py +2 -0
- tonutils/contracts/wallet/base.py +3 -3
- tonutils/contracts/wallet/messages.py +1 -1
- tonutils/contracts/wallet/methods.py +2 -2
- tonutils/{protocols/wallet.py → contracts/wallet/protocol.py} +35 -35
- tonutils/contracts/wallet/versions/v5.py +3 -3
- tonutils/exceptions.py +134 -226
- tonutils/types.py +115 -0
- tonutils/utils.py +3 -3
- {tonutils-2.0.1b1.dist-info → tonutils-2.0.1b3.dist-info}/METADATA +4 -4
- tonutils-2.0.1b3.dist-info/RECORD +93 -0
- tonutils/clients/adnl/provider/limiter.py +0 -56
- tonutils/clients/adnl/stack.py +0 -64
- tonutils/clients/http/chainstack/__init__.py +0 -4
- tonutils/clients/http/chainstack/client.py +0 -63
- tonutils/clients/http/chainstack/provider.py +0 -44
- tonutils/clients/http/quicknode/__init__.py +0 -4
- tonutils/clients/http/quicknode/client.py +0 -60
- tonutils/clients/http/quicknode/provider.py +0 -42
- tonutils/clients/http/tatum/__init__.py +0 -4
- tonutils/clients/http/tatum/client.py +0 -66
- tonutils/clients/http/tatum/provider.py +0 -53
- tonutils/clients/http/tonapi/__init__.py +0 -4
- tonutils/clients/http/tonapi/provider.py +0 -150
- tonutils/clients/http/tonapi/stack.py +0 -71
- tonutils/clients/http/toncenter/__init__.py +0 -4
- tonutils/clients/http/toncenter/provider.py +0 -145
- tonutils/clients/http/toncenter/stack.py +0 -73
- tonutils/protocols/__init__.py +0 -9
- tonutils-2.0.1b1.dist-info/RECORD +0 -94
- /tonutils/{protocols/client.py → clients/protocol.py} +0 -0
- {tonutils-2.0.1b1.dist-info → tonutils-2.0.1b3.dist-info}/WHEEL +0 -0
- {tonutils-2.0.1b1.dist-info → tonutils-2.0.1b3.dist-info}/licenses/LICENSE +0 -0
- {tonutils-2.0.1b1.dist-info → tonutils-2.0.1b3.dist-info}/top_level.txt +0 -0
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import typing as t
|
|
2
|
-
|
|
3
|
-
from aiohttp import ClientSession
|
|
4
|
-
from pyapiq import AsyncClientAPI, async_endpoint
|
|
5
|
-
from pyapiq.types import HTTPMethod, ReturnType, RepeatQuery
|
|
6
|
-
|
|
7
|
-
from tonutils.clients.http.tonapi.models import (
|
|
8
|
-
BlockchainAccountMethodResult,
|
|
9
|
-
BlockchainAccountResult,
|
|
10
|
-
BlockchainAccountTransactionsResult,
|
|
11
|
-
BlockchainConfigResult,
|
|
12
|
-
BlockchainMessagePayload,
|
|
13
|
-
)
|
|
14
|
-
from tonutils.types import NetworkGlobalID
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TonapiHttpProvider(AsyncClientAPI):
|
|
18
|
-
"""Low-level HTTP provider for Tonapi API."""
|
|
19
|
-
|
|
20
|
-
version = "v2"
|
|
21
|
-
|
|
22
|
-
def __init__(
|
|
23
|
-
self,
|
|
24
|
-
network: NetworkGlobalID,
|
|
25
|
-
api_key: str,
|
|
26
|
-
base_url: t.Optional[str] = None,
|
|
27
|
-
timeout: int = 10,
|
|
28
|
-
session: t.Optional[ClientSession] = None,
|
|
29
|
-
rps_limit: t.Optional[int] = None,
|
|
30
|
-
rps_period: t.Optional[float] = None,
|
|
31
|
-
rps_retries: t.Optional[int] = None,
|
|
32
|
-
) -> None:
|
|
33
|
-
"""
|
|
34
|
-
Initialize provider with Tonapi API settings.
|
|
35
|
-
|
|
36
|
-
:param network: TON network selector (mainnet/testnet)
|
|
37
|
-
:param api_key: Tonapi API key
|
|
38
|
-
You can get an API key on the Tonconsole website: https://tonconsole.com/
|
|
39
|
-
:param base_url: Custom Tonapi base URL
|
|
40
|
-
:param timeout: HTTP request timeout in seconds
|
|
41
|
-
:param session: Optional aiohttp.ClientSession, external or auto-created
|
|
42
|
-
:param rps_limit: Requests-per-second rate limit
|
|
43
|
-
:param rps_period: Time period window for rate limiting
|
|
44
|
-
:param rps_retries: Number of retries on rate-limit errors
|
|
45
|
-
"""
|
|
46
|
-
urls = {
|
|
47
|
-
NetworkGlobalID.MAINNET: "https://tonapi.io",
|
|
48
|
-
NetworkGlobalID.TESTNET: "https://testnet.tonapi.io",
|
|
49
|
-
}
|
|
50
|
-
base_url = base_url or urls.get(network)
|
|
51
|
-
headers = {"Authorization": f"Bearer {api_key}"}
|
|
52
|
-
|
|
53
|
-
super().__init__(
|
|
54
|
-
base_url=base_url,
|
|
55
|
-
headers=headers,
|
|
56
|
-
timeout=timeout,
|
|
57
|
-
session=session,
|
|
58
|
-
rps=rps_limit,
|
|
59
|
-
time_period=rps_period,
|
|
60
|
-
max_retries=rps_retries,
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
@async_endpoint(
|
|
64
|
-
HTTPMethod.POST,
|
|
65
|
-
path="/blockchain/message",
|
|
66
|
-
return_as=ReturnType.NONE,
|
|
67
|
-
)
|
|
68
|
-
async def blockchain_message( # type: ignore[empty-body]
|
|
69
|
-
self,
|
|
70
|
-
payload: BlockchainMessagePayload,
|
|
71
|
-
) -> None:
|
|
72
|
-
"""
|
|
73
|
-
Send an external message to the blockchain.
|
|
74
|
-
|
|
75
|
-
:param payload: Payload with base64-encoded BoC
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
@async_endpoint(
|
|
79
|
-
HTTPMethod.GET,
|
|
80
|
-
path="/blockchain/config",
|
|
81
|
-
return_as=BlockchainConfigResult,
|
|
82
|
-
)
|
|
83
|
-
async def blockchain_config( # type: ignore[empty-body]
|
|
84
|
-
self,
|
|
85
|
-
) -> BlockchainConfigResult:
|
|
86
|
-
"""
|
|
87
|
-
Fetch global blockchain configuration.
|
|
88
|
-
|
|
89
|
-
:return: BlockchainConfigResult with raw config BoC
|
|
90
|
-
"""
|
|
91
|
-
|
|
92
|
-
@async_endpoint(
|
|
93
|
-
HTTPMethod.GET,
|
|
94
|
-
path="/blockchain/accounts/{address}",
|
|
95
|
-
return_as=BlockchainAccountResult,
|
|
96
|
-
)
|
|
97
|
-
async def blockchain_account( # type: ignore[empty-body]
|
|
98
|
-
self,
|
|
99
|
-
address: str,
|
|
100
|
-
) -> BlockchainAccountResult:
|
|
101
|
-
"""
|
|
102
|
-
Fetch basic account information.
|
|
103
|
-
|
|
104
|
-
:param address: Raw TON address
|
|
105
|
-
:return: BlockchainAccountResult
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
@async_endpoint(
|
|
109
|
-
HTTPMethod.GET,
|
|
110
|
-
path="/blockchain/accounts/{address}/transactions",
|
|
111
|
-
return_as=BlockchainAccountTransactionsResult,
|
|
112
|
-
)
|
|
113
|
-
async def blockchain_account_transactions( # type: ignore[empty-body]
|
|
114
|
-
self,
|
|
115
|
-
address: str,
|
|
116
|
-
limit: int = 100,
|
|
117
|
-
after_lt: t.Optional[int] = None,
|
|
118
|
-
before_lt: t.Optional[int] = 0,
|
|
119
|
-
sort_order: t.Optional[t.Literal["asc", "desc"]] = "desc",
|
|
120
|
-
) -> BlockchainAccountTransactionsResult:
|
|
121
|
-
"""
|
|
122
|
-
Fetch recent transactions for an account.
|
|
123
|
-
|
|
124
|
-
:param address: Raw TON address
|
|
125
|
-
:param limit: Maximum number of transactions to return
|
|
126
|
-
:param after_lt: Lower logical-time bound (exclusive)
|
|
127
|
-
:param before_lt: Upper logical-time bound (inclusive)
|
|
128
|
-
:param sort_order: Transaction sorting order ("asc" or "desc")
|
|
129
|
-
:return: BlockchainAccountTransactionsResult
|
|
130
|
-
"""
|
|
131
|
-
|
|
132
|
-
@async_endpoint(
|
|
133
|
-
HTTPMethod.GET,
|
|
134
|
-
path="/blockchain/accounts/{address}/methods/{method_name}",
|
|
135
|
-
return_as=BlockchainAccountMethodResult,
|
|
136
|
-
)
|
|
137
|
-
async def blockchain_account_method( # type: ignore[empty-body]
|
|
138
|
-
self,
|
|
139
|
-
address: str,
|
|
140
|
-
method_name: str,
|
|
141
|
-
args: t.Annotated[t.List[t.Any], RepeatQuery],
|
|
142
|
-
) -> BlockchainAccountMethodResult:
|
|
143
|
-
"""
|
|
144
|
-
Execute a smart-contract get-method via Tonapi.
|
|
145
|
-
|
|
146
|
-
:param address: Raw TON address
|
|
147
|
-
:param method_name: Name of the method to execute
|
|
148
|
-
:param args: Encoded TVM stack arguments (repeatable query items)
|
|
149
|
-
:return: BlockchainAccountMethodResult with stack output
|
|
150
|
-
"""
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing as t
|
|
4
|
-
|
|
5
|
-
from pytoniq_core import Address, Slice
|
|
6
|
-
|
|
7
|
-
from tonutils.types import StackTag, StackItem, StackItems
|
|
8
|
-
from tonutils.utils import cell_to_hex, norm_stack_num, norm_stack_cell
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def decode_stack(items: t.List[t.Any]) -> StackItems:
|
|
12
|
-
"""
|
|
13
|
-
Decode Tonapi TVM stack format into internal Python structures.
|
|
14
|
-
|
|
15
|
-
Tonapi represents stack items as dictionaries with a "type" key and
|
|
16
|
-
a value under the same key. This function converts them into:
|
|
17
|
-
- NUM → int
|
|
18
|
-
- CELL/SLICE → Cell or Address (auto-detected)
|
|
19
|
-
- LIST/TUPLE → nested Python lists
|
|
20
|
-
- NULL → None
|
|
21
|
-
|
|
22
|
-
:param items: Raw stack items as returned by Tonapi
|
|
23
|
-
:return: Normalized list of decoded stack values
|
|
24
|
-
"""
|
|
25
|
-
out: StackItems = []
|
|
26
|
-
for item in items:
|
|
27
|
-
if not isinstance(item, dict):
|
|
28
|
-
continue
|
|
29
|
-
tpe = item.get("type")
|
|
30
|
-
val = item.get(tpe)
|
|
31
|
-
if tpe == StackTag.NULL.value:
|
|
32
|
-
out.append(None)
|
|
33
|
-
elif tpe == StackTag.NUM.value and val is not None:
|
|
34
|
-
out.append(norm_stack_num(t.cast(str | int, val)))
|
|
35
|
-
elif tpe in (StackTag.CELL.value, StackTag.SLICE.value):
|
|
36
|
-
out.append(norm_stack_cell(val))
|
|
37
|
-
elif tpe in (StackTag.LIST.value, StackTag.TUPLE.value):
|
|
38
|
-
inner: t.List[t.Any] = []
|
|
39
|
-
for el in val or []:
|
|
40
|
-
inner.append(decode_stack([el])[0] if isinstance(el, dict) else el)
|
|
41
|
-
out.append(inner)
|
|
42
|
-
return out
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def encode_stack(items: t.List[StackItem]) -> t.List[t.Any]:
|
|
46
|
-
"""
|
|
47
|
-
Encode Python TVM stack values into Tonapi-compatible format.
|
|
48
|
-
|
|
49
|
-
Produces values expected by Tonapi query parameters:
|
|
50
|
-
- int → hex string
|
|
51
|
-
- Cell/Address → hex BoC string
|
|
52
|
-
- Slice → hex BoC string
|
|
53
|
-
- list/tuple → recursively encoded list
|
|
54
|
-
|
|
55
|
-
:param items: List of python TVM stack values
|
|
56
|
-
:return: Encoded stack items suitable for Tonapi API
|
|
57
|
-
"""
|
|
58
|
-
out: t.List[t.Any] = []
|
|
59
|
-
for item in items:
|
|
60
|
-
tpe = StackTag.of(item)
|
|
61
|
-
if tpe == StackTag.NUM:
|
|
62
|
-
out.append(hex(t.cast(int, item)))
|
|
63
|
-
elif tpe == StackTag.CELL:
|
|
64
|
-
cell = item.to_cell() if isinstance(item, Address) else item
|
|
65
|
-
out.append(cell_to_hex(cell))
|
|
66
|
-
elif tpe == StackTag.SLICE:
|
|
67
|
-
cell = t.cast(Slice, item).to_cell()
|
|
68
|
-
out.append(cell_to_hex(cell))
|
|
69
|
-
elif tpe in (StackTag.LIST, StackTag.TUPLE):
|
|
70
|
-
out.append(encode_stack(t.cast(list, item)))
|
|
71
|
-
return out
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import typing as t
|
|
2
|
-
|
|
3
|
-
from aiohttp import ClientSession
|
|
4
|
-
from pyapiq import AsyncClientAPI, async_endpoint
|
|
5
|
-
from pyapiq.types import ReturnType, HTTPMethod
|
|
6
|
-
|
|
7
|
-
from tonutils.clients.http.toncenter.models import (
|
|
8
|
-
GetAddressInformationResult,
|
|
9
|
-
GetConfigAllResult,
|
|
10
|
-
GetTransactionResult,
|
|
11
|
-
RunGetMethodPayload,
|
|
12
|
-
RunGetMethodResul,
|
|
13
|
-
SendBocPayload,
|
|
14
|
-
)
|
|
15
|
-
from tonutils.types import NetworkGlobalID
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class ToncenterHttpProvider(AsyncClientAPI):
|
|
19
|
-
"""Low-level HTTP provider for Toncenter API."""
|
|
20
|
-
|
|
21
|
-
version = "v2"
|
|
22
|
-
|
|
23
|
-
def __init__(
|
|
24
|
-
self,
|
|
25
|
-
network: NetworkGlobalID,
|
|
26
|
-
api_key: t.Optional[str] = None,
|
|
27
|
-
base_url: t.Optional[str] = None,
|
|
28
|
-
timeout: int = 10,
|
|
29
|
-
session: t.Optional[ClientSession] = None,
|
|
30
|
-
rps_limit: t.Optional[int] = None,
|
|
31
|
-
rps_period: t.Optional[float] = None,
|
|
32
|
-
rps_retries: t.Optional[int] = None,
|
|
33
|
-
) -> None:
|
|
34
|
-
"""
|
|
35
|
-
Initialize provider with Toncenter API settings.
|
|
36
|
-
|
|
37
|
-
:param network: TON network selector (mainnet/testnet)
|
|
38
|
-
:param api_key: Optional Toncenter API key
|
|
39
|
-
You can get an API key on the Toncenter telegram bot: https://t.me/toncenter
|
|
40
|
-
:param base_url: Custom Toncenter endpoint base URL
|
|
41
|
-
:param timeout: HTTP request timeout in seconds
|
|
42
|
-
:param session: Optional aiohttp.ClientSession, external or auto-created
|
|
43
|
-
:param rps_limit: Requests-per-second rate limit
|
|
44
|
-
:param rps_period: Time period window for rate limiting
|
|
45
|
-
:param rps_retries: Number of retries on rate-limit errors
|
|
46
|
-
"""
|
|
47
|
-
urls = {
|
|
48
|
-
NetworkGlobalID.MAINNET: "https://toncenter.com/api",
|
|
49
|
-
NetworkGlobalID.TESTNET: "https://testnet.toncenter.com/api",
|
|
50
|
-
}
|
|
51
|
-
base_url = base_url or urls.get(network)
|
|
52
|
-
headers = {"X-Api-Key": api_key} if api_key else {}
|
|
53
|
-
|
|
54
|
-
super().__init__(
|
|
55
|
-
base_url=base_url,
|
|
56
|
-
headers=headers,
|
|
57
|
-
timeout=timeout,
|
|
58
|
-
session=session,
|
|
59
|
-
rps=rps_limit,
|
|
60
|
-
time_period=rps_period,
|
|
61
|
-
max_retries=rps_retries,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
@async_endpoint(
|
|
65
|
-
HTTPMethod.POST,
|
|
66
|
-
path="/sendBoc",
|
|
67
|
-
return_as=ReturnType.NONE,
|
|
68
|
-
)
|
|
69
|
-
async def send_boc( # type: ignore[empty-body]
|
|
70
|
-
self,
|
|
71
|
-
payload: SendBocPayload,
|
|
72
|
-
) -> None:
|
|
73
|
-
"""
|
|
74
|
-
Send an external message to the blockchain.
|
|
75
|
-
|
|
76
|
-
:param payload: Pre-validated SendBocPayload with BoC data
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
@async_endpoint(
|
|
80
|
-
HTTPMethod.GET,
|
|
81
|
-
path="/getConfigAll",
|
|
82
|
-
return_as=GetConfigAllResult,
|
|
83
|
-
)
|
|
84
|
-
async def get_config_all( # type: ignore[empty-body]
|
|
85
|
-
self,
|
|
86
|
-
) -> GetConfigAllResult:
|
|
87
|
-
"""
|
|
88
|
-
Fetch the full blockchain configuration dictionary.
|
|
89
|
-
|
|
90
|
-
:return: Parsed GetConfigAllResult object
|
|
91
|
-
"""
|
|
92
|
-
|
|
93
|
-
@async_endpoint(
|
|
94
|
-
HTTPMethod.GET,
|
|
95
|
-
path="/getAddressInformation",
|
|
96
|
-
return_as=GetAddressInformationResult,
|
|
97
|
-
)
|
|
98
|
-
async def get_address_information( # type: ignore[empty-body]
|
|
99
|
-
self,
|
|
100
|
-
address: str,
|
|
101
|
-
) -> GetAddressInformationResult:
|
|
102
|
-
"""
|
|
103
|
-
Fetch basic information about a contract.
|
|
104
|
-
|
|
105
|
-
:param address: Raw TON address (workchain:hash)
|
|
106
|
-
:return: GetAddressInformationResult
|
|
107
|
-
"""
|
|
108
|
-
|
|
109
|
-
@async_endpoint(
|
|
110
|
-
HTTPMethod.GET,
|
|
111
|
-
path="/getTransactions",
|
|
112
|
-
return_as=GetTransactionResult,
|
|
113
|
-
)
|
|
114
|
-
async def get_transaction( # type: ignore[empty-body]
|
|
115
|
-
self,
|
|
116
|
-
address: str,
|
|
117
|
-
limit: int = 100,
|
|
118
|
-
from_lt: t.Optional[int] = None,
|
|
119
|
-
to_lt: int = 0,
|
|
120
|
-
) -> GetTransactionResult:
|
|
121
|
-
"""
|
|
122
|
-
Fetch recent transactions for a contract.
|
|
123
|
-
|
|
124
|
-
:param address: Raw TON address
|
|
125
|
-
:param limit: Maximum number of transactions to return
|
|
126
|
-
:param from_lt: Lower logical-time bound (exclusive)
|
|
127
|
-
:param to_lt: Upper logical-time bound (inclusive)
|
|
128
|
-
:return: GetTransactionResult
|
|
129
|
-
"""
|
|
130
|
-
|
|
131
|
-
@async_endpoint(
|
|
132
|
-
HTTPMethod.POST,
|
|
133
|
-
path="/runGetMethod",
|
|
134
|
-
return_as=RunGetMethodResul,
|
|
135
|
-
)
|
|
136
|
-
async def run_get_method( # type: ignore[empty-body]
|
|
137
|
-
self,
|
|
138
|
-
payload: RunGetMethodPayload,
|
|
139
|
-
) -> RunGetMethodResul:
|
|
140
|
-
"""
|
|
141
|
-
Execute a smart-contract get-method.
|
|
142
|
-
|
|
143
|
-
:param payload: RunGetMethodPayload containing method name and stack
|
|
144
|
-
:return: RunGetMethodResul with TVM stack output
|
|
145
|
-
"""
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import typing as t
|
|
4
|
-
|
|
5
|
-
from pytoniq_core import Address, Cell, Slice
|
|
6
|
-
|
|
7
|
-
from tonutils.types import StackTag, StackItem, StackItems
|
|
8
|
-
from tonutils.utils import cell_to_b64, norm_stack_num, norm_stack_cell
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def decode_stack(items: t.List[t.Any]) -> StackItems:
|
|
12
|
-
"""
|
|
13
|
-
Decode Toncenter TVM stack format into internal python structures.
|
|
14
|
-
|
|
15
|
-
Converts Toncenter stack elements into native Python values:
|
|
16
|
-
- NUM → int
|
|
17
|
-
- CELL/SLICE → Cell or Address (auto-detected)
|
|
18
|
-
- LIST/TUPLE → recursively decoded lists
|
|
19
|
-
- NULL → None
|
|
20
|
-
|
|
21
|
-
:param items: Raw stack items as returned by Toncenter
|
|
22
|
-
:return: Normalized list of decoded stack values
|
|
23
|
-
"""
|
|
24
|
-
out: StackItems = []
|
|
25
|
-
for item in items:
|
|
26
|
-
if not (isinstance(item, list) and len(item) == 2):
|
|
27
|
-
continue
|
|
28
|
-
tag, payload = item
|
|
29
|
-
if tag == StackTag.NULL:
|
|
30
|
-
out.append(None)
|
|
31
|
-
elif tag == StackTag.NUM.value:
|
|
32
|
-
out.append(norm_stack_num(payload))
|
|
33
|
-
elif tag in (
|
|
34
|
-
StackTag.CELL.value,
|
|
35
|
-
StackTag.TVM_CELL.value,
|
|
36
|
-
StackTag.SLICE.value,
|
|
37
|
-
StackTag.TVM_SLICE.value,
|
|
38
|
-
):
|
|
39
|
-
out.append(norm_stack_cell((payload or {}).get("bytes")))
|
|
40
|
-
elif tag in (StackTag.LIST.value, StackTag.TUPLE.value):
|
|
41
|
-
elements = (payload or {}).get("elements") or []
|
|
42
|
-
out.append(decode_stack(elements) if len(elements) > 0 else None)
|
|
43
|
-
return out
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def encode_stack(items: t.List[StackItem]) -> t.List[list]:
|
|
47
|
-
"""
|
|
48
|
-
Encode Python stack values into Toncenter-compatible TVM stack format.
|
|
49
|
-
|
|
50
|
-
Supports:
|
|
51
|
-
- int → NUM
|
|
52
|
-
- Cell → TVM_CELL
|
|
53
|
-
- Slice → TVM_SLICE
|
|
54
|
-
- list/tuple → LIST/TUPLE (recursive)
|
|
55
|
-
- Address → encoded as TVM_CELL
|
|
56
|
-
|
|
57
|
-
:param items: List of python TVM stack values
|
|
58
|
-
:return: Encoded stack items suitable for Toncenter API
|
|
59
|
-
"""
|
|
60
|
-
out: t.List[t.Any] = []
|
|
61
|
-
for item in items:
|
|
62
|
-
tpe = StackTag.of(item)
|
|
63
|
-
if tpe is StackTag.NUM:
|
|
64
|
-
out.append([StackTag.NUM.value, str(t.cast(str, item))])
|
|
65
|
-
elif tpe is StackTag.CELL:
|
|
66
|
-
cell = item.to_cell() if isinstance(item, Address) else t.cast(Cell, item)
|
|
67
|
-
out.append([StackTag.TVM_CELL.value, cell_to_b64(cell)])
|
|
68
|
-
elif tpe is StackTag.SLICE:
|
|
69
|
-
cell = t.cast(Slice, item).to_cell()
|
|
70
|
-
out.append([StackTag.TVM_SLICE.value, cell_to_b64(cell)])
|
|
71
|
-
elif tpe in (StackTag.LIST, StackTag.TUPLE):
|
|
72
|
-
out.append([tpe.value, {"elements": encode_stack(t.cast(list, item))}])
|
|
73
|
-
return out
|
tonutils/protocols/__init__.py
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
tonutils/__init__.py,sha256=7GLHTRx0vOD5oyzKcrBbpfyU3dFc8fa1KeCESnT4EJU,260
|
|
2
|
-
tonutils/__meta__.py,sha256=89lH3Ln3p4HjZ-eajpbepwwALmKgwvx-TE0YNP0peIQ,24
|
|
3
|
-
tonutils/exceptions.py,sha256=UE-5XzUUGUndx-AxaIAOiorYMw6wTLO-CYuDY0gfk0U,8405
|
|
4
|
-
tonutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
tonutils/types.py,sha256=0SfJ-ucrxf2BglvGtaNmzAg74TmrP3ljbEb1yAqJ_Eg,10739
|
|
6
|
-
tonutils/utils.py,sha256=W-EmDtd-V5ViOBcZjsBuqO50Xala5kMDY0HBsgliFe0,16491
|
|
7
|
-
tonutils/clients/__init__.py,sha256=vTBnOtCoC2O3gqcTxnSRbg0DAen3jdNp4r49IG_BPro,753
|
|
8
|
-
tonutils/clients/base.py,sha256=K2Z0FTF1c1V420mJn8Az9PGgzfbHmK6fnyFPXtrEWGM,9594
|
|
9
|
-
tonutils/clients/adnl/__init__.py,sha256=vTCie2FEzWnNm5a4oqNcQLFb_y8_rxxHDOi4jTsBqFc,159
|
|
10
|
-
tonutils/clients/adnl/balancer.py,sha256=4Vzn2bAGJl12J_7umcbxq0GFc3kYAHxtpCUsqHY7y6g,20098
|
|
11
|
-
tonutils/clients/adnl/client.py,sha256=4iP5xnZXG9sIGpVHrBCMlRJCeNsgk7IXHAJ0T7Fkauc,9406
|
|
12
|
-
tonutils/clients/adnl/stack.py,sha256=cT5abVxh6uOYb9--k11z3kxTTJl4B4e70wBLKsjCzZI,1840
|
|
13
|
-
tonutils/clients/adnl/provider/__init__.py,sha256=lLwFEEgCifMlYozwSzQbvq97R6Du7TzgGFnTgUnk4gw,63
|
|
14
|
-
tonutils/clients/adnl/provider/builder.py,sha256=81LHEvM0IjX-wk9u591OdzFdAypH6nvTp1dqWA0Gw4Q,3418
|
|
15
|
-
tonutils/clients/adnl/provider/config.py,sha256=eyxC54nnGKGbS3XazqzQTQGGObpoZr350st5vR1l3bU,945
|
|
16
|
-
tonutils/clients/adnl/provider/limiter.py,sha256=7943NWYZR5UrxMzE0k5LNPmUXZI0zqdxMWaent4-tvw,1781
|
|
17
|
-
tonutils/clients/adnl/provider/models.py,sha256=uS6W6-jsHK9-xX_mkoaDhw3BLh8mZHTisO4NK1jFAA8,4449
|
|
18
|
-
tonutils/clients/adnl/provider/provider.py,sha256=hJCHTv_FxpD1doK344HsTAvBMNCOIMPdvdf0lbWWxSE,23416
|
|
19
|
-
tonutils/clients/adnl/provider/transport.py,sha256=_xRCqKbOiOQqlWRYAr5wnTnLejOXd4i9DZTS5Gu7QO4,10540
|
|
20
|
-
tonutils/clients/adnl/provider/workers/__init__.py,sha256=M65q7mVfinHImIZNCEaHBJ-SO4DdVBsSkeZFrJs9OoE,177
|
|
21
|
-
tonutils/clients/adnl/provider/workers/base.py,sha256=o1uYWTisiw4sN2NfAh1yv-2jGk6H8UJscOGm-H7U6eo,2077
|
|
22
|
-
tonutils/clients/adnl/provider/workers/pinger.py,sha256=bvZWlGudrnQy6SPYmg5D_jMXNV_-6xh4BfR1oJ15QAc,2435
|
|
23
|
-
tonutils/clients/adnl/provider/workers/reader.py,sha256=tyMjE6w7nhQjDe3H8VEbSNNUNDByWi84neUtogwwzf4,1878
|
|
24
|
-
tonutils/clients/adnl/provider/workers/updater.py,sha256=r7NrZXDg3nY4jAF-sYkX1ZvxTE8sN99qSFctbAmHTME,1978
|
|
25
|
-
tonutils/clients/http/__init__.py,sha256=8esyJ76IEJsMeeVkYwhbON6ZZ0tBaKMAJjbAyeBY5BA,650
|
|
26
|
-
tonutils/clients/http/balancer.py,sha256=SoQA6kubmJMIT5l6DK2UOVZMzYvqTYr8PrmOGxhm0SA,11992
|
|
27
|
-
tonutils/clients/http/chainstack/__init__.py,sha256=t3ySr22Hj2NIuug2DntgOAuOGYVm_7ZqzwMYGSWaK4o,148
|
|
28
|
-
tonutils/clients/http/chainstack/client.py,sha256=qjljwDPqMT1tadRSFO4PMOuVgVRPffQF7umbX795-s8,2219
|
|
29
|
-
tonutils/clients/http/chainstack/provider.py,sha256=zkgOmB4a75rS9QdsQOWwJuypYv1EpJRrjmekQoSwp5o,1517
|
|
30
|
-
tonutils/clients/http/quicknode/__init__.py,sha256=fynHQCz6KDSNmQlHCVCmoVMop9Uy6vy54F6_Ows9H-I,144
|
|
31
|
-
tonutils/clients/http/quicknode/client.py,sha256=JWyHfI0U-R1xGh6htzErRqGllAGJANrWOvcqjfdTn5E,2073
|
|
32
|
-
tonutils/clients/http/quicknode/provider.py,sha256=Udw1vKIb0SfmffjeatsFjUfOANOEHwbxRgMYfFckKh8,1435
|
|
33
|
-
tonutils/clients/http/tatum/__init__.py,sha256=N3IDMILYwI43w_yt6HFJWGFdOw9RYvaCPikEafg6sN8,128
|
|
34
|
-
tonutils/clients/http/tatum/client.py,sha256=ra29qSbd40fLx54BYSAnvm8jFoguh1aceo80qhN8cT4,2211
|
|
35
|
-
tonutils/clients/http/tatum/provider.py,sha256=R1zuxmMc2tI--GxUeaj_m_SmeSL9emTEgCoWCqsUeKo,1811
|
|
36
|
-
tonutils/clients/http/tonapi/__init__.py,sha256=ypTm6pLiSrWJCm8kV7Lc680Ofl_HVEkETfGC6yhYQbo,132
|
|
37
|
-
tonutils/clients/http/tonapi/client.py,sha256=Jcjw45DXrS7Nj-Mi9_Ik7iKuNTfna-mZX4lhfTyt5cg,5734
|
|
38
|
-
tonutils/clients/http/tonapi/models.py,sha256=Iuxa_3Ze271swvO9jM0aN4NUwLb0f-tYa9WA2jU4CPE,1185
|
|
39
|
-
tonutils/clients/http/tonapi/provider.py,sha256=eHdC7prmaqJ5U1km7RjBMKpdBkXulwZT25pHiHFMKsk,4869
|
|
40
|
-
tonutils/clients/http/tonapi/stack.py,sha256=QS4c1ZIgLGkFAbRMGNotJFoax7ANav0m5j54Vl2sMdA,2497
|
|
41
|
-
tonutils/clients/http/toncenter/__init__.py,sha256=4_fVfRWTUEniXJBTUHGOVxULgM1MgWipdTwWIqzxc7M,144
|
|
42
|
-
tonutils/clients/http/toncenter/client.py,sha256=P1QpyREzPDzxERLUwZIgJA1S8PEJd3LBbGUEdIyqTBo,7316
|
|
43
|
-
tonutils/clients/http/toncenter/models.py,sha256=L5SestV2OC5IsOTDSIbO8SCXCMi9W_3nLM2hsKuCrtE,2378
|
|
44
|
-
tonutils/clients/http/toncenter/provider.py,sha256=feEItRWbC-QAAz7Ia3LX4yXhVrFE3V3eQ5OVKWOOgJ8,4423
|
|
45
|
-
tonutils/clients/http/toncenter/stack.py,sha256=b_fI9K_dsmYLohYiV-o1-3avdHoeq-nO4hdM3eKR5VE,2576
|
|
46
|
-
tonutils/contracts/__init__.py,sha256=SlN_6ybdM42g2plKVB3JmFeMBQx9g6G4w0PU7KkiL2s,9210
|
|
47
|
-
tonutils/contracts/base.py,sha256=vGgOxP5mDjoJJeF2j7pDYgI2PMtMJ7xgwgN6VDgHzX4,10214
|
|
48
|
-
tonutils/contracts/codes.py,sha256=1Sbbs_izHZHd-i1cjWHRP8VN3Xc2BDPr4pnjojj6mZc,37741
|
|
49
|
-
tonutils/contracts/opcodes.py,sha256=niPd-pDmtXiEpYX8xvorFmd7O4vkY0i8nX71e3iaJ1s,1001
|
|
50
|
-
tonutils/contracts/versions.py,sha256=V1rJECQSQuAVYwDmXl4lZzLzDeqZ9OChOgipzAlTPQE,1705
|
|
51
|
-
tonutils/contracts/dns/__init__.py,sha256=H57OtOeohbQlcNTHZS5YI7wtZjlqlpKg4wVso2kPRrU,987
|
|
52
|
-
tonutils/contracts/dns/collection.py,sha256=wSpKGOyCnmXBq1IITjjq5oOt2OZO3u5ckibDcacbJ9I,3089
|
|
53
|
-
tonutils/contracts/dns/item.py,sha256=H0kyZ8h4Aq8ybRLhqJdMj4YzGY6I1F_bDQrfn8BUt8Y,2998
|
|
54
|
-
tonutils/contracts/dns/methods.py,sha256=c7-lnhyZKXPhmUoXDddUVr93JOvhAbCPjx61th4RRDM,4823
|
|
55
|
-
tonutils/contracts/dns/tlb.py,sha256=e0kQQ-yoXH3ptg4-42mWQqLVspjUHBsGQiV7bpARyxc,18352
|
|
56
|
-
tonutils/contracts/jetton/__init__.py,sha256=q4veZ0vA5OgonorVxcrZ2pZm4c6uoITfUcuRcBhnHR4,1895
|
|
57
|
-
tonutils/contracts/jetton/master.py,sha256=iYlEmhyLp1Dquwam4Hh6AIPIW5PV3tCUVN4zSjjHDTg,9917
|
|
58
|
-
tonutils/contracts/jetton/methods.py,sha256=Nc6t752ordaHeBDCuKJa7wXBRt5NV_-JC9WtNZC8VGE,5479
|
|
59
|
-
tonutils/contracts/jetton/tlb.py,sha256=Bv0-8cmqxnGVyik60hu-zpQ8KJoSnL4Y5WK7eflfKhI,29341
|
|
60
|
-
tonutils/contracts/jetton/wallet.py,sha256=mhTcGucqEIgjHNaL4ee8vcv944zNFvMsA6AhaWZMUGk,2464
|
|
61
|
-
tonutils/contracts/nft/__init__.py,sha256=Oyhr6dVKcJuFxUV2hH62ehtaPlXXAsaNKbskdecEvec,2183
|
|
62
|
-
tonutils/contracts/nft/collection.py,sha256=EIAPs5gF_HW7tev1rNRCELRyVcxcNvgPVetF7Exa5O0,3086
|
|
63
|
-
tonutils/contracts/nft/item.py,sha256=zNCbHgykIPL0mn8eIcFbdFA2ZiGEXjaE2MgiS4flnuI,3746
|
|
64
|
-
tonutils/contracts/nft/methods.py,sha256=7SlBEbgaJJ8-bTBcFq5AO-IozS5R8AnxT2rD2nn3cCs,9913
|
|
65
|
-
tonutils/contracts/nft/tlb.py,sha256=MW-4kAMiJJaDpAueQ4WVaKgp_g8l4L1sUtPM-A3JNHg,36669
|
|
66
|
-
tonutils/contracts/telegram/__init__.py,sha256=nr0O0rzr2UJu1KrtrqbBqLOuUfMSLSWo4Iam5N76uak,1051
|
|
67
|
-
tonutils/contracts/telegram/collection.py,sha256=CM3T_8eWmrO_Ovq-crZgesfJ4h6JV4DhyggjV6nBY-U,3925
|
|
68
|
-
tonutils/contracts/telegram/item.py,sha256=DhNs5WFjhI1vqMfUg-cm311JTIvSaznc3aTqtLOCr9w,3887
|
|
69
|
-
tonutils/contracts/telegram/methods.py,sha256=qd0EK6iu4LmxSiw53d-k1jVUjrSjXK4ssigvDZrht6w,4403
|
|
70
|
-
tonutils/contracts/telegram/tlb.py,sha256=QRYijGDT0YGjRRjYiHjbgyeSxMP9RiSmRvmdhh6itS4,17848
|
|
71
|
-
tonutils/contracts/wallet/__init__.py,sha256=xjsKAfW4A5BqqqgZf8nTaBCP_c79ZnqAqDIeJkkjAOY,3236
|
|
72
|
-
tonutils/contracts/wallet/base.py,sha256=kKPJwwuWE-ZFtB3x5REuPQtBgY_MYo1Ol_g9ZBu3ScE,15967
|
|
73
|
-
tonutils/contracts/wallet/configs.py,sha256=yQfuCEGL_fBuc5qGJ93rPIUATTR8V1wpYscgrWb7cEQ,4082
|
|
74
|
-
tonutils/contracts/wallet/messages.py,sha256=gCJDh0d6ilJGlozBqNOROKgEsez2JtkSOWDazOia36A,13895
|
|
75
|
-
tonutils/contracts/wallet/methods.py,sha256=JYF3bq9tqXjIONTAiEJSPEQcwTz3AgL_RYlYNolxReg,10732
|
|
76
|
-
tonutils/contracts/wallet/params.py,sha256=hqinZJmhWiZUywDcmolvRxB0HYJgMAPDWYJiTmgjZ7w,4569
|
|
77
|
-
tonutils/contracts/wallet/tlb.py,sha256=rS1oZJ6jvi7zGOuPPN6S7RajQaLaUsMm-VqO09dys8I,21871
|
|
78
|
-
tonutils/contracts/wallet/versions/__init__.py,sha256=DOHAEpx1mOlHdyTg2K0Mj8ZkcjabSdpLvIQY9_Pk6gw,592
|
|
79
|
-
tonutils/contracts/wallet/versions/hw.py,sha256=9kc_mlCegBo1O4_MvRQGLE3ZqLHsvqGN2F1IgnJeBOE,8348
|
|
80
|
-
tonutils/contracts/wallet/versions/pp.py,sha256=QfTqd4TAJHFMuatIwe0lg80uixno2JqSZFmQboxhca0,3793
|
|
81
|
-
tonutils/contracts/wallet/versions/v1.py,sha256=BYRWXdM0OlSeCfayHAUBj_wM4bb3WTVYoI-pPWDJD64,2881
|
|
82
|
-
tonutils/contracts/wallet/versions/v2.py,sha256=pwrlan-utZo_WmnzDwSbnzV8ibkPEWx2WU1uOjkdrrA,2452
|
|
83
|
-
tonutils/contracts/wallet/versions/v3.py,sha256=d7cM8wjmW-1H7jGuY3AuUd7eTY3wq9ZYpJ4f5OeYX08,2470
|
|
84
|
-
tonutils/contracts/wallet/versions/v4.py,sha256=2sAsjJ8_3oYAj5JwWH3PiMyoGbgl6-f7-p6T5X7MGTI,2713
|
|
85
|
-
tonutils/contracts/wallet/versions/v5.py,sha256=QzQKp9YdQuKoSV9YADufiqJIzMYs8xDoNnFlnObfQl0,8878
|
|
86
|
-
tonutils/protocols/__init__.py,sha256=1IpH8rcX2SqzzVf1ksWaO_m42o_MgCtjWd-zYwikGPE,246
|
|
87
|
-
tonutils/protocols/client.py,sha256=4QerYoqBKAAfNZVpyQW2sp5KZZlq8xHCn9yWbbJERPQ,2557
|
|
88
|
-
tonutils/protocols/contract.py,sha256=sR7poBuvsheADT2a8bSzZt-2MHCPOm02A_Xx8JEvtBU,6182
|
|
89
|
-
tonutils/protocols/wallet.py,sha256=u_bDUA308QffVdUPH7A7t4M883cBkM1PZmwPaOjoyPM,6183
|
|
90
|
-
tonutils-2.0.1b1.dist-info/licenses/LICENSE,sha256=fG-yM-8DSkOTaJ558P7uF5PNXBmineVO9-HC12YbIxs,1060
|
|
91
|
-
tonutils-2.0.1b1.dist-info/METADATA,sha256=uz6buhhAEtoxdyeuAvc8HYdZknOm_BJENVLnirN-MBI,4284
|
|
92
|
-
tonutils-2.0.1b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
93
|
-
tonutils-2.0.1b1.dist-info/top_level.txt,sha256=-7H_mGl8S9HKQrkUiTLmEbtMM-knzRzd_a0cZZnuZIU,9
|
|
94
|
-
tonutils-2.0.1b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|