@tonappchain/sdk 0.7.0 → 0.7.1-frost-test-1
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 +198 -198
- package/dist/artifacts/dev/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.d.ts +12 -1
- package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.js +32 -4
- package/dist/src/assets/AssetFactory.js +3 -2
- package/dist/src/assets/TON.d.ts +1 -0
- package/dist/src/assets/TON.js +5 -1
- package/dist/src/sdk/TONTransactionManager.js +1 -1
- package/package.json +2 -3
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
|
-
[](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
|
-
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
|
+
[](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
|
+
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "hash": "
|
|
1
|
+
{ "hash": "fcba43aae4865dab529e192843faa1c0e716bc81088d23c5023b793ca5b73a69", "hashBase64": "/LpDquSGXatSnhkoQ/qhwOcWvIEIjSPFAjt5PKW3Omk=", "hex": "b5ee9c7241023201000efe000114ff00f4a413f4bcf2c80b01020120022e02014803240168d0eda2edfb20c700925f04e001d0d3030171b0925f04e0fa40fa4031fa0031f401fa0031fa00013170f83a02d31f0101d33f01120401b8ed44d0fa4001f861fa4001f862fa4001f863d401d0d3ff0131f864d401d0fa0001f86dfa0001f86cfa0030f86ed401f86fd430d0d32f01f86bd32f01f867d32f01f868d32f01f869d32f01f86ad30301f865f40430f8665365a1f8460504aef80701830cf94130f8075003a101a655820086e65003a0128209e1338070f8370170f836a066b608a1a6645166a122821048e660b5bae3022282106c582059bae3002282100e50d313bae302303435248210cf6a5da4ba06070d1600c46c7181193c70f8365cbcf2e064f84e59a1a0f86ef846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed5402fe03d31ffa00f404fa4055302170547000246ec0008e156c3101d0d300fa00fa0023963403fa0030039130e29134e255027f266ec000f84df84c5007a816a05240b915b0927034de5320a022a027a02e81354470f836a0a052c0be5240b0e30210365f06288014fb02c88210ae7df95b2502cb1fcb3f12cb1f22cf16c9702702080c02fc3339393a3b5266a05008a05008a026a08014fb02f84e5004a0f86ef846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54216ec00092316de30d05c8cb1f2101cb3f5003cf16090a001a01c8f400f84dfa02f84cfa02c901fe5003fa0213f40001cf16c982106c582059017f830771800cc8cb03cb01cb0813cbff02957158cb61cc987058cb6101d0cf16e2c98010fb0021d70b01c000b38e3bc88210d53276db5802cb1fcb3fc970018010810082226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb00915be20b0004db3100748010810082226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb00f80fc000938100cc928064e2f2f00303ee323501fa40d4d4f828f84f52300270705003c85003cf168b02cf16ca00ccc921c8cb0113f40012f400cb00c97001f90074c8cb0212ca07cbffc9d05006c705f2e04701d7393078d721d3ff0131f8468307f40e6fa131f2e0c920d0f404f401fa40fa003020c300935b3234e30ddb3c5222a1c200f2e0640e111402f8280441381523d70b01c0008e64aa00814cfb70f836a0738103b582100966018070f837a0801c8127e08209e1338070f837a0a47020c88210d7b9c06e580802cb1fcb3f23cf165004fa0258cf1671fa0214cb00cb00c970c87001ca0012cccb00c9c87001cbff58cf1658fa02ccc9c8ccc9e30d218307f48e6fa56c120f10003e306c2270c8c9c87f01ca00cccb00c9c87001cbff58cf1658fa02ccc9c8ccc9001a91a4923070e201d0028307f41602f670207f8ef6238307f47c6fa5208ee702d430d0d3ff0130fa40fa00d430d0d2000101d4f40430206e8e2e3054232080108011226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb008e90c802d012cf162310355980108011db3ce2019213a09414a04313e2029132e201b3121300a28e4dc85801cb055005cf165003fa0254712323ed41ed43ed44ed45ed479f5bc85003cf17c913775003cb6bcccced67ed65ed64ed63ed61747fed11987601cb6bcc01cf17ed41edf101f2ffc901fb00db060008e6306c1201fef846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed5482100e50d31350047f830771800cc8cb03cb01cb0813cbff02957158cb61cc987058cb6101d0cf16e2c98010fb0014a1011500b2a1f84e5210bef2e0658010fb0201fa403020d70b01c000b38e3cc88210d53276db580302cb1fcb3fc970018010810082226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb00915be204fe8ffd3403d4f828f84f52300270705003c85003cf168b02cf16ca00ccc921c8cb0113f40012f400cb00c97001f90074c8cb0212ca07cbffc9d05005c705f2e047028014fb0202fa40308210cf6a5da4587f830771800cc8cb03cb01cb0813cbff02957158cb61cc987058cb6101d0cf16e2c98010fb0020d70b01c000b3e30f171831190078c88210ae7df95b580302cb1fcb3fc970018010810082226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb0000025b02f8e0248210da524dc5ba8e633233f84313c705f2e04801d3ff0131f8648014fb02f846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54e0332382101f95f86cbae30231221a1b019a135f03f84ec300f2e0c8c88210f358b6d05802cb1fcb3ff84efa02c9f841f84e58801072226eb32091719170e2c8500401cb055006cf165004fa02cb6a039358cc019130e201c901fb0070f86e3103f68210063199b7ba8e5c32f84112c705f2e046fa0030f86cf846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54e02282103531465cbae3022282105cec6be0bae302221c1d1e00b832f84112c705f2e046fa0030f86df846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed5400b832f84112c705f2e046fa4030f863f846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed5402f48210581879bcba8e6532f84112c705f2e046fa4030f862f8428b02c705f2d050f846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54e022821060094a1bbae302221f2000b66c21f841c705f2e0468b02f862f846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed5403fc82106a4fbe34ba8e5f6c21f842c705f2e049f842f8618b02f862f846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54e022821020faec53bae3022282107ee5a6d0bae30222212223002e32f84112c705f2e046d421fb0401d0ed1eed53d430ed54017c32f84112c705f2e046d430f86f6df86682107ee5a6d0c8c970830771800cc8cb03cb01cb0813cbff02957158cb61cc987058cb6101d0cf16e2c98010fb003100e88210e97250b7ba8e5d32f84112c705f2e046d32f0131f86bf846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed54e05b8210d53276dbbadc840ff2f00201202529020158262700efb444bda89a1f48003f0c3f48003f0c5f48003f0c7a803a1a7fe0263f0c9a803a1f40003f0dbf40003f0d9f40061f0dda803f0dfa861a1a65e03f0d7a65e03f0cfa65e03f0d1a65e03f0d3a65e03f0d5a60603f0cbe80861f0cdf083f085f087f089f08bf08df08ff091f093f097f095f09bf099f09df09f001b3b4817da89a1f48003f0c3f48003f0c5f48003f0c7a803a1a7fe0263f0c9a803a1f40003f0dbf40003f0d9f40061f0dda803f0dfa861a1a65e03f0d7a65e03f0cfa65e03f0d1a65e03f0d3a65e03f0d5a60603f0cbe80861f0cd02800707020f8468307f4866fa5908e1801d32f01315303bc946c2251109130e2f8468307f47c6fa5e810235f03f847f848f849f84af84bf845f8440201202a2c01fbb9685ed44d0fa4001f861fa4001f862fa4001f863d401d0d3ff0131f864d401d0fa0001f86dfa0001f86cfa0030f86ed401f86fd430d0d32f01f86bd32f01f867d32f01f868d32f01f869d32f01f86ad30301f865f40430f866f828f84f120270705003c85003cf168b02cf16ca00ccc921c8cb0113f40012f400cb00c982b0022207001f90074c8cb0212ca07cbffc9d00101fbbb316ed44d0fa4001f861fa4001f862fa4001f863d401d0d3ff0131f864d401d0fa0001f86dfa0001f86cfa0030f86ed401f86fd430d0d32f01f86bd32f01f867d32f01f868d32f01f869d32f01f86ad30301f865f40430f866f828f84f120270705003c85003cf168b02cf16ca00ccc921c8cb0113f40012f400cb00c982d001e7001f90074c8cb0212ca07cbffc9d001f6f220c7009130e0d31f01821023b05641bd94840ff2f0de8308d71820f901ed44d0fa4001f861fa4001f862fa4001f863d401d0d3ff0131f864d401d0fa0001f86dfa0001f86cfa0030f86ed401f86fd430d0d32f01f86bd32f01f867d32f01f868d32f01f869d32f01f86ad30301f865f40430f86601d3ff01f8442f01fe5e21f910f2a0f84901d32f0131f869f823f849bef2e0cdf849f84abef2e0cbf800f848f867f823f868f848f84ba0f86af823f845f84ba8a1f8468307f4866fa5908e1c01d32f013122bb9bf84652108307f45b30f866def8468307f47c6fa5e85f03c8f84a01cb2fc9d0f84652308307f416f866c85801cbff0101cb2ff84930018001cb2ff84701cb2ff84801cb2ff84a01cb2fc9821023b05641017f830771800cc8cb03cb01cb0813cbff02957158cb61cc987058cb6101d0cf16e2c98010fb0031009cf846f845c8f84b01cb2ff84701cb2ff84801cb2ff84901cb2ff84a01cb2fcb03f400c9f84fc8f84dfa02f84cfa02f84efa02c9c8f84401cbffc9c8f841cf16f842cf16f843cf16ccccccccc9ed544651d34d" }
|
|
@@ -5,6 +5,7 @@ export type CrossChainLayerConfig = {
|
|
|
5
5
|
adminAddress: string;
|
|
6
6
|
newAdminAddress?: string;
|
|
7
7
|
sequencerMultisigAddress: string;
|
|
8
|
+
groupPublicKey?: bigint;
|
|
8
9
|
maxRootsSize: number;
|
|
9
10
|
merkleRoots?: MerkleRoot[];
|
|
10
11
|
prevEpoch?: number;
|
|
@@ -25,6 +26,7 @@ export type EpochInfo = {
|
|
|
25
26
|
messageCollectEndTime: number;
|
|
26
27
|
nextVotingTime: number;
|
|
27
28
|
epochDelay: number;
|
|
29
|
+
groupPublicKey: bigint;
|
|
28
30
|
};
|
|
29
31
|
export type ExecutorData = {
|
|
30
32
|
address: Address;
|
|
@@ -57,6 +59,7 @@ export declare const CrossChainLayerOpCodes: {
|
|
|
57
59
|
newAdmin_confirmChangingAdminAddress: number;
|
|
58
60
|
sequencerMultisig_changeSequencerMultisigAddress: number;
|
|
59
61
|
sequencerMultisig_updateMerkleRoot: number;
|
|
62
|
+
sequencerMultisig_updateGroupPublicKey: number;
|
|
60
63
|
};
|
|
61
64
|
export declare const CrossChainLayerErrors: {
|
|
62
65
|
noErrors: number;
|
|
@@ -73,6 +76,9 @@ export declare const CrossChainLayerErrors: {
|
|
|
73
76
|
votingNotActive: number;
|
|
74
77
|
messageCollectEndTimeLow: number;
|
|
75
78
|
notEnoughProtocolFee: number;
|
|
79
|
+
messageCollectEndTimeHigh: number;
|
|
80
|
+
invalidSenderSignature: number;
|
|
81
|
+
unknownOp: number;
|
|
76
82
|
};
|
|
77
83
|
export declare function crossChainLayerConfigToCell(config: CrossChainLayerConfig): Cell;
|
|
78
84
|
export declare class CrossChainLayer implements Contract {
|
|
@@ -111,7 +117,12 @@ export declare class CrossChainLayer implements Contract {
|
|
|
111
117
|
payload: Cell;
|
|
112
118
|
responseAddress: Address;
|
|
113
119
|
}): Promise<void>;
|
|
114
|
-
|
|
120
|
+
sendUpdateGroupPublicKey(provider: ContractProvider, via: Sender, value: bigint, opts: {
|
|
121
|
+
queryId?: number;
|
|
122
|
+
groupPublicKey: bigint;
|
|
123
|
+
}): Promise<void>;
|
|
124
|
+
buildSignedUpdateMerkleRoot(secretKey: Buffer, merkleRoot: bigint, messageCollectEndTime: number): Cell;
|
|
125
|
+
sendUpdateMerkleRoot(provider: ContractProvider, secretKey: Buffer, opts: {
|
|
115
126
|
queryId?: number;
|
|
116
127
|
merkleRoot: bigint;
|
|
117
128
|
messageCollectEndTime: number;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CrossChainLayer = exports.CrossChainLayerErrors = exports.CrossChainLayerOpCodes = exports.MsgType = void 0;
|
|
4
4
|
exports.crossChainLayerConfigToCell = crossChainLayerConfigToCell;
|
|
5
5
|
const core_1 = require("@ton/core");
|
|
6
|
+
const crypto_1 = require("@ton/crypto");
|
|
6
7
|
const Constants_1 = require("./Constants");
|
|
7
8
|
const GasUtils_1 = require("./utils/GasUtils");
|
|
8
9
|
const MerkleRoots_1 = require("./utils/MerkleRoots");
|
|
@@ -34,6 +35,7 @@ exports.CrossChainLayerOpCodes = {
|
|
|
34
35
|
newAdmin_confirmChangingAdminAddress: 0x6a4fbe34,
|
|
35
36
|
sequencerMultisig_changeSequencerMultisigAddress: 0x5cec6be0,
|
|
36
37
|
sequencerMultisig_updateMerkleRoot: 0x23b05641,
|
|
38
|
+
sequencerMultisig_updateGroupPublicKey: 0xda524dc5,
|
|
37
39
|
};
|
|
38
40
|
exports.CrossChainLayerErrors = {
|
|
39
41
|
noErrors: 0,
|
|
@@ -50,6 +52,9 @@ exports.CrossChainLayerErrors = {
|
|
|
50
52
|
votingNotActive: 202,
|
|
51
53
|
messageCollectEndTimeLow: 203,
|
|
52
54
|
notEnoughProtocolFee: 204,
|
|
55
|
+
messageCollectEndTimeHigh: 205,
|
|
56
|
+
invalidSenderSignature: 32,
|
|
57
|
+
unknownOp: 0xfffff,
|
|
53
58
|
};
|
|
54
59
|
function crossChainLayerConfigToCell(config) {
|
|
55
60
|
return (0, core_1.beginCell)()
|
|
@@ -57,6 +62,9 @@ function crossChainLayerConfigToCell(config) {
|
|
|
57
62
|
.storeAddress(config.newAdminAddress ? core_1.Address.parse(config.newAdminAddress) : null)
|
|
58
63
|
.storeAddress(core_1.Address.parse(config.sequencerMultisigAddress))
|
|
59
64
|
.storeRef((0, core_1.beginCell)()
|
|
65
|
+
.storeUint(config.groupPublicKey ? config.groupPublicKey : 0n, Constants_1.Params.bitsize.hash)
|
|
66
|
+
.endCell())
|
|
67
|
+
.storeRef((0, core_1.beginCell)()
|
|
60
68
|
.storeCoins(config.tacProtocolFee ? (0, core_1.toNano)(config.tacProtocolFee.toFixed(9)) : 0)
|
|
61
69
|
.storeCoins(config.tonProtocolFee ? (0, core_1.toNano)(config.tonProtocolFee.toFixed(9)) : 0)
|
|
62
70
|
.storeCoins(config.protocolFeeSupply ? (0, core_1.toNano)(config.protocolFeeSupply.toFixed(9)) : 0)
|
|
@@ -134,18 +142,34 @@ class CrossChainLayer {
|
|
|
134
142
|
.endCell(),
|
|
135
143
|
});
|
|
136
144
|
}
|
|
137
|
-
async
|
|
145
|
+
async sendUpdateGroupPublicKey(provider, via, value, opts) {
|
|
138
146
|
await provider.internal(via, {
|
|
139
147
|
value,
|
|
140
148
|
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
141
149
|
body: (0, core_1.beginCell)()
|
|
142
|
-
.storeUint(exports.CrossChainLayerOpCodes.
|
|
150
|
+
.storeUint(exports.CrossChainLayerOpCodes.sequencerMultisig_updateGroupPublicKey, Constants_1.Params.bitsize.op)
|
|
143
151
|
.storeUint(opts.queryId || 0, Constants_1.Params.bitsize.queryId)
|
|
144
|
-
.storeUint(opts.
|
|
145
|
-
.storeUint(opts.messageCollectEndTime, Constants_1.Params.bitsize.time)
|
|
152
|
+
.storeUint(opts.groupPublicKey, Constants_1.Params.bitsize.hash)
|
|
146
153
|
.endCell(),
|
|
147
154
|
});
|
|
148
155
|
}
|
|
156
|
+
buildSignedUpdateMerkleRoot(secretKey, merkleRoot, messageCollectEndTime) {
|
|
157
|
+
let msg = (0, core_1.beginCell)()
|
|
158
|
+
.storeUint(merkleRoot, Constants_1.Params.bitsize.hash)
|
|
159
|
+
.storeUint(messageCollectEndTime, Constants_1.Params.bitsize.time)
|
|
160
|
+
.endCell();
|
|
161
|
+
let signature = (0, crypto_1.sign)(msg.hash(), secretKey);
|
|
162
|
+
msg = (0, core_1.beginCell)()
|
|
163
|
+
.storeUint(exports.CrossChainLayerOpCodes.sequencerMultisig_updateMerkleRoot, 32)
|
|
164
|
+
.storeBuffer(signature)
|
|
165
|
+
.storeSlice(msg.asSlice())
|
|
166
|
+
.endCell();
|
|
167
|
+
return msg;
|
|
168
|
+
}
|
|
169
|
+
async sendUpdateMerkleRoot(provider, secretKey, opts) {
|
|
170
|
+
const msg = this.buildSignedUpdateMerkleRoot(secretKey, opts.merkleRoot, opts.messageCollectEndTime);
|
|
171
|
+
await provider.external(msg);
|
|
172
|
+
}
|
|
149
173
|
async sendAddProtocolFee(provider, via, value, opts) {
|
|
150
174
|
await provider.internal(via, {
|
|
151
175
|
value,
|
|
@@ -269,6 +293,7 @@ class CrossChainLayer {
|
|
|
269
293
|
const adminAddress = result.stack.readAddress().toString();
|
|
270
294
|
const newAdminAddress = result.stack.readAddressOpt()?.toString();
|
|
271
295
|
const sequencerMultisigAddress = result.stack.readAddress().toString();
|
|
296
|
+
const groupPublicKey = result.stack.readBigNumber();
|
|
272
297
|
const maxRootsSize = result.stack.readNumber();
|
|
273
298
|
const merkleRoots = result.stack.readCellOpt();
|
|
274
299
|
const prevEpoch = result.stack.readNumber();
|
|
@@ -284,6 +309,7 @@ class CrossChainLayer {
|
|
|
284
309
|
adminAddress,
|
|
285
310
|
newAdminAddress,
|
|
286
311
|
sequencerMultisigAddress,
|
|
312
|
+
groupPublicKey,
|
|
287
313
|
maxRootsSize,
|
|
288
314
|
merkleRoots: (0, MerkleRoots_1.cellToArray)(merkleRoots),
|
|
289
315
|
prevEpoch,
|
|
@@ -306,6 +332,7 @@ class CrossChainLayer {
|
|
|
306
332
|
const nextVotingTime = result.stack.readNumber();
|
|
307
333
|
const epochDelay = result.stack.readNumber();
|
|
308
334
|
const maxRootsSize = result.stack.readNumber();
|
|
335
|
+
const groupPublicKey = result.stack.readBigNumber();
|
|
309
336
|
return {
|
|
310
337
|
lastMerkleRoot,
|
|
311
338
|
prevEpoch,
|
|
@@ -314,6 +341,7 @@ class CrossChainLayer {
|
|
|
314
341
|
nextVotingTime,
|
|
315
342
|
epochDelay,
|
|
316
343
|
maxRootsSize,
|
|
344
|
+
groupPublicKey,
|
|
317
345
|
};
|
|
318
346
|
}
|
|
319
347
|
async getExecutorAddress(provider, payload) {
|
|
@@ -25,8 +25,9 @@ class AssetFactory {
|
|
|
25
25
|
return asset;
|
|
26
26
|
}
|
|
27
27
|
static async createFTAsset(configuration, address) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const ton = TON_1.TON.create(configuration);
|
|
29
|
+
if (address === configuration.nativeTONAddress || address === '' || address === (await ton.getEVMAddress())) {
|
|
30
|
+
return ton;
|
|
30
31
|
}
|
|
31
32
|
return FT_1.FT.fromAddress(configuration, address);
|
|
32
33
|
}
|
package/dist/src/assets/TON.d.ts
CHANGED
package/dist/src/assets/TON.js
CHANGED
|
@@ -12,6 +12,7 @@ class TON {
|
|
|
12
12
|
this.address = '';
|
|
13
13
|
this._config = config;
|
|
14
14
|
this._rawAmount = 0n;
|
|
15
|
+
this.evmAddress = '';
|
|
15
16
|
}
|
|
16
17
|
static create(config) {
|
|
17
18
|
return new TON(config);
|
|
@@ -51,7 +52,10 @@ class TON {
|
|
|
51
52
|
return this;
|
|
52
53
|
}
|
|
53
54
|
async getEVMAddress() {
|
|
54
|
-
|
|
55
|
+
if (this.evmAddress === '') {
|
|
56
|
+
this.evmAddress = await this._config.TACParams.tokenUtils.computeAddress(this._config.nativeTONAddress);
|
|
57
|
+
}
|
|
58
|
+
return this.evmAddress;
|
|
55
59
|
}
|
|
56
60
|
async getTVMAddress() {
|
|
57
61
|
return '';
|
|
@@ -208,7 +208,7 @@ class TONTransactionManager {
|
|
|
208
208
|
this.logger.debug(`Operation IDs: ${(0, Utils_1.formatObjectForLogging)(operationIds)}`);
|
|
209
209
|
return transactionLinkers.map((linker) => ({
|
|
210
210
|
...linker,
|
|
211
|
-
operationId: operationIds[linker.shardsKey].operationIds
|
|
211
|
+
operationId: operationIds[linker.shardsKey].operationIds[0],
|
|
212
212
|
}));
|
|
213
213
|
}
|
|
214
214
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonappchain/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-frost-test-1",
|
|
4
4
|
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
5
|
"author": "TAC. <developers@tac>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
51
|
"scripts": {
|
|
52
|
-
"prebuild": "git submodule update --init --recursive",
|
|
53
52
|
"litebuild": "rm -rf dist && tsc --declaration",
|
|
54
53
|
"build": "rm -rf dist && npm run build:artifacts && tsc --declaration",
|
|
55
54
|
"build:artifacts:tac:dev": "cd artifacts/dev/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"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
60
|
"build:artifacts:ton:all": "npm run build:artifacts:ton:dev && npm run build:artifacts:ton:testnet && npm run build:artifacts:ton:mainnet",
|
|
62
61
|
"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
|
|
62
|
+
"build:artifacts": "npm run build:artifacts:ton:all && npm run build:artifacts:tac:all",
|
|
64
63
|
"test": "jest --verbose --runInBand",
|
|
65
64
|
"release": "yarn build && yarn release-it --npm.yarn1",
|
|
66
65
|
"lint": "eslint .",
|