@tonappchain/sdk 0.7.2 → 0.7.3-rc1

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 (44) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +203 -199
  3. package/dist/src/adapters/BaseContractOpener.js +8 -5
  4. package/dist/src/assets/AssetFactory.d.ts +4 -1
  5. package/dist/src/assets/AssetFactory.js +4 -0
  6. package/dist/src/assets/FT.d.ts +3 -3
  7. package/dist/src/assets/FT.js +28 -15
  8. package/dist/src/assets/NFT.d.ts +3 -3
  9. package/dist/src/assets/NFT.js +10 -4
  10. package/dist/src/assets/TAC.d.ts +24 -0
  11. package/dist/src/assets/TAC.js +74 -0
  12. package/dist/src/assets/TON.d.ts +3 -3
  13. package/dist/src/assets/TON.js +12 -5
  14. package/dist/src/assets/index.d.ts +1 -0
  15. package/dist/src/assets/index.js +3 -1
  16. package/dist/src/errors/index.d.ts +1 -1
  17. package/dist/src/errors/index.js +6 -1
  18. package/dist/src/errors/instances.d.ts +4 -0
  19. package/dist/src/errors/instances.js +7 -1
  20. package/dist/src/interfaces/Asset.d.ts +11 -6
  21. package/dist/src/interfaces/IConfiguration.d.ts +1 -3
  22. package/dist/src/interfaces/ILiteSequencerClient.d.ts +9 -1
  23. package/dist/src/interfaces/IOperationTracker.d.ts +20 -1
  24. package/dist/src/interfaces/ITACTransactionManager.d.ts +19 -1
  25. package/dist/src/interfaces/ITacSDK.d.ts +29 -8
  26. package/dist/src/sdk/Consts.d.ts +4 -0
  27. package/dist/src/sdk/Consts.js +5 -1
  28. package/dist/src/sdk/LiteSequencerClient.d.ts +3 -1
  29. package/dist/src/sdk/LiteSequencerClient.js +37 -0
  30. package/dist/src/sdk/OperationTracker.d.ts +4 -1
  31. package/dist/src/sdk/OperationTracker.js +58 -0
  32. package/dist/src/sdk/TACTransactionManager.d.ts +3 -0
  33. package/dist/src/sdk/TACTransactionManager.js +170 -34
  34. package/dist/src/sdk/TONTransactionManager.js +28 -6
  35. package/dist/src/sdk/TacSdk.d.ts +4 -3
  36. package/dist/src/sdk/TacSdk.js +4 -0
  37. package/dist/src/sdk/Utils.d.ts +2 -1
  38. package/dist/src/sdk/Utils.js +4 -0
  39. package/dist/src/structs/InternalStruct.d.ts +35 -1
  40. package/dist/src/structs/Struct.d.ts +155 -5
  41. package/dist/src/structs/Struct.js +12 -1
  42. package/dist/src/wrappers/ContentUtils.d.ts +36 -13
  43. package/dist/src/wrappers/ContentUtils.js +197 -98
  44. package/package.json +121 -121
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 TAC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TAC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,199 +1,203 @@
1
- # TacSdk
2
-
3
- [![Version npm](https://img.shields.io/npm/v/@tonappchain/sdk.svg?logo=npm)](https://www.npmjs.com/package/@tonappchain/sdk)
4
- [![Downloads](https://img.shields.io/npm/dm/@tonappchain/sdk.svg)](https://www.npmjs.com/package/@tonappchain/sdk)
5
- [![Try on RunKit](https://badge.runkitcdn.com/@tonappchain/sdk.svg)](https://runkit.com/npm/@tonappchain/sdk)
6
-
7
-
8
- The TAC SDK makes it possible to create hybrid dApps that let TON users interact directly with EVM smart contracts without needing to manage multiple wallets or understand the complexities of cross-chain messaging.
9
-
10
- ### Documentation
11
-
12
- For full documentation and examples, please visit [TAC SDK Documentation](https://docs.tac.build/build/sdk/introduction).
13
-
14
- For practical examples and usage patterns, see [Examples Documentation](./docs/examples/examples.md).
15
-
16
- ### Installation
17
-
18
- ```bash
19
- npm install @tonappchain/sdk
20
- ```
21
-
22
- or
23
-
24
- ```bash
25
- yarn add @tonappchain/sdk
26
- ```
27
-
28
-
29
- ## Features
30
-
31
- The TAC SDK enables you to create frontends that:
32
-
33
- - Connect to TON wallets like Tonkeeper or Tonhub
34
- - Send transactions from TON to your EVM contracts
35
- - Track cross-chain transaction status in real-time
36
- - Handle tokens across both chains
37
- - Create a seamless user experience for TON users
38
-
39
- ## Available Resources
40
-
41
-
42
- ### SDK Components
43
-
44
- - **[`TacSdk`](./docs/sdks/tac_sdk.md)**: The main class for interacting with the TAC protocol.
45
- - [`create`](./docs/sdks/tac_sdk.md#creating-an-instance-of-tacsdk): Initializes the SDK instance.
46
- - [`sendCrossChainTransaction`](./docs/sdks/tac_sdk.md#sendcrosschaintransaction): Sends a cross-chain transaction from TON to TAC.
47
- - [`getEVMTokenAddress`](./docs/sdks/tac_sdk.md#getevmtokenaddress): Gets the TAC address for a TON token.
48
- - [`getTVMTokenAddress`](./docs/sdks/tac_sdk.md#gettvmtokenaddress): Gets the TON address for a TAC token.
49
- - [`getSimulationInfo`](./docs/sdks/tac_sdk.md#getsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
50
- - [`getUserJettonBalance`](./docs/sdks/tac_sdk.md#getuserjettonbalance): Gets a user's Jetton balance (raw).
51
- - [`getUserJettonBalanceExtended`](./docs/sdks/tac_sdk.md#getuserjettonbalanceextended): Gets extended Jetton balance info (including decimals).
52
- - [`getUserJettonWalletAddress`](./docs/sdks/tac_sdk.md#getuserjettonwalletaddress): Calculates a user's Jetton wallet address.
53
- - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress): Placeholder address for native TON.
54
- - [`nativeTACAddress (method)`](./docs/sdks/tac_sdk.md#nativetacaddress): Gets the native asset address on the TAC chain.
55
- - *(See file for more...)*
56
-
57
- - **[`OperationTracker`](./docs/sdks/operation_tracker.md)**: Tools for monitoring cross-chain operation status.
58
- - [`constructor`](./docs/sdks/operation_tracker.md#constructor): Creates a tracker instance.
59
- - [`getOperationId`](./docs/sdks/operation_tracker.md#getoperationid): Retrieves the Operation ID from a `TransactionLinker`.
60
- - [`getStageProfiling`](./docs/sdks/operation_tracker.md#getstageprofiling): Gets detailed timing and status for all stages of an operation.
61
- - [`getSimplifiedOperationStatus`](./docs/sdks/operation_tracker.md#getsimplifiedoperationstatus): Gets a simplified overall status (Pending, Successful, Failed, Not Found).
62
- - *(See file for more...)*
63
-
64
- - **[`Senders`](./docs/sdks/sender.md)**: Handles signing and sending TON transactions.
65
- - [`TonConnectSender`](./docs/sdks/sender.md#tonconnectsender): Implements sending via TonConnect UI.
66
- - [`RawSender`](./docs/sdks/sender.md#rawsender): Implements sending using a raw private key.
67
-
68
- - **[`Utilities`](./docs/sdks/utilities.md)**: Helper functions and interfaces.
69
- - [`startTracking`](./docs/sdks/utilities.md#starttracking): Utility function to poll and log operation status to the console.
70
-
71
- - **[`AgnosticSdk`](./docs/sdks/agnostic_proxy_sdk.md)**: Agnostic SDK for cross-chain interactions.
72
-
73
- - **[`Simulator`](./docs/sdks/simulator.md)**: Transaction simulation capabilities.
74
-
75
- - **[`TACTransactionManager`](./docs/sdks/tac_transaction_manager.md)**: Manages TAC-side transactions.
76
-
77
- - **[`TONTransactionManager`](./docs/sdks/ton_transaction_manager.md)**: Manages TON-side transactions.
78
-
79
- ### Data Models
80
-
81
- - **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
82
- - [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
83
- - [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
84
- - [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation types (`PENDING`, `TON_TAC_TON`, `ROLLBACK`, etc.).
85
- - [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
86
-
87
- - **[`Structs`](./docs/models/structs.md)**: Core data structures.
88
- - [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
89
- - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
90
- - [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
91
- - *(See file for more...)*
92
-
93
- Navigate through the linked files for full details on parameters, return types, examples, and more.
94
-
95
- ### TACHeader
96
- > **Note:** The TAC protocol only knows how to send data to contracts that inherit from a TacProxy (TacProxyV1) contract. Such a contract must have a strictly defined signature of its methods. It is specified below:
97
-
98
- ```
99
- function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
100
- // Function implementation
101
- }
102
- ```
103
-
104
- > **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
105
-
106
- The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
107
- - **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
108
- - **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
109
- - **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
110
- - **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
111
- - **`string tvmCaller`**: The TON user's wallet address that sent the message.
112
- - **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
113
-
114
- You need to specify all the remaining data you need in tuple (bytes) in arguments. For example this is how arguments for addLiquidity method in UniswapV2 (a special proxy contract for it) will look like:
115
-
116
- ```
117
- const abi = new ethers.AbiCoder();
118
- const encodedParameters = abi.encode(
119
- ['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
120
- [
121
- [
122
- EVM_TOKEN_A_ADDRESS,
123
- EVM_TOKEN_B_ADDRESS,
124
- amountA,
125
- amountB,
126
- amountAMin,
127
- amountBMin,
128
- UNISWAPV2_PROXY_ADDRESS,
129
- deadline
130
- ]
131
- ]
132
- );
133
- ```
134
- More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
135
-
136
- ---
137
-
138
- ## Usage
139
-
140
- ```typescript
141
- import { TacSdk, AssetLike, EvmProxyMsg, SDKParams, Network, SenderFactory } from '@tonappchain/sdk';
142
- import { TonConnectUI } from '@tonconnect/ui';
143
- import { ethers } from 'ethers';
144
-
145
- // Create EVM payload for DappProxy
146
- const abi = new ethers.AbiCoder();
147
- const encodedParameters = abi.encode(
148
- ['tuple(uint256,uint256,address[],address)'],
149
- [
150
- [
151
- tokenAAmount,
152
- tokenBAmount,
153
- [EVMtokenAAddress, EVMtokenBAddress],
154
- proxyDapp
155
- ]
156
- ]
157
- );
158
- const evmProxyMsg: EvmProxyMsg = {
159
- evmTargetAddress: DappProxyAddress,
160
- methodName: 'addLiquidity',
161
- encodedParameters
162
- };
163
-
164
- // Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
165
- const assets: AssetLike[] = [
166
- {
167
- address: TVMtokenAAddress,
168
- amount: tokenAAmount,
169
- },
170
- {
171
- address: TVMtokenBAddress,
172
- amount: tokenBAmount,
173
- }
174
- ];
175
-
176
- const sdkParams: SDKParams = {
177
- network: Network.TESTNET
178
- };
179
- const tacSdk = await TacSdk.create(sdkParams);
180
-
181
- //Send transaction via tonConnect or mnemonic
182
- const tonConnectUI = new TonConnectUI({
183
- manifestUrl: config.tonconnectManifestUrl as string
184
- });
185
- const sender = await SenderFactory.getSender({
186
- tonConnect: tonConnectUI
187
- });
188
-
189
- await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
190
-
191
- tacSdk.closeConnections();
192
- ```
193
- For a detailed example, see `tests/uniswap_v2/sendSwap.ts` or `tests/uniswap_v2/sendRemoveLiquidity.ts`, which demonstrates swapping tokens and removing liquidity on Uniswap and tracking the transaction status.
194
-
195
- ---
196
-
197
- ## License
198
-
199
- MIT
1
+ # TacSdk
2
+
3
+ [![Version npm](https://img.shields.io/npm/v/@tonappchain/sdk.svg?logo=npm)](https://www.npmjs.com/package/@tonappchain/sdk)
4
+ [![Downloads](https://img.shields.io/npm/dm/@tonappchain/sdk.svg)](https://www.npmjs.com/package/@tonappchain/sdk)
5
+ [![Try on RunKit](https://badge.runkitcdn.com/@tonappchain/sdk.svg)](https://runkit.com/npm/@tonappchain/sdk)
6
+
7
+
8
+ The TAC SDK makes it possible to create hybrid dApps that let TON users interact directly with EVM smart contracts without needing to manage multiple wallets or understand the complexities of cross-chain messaging.
9
+
10
+ ### Documentation
11
+
12
+ For full documentation and examples, please visit [TAC SDK Documentation](https://docs.tac.build/build/sdk/introduction).
13
+
14
+ For practical examples and usage patterns, see [Examples Documentation](./docs/examples/examples.md).
15
+
16
+ ### Installation
17
+
18
+ ```bash
19
+ npm install @tonappchain/sdk
20
+ ```
21
+
22
+ or
23
+
24
+ ```bash
25
+ yarn add @tonappchain/sdk
26
+ ```
27
+
28
+
29
+ ## Features
30
+
31
+ The TAC SDK enables you to create frontends that:
32
+
33
+ - Connect to TON wallets like Tonkeeper or Tonhub
34
+ - Send transactions from TON to your EVM contracts
35
+ - Track cross-chain transaction status in real-time
36
+ - Handle tokens across both chains
37
+ - Create a seamless user experience for TON users
38
+
39
+ ## Available Resources
40
+
41
+
42
+ ### SDK Components
43
+
44
+ - **[`TacSdk`](./docs/sdks/tac_sdk.md)**: The main class for interacting with the TAC protocol.
45
+ - [`create`](./docs/sdks/tac_sdk.md#creating-an-instance-of-tacsdk): Initializes the SDK instance.
46
+ - [`sendCrossChainTransaction`](./docs/sdks/tac_sdk.md#sendcrosschaintransaction): Sends a cross-chain transaction from TON to TAC.
47
+ - [`getEVMTokenAddress`](./docs/sdks/tac_sdk.md#getevmtokenaddress): Gets the TAC address for a TON token.
48
+ - [`getTVMTokenAddress`](./docs/sdks/tac_sdk.md#gettvmtokenaddress): Gets the TON address for a TAC token.
49
+ - [`getSimulationInfo`](./docs/sdks/tac_sdk.md#getsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
50
+ - [`getUserJettonBalance`](./docs/sdks/tac_sdk.md#getuserjettonbalance): Gets a user's Jetton balance (raw).
51
+ - [`getUserJettonBalanceExtended`](./docs/sdks/tac_sdk.md#getuserjettonbalanceextended): Gets extended Jetton balance info (including decimals).
52
+ - [`getUserJettonWalletAddress`](./docs/sdks/tac_sdk.md#getuserjettonwalletaddress): Calculates a user's Jetton wallet address.
53
+ - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress): Placeholder address for native TON.
54
+ - [`nativeTACAddress (method)`](./docs/sdks/tac_sdk.md#nativetacaddress): Gets the native asset address on the TAC chain.
55
+ - *(See file for more...)*
56
+
57
+ - **[`OperationTracker`](./docs/sdks/operation_tracker.md)**: Tools for monitoring cross-chain operation status.
58
+ - [`constructor`](./docs/sdks/operation_tracker.md#constructor): Creates a tracker instance.
59
+ - [`getOperationId`](./docs/sdks/operation_tracker.md#getoperationid): Retrieves the Operation ID from a `TransactionLinker`.
60
+ - [`getStageProfiling`](./docs/sdks/operation_tracker.md#getstageprofiling): Gets detailed timing and status for all stages of an operation.
61
+ - [`getStageProfilingV2`](./docs/sdks/operation_tracker.md#getstageprofilingv2): Gets stage profiling with `finalized`, `status`, and `rollback`.
62
+ - [`getOperationTypeV2`](./docs/sdks/operation_tracker.md#getoperationtypev2): Gets the operation type plus `finalized`.
63
+ - [`getSimplifiedOperationStatus`](./docs/sdks/operation_tracker.md#getsimplifiedoperationstatus): Gets a simplified overall status (Pending, Successful, Failed, Not Found).
64
+ - *(See file for more...)*
65
+
66
+ - **[`Senders`](./docs/sdks/sender.md)**: Handles signing and sending TON transactions.
67
+ - [`TonConnectSender`](./docs/sdks/sender.md#tonconnectsender): Implements sending via TonConnect UI.
68
+ - [`RawSender`](./docs/sdks/sender.md#rawsender): Implements sending using a raw private key.
69
+
70
+ - **[`Utilities`](./docs/sdks/utilities.md)**: Helper functions and interfaces.
71
+ - [`startTracking`](./docs/sdks/utilities.md#starttracking): Utility function to poll and log operation status to the console.
72
+
73
+ - **[`AgnosticSdk`](./docs/sdks/agnostic_proxy_sdk.md)**: Agnostic SDK for cross-chain interactions.
74
+
75
+ - **[`Simulator`](./docs/sdks/simulator.md)**: Transaction simulation capabilities.
76
+
77
+ - **[`TACTransactionManager`](./docs/sdks/tac_transaction_manager.md)**: Manages TAC-side transactions.
78
+
79
+ - **[`TONTransactionManager`](./docs/sdks/ton_transaction_manager.md)**: Manages TON-side transactions.
80
+
81
+ ### Data Models
82
+
83
+ - **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
84
+ - [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
85
+ - [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
86
+ - [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation type.
87
+ - [`OperationTypeV2`](./docs/models/enums.md#operationtypev2): Operation type used by `getOperationTypeV2`.
88
+ - [`OperationExecutionStatus`](./docs/models/enums.md#operationexecutionstatus): Top-level operation status (`success` / `failed`).
89
+ - [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
90
+
91
+ - **[`Structs`](./docs/models/structs.md)**: Core data structures.
92
+ - [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
93
+ - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
94
+ - [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
95
+ - *(See file for more...)*
96
+
97
+ Navigate through the linked files for full details on parameters, return types, examples, and more.
98
+
99
+ ### TACHeader
100
+ > **Note:** The TAC protocol only knows how to send data to contracts that inherit from a TacProxy (TacProxyV1) contract. Such a contract must have a strictly defined signature of its methods. It is specified below:
101
+
102
+ ```
103
+ function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
104
+ // Function implementation
105
+ }
106
+ ```
107
+
108
+ > **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
109
+
110
+ The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
111
+ - **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
112
+ - **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
113
+ - **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
114
+ - **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
115
+ - **`string tvmCaller`**: The TON user's wallet address that sent the message.
116
+ - **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
117
+
118
+ You need to specify all the remaining data you need in tuple (bytes) in arguments. For example this is how arguments for addLiquidity method in UniswapV2 (a special proxy contract for it) will look like:
119
+
120
+ ```
121
+ const abi = new ethers.AbiCoder();
122
+ const encodedParameters = abi.encode(
123
+ ['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
124
+ [
125
+ [
126
+ EVM_TOKEN_A_ADDRESS,
127
+ EVM_TOKEN_B_ADDRESS,
128
+ amountA,
129
+ amountB,
130
+ amountAMin,
131
+ amountBMin,
132
+ UNISWAPV2_PROXY_ADDRESS,
133
+ deadline
134
+ ]
135
+ ]
136
+ );
137
+ ```
138
+ More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
139
+
140
+ ---
141
+
142
+ ## Usage
143
+
144
+ ```typescript
145
+ import { TacSdk, AssetLike, EvmProxyMsg, SDKParams, Network, SenderFactory } from '@tonappchain/sdk';
146
+ import { TonConnectUI } from '@tonconnect/ui';
147
+ import { ethers } from 'ethers';
148
+
149
+ // Create EVM payload for DappProxy
150
+ const abi = new ethers.AbiCoder();
151
+ const encodedParameters = abi.encode(
152
+ ['tuple(uint256,uint256,address[],address)'],
153
+ [
154
+ [
155
+ tokenAAmount,
156
+ tokenBAmount,
157
+ [EVMtokenAAddress, EVMtokenBAddress],
158
+ proxyDapp
159
+ ]
160
+ ]
161
+ );
162
+ const evmProxyMsg: EvmProxyMsg = {
163
+ evmTargetAddress: DappProxyAddress,
164
+ methodName: 'addLiquidity',
165
+ encodedParameters
166
+ };
167
+
168
+ // Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
169
+ const assets: AssetLike[] = [
170
+ {
171
+ address: TVMtokenAAddress,
172
+ amount: tokenAAmount,
173
+ },
174
+ {
175
+ address: TVMtokenBAddress,
176
+ amount: tokenBAmount,
177
+ }
178
+ ];
179
+
180
+ const sdkParams: SDKParams = {
181
+ network: Network.TESTNET
182
+ };
183
+ const tacSdk = await TacSdk.create(sdkParams);
184
+
185
+ //Send transaction via tonConnect or mnemonic
186
+ const tonConnectUI = new TonConnectUI({
187
+ manifestUrl: config.tonconnectManifestUrl as string
188
+ });
189
+ const sender = await SenderFactory.getSender({
190
+ tonConnect: tonConnectUI
191
+ });
192
+
193
+ await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
194
+
195
+ tacSdk.closeConnections();
196
+ ```
197
+ For a detailed example, see `tests/uniswap_v2/sendSwap.ts` or `tests/uniswap_v2/sendRemoveLiquidity.ts`, which demonstrates swapping tokens and removing liquidity on Uniswap and tracking the transaction status.
198
+
199
+ ---
200
+
201
+ ## License
202
+
203
+ MIT
@@ -5,6 +5,7 @@ const ton_1 = require("@ton/ton");
5
5
  const errors_1 = require("../errors");
6
6
  const Consts_1 = require("../sdk/Consts");
7
7
  const Utils_1 = require("../sdk/Utils");
8
+ const Struct_1 = require("../structs/Struct");
8
9
  /**
9
10
  * Base class for ContractOpener implementations with common functionality
10
11
  */
@@ -327,7 +328,7 @@ class BaseContractOpener {
327
328
  maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH,
328
329
  ignoreOpcodeList: Consts_1.IGNORE_OPCODE,
329
330
  limit: Consts_1.DEFAULT_FIND_TX_LIMIT,
330
- direction: 'both',
331
+ direction: Struct_1.TransactionTreeDirection.FORWARD,
331
332
  retryOnNotFound: Consts_1.DEFAULT_RETRY_ON_NOT_FOUND,
332
333
  }) {
333
334
  const result = await this.trackTransactionTreeWithResult(address, hash, params);
@@ -353,10 +354,10 @@ class BaseContractOpener {
353
354
  maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH,
354
355
  ignoreOpcodeList: Consts_1.IGNORE_OPCODE,
355
356
  limit: Consts_1.DEFAULT_FIND_TX_LIMIT,
356
- direction: 'both',
357
+ direction: Struct_1.TransactionTreeDirection.FORWARD,
357
358
  retryOnNotFound: Consts_1.DEFAULT_RETRY_ON_NOT_FOUND,
358
359
  }) {
359
- const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList = Consts_1.IGNORE_OPCODE, limit = Consts_1.DEFAULT_FIND_TX_LIMIT, maxScannedTransactions = Consts_1.DEFAULT_MAX_SCANNED_TRANSACTIONS, direction = 'both', retryOnNotFound = Consts_1.DEFAULT_RETRY_ON_NOT_FOUND, retryDelayMs, retries, } = params;
360
+ const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList = Consts_1.IGNORE_OPCODE, limit = Consts_1.DEFAULT_FIND_TX_LIMIT, maxScannedTransactions = Consts_1.DEFAULT_MAX_SCANNED_TRANSACTIONS, direction = Struct_1.TransactionTreeDirection.FORWARD, retryOnNotFound = Consts_1.DEFAULT_RETRY_ON_NOT_FOUND, retryDelayMs, retries, } = params;
360
361
  const parsedAddress = ton_1.Address.parse(address);
361
362
  const normalizedRootHash = (0, Utils_1.normalizeHashToBase64)(hash);
362
363
  const visitedSearchKeys = new Set();
@@ -410,7 +411,8 @@ class BaseContractOpener {
410
411
  }
411
412
  // Add adjacent transactions to queue
412
413
  if (currentDepth < maxDepth) {
413
- if ((direction === 'forward' || direction === 'both') && tx.outMessages.size > 0) {
414
+ if ((direction === Struct_1.TransactionTreeDirection.FORWARD || direction === Struct_1.TransactionTreeDirection.BOTH) &&
415
+ tx.outMessages.size > 0) {
414
416
  for (const msg of tx.outMessages.values()) {
415
417
  const dst = msg.info.dest;
416
418
  if (!dst || dst instanceof ton_1.ExternalAddress)
@@ -424,7 +426,8 @@ class BaseContractOpener {
424
426
  }
425
427
  }
426
428
  // Backward: add parent (incoming message source)
427
- if ((direction === 'backward' || direction === 'both') && tx.inMessage?.info.type === 'internal') {
429
+ if ((direction === Struct_1.TransactionTreeDirection.BACKWARD || direction === Struct_1.TransactionTreeDirection.BOTH) &&
430
+ tx.inMessage?.info.type === 'internal') {
428
431
  queue.push({
429
432
  hash: (0, ton_1.beginCell)().store((0, ton_1.storeMessage)(tx.inMessage)).endCell().hash().toString('base64'),
430
433
  address: tx.inMessage.info.src,
@@ -1,7 +1,10 @@
1
1
  import { Asset, IConfiguration } from '../interfaces';
2
2
  import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, EVMAddress, NFTAddressType, TVMAddress } from '../structs/Struct';
3
+ import { FT } from './FT';
4
+ import { TAC } from './TAC';
5
+ import { TON } from './TON';
3
6
  export declare class AssetFactory {
4
7
  static from(configuration: IConfiguration, token: AssetFromFTArg | AssetFromNFTCollectionArg | AssetFromNFTItemArg): Promise<Asset>;
5
- static createFTAsset(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<Asset>;
8
+ static createFTAsset(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<FT | TAC | TON>;
6
9
  static createNFTAsset(configuration: IConfiguration, address: TVMAddress | EVMAddress, addressType: NFTAddressType, index?: bigint): Promise<Asset>;
7
10
  }
@@ -7,6 +7,7 @@ const Struct_1 = require("../structs/Struct");
7
7
  const AssetCache_1 = require("./AssetCache");
8
8
  const FT_1 = require("./FT");
9
9
  const NFT_1 = require("./NFT");
10
+ const TAC_1 = require("./TAC");
10
11
  const TON_1 = require("./TON");
11
12
  class AssetFactory {
12
13
  static async from(configuration, token) {
@@ -35,6 +36,9 @@ class AssetFactory {
35
36
  address === Consts_1.TON_BURN_ADDRESS) {
36
37
  return ton;
37
38
  }
39
+ if (address === (await configuration.nativeTACAddress())) {
40
+ return TAC_1.TAC.create(configuration);
41
+ }
38
42
  return FT_1.FT.fromAddress(configuration, address);
39
43
  }
40
44
  static async createNFTAsset(configuration, address, addressType, index) {
@@ -3,7 +3,7 @@ import { Cell, OpenedContract } from '@ton/ton';
3
3
  import { JettonMinterData, JettonWallet } from '../../artifacts/tonTypes';
4
4
  import { Asset, IConfiguration } from '../interfaces';
5
5
  import { AssetOpType } from '../structs/InternalStruct';
6
- import { AssetType, EVMAddress, FeeParams, FTOriginAndData, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
6
+ import { AssetType, BlockchainType, EVMAddress, FeeParams, FTOriginAndData, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
7
7
  import { Origin } from '../structs/Struct';
8
8
  export declare class FT implements Asset {
9
9
  private _tvmAddress;
@@ -55,8 +55,8 @@ export declare class FT implements Asset {
55
55
  getUserBalance(userAddress: string): Promise<bigint>;
56
56
  getUserBalanceExtended(userAddress: string): Promise<UserWalletBalanceExtended>;
57
57
  checkBalance(userAddress: string): Promise<void>;
58
- checkCanBeTransferredBy(userAddress: string): Promise<void>;
59
- getBalanceOf(userAddress: string): Promise<bigint>;
58
+ checkCanBeTransferredBy(userAddress: string, blockchainType?: BlockchainType): Promise<void>;
59
+ getBalanceOf(userAddress: string, blockchainType?: BlockchainType): Promise<bigint>;
60
60
  private getTransferPayload;
61
61
  private getBurnPayload;
62
62
  }
@@ -122,20 +122,18 @@ class FT {
122
122
  throw errors_1.missingJettonDataError;
123
123
  }
124
124
  const metadata = await (0, ContentUtils_1.readJettonMetadata)(jettonData.content);
125
- const decimalsRaw = metadata.metadata.decimals ?? Consts_1.TON_DECIMALS;
125
+ const decimalsRaw = metadata.metadata?.decimals ?? Consts_1.TON_DECIMALS;
126
126
  if (decimalsRaw === undefined) {
127
127
  throw errors_1.missingDecimals;
128
128
  }
129
129
  decimals = Number(decimalsRaw);
130
130
  }
131
131
  else {
132
- if ((0, ethers_1.isAddress)(address)) {
133
- finalEvmAddress = address;
134
- }
135
- else {
136
- finalEvmAddress = cachedEvmAddress || (await jettonMinter.getEVMTokenAddress());
137
- }
138
- decimals = await this.getTACDecimals(configuration, finalEvmAddress);
132
+ const resolvedEvmAddress = (0, ethers_1.isAddress)(address)
133
+ ? address
134
+ : cachedEvmAddress ?? (await jettonMinter.getEVMTokenAddress());
135
+ finalEvmAddress = resolvedEvmAddress;
136
+ decimals = await this.getTACDecimals(configuration, resolvedEvmAddress);
139
137
  }
140
138
  const token = new FT(tvmAddress, origin, configuration, decimals);
141
139
  if (finalEvmAddress || (0, ethers_1.isAddress)(address)) {
@@ -224,17 +222,19 @@ class FT {
224
222
  return this._evmAddress;
225
223
  }
226
224
  const tokenAddressString = this._tvmAddress.toString({ bounceable: true });
225
+ let evmAddress;
227
226
  if (this.origin === Struct_2.Origin.TON) {
228
- this._evmAddress = await this._configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
227
+ evmAddress = await this._configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
229
228
  }
230
229
  else if (this.origin === Struct_2.Origin.TAC) {
231
230
  const givenMinter = this._configuration.TONParams.contractOpener.open(this._configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(ton_1.Address.parse(tokenAddressString)));
232
- this._evmAddress = await givenMinter.getEVMTokenAddress();
231
+ evmAddress = await givenMinter.getEVMTokenAddress();
233
232
  }
234
233
  else {
235
234
  throw (0, errors_1.unknownTokenTypeError)(tokenAddressString, 'Token origin is neither TON nor TAC');
236
235
  }
237
- return this._evmAddress;
236
+ this._evmAddress = evmAddress;
237
+ return evmAddress;
238
238
  }
239
239
  async getTVMAddress() {
240
240
  return this._tvmAddress.toString({ bounceable: true });
@@ -290,11 +290,24 @@ class FT {
290
290
  throw (0, errors_1.insufficientBalanceError)(this._tvmAddress.toString());
291
291
  }
292
292
  }
293
- async checkCanBeTransferredBy(userAddress) {
294
- await this.checkBalance(userAddress);
293
+ async checkCanBeTransferredBy(userAddress, blockchainType = Struct_1.BlockchainType.TON) {
294
+ if ((await this.getBalanceOf(userAddress, blockchainType)) < this._transferAmount) {
295
+ throw (0, errors_1.insufficientBalanceError)(this._tvmAddress.toString());
296
+ }
295
297
  }
296
- async getBalanceOf(userAddress) {
297
- return this.getUserBalance(userAddress);
298
+ async getBalanceOf(userAddress, blockchainType = Struct_1.BlockchainType.TON) {
299
+ if (blockchainType === Struct_1.BlockchainType.TON) {
300
+ Validator_1.Validator.validateTVMAddress(userAddress);
301
+ return this.getUserBalance(userAddress);
302
+ }
303
+ Validator_1.Validator.validateEVMAddress(userAddress);
304
+ const evmAddress = await this.getEVMAddress();
305
+ const nativeTACAddress = await this._configuration.nativeTACAddress();
306
+ if (evmAddress === nativeTACAddress) {
307
+ return this._configuration.TACParams.provider.getBalance(userAddress);
308
+ }
309
+ const erc20Token = new ethers_1.ethers.Contract(evmAddress, this._configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this._configuration.TACParams.provider);
310
+ return erc20Token.balanceOf(userAddress);
298
311
  }
299
312
  getTransferPayload(rawAmount, notificationReceiverAddress, responseAddress, evmData, crossChainTonAmount, forwardFeeAmount, feeData) {
300
313
  const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;