@tonappchain/sdk 0.7.0-rc24-test-14 → 0.7.0-rc25

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.
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,197 +1,197 @@
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
- ### Installation
15
-
16
- ```bash
17
- npm install @tonappchain/sdk
18
- ```
19
-
20
- or
21
-
22
- ```bash
23
- yarn add @tonappchain/sdk
24
- ```
25
-
26
-
27
- ## Features
28
-
29
- The TAC SDK enables you to create frontends that:
30
-
31
- - Connect to TON wallets like Tonkeeper or Tonhub
32
- - Send transactions from TON to your EVM contracts
33
- - Track cross-chain transaction status in real-time
34
- - Handle tokens across both chains
35
- - Create a seamless user experience for TON users
36
-
37
- ## Available Resources
38
-
39
-
40
- ### SDK Components
41
-
42
- - **[`TacSdk`](./docs/sdks/tac_sdk.md)**: The main class for interacting with the TAC protocol.
43
- - [`create`](./docs/sdks/tac_sdk.md#creating-an-instance-of-tacsdk): Initializes the SDK instance.
44
- - [`sendCrossChainTransaction`](./docs/sdks/tac_sdk.md#sendcrosschaintransaction): Sends a cross-chain transaction from TON to TAC.
45
- - [`getEVMTokenAddress`](./docs/sdks/tac_sdk.md#getevmtokenaddress): Gets the TAC address for a TON token.
46
- - [`getTVMTokenAddress`](./docs/sdks/tac_sdk.md#gettvmtokenaddress): Gets the TON address for a TAC token.
47
- - [`getSimulationInfo`](./docs/sdks/tac_sdk.md#getsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
48
- - [`getUserJettonBalance`](./docs/sdks/tac_sdk.md#getuserjettonbalance): Gets a user's Jetton balance (raw).
49
- - [`getUserJettonBalanceExtended`](./docs/sdks/tac_sdk.md#getuserjettonbalanceextended): Gets extended Jetton balance info (including decimals).
50
- - [`getUserJettonWalletAddress`](./docs/sdks/tac_sdk.md#getuserjettonwalletaddress): Calculates a user's Jetton wallet address.
51
- - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress): Placeholder address for native TON.
52
- - [`nativeTACAddress (method)`](./docs/sdks/tac_sdk.md#nativetacaddress): Gets the native asset address on the TAC chain.
53
- - *(See file for more...)*
54
-
55
- - **[`OperationTracker`](./docs/sdks/operation_tracker.md)**: Tools for monitoring cross-chain operation status.
56
- - [`constructor`](./docs/sdks/operation_tracker.md#constructor): Creates a tracker instance.
57
- - [`getOperationId`](./docs/sdks/operation_tracker.md#getoperationid): Retrieves the Operation ID from a `TransactionLinker`.
58
- - [`getStageProfiling`](./docs/sdks/operation_tracker.md#getstageprofiling): Gets detailed timing and status for all stages of an operation.
59
- - [`getSimplifiedOperationStatus`](./docs/sdks/operation_tracker.md#getsimplifiedoperationstatus): Gets a simplified overall status (Pending, Successful, Failed, Not Found).
60
- - *(See file for more...)*
61
-
62
- - **[`Senders`](./docs/sdks/sender.md)**: Handles signing and sending TON transactions.
63
- - [`TonConnectSender`](./docs/sdks/sender.md#tonconnectsender): Implements sending via TonConnect UI.
64
- - [`RawSender`](./docs/sdks/sender.md#rawsender): Implements sending using a raw private key.
65
-
66
- - **[`Utilities`](./docs/sdks/utilities.md)**: Helper functions and interfaces.
67
- - [`startTracking`](./docs/sdks/utilities.md#starttracking): Utility function to poll and log operation status to the console.
68
-
69
- - **[`AgnosticSdk`](./docs/sdks/agnostic_proxy_sdk.md)**: Agnostic SDK for cross-chain interactions.
70
-
71
- - **[`Simulator`](./docs/sdks/simulator.md)**: Transaction simulation capabilities.
72
-
73
- - **[`TACTransactionManager`](./docs/sdks/tac_transaction_manager.md)**: Manages TAC-side transactions.
74
-
75
- - **[`TONTransactionManager`](./docs/sdks/ton_transaction_manager.md)**: Manages TON-side transactions.
76
-
77
- ### Data Models
78
-
79
- - **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
80
- - [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
81
- - [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
82
- - [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation types (`PENDING`, `TON_TAC_TON`, `ROLLBACK`, etc.).
83
- - [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
84
-
85
- - **[`Structs`](./docs/models/structs.md)**: Core data structures.
86
- - [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
87
- - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
88
- - [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
89
- - *(See file for more...)*
90
-
91
- Navigate through the linked files for full details on parameters, return types, examples, and more.
92
-
93
- ### TACHeader
94
- > **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:
95
-
96
- ```
97
- function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
98
- // Function implementation
99
- }
100
- ```
101
-
102
- > **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
103
-
104
- The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
105
- - **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
106
- - **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
107
- - **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
108
- - **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
109
- - **`string tvmCaller`**: The TON user's wallet address that sent the message.
110
- - **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
111
-
112
- 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:
113
-
114
- ```
115
- const abi = new ethers.AbiCoder();
116
- const encodedParameters = abi.encode(
117
- ['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
118
- [
119
- [
120
- EVM_TOKEN_A_ADDRESS,
121
- EVM_TOKEN_B_ADDRESS,
122
- amountA,
123
- amountB,
124
- amountAMin,
125
- amountBMin,
126
- UNISWAPV2_PROXY_ADDRESS,
127
- deadline
128
- ]
129
- ]
130
- );
131
- ```
132
- More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
133
-
134
- ---
135
-
136
- ## Usage
137
-
138
- ```typescript
139
- import { TacSdk, AssetLike, EvmProxyMsg, SDKParams, Network, SenderFactory } from '@tonappchain/sdk';
140
- import { TonConnectUI } from '@tonconnect/ui';
141
- import { ethers } from 'ethers';
142
-
143
- // Create EVM payload for DappProxy
144
- const abi = new ethers.AbiCoder();
145
- const encodedParameters = abi.encode(
146
- ['tuple(uint256,uint256,address[],address)'],
147
- [
148
- [
149
- tokenAAmount,
150
- tokenBAmount,
151
- [EVMtokenAAddress, EVMtokenBAddress],
152
- proxyDapp
153
- ]
154
- ]
155
- );
156
- const evmProxyMsg: EvmProxyMsg = {
157
- evmTargetAddress: DappProxyAddress,
158
- methodName: 'addLiquidity',
159
- encodedParameters
160
- };
161
-
162
- // Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
163
- const assets: AssetLike[] = [
164
- {
165
- address: TVMtokenAAddress,
166
- amount: tokenAAmount,
167
- },
168
- {
169
- address: TVMtokenBAddress,
170
- amount: tokenBAmount,
171
- }
172
- ];
173
-
174
- const sdkParams: SDKParams = {
175
- network: Network.TESTNET
176
- };
177
- const tacSdk = await TacSdk.create(sdkParams);
178
-
179
- //Send transaction via tonConnect or mnemonic
180
- const tonConnectUI = new TonConnectUI({
181
- manifestUrl: config.tonconnectManifestUrl as string
182
- });
183
- const sender = await SenderFactory.getSender({
184
- tonConnect: tonConnectUI
185
- });
186
-
187
- await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
188
-
189
- tacSdk.closeConnections();
190
- ```
191
- 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.
192
-
193
- ---
194
-
195
- ## License
196
-
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
+ ### Installation
15
+
16
+ ```bash
17
+ npm install @tonappchain/sdk
18
+ ```
19
+
20
+ or
21
+
22
+ ```bash
23
+ yarn add @tonappchain/sdk
24
+ ```
25
+
26
+
27
+ ## Features
28
+
29
+ The TAC SDK enables you to create frontends that:
30
+
31
+ - Connect to TON wallets like Tonkeeper or Tonhub
32
+ - Send transactions from TON to your EVM contracts
33
+ - Track cross-chain transaction status in real-time
34
+ - Handle tokens across both chains
35
+ - Create a seamless user experience for TON users
36
+
37
+ ## Available Resources
38
+
39
+
40
+ ### SDK Components
41
+
42
+ - **[`TacSdk`](./docs/sdks/tac_sdk.md)**: The main class for interacting with the TAC protocol.
43
+ - [`create`](./docs/sdks/tac_sdk.md#creating-an-instance-of-tacsdk): Initializes the SDK instance.
44
+ - [`sendCrossChainTransaction`](./docs/sdks/tac_sdk.md#sendcrosschaintransaction): Sends a cross-chain transaction from TON to TAC.
45
+ - [`getEVMTokenAddress`](./docs/sdks/tac_sdk.md#getevmtokenaddress): Gets the TAC address for a TON token.
46
+ - [`getTVMTokenAddress`](./docs/sdks/tac_sdk.md#gettvmtokenaddress): Gets the TON address for a TAC token.
47
+ - [`getSimulationInfo`](./docs/sdks/tac_sdk.md#getsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
48
+ - [`getUserJettonBalance`](./docs/sdks/tac_sdk.md#getuserjettonbalance): Gets a user's Jetton balance (raw).
49
+ - [`getUserJettonBalanceExtended`](./docs/sdks/tac_sdk.md#getuserjettonbalanceextended): Gets extended Jetton balance info (including decimals).
50
+ - [`getUserJettonWalletAddress`](./docs/sdks/tac_sdk.md#getuserjettonwalletaddress): Calculates a user's Jetton wallet address.
51
+ - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress): Placeholder address for native TON.
52
+ - [`nativeTACAddress (method)`](./docs/sdks/tac_sdk.md#nativetacaddress): Gets the native asset address on the TAC chain.
53
+ - *(See file for more...)*
54
+
55
+ - **[`OperationTracker`](./docs/sdks/operation_tracker.md)**: Tools for monitoring cross-chain operation status.
56
+ - [`constructor`](./docs/sdks/operation_tracker.md#constructor): Creates a tracker instance.
57
+ - [`getOperationId`](./docs/sdks/operation_tracker.md#getoperationid): Retrieves the Operation ID from a `TransactionLinker`.
58
+ - [`getStageProfiling`](./docs/sdks/operation_tracker.md#getstageprofiling): Gets detailed timing and status for all stages of an operation.
59
+ - [`getSimplifiedOperationStatus`](./docs/sdks/operation_tracker.md#getsimplifiedoperationstatus): Gets a simplified overall status (Pending, Successful, Failed, Not Found).
60
+ - *(See file for more...)*
61
+
62
+ - **[`Senders`](./docs/sdks/sender.md)**: Handles signing and sending TON transactions.
63
+ - [`TonConnectSender`](./docs/sdks/sender.md#tonconnectsender): Implements sending via TonConnect UI.
64
+ - [`RawSender`](./docs/sdks/sender.md#rawsender): Implements sending using a raw private key.
65
+
66
+ - **[`Utilities`](./docs/sdks/utilities.md)**: Helper functions and interfaces.
67
+ - [`startTracking`](./docs/sdks/utilities.md#starttracking): Utility function to poll and log operation status to the console.
68
+
69
+ - **[`AgnosticSdk`](./docs/sdks/agnostic_proxy_sdk.md)**: Agnostic SDK for cross-chain interactions.
70
+
71
+ - **[`Simulator`](./docs/sdks/simulator.md)**: Transaction simulation capabilities.
72
+
73
+ - **[`TACTransactionManager`](./docs/sdks/tac_transaction_manager.md)**: Manages TAC-side transactions.
74
+
75
+ - **[`TONTransactionManager`](./docs/sdks/ton_transaction_manager.md)**: Manages TON-side transactions.
76
+
77
+ ### Data Models
78
+
79
+ - **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
80
+ - [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
81
+ - [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
82
+ - [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation types (`PENDING`, `TON_TAC_TON`, `ROLLBACK`, etc.).
83
+ - [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
84
+
85
+ - **[`Structs`](./docs/models/structs.md)**: Core data structures.
86
+ - [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
87
+ - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
88
+ - [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
89
+ - *(See file for more...)*
90
+
91
+ Navigate through the linked files for full details on parameters, return types, examples, and more.
92
+
93
+ ### TACHeader
94
+ > **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:
95
+
96
+ ```
97
+ function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
98
+ // Function implementation
99
+ }
100
+ ```
101
+
102
+ > **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
103
+
104
+ The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
105
+ - **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
106
+ - **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
107
+ - **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
108
+ - **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
109
+ - **`string tvmCaller`**: The TON user's wallet address that sent the message.
110
+ - **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
111
+
112
+ 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:
113
+
114
+ ```
115
+ const abi = new ethers.AbiCoder();
116
+ const encodedParameters = abi.encode(
117
+ ['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
118
+ [
119
+ [
120
+ EVM_TOKEN_A_ADDRESS,
121
+ EVM_TOKEN_B_ADDRESS,
122
+ amountA,
123
+ amountB,
124
+ amountAMin,
125
+ amountBMin,
126
+ UNISWAPV2_PROXY_ADDRESS,
127
+ deadline
128
+ ]
129
+ ]
130
+ );
131
+ ```
132
+ More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
133
+
134
+ ---
135
+
136
+ ## Usage
137
+
138
+ ```typescript
139
+ import { TacSdk, AssetLike, EvmProxyMsg, SDKParams, Network, SenderFactory } from '@tonappchain/sdk';
140
+ import { TonConnectUI } from '@tonconnect/ui';
141
+ import { ethers } from 'ethers';
142
+
143
+ // Create EVM payload for DappProxy
144
+ const abi = new ethers.AbiCoder();
145
+ const encodedParameters = abi.encode(
146
+ ['tuple(uint256,uint256,address[],address)'],
147
+ [
148
+ [
149
+ tokenAAmount,
150
+ tokenBAmount,
151
+ [EVMtokenAAddress, EVMtokenBAddress],
152
+ proxyDapp
153
+ ]
154
+ ]
155
+ );
156
+ const evmProxyMsg: EvmProxyMsg = {
157
+ evmTargetAddress: DappProxyAddress,
158
+ methodName: 'addLiquidity',
159
+ encodedParameters
160
+ };
161
+
162
+ // Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
163
+ const assets: AssetLike[] = [
164
+ {
165
+ address: TVMtokenAAddress,
166
+ amount: tokenAAmount,
167
+ },
168
+ {
169
+ address: TVMtokenBAddress,
170
+ amount: tokenBAmount,
171
+ }
172
+ ];
173
+
174
+ const sdkParams: SDKParams = {
175
+ network: Network.TESTNET
176
+ };
177
+ const tacSdk = await TacSdk.create(sdkParams);
178
+
179
+ //Send transaction via tonConnect or mnemonic
180
+ const tonConnectUI = new TonConnectUI({
181
+ manifestUrl: config.tonconnectManifestUrl as string
182
+ });
183
+ const sender = await SenderFactory.getSender({
184
+ tonConnect: tonConnectUI
185
+ });
186
+
187
+ await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
188
+
189
+ tacSdk.closeConnections();
190
+ ```
191
+ 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.
192
+
193
+ ---
194
+
195
+ ## License
196
+
197
197
  MIT
@@ -170,7 +170,7 @@ class DebugHelpers {
170
170
  const perspective = isFromSA ? 'Smart Account' : 'Proxy Contract';
171
171
  const valueStr = value > 0n ? ` (sending ${ethers_1.ethers.formatEther(value)} ETH)` : '';
172
172
  const replacementStr = hasReplacements ? ' 🔄 [with dynamic value replacement]' : '';
173
- return `📞 Custom call to ${this._formatAddress(contractAddress)} from ${perspective}${valueStr}
173
+ return `📞 Custom call to ${this._formatAddress(contractAddress)} from ${perspective}${valueStr}
174
174
  Function: ${functionDescription}${replacementStr}`;
175
175
  }
176
176
  /**
@@ -1,2 +1,2 @@
1
1
  export { AddressError, BitError, ContractError, EVMCallError, FetchError, FormatError, KeyError, MetadataError, SettingError, TokenError, WalletError, } from './errors';
2
- export { allEndpointsFailedError, emptyArrayError, emptyContractError, emptySettingError, evmAddressError, indexRequiredError, insufficientBalanceError, invalidMethodNameError, missingDecimals, missingFeeParamsError, missingGasLimitError, missingJettonDataError, missingTvmExecutorFeeError, notMultiplyOf8Error, operationFetchError, prefixError, profilingFetchError, simulationFetchError, statusFetchError, tvmAddressError, unknownTokenTypeError, unknownWalletError, unsupportedFormatError, unsupportedKeyError, } from './instances';
2
+ export { allEndpointsFailedError, emptyArrayError, emptyContractError, emptySettingError, evmAddressError, indexRequiredError, insufficientBalanceError, invalidMethodNameError, missingDecimals, missingFeeParamsError, missingGasLimitError, missingJettonDataError, missingTvmExecutorFeeError, notMultiplyOf8Error, operationFetchError, prefixError, profilingFetchError, simulationFetchError, statusFetchError, tvmAddressError, unknownTokenTypeError, unknownWalletError, unsupportedFormatError, unsupportedKeyError, zeroRawAmountError, } from './instances';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.tvmAddressError = exports.statusFetchError = exports.simulationFetchError = exports.profilingFetchError = exports.prefixError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.missingTvmExecutorFeeError = exports.missingJettonDataError = exports.missingGasLimitError = exports.missingFeeParamsError = exports.missingDecimals = exports.invalidMethodNameError = exports.insufficientBalanceError = exports.indexRequiredError = exports.evmAddressError = exports.emptySettingError = exports.emptyContractError = exports.emptyArrayError = exports.allEndpointsFailedError = exports.WalletError = exports.TokenError = exports.SettingError = exports.MetadataError = exports.KeyError = exports.FormatError = exports.FetchError = exports.EVMCallError = exports.ContractError = exports.BitError = exports.AddressError = void 0;
3
+ exports.zeroRawAmountError = exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.tvmAddressError = exports.statusFetchError = exports.simulationFetchError = exports.profilingFetchError = exports.prefixError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.missingTvmExecutorFeeError = exports.missingJettonDataError = exports.missingGasLimitError = exports.missingFeeParamsError = exports.missingDecimals = exports.invalidMethodNameError = exports.insufficientBalanceError = exports.indexRequiredError = exports.evmAddressError = exports.emptySettingError = exports.emptyContractError = exports.emptyArrayError = exports.allEndpointsFailedError = exports.WalletError = exports.TokenError = exports.SettingError = exports.MetadataError = exports.KeyError = exports.FormatError = exports.FetchError = exports.EVMCallError = exports.ContractError = exports.BitError = exports.AddressError = void 0;
4
4
  var errors_1 = require("./errors");
5
5
  Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return errors_1.AddressError; } });
6
6
  Object.defineProperty(exports, "BitError", { enumerable: true, get: function () { return errors_1.BitError; } });
@@ -38,3 +38,4 @@ Object.defineProperty(exports, "unknownTokenTypeError", { enumerable: true, get:
38
38
  Object.defineProperty(exports, "unknownWalletError", { enumerable: true, get: function () { return instances_1.unknownWalletError; } });
39
39
  Object.defineProperty(exports, "unsupportedFormatError", { enumerable: true, get: function () { return instances_1.unsupportedFormatError; } });
40
40
  Object.defineProperty(exports, "unsupportedKeyError", { enumerable: true, get: function () { return instances_1.unsupportedKeyError; } });
41
+ Object.defineProperty(exports, "zeroRawAmountError", { enumerable: true, get: function () { return instances_1.zeroRawAmountError; } });
@@ -29,3 +29,4 @@ export declare const missingTvmExecutorFeeError: FormatError;
29
29
  export declare const missingGasLimitError: FormatError;
30
30
  export declare const missingDecimals: MetadataError;
31
31
  export declare const missingJettonDataError: MetadataError;
32
+ export declare const zeroRawAmountError: (assetAddress: string) => TokenError;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.missingJettonDataError = exports.missingDecimals = exports.missingGasLimitError = exports.missingTvmExecutorFeeError = exports.missingFeeParamsError = exports.getTONFeeInfoFetchError = exports.simulationFetchError = exports.convertCurrencyFetchError = exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
3
+ exports.zeroRawAmountError = exports.missingJettonDataError = exports.missingDecimals = exports.missingGasLimitError = exports.missingTvmExecutorFeeError = exports.missingFeeParamsError = exports.getTONFeeInfoFetchError = exports.simulationFetchError = exports.convertCurrencyFetchError = exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
4
4
  const errors_1 = require("./errors");
5
5
  exports.emptyContractError = new errors_1.ContractError('unexpected empty contract code of given jetton.', 100);
6
6
  const operationFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch OperationId: ${msg}`, 101, inner);
@@ -51,3 +51,5 @@ exports.missingTvmExecutorFeeError = new errors_1.FormatError('When withoutSimul
51
51
  exports.missingGasLimitError = new errors_1.FormatError('When withoutSimulation is true, gasLimit must be provided in evmProxyMsg', 127);
52
52
  exports.missingDecimals = new errors_1.MetadataError('Missing decimals in jetton metadata', 128);
53
53
  exports.missingJettonDataError = new errors_1.MetadataError('Jetton data should be available for TON origin', 129);
54
+ const zeroRawAmountError = (assetAddress) => new errors_1.TokenError(`FT asset with zero rawAmount/amount is not allowed: ${assetAddress}`, 130);
55
+ exports.zeroRawAmountError = zeroRawAmountError;
@@ -203,10 +203,11 @@ async function aggregateTokens(assets) {
203
203
  const uniqueAssetsMap = new Map();
204
204
  let ton;
205
205
  for await (const asset of assets ?? []) {
206
- if (asset.rawAmount === 0n)
207
- continue;
208
206
  if (asset.type !== Struct_1.AssetType.FT)
209
207
  continue;
208
+ if (asset.rawAmount === 0n) {
209
+ throw (0, errors_1.zeroRawAmountError)(asset.address || 'NATIVE TON');
210
+ }
210
211
  if (!asset.address) {
211
212
  ton = ton ? ton.addRawAmount(asset.rawAmount) : asset.clone;
212
213
  continue;
package/package.json CHANGED
@@ -1,118 +1,118 @@
1
- {
2
- "name": "@tonappchain/sdk",
3
- "version": "0.7.0-rc24-test-14",
4
- "repository": "https://github.com/TacBuild/tac-sdk.git",
5
- "author": "TAC. <developers@tac>",
6
- "license": "MIT",
7
- "main": "dist/src/index.js",
8
- "types": "dist/src/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "node": {
12
- "types": "./dist/src/index.d.ts",
13
- "require": "./dist/src/index.js",
14
- "import": "./dist/src/index.js"
15
- },
16
- "browser": {
17
- "types": "./dist/src/index.d.ts",
18
- "import": "./dist/src/index.js"
19
- },
20
- "types": "./dist/src/index.d.ts",
21
- "require": "./dist/src/index.js",
22
- "import": "./dist/src/index.js",
23
- "default": "./dist/src/index.js"
24
- },
25
- "./package.json": "./package.json",
26
- "./dist": null,
27
- "./dist/*": null,
28
- "./src": null,
29
- "./src/*": null,
30
- "./artifacts": {
31
- "types": "./dist/artifacts/index.d.ts",
32
- "import": "./dist/artifacts/index.js",
33
- "require": "./dist/artifacts/index.js"
34
- },
35
- "./artifacts/types/ton": {
36
- "types": "./dist/artifacts/tonTypes.d.ts",
37
- "import": "./dist/artifacts/tonTypes.js",
38
- "require": "./dist/artifacts/tonTypes.js"
39
- },
40
- "./artifacts/types/tac": {
41
- "types": "./dist/artifacts/tacTypes.d.ts",
42
- "import": "./dist/artifacts/tacTypes.js",
43
- "require": "./dist/artifacts/tacTypes.js"
44
- },
45
- "./artifacts/*": null,
46
- "./*": null
47
- },
48
- "files": [
49
- "dist"
50
- ],
51
- "scripts": {
52
- "prebuild": "git submodule update --init --recursive --remote",
53
- "litebuild": "rm -rf dist && tsc --declaration",
54
- "build": "rm -rf dist && yarn build:artifacts && tsc --declaration",
55
- "build:artifacts:tac:dev": "cd artifacts/dev/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
56
- "build:artifacts:ton:dev": "cd artifacts/dev/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
57
- "build:artifacts:tac:testnet": "cd artifacts/testnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
58
- "build:artifacts:ton:testnet": "cd artifacts/testnet/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
59
- "build:artifacts:tac:mainnet": "cd artifacts/mainnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
60
- "build:artifacts:ton:mainnet": "cd artifacts/mainnet/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
61
- "build:artifacts:ton:all": "yarn build:artifacts:ton:dev && yarn build:artifacts:ton:testnet && yarn build:artifacts:ton:mainnet",
62
- "build:artifacts:tac:all": "yarn build:artifacts:tac:dev && yarn build:artifacts:tac:testnet && yarn build:artifacts:tac:mainnet",
63
- "build:artifacts": "yarn prebuild && yarn build:artifacts:ton:all && yarn build:artifacts:tac:all",
64
- "test": "jest --verbose --runInBand",
65
- "release": "yarn build && yarn release-it --npm.yarn1",
66
- "lint": "eslint .",
67
- "lint:fix": "eslint . --fix",
68
- "prettier": "prettier --ignore-path .gitignore --write \"./src/**/*.+(js|ts|json)\""
69
- },
70
- "dependencies": {
71
- "@aws-crypto/sha256-js": "^5.2.0",
72
- "@orbs-network/ton-access": "^2.3.3",
73
- "@ton/ton": "15.1.0",
74
- "@tonappchain/ton-lite-client": "3.0.6",
75
- "@tonconnect/ui": "^2.0.11",
76
- "bn.js": "^5.2.1",
77
- "cli-table3": "^0.6.5",
78
- "dotenv": "^16.4.7",
79
- "ethers": "^6.13.5",
80
- "ton-crypto": "^3.2.0",
81
- "yarn": "^1.22.22"
82
- },
83
- "keywords": [],
84
- "description": "",
85
- "devDependencies": {
86
- "@eslint/js": "^9.21.0",
87
- "@jest/globals": "^29.7.0",
88
- "@release-it/keep-a-changelog": "^6.0.0",
89
- "@ton/sandbox": "^0.27.1",
90
- "@ton/test-utils": "^0.5.0",
91
- "@types/bn.js": "^5.1.6",
92
- "@types/jest": "^29.5.14",
93
- "eslint": "^9.21.0",
94
- "eslint-config-prettier": "^10.0.2",
95
- "eslint-plugin-simple-import-sort": "^12.1.1",
96
- "jest": "^29.7.0",
97
- "prettier": "^3.5.3",
98
- "ts-jest": "^29.2.6",
99
- "ts-node": "^10.9.2",
100
- "typescript": "^5.7.3",
101
- "typescript-eslint": "^8.17.0"
102
- },
103
- "publishConfig": {
104
- "access": "public",
105
- "registry": "https://registry.npmjs.org/"
106
- },
107
- "release-it": {
108
- "plugins": {
109
- "@release-it/keep-a-changelog": {
110
- "filename": "CHANGELOG.md"
111
- }
112
- },
113
- "npm": {
114
- "publish": false
115
- }
116
- },
117
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
118
- }
1
+ {
2
+ "name": "@tonappchain/sdk",
3
+ "version": "0.7.0-rc25",
4
+ "repository": "https://github.com/TacBuild/tac-sdk.git",
5
+ "author": "TAC. <developers@tac>",
6
+ "license": "MIT",
7
+ "main": "dist/src/index.js",
8
+ "types": "dist/src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "node": {
12
+ "types": "./dist/src/index.d.ts",
13
+ "require": "./dist/src/index.js",
14
+ "import": "./dist/src/index.js"
15
+ },
16
+ "browser": {
17
+ "types": "./dist/src/index.d.ts",
18
+ "import": "./dist/src/index.js"
19
+ },
20
+ "types": "./dist/src/index.d.ts",
21
+ "require": "./dist/src/index.js",
22
+ "import": "./dist/src/index.js",
23
+ "default": "./dist/src/index.js"
24
+ },
25
+ "./package.json": "./package.json",
26
+ "./dist": null,
27
+ "./dist/*": null,
28
+ "./src": null,
29
+ "./src/*": null,
30
+ "./artifacts": {
31
+ "types": "./dist/artifacts/index.d.ts",
32
+ "import": "./dist/artifacts/index.js",
33
+ "require": "./dist/artifacts/index.js"
34
+ },
35
+ "./artifacts/types/ton": {
36
+ "types": "./dist/artifacts/tonTypes.d.ts",
37
+ "import": "./dist/artifacts/tonTypes.js",
38
+ "require": "./dist/artifacts/tonTypes.js"
39
+ },
40
+ "./artifacts/types/tac": {
41
+ "types": "./dist/artifacts/tacTypes.d.ts",
42
+ "import": "./dist/artifacts/tacTypes.js",
43
+ "require": "./dist/artifacts/tacTypes.js"
44
+ },
45
+ "./artifacts/*": null,
46
+ "./*": null
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "scripts": {
52
+ "prebuild": "git submodule update --init --recursive --remote",
53
+ "litebuild": "rm -rf dist && tsc --declaration",
54
+ "build": "rm -rf dist && yarn build:artifacts && tsc --declaration",
55
+ "build:artifacts:tac:dev": "cd artifacts/dev/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
56
+ "build:artifacts:ton:dev": "cd artifacts/dev/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
57
+ "build:artifacts:tac:testnet": "cd artifacts/testnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
58
+ "build:artifacts:ton:testnet": "cd artifacts/testnet/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
59
+ "build:artifacts:tac:mainnet": "cd artifacts/mainnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
60
+ "build:artifacts:ton:mainnet": "cd artifacts/mainnet/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
61
+ "build:artifacts:ton:all": "yarn build:artifacts:ton:dev && yarn build:artifacts:ton:testnet && yarn build:artifacts:ton:mainnet",
62
+ "build:artifacts:tac:all": "yarn build:artifacts:tac:dev && yarn build:artifacts:tac:testnet && yarn build:artifacts:tac:mainnet",
63
+ "build:artifacts": "yarn prebuild && yarn build:artifacts:ton:all && yarn build:artifacts:tac:all",
64
+ "test": "jest --verbose --runInBand",
65
+ "release": "yarn build && yarn release-it --npm.yarn1",
66
+ "lint": "eslint .",
67
+ "lint:fix": "eslint . --fix",
68
+ "prettier": "prettier --ignore-path .gitignore --write \"./src/**/*.+(js|ts|json)\""
69
+ },
70
+ "dependencies": {
71
+ "@aws-crypto/sha256-js": "^5.2.0",
72
+ "@orbs-network/ton-access": "^2.3.3",
73
+ "@ton/ton": "15.1.0",
74
+ "@tonappchain/ton-lite-client": "3.0.6",
75
+ "@tonconnect/ui": "^2.0.11",
76
+ "bn.js": "^5.2.1",
77
+ "cli-table3": "^0.6.5",
78
+ "dotenv": "^16.4.7",
79
+ "ethers": "^6.13.5",
80
+ "ton-crypto": "^3.2.0",
81
+ "yarn": "^1.22.22"
82
+ },
83
+ "keywords": [],
84
+ "description": "",
85
+ "devDependencies": {
86
+ "@eslint/js": "^9.21.0",
87
+ "@jest/globals": "^29.7.0",
88
+ "@release-it/keep-a-changelog": "^6.0.0",
89
+ "@ton/sandbox": "^0.27.1",
90
+ "@ton/test-utils": "^0.5.0",
91
+ "@types/bn.js": "^5.1.6",
92
+ "@types/jest": "^29.5.14",
93
+ "eslint": "^9.21.0",
94
+ "eslint-config-prettier": "^10.0.2",
95
+ "eslint-plugin-simple-import-sort": "^12.1.1",
96
+ "jest": "^29.7.0",
97
+ "prettier": "^3.5.3",
98
+ "ts-jest": "^29.2.6",
99
+ "ts-node": "^10.9.2",
100
+ "typescript": "^5.7.3",
101
+ "typescript-eslint": "^8.17.0"
102
+ },
103
+ "publishConfig": {
104
+ "access": "public",
105
+ "registry": "https://registry.npmjs.org/"
106
+ },
107
+ "release-it": {
108
+ "plugins": {
109
+ "@release-it/keep-a-changelog": {
110
+ "filename": "CHANGELOG.md"
111
+ }
112
+ },
113
+ "npm": {
114
+ "publish": false
115
+ }
116
+ },
117
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
118
+ }