@tonappchain/sdk 0.7.0-rc29 → 0.7.0-rc31

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,199 +1,199 @@
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
-
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
199
  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
  /**
@@ -31,3 +31,4 @@ export declare const missingDecimals: MetadataError;
31
31
  export declare const missingJettonDataError: MetadataError;
32
32
  export declare const zeroRawAmountError: (assetAddress: string) => TokenError;
33
33
  export declare const sendCrossChainTransactionFailedError: (msg: string) => WalletError;
34
+ export declare const convertCurrencyZeroValueError: FormatError;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendCrossChainTransactionFailedError = 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;
3
+ exports.convertCurrencyZeroValueError = exports.sendCrossChainTransactionFailedError = 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);
@@ -55,3 +55,4 @@ const zeroRawAmountError = (assetAddress) => new errors_1.TokenError(`FT asset w
55
55
  exports.zeroRawAmountError = zeroRawAmountError;
56
56
  const sendCrossChainTransactionFailedError = (msg) => new errors_1.WalletError(`failed to send cross chain transaction: ${msg}`, 131);
57
57
  exports.sendCrossChainTransactionFailedError = sendCrossChainTransactionFailedError;
58
+ exports.convertCurrencyZeroValueError = new errors_1.FormatError('Value cannot be zero for currency conversion', 132);
@@ -78,6 +78,7 @@ class Configuration {
78
78
  const artifacts = network === Struct_1.Network.MAINNET ? artifacts_1.mainnet : network === Struct_1.Network.TESTNET ? artifacts_1.testnet : artifacts_1.dev;
79
79
  let provider;
80
80
  let settingsAddress;
81
+ let saFactoryAddress;
81
82
  if (network === Struct_1.Network.DEV) {
82
83
  if (!TACParams || !TACParams.provider) {
83
84
  throw new Error('For dev network, a custom provider must be provided in TACParams');
@@ -86,11 +87,16 @@ class Configuration {
86
87
  if (!TACParams.settingsAddress) {
87
88
  throw new Error('For dev network, a custom settings address must be provided in TACParams');
88
89
  }
89
- settingsAddress = TACParams.settingsAddress.toString();
90
+ settingsAddress = TACParams.settingsAddress;
91
+ if (!TACParams.saFactoryAddress) {
92
+ throw new Error('For dev network, a custom smart account factory address must be provided in TACParams');
93
+ }
94
+ saFactoryAddress = TACParams.saFactoryAddress;
90
95
  }
91
96
  else {
92
97
  provider = TACParams?.provider ?? ethers_1.ethers.getDefaultProvider(artifacts.TAC_RPC_ENDPOINT);
93
- settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.TAC_SETTINGS_ADDRESS;
98
+ settingsAddress = TACParams?.settingsAddress ?? artifacts.TAC_SETTINGS_ADDRESS;
99
+ saFactoryAddress = TACParams?.saFactoryAddress ?? artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS;
94
100
  }
95
101
  Validator_1.Validator.validateEVMAddress(settingsAddress);
96
102
  const settingsAbi = artifacts.tac.compilationArtifacts.ISettings.abi;
@@ -117,7 +123,7 @@ class Configuration {
117
123
  const tokenUtilsAbi = artifacts.tac.compilationArtifacts.ITokenUtils.abi;
118
124
  const tokenUtils = new ethers_1.ethers.Contract(tokenUtilsAddress, tokenUtilsAbi, provider);
119
125
  const TacSAFactoryAbi = artifacts.tac.compilationArtifacts.ISAFactory.abi;
120
- const smartAccountFactory = new ethers_1.ethers.Contract(artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS, TacSAFactoryAbi, provider);
126
+ const smartAccountFactory = new ethers_1.ethers.Contract(saFactoryAddress, TacSAFactoryAbi, provider);
121
127
  return {
122
128
  provider,
123
129
  settings,
@@ -123,6 +123,9 @@ class LiteSequencerClient {
123
123
  }
124
124
  }
125
125
  async convertCurrency(params) {
126
+ if (params.value === 0n) {
127
+ throw instances_1.convertCurrencyZeroValueError;
128
+ }
126
129
  try {
127
130
  const payload = {
128
131
  currency: params.currency,
@@ -149,12 +149,11 @@ class TONTransactionManager {
149
149
  if (!shouldWaitForOperationId) {
150
150
  return { sendTransactionResult, ...transactionLinker };
151
151
  }
152
+ const waitOptions = tx.options?.waitOptions ?? {};
153
+ waitOptions.successCheck = waitOptions.successCheck ?? ((id) => !!id);
154
+ waitOptions.logger = waitOptions.logger ?? this.logger;
152
155
  const operationId = await this.operationTracker
153
- .getOperationId(transactionLinker, {
154
- ...(tx.options?.waitOptions ?? {}),
155
- successCheck: (id) => !!id,
156
- logger: this.logger,
157
- })
156
+ .getOperationId(transactionLinker, waitOptions)
158
157
  .catch((error) => {
159
158
  this.logger.error(`Error while waiting for operation ID: ${error}`);
160
159
  return undefined;
@@ -200,12 +199,12 @@ class TONTransactionManager {
200
199
  async waitForOperationIds(transactionLinkers, caller, waitOptions) {
201
200
  this.logger.debug(`Waiting for operation IDs`);
202
201
  try {
203
- const operationIds = await this.operationTracker.getOperationIdsByShardsKeys(transactionLinkers.map((linker) => linker.shardsKey), caller, {
204
- ...waitOptions,
205
- logger: this.logger,
206
- successCheck: (operationIds) => Object.keys(operationIds).length == transactionLinkers.length &&
207
- Object.values(operationIds).every((ids) => ids.operationIds.length > 0),
208
- });
202
+ waitOptions.successCheck =
203
+ waitOptions.successCheck ??
204
+ ((operationIds) => Object.keys(operationIds).length == transactionLinkers.length &&
205
+ Object.values(operationIds).every((ids) => ids.operationIds.length > 0));
206
+ waitOptions.logger = waitOptions.logger ?? this.logger;
207
+ const operationIds = await this.operationTracker.getOperationIdsByShardsKeys(transactionLinkers.map((linker) => linker.shardsKey), caller, waitOptions);
209
208
  this.logger.debug(`Operation IDs: ${(0, Utils_1.formatObjectForLogging)(operationIds)}`);
210
209
  return transactionLinkers.map((linker) => ({
211
210
  ...linker,
@@ -1,6 +1,6 @@
1
1
  import { SandboxContract } from '@ton/sandbox';
2
2
  import { OpenedContract } from '@ton/ton';
3
- import { AbstractProvider, Addressable } from 'ethers';
3
+ import { AbstractProvider } from 'ethers';
4
4
  import { JettonMinter, JettonMinterData } from '../../artifacts/tonTypes';
5
5
  import type { FT, NFT } from '../assets';
6
6
  import type { Asset, ContractOpener, ILogger } from '../interfaces';
@@ -44,7 +44,11 @@ export type TACParams = {
44
44
  /**
45
45
  * Address of TAC settings contract. Use only for tests.
46
46
  */
