@tonappchain/sdk 0.7.0-rc16 → 0.7.0-rc17
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 +20 -20
- package/README.md +191 -191
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/sdk/Consts.js +3 -3
- package/package.json +68 -68
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,192 +1,192 @@
|
|
|
1
|
-
# TacSdk
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@tonappchain/sdk)
|
|
4
|
-
[](https://www.npmjs.com/package/@tonappchain/sdk)
|
|
5
|
-
[](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 (getter)`](./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
|
-
### Data Models
|
|
70
|
-
|
|
71
|
-
- **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
|
|
72
|
-
- [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
|
|
73
|
-
- [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
|
|
74
|
-
- [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation types (`PENDING`, `TON_TAC_TON`, `ROLLBACK`, etc.).
|
|
75
|
-
- [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
|
|
76
|
-
|
|
77
|
-
- **[`Structs`](./docs/models/structs.md)**: Core data structures.
|
|
78
|
-
- [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
|
|
79
|
-
- [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
|
|
80
|
-
- [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
|
|
81
|
-
- *(See file for more...)*
|
|
82
|
-
|
|
83
|
-
Navigate through the linked files for full details on parameters, return types, examples, and more.
|
|
84
|
-
|
|
85
|
-
### TACHeader
|
|
86
|
-
> **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:
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
|
|
90
|
-
// Function implementation
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
> **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
|
|
95
|
-
|
|
96
|
-
The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
|
|
97
|
-
- **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
|
|
98
|
-
- **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
|
|
99
|
-
- **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
|
|
100
|
-
- **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
|
|
101
|
-
- **`string tvmCaller`**: The TON user's wallet address that sent the message.
|
|
102
|
-
- **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
|
|
103
|
-
|
|
104
|
-
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:
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
const abi = new ethers.AbiCoder();
|
|
108
|
-
const encodedParameters = abi.encode(
|
|
109
|
-
['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
|
|
110
|
-
[
|
|
111
|
-
[
|
|
112
|
-
EVM_TOKEN_A_ADDRESS,
|
|
113
|
-
EVM_TOKEN_B_ADDRESS,
|
|
114
|
-
amountA,
|
|
115
|
-
amountB,
|
|
116
|
-
amountAMin,
|
|
117
|
-
amountBMin,
|
|
118
|
-
UNISWAPV2_PROXY_ADDRESS,
|
|
119
|
-
deadline
|
|
120
|
-
]
|
|
121
|
-
]
|
|
122
|
-
);
|
|
123
|
-
```
|
|
124
|
-
More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Usage
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
import { TacSdk } from '@tonappchain/sdk';
|
|
132
|
-
import { TonConnectUI } from '@tonconnect/ui';
|
|
133
|
-
import { ethers } from 'ethers';
|
|
134
|
-
|
|
135
|
-
// Create EVM payload for DappProxy
|
|
136
|
-
const abi = new ethers.AbiCoder();
|
|
137
|
-
const encodedParameters = abi.encode(
|
|
138
|
-
['tuple(uint256,uint256,address[],address)'],
|
|
139
|
-
[
|
|
140
|
-
[
|
|
141
|
-
tokenAAmount,
|
|
142
|
-
tokenBAmount,
|
|
143
|
-
[EVMtokenAAddress, EVMtokenBAddress],
|
|
144
|
-
proxyDapp
|
|
145
|
-
]
|
|
146
|
-
]
|
|
147
|
-
);
|
|
148
|
-
const evmProxyMsg: EvmProxyMsg = {
|
|
149
|
-
evmTargetAddress: DappProxyAddress,
|
|
150
|
-
methodName: 'addLiquidity',
|
|
151
|
-
encodedParameters
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
|
|
155
|
-
const assets: AssetBridgingData[] = [
|
|
156
|
-
{
|
|
157
|
-
address: TVMtokenAAddress,
|
|
158
|
-
amount: tokenAAmount,
|
|
159
|
-
type: AssetType.FT,
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
address: TVMtokenBAddress,
|
|
164
|
-
amount: tokenBAmount,
|
|
165
|
-
type: AssetType.FT,
|
|
166
|
-
}
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
const sdkParams: SDKParams = {
|
|
170
|
-
network: Network.TESTNET
|
|
171
|
-
};
|
|
172
|
-
const tacSdk = await TacSdk.create(sdkParams);
|
|
173
|
-
|
|
174
|
-
//Send transaction via tonConnect or mnemonic
|
|
175
|
-
const tonConnectUI = new TonConnectUI({
|
|
176
|
-
manifestUrl: config.tonconnectManifestUrl as string
|
|
177
|
-
});
|
|
178
|
-
const sender = await SenderFactory.getSender({
|
|
179
|
-
tonConnect: tonConnectUI
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
|
|
183
|
-
|
|
184
|
-
tacSdk.closeConnections();
|
|
185
|
-
```
|
|
186
|
-
For a detailed example, see `test/sendSwap.ts` or `test/sendRemoveLiquidity.ts`, which demonstrates swapping tokens and removing liquidity on Uniswap and tracking the transaction status.
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## License
|
|
191
|
-
|
|
1
|
+
# TacSdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tonappchain/sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/@tonappchain/sdk)
|
|
5
|
+
[](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 (getter)`](./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
|
+
### Data Models
|
|
70
|
+
|
|
71
|
+
- **[`Enums`](./docs/models/enums.md)**: Key enumerations used by the SDK.
|
|
72
|
+
- [`Network`](./docs/models/enums.md#network): `TESTNET` or `MAINNET`.
|
|
73
|
+
- [`SimplifiedStatuses`](./docs/models/enums.md#simplifiedstatuses): `PENDING`, `FAILED`, `SUCCESSFUL`, `OPERATION_ID_NOT_FOUND`.
|
|
74
|
+
- [`OperationType`](./docs/models/enums.md#operationtype): Detailed operation types (`PENDING`, `TON_TAC_TON`, `ROLLBACK`, etc.).
|
|
75
|
+
- [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
|
|
76
|
+
|
|
77
|
+
- **[`Structs`](./docs/models/structs.md)**: Core data structures.
|
|
78
|
+
- [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
|
|
79
|
+
- [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
|
|
80
|
+
- [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
|
|
81
|
+
- *(See file for more...)*
|
|
82
|
+
|
|
83
|
+
Navigate through the linked files for full details on parameters, return types, examples, and more.
|
|
84
|
+
|
|
85
|
+
### TACHeader
|
|
86
|
+
> **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:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
function myProxyFunction(bytes calldata tacHeader, bytes calldata arguments) external onlyTacCCL {
|
|
90
|
+
// Function implementation
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> **Note:** methodName in `evmProxyMsg` must be either a simple method name or a signature of the form MethodName(bytes,bytes)
|
|
95
|
+
|
|
96
|
+
The first argument of methods must always be TACHeader. It is sent by protocol, augmented with data from executor.
|
|
97
|
+
- **`bytes tacHeader`**: Encoded structure TacHeaderV1, containing:
|
|
98
|
+
- **`uint64 shardsKey`**: ID you can specify for yourself an inside message to the TVM contract on the TON network.
|
|
99
|
+
- **`uint256 timestamp`**: The block timestamp on TON where the user's message was created.
|
|
100
|
+
- **`bytes32 operationId`**: Unique identifier for the message created by the TAC infrastructure.
|
|
101
|
+
- **`string tvmCaller`**: The TON user's wallet address that sent the message.
|
|
102
|
+
- **`bytes extraData`**: Untrusted extra data, provided by executor with the current message if needed. Otherwise, it's an empty bytes array.
|
|
103
|
+
|
|
104
|
+
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:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
const abi = new ethers.AbiCoder();
|
|
108
|
+
const encodedParameters = abi.encode(
|
|
109
|
+
['tuple(address,address,uint256,uint256,uint256,uint256,address,uint256)'],
|
|
110
|
+
[
|
|
111
|
+
[
|
|
112
|
+
EVM_TOKEN_A_ADDRESS,
|
|
113
|
+
EVM_TOKEN_B_ADDRESS,
|
|
114
|
+
amountA,
|
|
115
|
+
amountB,
|
|
116
|
+
amountAMin,
|
|
117
|
+
amountBMin,
|
|
118
|
+
UNISWAPV2_PROXY_ADDRESS,
|
|
119
|
+
deadline
|
|
120
|
+
]
|
|
121
|
+
]
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
More details in [sendAddLiquidity.ts](tests/uniswap_v2/sendAddLiquidity.ts) and in other tests.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Usage
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { TacSdk } from '@tonappchain/sdk';
|
|
132
|
+
import { TonConnectUI } from '@tonconnect/ui';
|
|
133
|
+
import { ethers } from 'ethers';
|
|
134
|
+
|
|
135
|
+
// Create EVM payload for DappProxy
|
|
136
|
+
const abi = new ethers.AbiCoder();
|
|
137
|
+
const encodedParameters = abi.encode(
|
|
138
|
+
['tuple(uint256,uint256,address[],address)'],
|
|
139
|
+
[
|
|
140
|
+
[
|
|
141
|
+
tokenAAmount,
|
|
142
|
+
tokenBAmount,
|
|
143
|
+
[EVMtokenAAddress, EVMtokenBAddress],
|
|
144
|
+
proxyDapp
|
|
145
|
+
]
|
|
146
|
+
]
|
|
147
|
+
);
|
|
148
|
+
const evmProxyMsg: EvmProxyMsg = {
|
|
149
|
+
evmTargetAddress: DappProxyAddress,
|
|
150
|
+
methodName: 'addLiquidity',
|
|
151
|
+
encodedParameters
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
|
|
155
|
+
const assets: AssetBridgingData[] = [
|
|
156
|
+
{
|
|
157
|
+
address: TVMtokenAAddress,
|
|
158
|
+
amount: tokenAAmount,
|
|
159
|
+
type: AssetType.FT,
|
|
160
|
+
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
address: TVMtokenBAddress,
|
|
164
|
+
amount: tokenBAmount,
|
|
165
|
+
type: AssetType.FT,
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
const sdkParams: SDKParams = {
|
|
170
|
+
network: Network.TESTNET
|
|
171
|
+
};
|
|
172
|
+
const tacSdk = await TacSdk.create(sdkParams);
|
|
173
|
+
|
|
174
|
+
//Send transaction via tonConnect or mnemonic
|
|
175
|
+
const tonConnectUI = new TonConnectUI({
|
|
176
|
+
manifestUrl: config.tonconnectManifestUrl as string
|
|
177
|
+
});
|
|
178
|
+
const sender = await SenderFactory.getSender({
|
|
179
|
+
tonConnect: tonConnectUI
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);
|
|
183
|
+
|
|
184
|
+
tacSdk.closeConnections();
|
|
185
|
+
```
|
|
186
|
+
For a detailed example, see `test/sendSwap.ts` or `test/sendRemoveLiquidity.ts`, which demonstrates swapping tokens and removing liquidity on Uniswap and tracking the transaction status.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
192
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export { OperationTracker } from './sdk/OperationTracker';
|
|
|
10
10
|
export { Simulator } from './sdk/Simulator';
|
|
11
11
|
export { startTracking, startTrackingMultiple } from './sdk/StartTracking';
|
|
12
12
|
export { TacSdk } from './sdk/TacSdk';
|
|
13
|
-
export { TONTransactionManager } from './sdk/TONTransactionManager';
|
|
14
13
|
export { TACTransactionManager } from './sdk/TACTransactionManager';
|
|
14
|
+
export { TONTransactionManager } from './sdk/TONTransactionManager';
|
|
15
15
|
export * from './sender';
|
|
16
16
|
export * from './structs/Struct';
|
|
17
17
|
export { Network, SimplifiedStatuses } from './structs/Struct';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.JettonWalletOpCodes = exports.JettonWallet = exports.HighloadWalletV3 = exports.readJettonMetadata = exports.SimplifiedStatuses = exports.Network = exports.
|
|
17
|
+
exports.JettonWalletOpCodes = exports.JettonWallet = exports.HighloadWalletV3 = exports.readJettonMetadata = exports.SimplifiedStatuses = exports.Network = exports.TONTransactionManager = exports.TACTransactionManager = exports.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.orbsOpener = exports.liteClientOpener = void 0;
|
|
18
18
|
var contractOpener_1 = require("./adapters/contractOpener");
|
|
19
19
|
Object.defineProperty(exports, "liteClientOpener", { enumerable: true, get: function () { return contractOpener_1.liteClientOpener; } });
|
|
20
20
|
Object.defineProperty(exports, "orbsOpener", { enumerable: true, get: function () { return contractOpener_1.orbsOpener; } });
|
|
@@ -39,10 +39,10 @@ Object.defineProperty(exports, "startTracking", { enumerable: true, get: functio
|
|
|
39
39
|
Object.defineProperty(exports, "startTrackingMultiple", { enumerable: true, get: function () { return StartTracking_1.startTrackingMultiple; } });
|
|
40
40
|
var TacSdk_1 = require("./sdk/TacSdk");
|
|
41
41
|
Object.defineProperty(exports, "TacSdk", { enumerable: true, get: function () { return TacSdk_1.TacSdk; } });
|
|
42
|
-
var TONTransactionManager_1 = require("./sdk/TONTransactionManager");
|
|
43
|
-
Object.defineProperty(exports, "TONTransactionManager", { enumerable: true, get: function () { return TONTransactionManager_1.TONTransactionManager; } });
|
|
44
42
|
var TACTransactionManager_1 = require("./sdk/TACTransactionManager");
|
|
45
43
|
Object.defineProperty(exports, "TACTransactionManager", { enumerable: true, get: function () { return TACTransactionManager_1.TACTransactionManager; } });
|
|
44
|
+
var TONTransactionManager_1 = require("./sdk/TONTransactionManager");
|
|
45
|
+
Object.defineProperty(exports, "TONTransactionManager", { enumerable: true, get: function () { return TONTransactionManager_1.TONTransactionManager; } });
|
|
46
46
|
__exportStar(require("./sender"), exports);
|
|
47
47
|
__exportStar(require("./structs/Struct"), exports);
|
|
48
48
|
var Struct_1 = require("./structs/Struct");
|
package/dist/sdk/Consts.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = exports.TRANSACTION_TON_AMOUNT = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
|
-
exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.
|
|
6
|
-
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.
|
|
7
|
-
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.
|
|
5
|
+
exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.55);
|
|
6
|
+
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
7
|
+
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
|
|
8
8
|
exports.MAX_ITERATION_COUNT = 120;
|
|
9
9
|
exports.DEFAULT_DELAY = 0;
|
|
10
10
|
exports.SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tonappchain/sdk",
|
|
3
|
-
"version": "0.7.0-
|
|
4
|
-
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
|
-
"author": "TAC. <developers@tac>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "rm -rf dist && tsc --declaration",
|
|
13
|
-
"test": "jest --verbose --runInBand",
|
|
14
|
-
"release": "yarn build && yarn release-it --npm.yarn1",
|
|
15
|
-
"lint": "eslint .",
|
|
16
|
-
"lint:fix": "eslint . --fix",
|
|
17
|
-
"prettier": "prettier --ignore-path .gitignore --write \"./src/**/*.+(js|ts|json)\""
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@aws-crypto/sha256-js": "^5.2.0",
|
|
21
|
-
"@orbs-network/ton-access": "^2.3.3",
|
|
22
|
-
"@ton/ton": "15.1.0",
|
|
23
|
-
"@tonappchain/agnostic-sdk": "0.0.9",
|
|
24
|
-
"@tonappchain/artifacts": "0.0.19-smart-accounts-7",
|
|
25
|
-
"@tonappchain/ton-lite-client": "3.0.6",
|
|
26
|
-
"@tonconnect/ui": "^2.0.11",
|
|
27
|
-
"bn.js": "^5.2.1",
|
|
28
|
-
"cli-table3": "^0.6.5",
|
|
29
|
-
"dotenv": "^16.4.7",
|
|
30
|
-
"ethers": "^6.13.5",
|
|
31
|
-
"ton-crypto": "^3.2.0"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [],
|
|
34
|
-
"description": "",
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@eslint/js": "^9.21.0",
|
|
37
|
-
"@jest/globals": "^29.7.0",
|
|
38
|
-
"@release-it/keep-a-changelog": "^6.0.0",
|
|
39
|
-
"@ton/sandbox": "^0.27.1",
|
|
40
|
-
"@ton/test-utils": "^0.5.0",
|
|
41
|
-
"@types/bn.js": "^5.1.6",
|
|
42
|
-
"@types/jest": "^29.5.14",
|
|
43
|
-
"eslint": "^9.21.0",
|
|
44
|
-
"eslint-config-prettier": "^10.0.2",
|
|
45
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
46
|
-
"jest": "^29.7.0",
|
|
47
|
-
"prettier": "^3.5.3",
|
|
48
|
-
"ts-jest": "^29.2.6",
|
|
49
|
-
"ts-node": "^10.9.2",
|
|
50
|
-
"typescript": "^5.7.3",
|
|
51
|
-
"typescript-eslint": "^8.17.0"
|
|
52
|
-
},
|
|
53
|
-
"publishConfig": {
|
|
54
|
-
"access": "public",
|
|
55
|
-
"registry": "https://registry.npmjs.org/"
|
|
56
|
-
},
|
|
57
|
-
"release-it": {
|
|
58
|
-
"plugins": {
|
|
59
|
-
"@release-it/keep-a-changelog": {
|
|
60
|
-
"filename": "CHANGELOG.md"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"npm": {
|
|
64
|
-
"publish": false
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tonappchain/sdk",
|
|
3
|
+
"version": "0.7.0-rc17",
|
|
4
|
+
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
|
+
"author": "TAC. <developers@tac>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rm -rf dist && tsc --declaration",
|
|
13
|
+
"test": "jest --verbose --runInBand",
|
|
14
|
+
"release": "yarn build && yarn release-it --npm.yarn1",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"lint:fix": "eslint . --fix",
|
|
17
|
+
"prettier": "prettier --ignore-path .gitignore --write \"./src/**/*.+(js|ts|json)\""
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@aws-crypto/sha256-js": "^5.2.0",
|
|
21
|
+
"@orbs-network/ton-access": "^2.3.3",
|
|
22
|
+
"@ton/ton": "15.1.0",
|
|
23
|
+
"@tonappchain/agnostic-sdk": "0.0.9",
|
|
24
|
+
"@tonappchain/artifacts": "0.0.19-smart-accounts-7",
|
|
25
|
+
"@tonappchain/ton-lite-client": "3.0.6",
|
|
26
|
+
"@tonconnect/ui": "^2.0.11",
|
|
27
|
+
"bn.js": "^5.2.1",
|
|
28
|
+
"cli-table3": "^0.6.5",
|
|
29
|
+
"dotenv": "^16.4.7",
|
|
30
|
+
"ethers": "^6.13.5",
|
|
31
|
+
"ton-crypto": "^3.2.0"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [],
|
|
34
|
+
"description": "",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@eslint/js": "^9.21.0",
|
|
37
|
+
"@jest/globals": "^29.7.0",
|
|
38
|
+
"@release-it/keep-a-changelog": "^6.0.0",
|
|
39
|
+
"@ton/sandbox": "^0.27.1",
|
|
40
|
+
"@ton/test-utils": "^0.5.0",
|
|
41
|
+
"@types/bn.js": "^5.1.6",
|
|
42
|
+
"@types/jest": "^29.5.14",
|
|
43
|
+
"eslint": "^9.21.0",
|
|
44
|
+
"eslint-config-prettier": "^10.0.2",
|
|
45
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"prettier": "^3.5.3",
|
|
48
|
+
"ts-jest": "^29.2.6",
|
|
49
|
+
"ts-node": "^10.9.2",
|
|
50
|
+
"typescript": "^5.7.3",
|
|
51
|
+
"typescript-eslint": "^8.17.0"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public",
|
|
55
|
+
"registry": "https://registry.npmjs.org/"
|
|
56
|
+
},
|
|
57
|
+
"release-it": {
|
|
58
|
+
"plugins": {
|
|
59
|
+
"@release-it/keep-a-changelog": {
|
|
60
|
+
"filename": "CHANGELOG.md"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"npm": {
|
|
64
|
+
"publish": false
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
68
|
+
}
|