tonutils 0.5.1__py3-none-any.whl → 0.6.0a1__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/{client → clients}/__init__.py +3 -11
- tonutils/clients/base.py +95 -0
- tonutils/clients/liteserver/__init__.py +3 -0
- tonutils/clients/liteserver/client.py +155 -0
- tonutils/clients/liteserver/stub.py +70 -0
- tonutils/clients/quicknode/__init__.py +3 -0
- tonutils/clients/quicknode/api.py +19 -0
- tonutils/clients/quicknode/client.py +20 -0
- tonutils/clients/tatum/__init__.py +3 -0
- tonutils/clients/tatum/api.py +28 -0
- tonutils/clients/tatum/client.py +24 -0
- tonutils/clients/tonapi/__init__.py +3 -0
- tonutils/clients/tonapi/api.py +93 -0
- tonutils/clients/tonapi/client.py +146 -0
- tonutils/clients/tonapi/models.py +34 -0
- tonutils/clients/toncenter/__init__.py +3 -0
- tonutils/clients/toncenter/api.py +91 -0
- tonutils/clients/toncenter/client.py +200 -0
- tonutils/clients/toncenter/models.py +70 -0
- tonutils/contracts/__init__.py +55 -0
- tonutils/contracts/base.py +155 -0
- tonutils/contracts/codes.py +30 -0
- tonutils/contracts/nft/__init__.py +21 -0
- tonutils/contracts/nft/collection.py +116 -0
- tonutils/contracts/nft/get_methods.py +124 -0
- tonutils/contracts/nft/item.py +119 -0
- tonutils/contracts/wallet/__init__.py +39 -0
- tonutils/contracts/wallet/base.py +300 -0
- tonutils/contracts/wallet/get_methods.py +145 -0
- tonutils/contracts/wallet/versions/__init__.py +45 -0
- tonutils/contracts/wallet/versions/hw.py +215 -0
- tonutils/contracts/wallet/versions/pp.py +88 -0
- tonutils/contracts/wallet/versions/v1.py +92 -0
- tonutils/contracts/wallet/versions/v2.py +81 -0
- tonutils/contracts/wallet/versions/v3.py +80 -0
- tonutils/contracts/wallet/versions/v4.py +102 -0
- tonutils/contracts/wallet/versions/v5.py +236 -0
- tonutils/exceptions.py +74 -25
- tonutils/protocols/__init__.py +9 -0
- tonutils/protocols/client.py +41 -0
- tonutils/protocols/contract.py +99 -0
- tonutils/protocols/wallet.py +116 -0
- tonutils/tonconnect/__init__.py +0 -11
- tonutils/types/__init__.py +187 -0
- tonutils/types/client.py +7 -0
- tonutils/types/common.py +39 -0
- tonutils/types/configs.py +79 -0
- tonutils/types/contract.py +79 -0
- tonutils/types/keystructs.py +91 -0
- tonutils/types/messages.py +142 -0
- tonutils/types/opcodes.py +15 -0
- tonutils/types/params.py +85 -0
- tonutils/types/stack.py +17 -0
- tonutils/types/tlb/__init__.py +87 -0
- tonutils/types/tlb/content.py +156 -0
- tonutils/types/tlb/contract.py +9 -0
- tonutils/types/tlb/msg.py +36 -0
- tonutils/types/tlb/nft.py +626 -0
- tonutils/types/tlb/text.py +53 -0
- tonutils/types/tlb/wallet.py +299 -0
- tonutils/utils/__init__.py +51 -0
- tonutils/utils/converters.py +58 -0
- tonutils/utils/msg_builders.py +82 -0
- tonutils/utils/parse_config.py +35 -0
- tonutils/utils/stack_codec.py +188 -0
- tonutils/utils/text_cipher.py +140 -0
- tonutils/utils/validations.py +23 -0
- tonutils/utils/value_utils.py +62 -0
- tonutils/utils/wallet_utils.py +55 -0
- {tonutils-0.5.1.dist-info → tonutils-0.6.0a1.dist-info}/METADATA +5 -10
- tonutils-0.6.0a1.dist-info/RECORD +76 -0
- {tonutils-0.5.1.dist-info → tonutils-0.6.0a1.dist-info}/licenses/LICENSE +1 -1
- tonutils/account.py +0 -32
- tonutils/cache.py +0 -82
- tonutils/client/_base.py +0 -292
- tonutils/client/lite.py +0 -163
- tonutils/client/quicknode.py +0 -33
- tonutils/client/tatum.py +0 -50
- tonutils/client/tonapi.py +0 -145
- tonutils/client/toncenter.py +0 -303
- tonutils/client/utils.py +0 -203
- tonutils/contract.py +0 -184
- tonutils/dns/__init__.py +0 -5
- tonutils/dns/categories.py +0 -15
- tonutils/dns/contract.py +0 -256
- tonutils/dns/op_codes.py +0 -1
- tonutils/dns/subdomain_collection/__init__.py +0 -5
- tonutils/dns/subdomain_collection/content.py +0 -18
- tonutils/dns/subdomain_collection/contract.py +0 -91
- tonutils/dns/subdomain_collection/data.py +0 -63
- tonutils/dns/subdomain_collection/op_codes.py +0 -5
- tonutils/dns/subdomain_manager/__init__.py +0 -5
- tonutils/dns/subdomain_manager/contract.py +0 -210
- tonutils/dns/subdomain_manager/data.py +0 -38
- tonutils/dns/subdomain_manager/op_codes.py +0 -1
- tonutils/dns/utils.py +0 -115
- tonutils/jetton/__init__.py +0 -15
- tonutils/jetton/content.py +0 -79
- tonutils/jetton/contract/__init__.py +0 -10
- tonutils/jetton/contract/base/__init__.py +0 -5
- tonutils/jetton/contract/base/master.py +0 -76
- tonutils/jetton/contract/stablecoin/__init__.py +0 -7
- tonutils/jetton/contract/stablecoin/master.py +0 -188
- tonutils/jetton/contract/stablecoin/op_codes.py +0 -15
- tonutils/jetton/contract/stablecoin/wallet.py +0 -130
- tonutils/jetton/contract/standard/__init__.py +0 -7
- tonutils/jetton/contract/standard/master.py +0 -141
- tonutils/jetton/contract/standard/op_codes.py +0 -11
- tonutils/jetton/contract/standard/wallet.py +0 -132
- tonutils/jetton/data.py +0 -165
- tonutils/jetton/dex/__init__.py +0 -0
- tonutils/jetton/dex/dedust/__init__.py +0 -5
- tonutils/jetton/dex/dedust/constants.py +0 -48
- tonutils/jetton/dex/dedust/factory.py +0 -362
- tonutils/jetton/dex/stonfi/__init__.py +0 -10
- tonutils/jetton/dex/stonfi/utils.py +0 -47
- tonutils/jetton/dex/stonfi/v1/__init__.py +0 -7
- tonutils/jetton/dex/stonfi/v1/pton/__init__.py +0 -5
- tonutils/jetton/dex/stonfi/v1/pton/constants.py +0 -19
- tonutils/jetton/dex/stonfi/v1/pton/pton.py +0 -78
- tonutils/jetton/dex/stonfi/v1/router/__init__.py +0 -5
- tonutils/jetton/dex/stonfi/v1/router/constants.py +0 -38
- tonutils/jetton/dex/stonfi/v1/router/router.py +0 -193
- tonutils/jetton/dex/stonfi/v2/__init__.py +0 -7
- tonutils/jetton/dex/stonfi/v2/pton/__init__.py +0 -5
- tonutils/jetton/dex/stonfi/v2/pton/constants.py +0 -21
- tonutils/jetton/dex/stonfi/v2/pton/pton.py +0 -102
- tonutils/jetton/dex/stonfi/v2/router/__init__.py +0 -5
- tonutils/jetton/dex/stonfi/v2/router/constants.py +0 -41
- tonutils/jetton/dex/stonfi/v2/router/router.py +0 -308
- tonutils/nft/__init__.py +0 -22
- tonutils/nft/content.py +0 -135
- tonutils/nft/contract/__init__.py +0 -0
- tonutils/nft/contract/base/__init__.py +0 -7
- tonutils/nft/contract/base/collection.py +0 -80
- tonutils/nft/contract/base/nft.py +0 -71
- tonutils/nft/contract/editable/__init__.py +0 -9
- tonutils/nft/contract/editable/collection.py +0 -341
- tonutils/nft/contract/editable/nft.py +0 -155
- tonutils/nft/contract/soulbound/__init__.py +0 -9
- tonutils/nft/contract/soulbound/collection.py +0 -277
- tonutils/nft/contract/soulbound/nft.py +0 -123
- tonutils/nft/contract/standard/__init__.py +0 -9
- tonutils/nft/contract/standard/collection.py +0 -257
- tonutils/nft/contract/standard/nft.py +0 -78
- tonutils/nft/data.py +0 -95
- tonutils/nft/marketplace/__init__.py +0 -0
- tonutils/nft/marketplace/getgems/__init__.py +0 -5
- tonutils/nft/marketplace/getgems/addresses.py +0 -8
- tonutils/nft/marketplace/getgems/contract/__init__.py +0 -5
- tonutils/nft/marketplace/getgems/contract/salev3r3.py +0 -161
- tonutils/nft/marketplace/getgems/data.py +0 -54
- tonutils/nft/marketplace/getgems/op_codes.py +0 -7
- tonutils/nft/op_codes.py +0 -19
- tonutils/nft/royalty_params.py +0 -29
- tonutils/tonconnect/connector.py +0 -699
- tonutils/tonconnect/models/__init__.py +0 -53
- tonutils/tonconnect/models/account.py +0 -57
- tonutils/tonconnect/models/chain.py +0 -10
- tonutils/tonconnect/models/device.py +0 -137
- tonutils/tonconnect/models/event.py +0 -33
- tonutils/tonconnect/models/proof.py +0 -80
- tonutils/tonconnect/models/request.py +0 -533
- tonutils/tonconnect/models/wallet.py +0 -248
- tonutils/tonconnect/provider/__init__.py +0 -5
- tonutils/tonconnect/provider/bridge.py +0 -581
- tonutils/tonconnect/provider/session.py +0 -104
- tonutils/tonconnect/storage/__init__.py +0 -7
- tonutils/tonconnect/storage/base.py +0 -39
- tonutils/tonconnect/storage/default.py +0 -40
- tonutils/tonconnect/tonconnect.py +0 -290
- tonutils/tonconnect/utils/__init__.py +0 -25
- tonutils/tonconnect/utils/exceptions.py +0 -140
- tonutils/tonconnect/utils/logger.py +0 -3
- tonutils/tonconnect/utils/verifiers.py +0 -255
- tonutils/tonconnect/utils/wallet_manager.py +0 -239
- tonutils/utils.py +0 -207
- tonutils/vanity/__init__.py +0 -5
- tonutils/vanity/contract.py +0 -35
- tonutils/vanity/data.py +0 -34
- tonutils/wallet/__init__.py +0 -31
- tonutils/wallet/contract/__init__.py +0 -24
- tonutils/wallet/contract/_base.py +0 -438
- tonutils/wallet/contract/highload.py +0 -505
- tonutils/wallet/contract/preprocessed.py +0 -291
- tonutils/wallet/contract/v2.py +0 -95
- tonutils/wallet/contract/v3.py +0 -94
- tonutils/wallet/contract/v4.py +0 -122
- tonutils/wallet/contract/v5.py +0 -193
- tonutils/wallet/data.py +0 -188
- tonutils/wallet/messages.py +0 -631
- tonutils/wallet/op_codes.py +0 -9
- tonutils/wallet/utils.py +0 -57
- tonutils-0.5.1.dist-info/RECORD +0 -131
- {tonutils-0.5.1.dist-info → tonutils-0.6.0a1.dist-info}/WHEEL +0 -0
- {tonutils-0.5.1.dist-info → tonutils-0.6.0a1.dist-info}/top_level.txt +0 -0
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
from typing import Union
|
|
2
|
-
|
|
3
|
-
from pytoniq_core import Address, Cell, StateInit, begin_cell
|
|
4
|
-
|
|
5
|
-
from .op_codes import *
|
|
6
|
-
from .wallet import JettonWalletStandard
|
|
7
|
-
from ..base import JettonMaster
|
|
8
|
-
from ...content import JettonOffchainContent, JettonOnchainContent
|
|
9
|
-
from ...data import JettonMasterData
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class JettonMasterStandard(JettonMaster):
|
|
13
|
-
CODE_HEX = "b5ee9c7241020b010001ed000114ff00f4a413f4bcf2c80b0102016202030202cc040502037a60090a03efd9910e38048adf068698180b8d848adf07d201800e98fe99ff6a2687d007d206a6a18400aa9385d47181a9aa8aae382f9702480fd207d006a18106840306b90fd001812881a28217804502a906428027d012c678b666664f6aa7041083deecbef29385d71811a92e001f1811802600271812f82c207f97840607080093dfc142201b82a1009aa0a01e428027d012c678b00e78b666491646580897a007a00658064907c80383a6465816503e5ffe4e83bc00c646582ac678b28027d0109e5b589666664b8fd80400fe3603fa00fa40f82854120870542013541403c85004fa0258cf1601cf16ccc922c8cb0112f400f400cb00c9f9007074c8cb02ca07cbffc9d05008c705f2e04a12a1035024c85004fa0258cf16ccccc9ed5401fa403020d70b01c3008e1f8210d53276db708010c8cb055003cf1622fa0212cb6acb1fcb3fc98042fb00915be200303515c705f2e049fa403059c85004fa0258cf16ccccc9ed54002e5143c705f2e049d43001c85004fa0258cf16ccccc9ed54007dadbcf6a2687d007d206a6a183618fc1400b82a1009aa0a01e428027d012c678b00e78b666491646580897a007a00658064fc80383a6465816503e5ffe4e840001faf16f6a2687d007d206a6a183faa904051007f09" # noqa
|
|
14
|
-
|
|
15
|
-
def __init__(
|
|
16
|
-
self,
|
|
17
|
-
content: Union[JettonOffchainContent, JettonOnchainContent],
|
|
18
|
-
admin_address: Union[Address, str],
|
|
19
|
-
jetton_wallet_code: Union[str, Cell] = JettonWalletStandard.CODE_HEX,
|
|
20
|
-
) -> None:
|
|
21
|
-
self._data = self.create_data(content, admin_address, jetton_wallet_code).serialize()
|
|
22
|
-
self._code = Cell.one_from_boc(self.CODE_HEX)
|
|
23
|
-
|
|
24
|
-
@classmethod
|
|
25
|
-
def create_data(
|
|
26
|
-
cls,
|
|
27
|
-
content: Union[JettonOffchainContent, JettonOnchainContent],
|
|
28
|
-
admin_address: Union[Address, str, None],
|
|
29
|
-
jetton_wallet_code: Union[str, Cell] = JettonWalletStandard.CODE_HEX,
|
|
30
|
-
) -> JettonMasterData:
|
|
31
|
-
return JettonMasterData(
|
|
32
|
-
admin_address=admin_address,
|
|
33
|
-
content=content,
|
|
34
|
-
jetton_wallet_code=jetton_wallet_code,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
@classmethod
|
|
38
|
-
def build_mint_body(
|
|
39
|
-
cls,
|
|
40
|
-
destination: Address,
|
|
41
|
-
jetton_amount: int,
|
|
42
|
-
amount: int = 20000000,
|
|
43
|
-
query_id: int = 0,
|
|
44
|
-
) -> Cell:
|
|
45
|
-
"""
|
|
46
|
-
Builds the body of the mint transaction.
|
|
47
|
-
|
|
48
|
-
:param destination: The address of the destination.
|
|
49
|
-
:param jetton_amount: The amount of jettons to be minted.
|
|
50
|
-
:param amount: The amount of coins in nanoton. Defaults to 20000000.
|
|
51
|
-
:param query_id: The query ID. Defaults to 0.
|
|
52
|
-
:return: The cell representing the body of the mint transaction.
|
|
53
|
-
"""
|
|
54
|
-
return (
|
|
55
|
-
begin_cell()
|
|
56
|
-
.store_uint(JETTON_MINT_OPCODE, 32)
|
|
57
|
-
.store_uint(query_id, 64)
|
|
58
|
-
.store_address(destination)
|
|
59
|
-
.store_coins(amount)
|
|
60
|
-
.store_maybe_ref(
|
|
61
|
-
begin_cell()
|
|
62
|
-
.store_uint(JETTON_INTERNAL_TRANSFER_OPCODE, 32)
|
|
63
|
-
.store_uint(query_id, 64)
|
|
64
|
-
.store_coins(jetton_amount)
|
|
65
|
-
.store_address(None)
|
|
66
|
-
.store_address(None)
|
|
67
|
-
.store_bit(0)
|
|
68
|
-
.store_coins(0)
|
|
69
|
-
.store_bit(0)
|
|
70
|
-
.end_cell()
|
|
71
|
-
)
|
|
72
|
-
.end_cell()
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
@classmethod
|
|
76
|
-
def build_change_content_body(
|
|
77
|
-
cls,
|
|
78
|
-
new_content: Union[JettonOffchainContent, JettonOnchainContent],
|
|
79
|
-
query_id: int = 0,
|
|
80
|
-
) -> Cell:
|
|
81
|
-
"""
|
|
82
|
-
Builds the body of the change content transaction.
|
|
83
|
-
|
|
84
|
-
:param new_content: The new content.
|
|
85
|
-
:param query_id: The query ID. Defaults to 0.
|
|
86
|
-
:return: The cell representing the body of the edit content transaction.
|
|
87
|
-
"""
|
|
88
|
-
return (
|
|
89
|
-
begin_cell()
|
|
90
|
-
.store_uint(JETTON_CHANGE_CONTENT_OPCODE, 32)
|
|
91
|
-
.store_uint(query_id, 64)
|
|
92
|
-
.store_ref(new_content.serialize())
|
|
93
|
-
.end_cell()
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
@classmethod
|
|
97
|
-
def build_change_admin_body(
|
|
98
|
-
cls,
|
|
99
|
-
new_admin_address: Address,
|
|
100
|
-
query_id: int = 0,
|
|
101
|
-
) -> Cell:
|
|
102
|
-
"""
|
|
103
|
-
Builds the body of the change admin transaction.
|
|
104
|
-
|
|
105
|
-
:param new_admin_address: The address of the new admin.
|
|
106
|
-
:param query_id: The query ID. Defaults to 0.
|
|
107
|
-
:return: The cell representing the body of the change admin transaction.
|
|
108
|
-
"""
|
|
109
|
-
return (
|
|
110
|
-
begin_cell()
|
|
111
|
-
.store_uint(JETTON_CHANGE_ADMIN_OPCODE, 32)
|
|
112
|
-
.store_uint(query_id, 64)
|
|
113
|
-
.store_address(new_admin_address)
|
|
114
|
-
.end_cell()
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
@classmethod
|
|
118
|
-
def calculate_user_jetton_wallet_address(
|
|
119
|
-
cls,
|
|
120
|
-
owner_address: Union[Address, str],
|
|
121
|
-
jetton_wallet_code: str,
|
|
122
|
-
jetton_master_address: Union[Address, str],
|
|
123
|
-
) -> Address:
|
|
124
|
-
if isinstance(owner_address, str):
|
|
125
|
-
owner_address = Address(owner_address)
|
|
126
|
-
|
|
127
|
-
if isinstance(jetton_master_address, str):
|
|
128
|
-
jetton_master_address = Address(jetton_master_address)
|
|
129
|
-
|
|
130
|
-
code = Cell.one_from_boc(jetton_wallet_code)
|
|
131
|
-
data = (
|
|
132
|
-
begin_cell()
|
|
133
|
-
.store_coins(0)
|
|
134
|
-
.store_address(owner_address)
|
|
135
|
-
.store_address(jetton_master_address)
|
|
136
|
-
.store_ref(code)
|
|
137
|
-
.end_cell()
|
|
138
|
-
)
|
|
139
|
-
state_init = StateInit(code=code, data=data)
|
|
140
|
-
|
|
141
|
-
return Address((0, state_init.serialize().hash))
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
from typing import Union, Optional
|
|
2
|
-
|
|
3
|
-
from pytoniq_core import Address, Cell, begin_cell
|
|
4
|
-
|
|
5
|
-
from .op_codes import *
|
|
6
|
-
from ...data import JettonWalletData
|
|
7
|
-
from ....client import (
|
|
8
|
-
Client,
|
|
9
|
-
)
|
|
10
|
-
from ....contract import Contract
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class JettonWalletStandard(Contract):
|
|
14
|
-
CODE_HEX = "b5ee9c7241021201000328000114ff00f4a413f4bcf2c80b0102016202030202cc0405001ba0f605da89a1f401f481f481a8610201d40607020148080900bb0831c02497c138007434c0c05c6c2544d7c0fc02f83e903e900c7e800c5c75c87e800c7e800c00b4c7e08403e29fa954882ea54c4d167c0238208405e3514654882ea58c511100fc02780d60841657c1ef2ea4d67c02b817c12103fcbc2000113e910c1c2ebcb853600201200a0b020120101101f500f4cffe803e90087c007b51343e803e903e90350c144da8548ab1c17cb8b04a30bffcb8b0950d109c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c032483e401c1d3232c0b281f2fff274013e903d010c7e801de0063232c1540233c59c3e8085f2dac4f3208405e351467232c7c6600c03f73b51343e803e903e90350c0234cffe80145468017e903e9014d6f1c1551cdb5c150804d50500f214013e809633c58073c5b33248b232c044bd003d0032c0327e401c1d3232c0b281f2fff274140371c1472c7cb8b0c2be80146a2860822625a020822625a004ad822860822625a028062849f8c3c975c2c070c008e00d0e0f009acb3f5007fa0222cf165006cf1625fa025003cf16c95005cc2391729171e25008a813a08208989680aa008208989680a0a014bcf2e2c504c98040fb001023c85004fa0258cf1601cf16ccc9ed5400705279a018a182107362d09cc8cb1f5230cb3f58fa025007cf165007cf16c9718018c8cb0524cf165006fa0215cb6a14ccc971fb0010241023000e10491038375f040076c200b08e218210d53276db708010c8cb055008cf165004fa0216cb6a12cb1f12cb3fc972fb0093356c21e203c85004fa0258cf1601cf16ccc9ed5400db3b51343e803e903e90350c01f4cffe803e900c145468549271c17cb8b049f0bffcb8b0a0822625a02a8005a805af3cb8b0e0841ef765f7b232c7c572cfd400fe8088b3c58073c5b25c60063232c14933c59c3e80b2dab33260103ec01004f214013e809633c58073c5b3327b55200083200835c87b51343e803e903e90350c0134c7e08405e3514654882ea0841ef765f784ee84ac7cb8b174cfcc7e800c04e81408f214013e809633c58073c5b3327b55205eccf23d" # noqa
|
|
15
|
-
|
|
16
|
-
def __init__(
|
|
17
|
-
self,
|
|
18
|
-
owner_address: Union[Address, str],
|
|
19
|
-
jetton_master_address: Union[Address, str],
|
|
20
|
-
balance: int = 0,
|
|
21
|
-
) -> None:
|
|
22
|
-
self._data = self.create_data(owner_address, jetton_master_address, balance).serialize()
|
|
23
|
-
self._code = Cell.one_from_boc(self.CODE_HEX)
|
|
24
|
-
|
|
25
|
-
@classmethod
|
|
26
|
-
def create_data(
|
|
27
|
-
cls,
|
|
28
|
-
owner_address: Union[Address, str],
|
|
29
|
-
jetton_master_address: Union[Address, str],
|
|
30
|
-
balance: int = 0,
|
|
31
|
-
) -> JettonWalletData:
|
|
32
|
-
return JettonWalletData(
|
|
33
|
-
owner_address=owner_address,
|
|
34
|
-
jetton_master_address=jetton_master_address,
|
|
35
|
-
jetton_wallet_code=JettonWalletStandard.CODE_HEX,
|
|
36
|
-
balance=balance,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
@classmethod
|
|
40
|
-
async def get_wallet_data(
|
|
41
|
-
cls,
|
|
42
|
-
client: Client,
|
|
43
|
-
jetton_wallet_address: Union[Address, str],
|
|
44
|
-
) -> JettonWalletData:
|
|
45
|
-
"""
|
|
46
|
-
Get the data of the jetton wallet.
|
|
47
|
-
|
|
48
|
-
:param client: The client to use.
|
|
49
|
-
:param jetton_wallet_address: The address of the jetton wallet.
|
|
50
|
-
:return: The data of the jetton wallet.
|
|
51
|
-
"""
|
|
52
|
-
if isinstance(jetton_wallet_address, str):
|
|
53
|
-
jetton_wallet_address = Address(jetton_wallet_address)
|
|
54
|
-
|
|
55
|
-
method_result = await client.run_get_method(
|
|
56
|
-
address=jetton_wallet_address.to_str(),
|
|
57
|
-
method_name="get_wallet_data",
|
|
58
|
-
)
|
|
59
|
-
balance = method_result[0]
|
|
60
|
-
owner_address = method_result[1]
|
|
61
|
-
jetton_master_address = method_result[2]
|
|
62
|
-
jetton_wallet_code = method_result[3]
|
|
63
|
-
|
|
64
|
-
return JettonWalletData(
|
|
65
|
-
balance=balance,
|
|
66
|
-
owner_address=owner_address,
|
|
67
|
-
jetton_master_address=jetton_master_address,
|
|
68
|
-
jetton_wallet_code=jetton_wallet_code,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
@classmethod
|
|
72
|
-
def build_transfer_body(
|
|
73
|
-
cls,
|
|
74
|
-
jetton_amount: int,
|
|
75
|
-
recipient_address: Optional[Address],
|
|
76
|
-
response_address: Optional[Address] = None,
|
|
77
|
-
custom_payload: Optional[Cell] = None,
|
|
78
|
-
forward_payload: Optional[Cell] = None,
|
|
79
|
-
forward_amount: int = 0,
|
|
80
|
-
query_id: int = 0,
|
|
81
|
-
) -> Cell:
|
|
82
|
-
"""
|
|
83
|
-
Builds the body of the transfer jetton transaction.
|
|
84
|
-
|
|
85
|
-
:param jetton_amount: The amount of jettons to transfer.
|
|
86
|
-
:param recipient_address: The address of the recipient.
|
|
87
|
-
:param response_address: The address to respond to. Defaults to the recipient address.
|
|
88
|
-
:param custom_payload: The custom payload. Defaults to an empty cell.
|
|
89
|
-
:param forward_payload: The payload to be forwarded. Defaults to an empty cell.
|
|
90
|
-
:param forward_amount: The amount of coins to be forwarded. Defaults to 0.
|
|
91
|
-
:param query_id: The query ID. Defaults to 0.
|
|
92
|
-
:return: The cell representing the body of the transfer jetton transaction.
|
|
93
|
-
"""
|
|
94
|
-
return (
|
|
95
|
-
begin_cell()
|
|
96
|
-
.store_uint(JETTON_TRANSFER_OPCODE, 32)
|
|
97
|
-
.store_uint(query_id, 64)
|
|
98
|
-
.store_coins(jetton_amount)
|
|
99
|
-
.store_address(recipient_address)
|
|
100
|
-
.store_address(response_address or recipient_address)
|
|
101
|
-
.store_maybe_ref(custom_payload)
|
|
102
|
-
.store_coins(forward_amount)
|
|
103
|
-
.store_maybe_ref(forward_payload)
|
|
104
|
-
.end_cell()
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
@classmethod
|
|
108
|
-
def build_burn_body(
|
|
109
|
-
cls,
|
|
110
|
-
jetton_amount: int,
|
|
111
|
-
response_address: Optional[Address] = None,
|
|
112
|
-
custom_payload: Optional[Cell] = None,
|
|
113
|
-
query_id: int = 0,
|
|
114
|
-
) -> Cell:
|
|
115
|
-
"""
|
|
116
|
-
Builds the body of the burn jetton transaction.
|
|
117
|
-
|
|
118
|
-
:param jetton_amount: The amount of jettons to burn.
|
|
119
|
-
:param response_address: The address to respond to. Defaults to the owner address.
|
|
120
|
-
:param custom_payload: The custom payload. Defaults to an empty cell.
|
|
121
|
-
:param query_id: The query ID. Defaults to 0.
|
|
122
|
-
:return: The cell representing the body of the burn jetton transaction.
|
|
123
|
-
"""
|
|
124
|
-
return (
|
|
125
|
-
begin_cell()
|
|
126
|
-
.store_uint(JETTON_BURN_OPCODE, 32)
|
|
127
|
-
.store_uint(query_id, 64)
|
|
128
|
-
.store_coins(jetton_amount)
|
|
129
|
-
.store_address(response_address)
|
|
130
|
-
.store_maybe_ref(custom_payload)
|
|
131
|
-
.end_cell()
|
|
132
|
-
)
|
tonutils/jetton/data.py
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Union, Optional
|
|
4
|
-
|
|
5
|
-
from pytoniq_core import Address, Cell, Slice, TlbScheme, begin_cell
|
|
6
|
-
|
|
7
|
-
from .content import JettonOnchainContent, JettonOffchainContent, JettonStablecoinContent
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class JettonMasterData(TlbScheme):
|
|
11
|
-
|
|
12
|
-
def __init__(
|
|
13
|
-
self,
|
|
14
|
-
admin_address: Optional[Union[Address, str]] = None,
|
|
15
|
-
content: Optional[Union[JettonOffchainContent, JettonOnchainContent, Cell]] = None,
|
|
16
|
-
jetton_wallet_code: Optional[Union[Cell, str]] = None,
|
|
17
|
-
total_supply: Optional[int] = 0,
|
|
18
|
-
mintable: Optional[bool] = True,
|
|
19
|
-
) -> None:
|
|
20
|
-
self.total_supply = total_supply
|
|
21
|
-
self.mintable = mintable
|
|
22
|
-
if isinstance(admin_address, str):
|
|
23
|
-
admin_address = Address(admin_address)
|
|
24
|
-
self.admin_address = admin_address
|
|
25
|
-
|
|
26
|
-
if isinstance(content, (JettonOffchainContent, JettonOnchainContent)):
|
|
27
|
-
content = content.serialize()
|
|
28
|
-
self.content = content
|
|
29
|
-
|
|
30
|
-
if isinstance(jetton_wallet_code, str):
|
|
31
|
-
jetton_wallet_code = Cell.one_from_boc(jetton_wallet_code)
|
|
32
|
-
self.jetton_wallet_code = jetton_wallet_code
|
|
33
|
-
|
|
34
|
-
def serialize(self) -> Cell:
|
|
35
|
-
return (
|
|
36
|
-
begin_cell()
|
|
37
|
-
.store_coins(self.total_supply)
|
|
38
|
-
.store_address(self.admin_address)
|
|
39
|
-
.store_ref(self.content)
|
|
40
|
-
.store_ref(self.jetton_wallet_code)
|
|
41
|
-
.end_cell()
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
@classmethod
|
|
45
|
-
def deserialize(cls, cell_slice: Slice) -> JettonMasterData:
|
|
46
|
-
raise NotImplementedError
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class JettonWalletData(TlbScheme):
|
|
50
|
-
|
|
51
|
-
def __init__(
|
|
52
|
-
self,
|
|
53
|
-
owner_address: Optional[Union[Address, str]] = None,
|
|
54
|
-
jetton_master_address: Optional[Union[Address, str]] = None,
|
|
55
|
-
jetton_wallet_code: Optional[Union[Cell, str]] = None,
|
|
56
|
-
balance: int = 0,
|
|
57
|
-
) -> None:
|
|
58
|
-
if isinstance(owner_address, str):
|
|
59
|
-
owner_address = Address(owner_address)
|
|
60
|
-
|
|
61
|
-
if isinstance(jetton_master_address, str):
|
|
62
|
-
jetton_master_address = Address(jetton_master_address)
|
|
63
|
-
|
|
64
|
-
if isinstance(jetton_wallet_code, str):
|
|
65
|
-
jetton_wallet_code = Cell.one_from_boc(jetton_wallet_code)
|
|
66
|
-
|
|
67
|
-
self.owner_address = owner_address
|
|
68
|
-
self.jetton_master_address = jetton_master_address
|
|
69
|
-
self.jetton_wallet_code = jetton_wallet_code
|
|
70
|
-
self.balance = balance
|
|
71
|
-
|
|
72
|
-
def serialize(self) -> Cell:
|
|
73
|
-
return (
|
|
74
|
-
begin_cell()
|
|
75
|
-
.store_coins(self.balance)
|
|
76
|
-
.store_address(self.owner_address)
|
|
77
|
-
.store_address(self.jetton_master_address)
|
|
78
|
-
.store_ref(self.jetton_wallet_code)
|
|
79
|
-
.end_cell()
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
@classmethod
|
|
83
|
-
def deserialize(cls, cell_slice: Slice) -> JettonWalletData:
|
|
84
|
-
raise NotImplementedError
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
class JettonMasterStablecoinData(TlbScheme):
|
|
88
|
-
|
|
89
|
-
def __init__(
|
|
90
|
-
self,
|
|
91
|
-
admin_address: Optional[Union[Address, str]] = None,
|
|
92
|
-
transfer_admin_address: Optional[Union[Address, str]] = None,
|
|
93
|
-
content: Optional[Union[JettonStablecoinContent, Cell]] = None,
|
|
94
|
-
jetton_wallet_code: Optional[Union[Cell, str]] = None,
|
|
95
|
-
total_supply: Optional[int] = 0,
|
|
96
|
-
mintable: Optional[bool] = True,
|
|
97
|
-
) -> None:
|
|
98
|
-
self.total_supply = total_supply
|
|
99
|
-
self.mintable = mintable
|
|
100
|
-
|
|
101
|
-
if isinstance(admin_address, str):
|
|
102
|
-
admin_address = Address(admin_address)
|
|
103
|
-
self.admin_address = admin_address
|
|
104
|
-
|
|
105
|
-
if isinstance(transfer_admin_address, str):
|
|
106
|
-
transfer_admin_address = Address(transfer_admin_address)
|
|
107
|
-
self.transfer_admin_address = transfer_admin_address
|
|
108
|
-
|
|
109
|
-
if isinstance(content, JettonStablecoinContent):
|
|
110
|
-
content = content.serialize()
|
|
111
|
-
self.content = content
|
|
112
|
-
|
|
113
|
-
if isinstance(jetton_wallet_code, str):
|
|
114
|
-
jetton_wallet_code = Cell.one_from_boc(jetton_wallet_code)
|
|
115
|
-
self.jetton_wallet_code = jetton_wallet_code
|
|
116
|
-
|
|
117
|
-
def serialize(self) -> Cell:
|
|
118
|
-
return (
|
|
119
|
-
begin_cell()
|
|
120
|
-
.store_coins(self.total_supply)
|
|
121
|
-
.store_address(self.admin_address)
|
|
122
|
-
.store_address(self.transfer_admin_address)
|
|
123
|
-
.store_ref(self.jetton_wallet_code)
|
|
124
|
-
.store_ref(self.content)
|
|
125
|
-
.end_cell()
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
@classmethod
|
|
129
|
-
def deserialize(cls, cell_slice: Slice) -> JettonMasterStablecoinData:
|
|
130
|
-
raise NotImplementedError
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class JettonWalletStablecoinData(TlbScheme):
|
|
134
|
-
|
|
135
|
-
def __init__(
|
|
136
|
-
self,
|
|
137
|
-
owner_address: Optional[Union[Address, str]] = None,
|
|
138
|
-
jetton_master_address: Optional[Union[Address, str]] = None,
|
|
139
|
-
balance: int = 0,
|
|
140
|
-
status: int = 0,
|
|
141
|
-
) -> None:
|
|
142
|
-
if isinstance(owner_address, str):
|
|
143
|
-
owner_address = Address(owner_address)
|
|
144
|
-
|
|
145
|
-
if isinstance(jetton_master_address, str):
|
|
146
|
-
jetton_master_address = Address(jetton_master_address)
|
|
147
|
-
|
|
148
|
-
self.owner_address = owner_address
|
|
149
|
-
self.jetton_master_address = jetton_master_address
|
|
150
|
-
self.balance = balance
|
|
151
|
-
self.status = status
|
|
152
|
-
|
|
153
|
-
def serialize(self) -> Cell:
|
|
154
|
-
return (
|
|
155
|
-
begin_cell()
|
|
156
|
-
.store_uint(self.status, 4)
|
|
157
|
-
.store_coins(self.balance)
|
|
158
|
-
.store_address(self.owner_address)
|
|
159
|
-
.store_address(self.jetton_master_address)
|
|
160
|
-
.end_cell()
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
@classmethod
|
|
164
|
-
def deserialize(cls, cell_slice: Slice) -> JettonWalletStablecoinData:
|
|
165
|
-
raise NotImplementedError
|
tonutils/jetton/dex/__init__.py
DELETED
|
File without changes
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
|
|
3
|
-
from tonutils.utils import to_nano
|
|
4
|
-
|
|
5
|
-
TX_DEADLINE = 60 * 5
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass
|
|
9
|
-
class OpCodes:
|
|
10
|
-
SWAP_NATIVE = 0xea06185d
|
|
11
|
-
SWAP_JETTON = 0xe3a0d482
|
|
12
|
-
CREATE_VAULT = 0x21cfe02b
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@dataclass
|
|
16
|
-
class FactoryAddresses:
|
|
17
|
-
MAINNET = "EQBfBWT7X2BHg9tXAxzhz2aKiNTU1tpt5NsiK0uSDW_YAJ67" # noqa
|
|
18
|
-
TESTNET = "kQDHcPxlCOSN_s-Vlw53bFpibNyKpZHV6xHhxGAAT_21nJre" # noqa
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@dataclass
|
|
22
|
-
class NativeVaultAddresses:
|
|
23
|
-
MAINNET = "EQDa4VOnTYlLvDJ0gZjNYm5PXfSmmtL6Vs6A_CZEtXCNICq_" # noqa
|
|
24
|
-
TESTNET = "kQDshQ2nyhezZleRdlZT12pvrj_cYp9XGmcRgYirA71DWlOb" # noqa
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@dataclass
|
|
28
|
-
class SwapJettonToJettonConstants:
|
|
29
|
-
GAS_AMOUNT = to_nano(0.3)
|
|
30
|
-
FORWARD_GAS_AMOUNT = to_nano(0.25)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@dataclass
|
|
34
|
-
class SwapJettonToTONConstants:
|
|
35
|
-
GAS_AMOUNT = to_nano(0.3)
|
|
36
|
-
FORWARD_GAS_AMOUNT = to_nano(0.25)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@dataclass
|
|
40
|
-
class SwapTONToJettonConstants:
|
|
41
|
-
FORWARD_GAS_AMOUNT = to_nano(0.25)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@dataclass
|
|
45
|
-
class GasConstants:
|
|
46
|
-
swap_jetton_to_jetton = SwapJettonToJettonConstants
|
|
47
|
-
swap_jetton_to_ton = SwapJettonToTONConstants
|
|
48
|
-
swap_ton_to_jetton = SwapTONToJettonConstants
|