47
- settingsAddress?: string | Addressable;
47
+ settingsAddress?: string;
48
+ /**
49
+ * Address of TAC smart account factory contract. Use only for tests.
50
+ */
51
+ saFactoryAddress?: string;
48
52
  };
49
53
  export type TONParams = {
50
54
  /**
package/package.json CHANGED
@@ -1,118 +1,118 @@
1
- {
2
- "name": "@tonappchain/sdk",
3
- "version": "0.7.0-rc29",
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 && npm run 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": "npm run build:artifacts:ton:dev && npm run build:artifacts:ton:testnet && npm run build:artifacts:ton:mainnet",
62
- "build:artifacts:tac:all": "npm run build:artifacts:tac:dev && npm run build:artifacts:tac:testnet && npm run build:artifacts:tac:mainnet",
63
- "build:artifacts": "npm run prebuild && npm run build:artifacts:ton:all && npm run 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
- },
82
- "keywords": [],
83
- "description": "",
84
- "devDependencies": {
85
- "@eslint/js": "^9.21.0",
86
- "@jest/globals": "^29.7.0",
87
- "@release-it/keep-a-changelog": "^6.0.0",
88
- "@ton/sandbox": "^0.27.1",
89
- "@ton/test-utils": "^0.5.0",
90
- "@types/bn.js": "^5.1.6",
91
- "@types/jest": "^29.5.14",
92
- "eslint": "^9.21.0",
93
- "eslint-config-prettier": "^10.0.2",
94
- "eslint-plugin-simple-import-sort": "^12.1.1",
95
- "jest": "^29.7.0",
96
- "prettier": "^3.5.3",
97
- "ts-jest": "^29.2.6",
98
- "ts-node": "^10.9.2",
99
- "typescript": "^5.7.3",
100
- "typescript-eslint": "^8.17.0",
101
- "yarn": "^1.22.22"
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-rc31",
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 && npm run 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": "npm run build:artifacts:ton:dev && npm run build:artifacts:ton:testnet && npm run build:artifacts:ton:mainnet",
62
+ "build:artifacts:tac:all": "npm run build:artifacts:tac:dev && npm run build:artifacts:tac:testnet && npm run build:artifacts:tac:mainnet",
63
+ "build:artifacts": "npm run prebuild && npm run build:artifacts:ton:all && npm run 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
+ },
82
+ "keywords": [],
83
+ "description": "",
84
+ "devDependencies": {
85
+ "@eslint/js": "^9.21.0",
86
+ "@jest/globals": "^29.7.0",
87
+ "@release-it/keep-a-changelog": "^6.0.0",
88
+ "@ton/sandbox": "^0.27.1",
89
+ "@ton/test-utils": "^0.5.0",
90
+ "@types/bn.js": "^5.1.6",
91
+ "@types/jest": "^29.5.14",
92
+ "eslint": "^9.21.0",
93
+ "eslint-config-prettier": "^10.0.2",
94
+ "eslint-plugin-simple-import-sort": "^12.1.1",
95
+ "jest": "^29.7.0",
96
+ "prettier": "^3.5.3",
97
+ "ts-jest": "^29.2.6",
98
+ "ts-node": "^10.9.2",
99
+ "typescript": "^5.7.3",
100
+ "typescript-eslint": "^8.17.0",
101
+ "yarn": "^1.22.22"
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
+ }