@tonappchain/sdk 0.6.4 → 0.7.0-rc6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/adapters/contractOpener.d.ts +1 -1
  2. package/dist/adapters/contractOpener.js +7 -8
  3. package/dist/adapters/retryableContractOpener.d.ts +21 -0
  4. package/dist/adapters/retryableContractOpener.js +101 -0
  5. package/dist/assets/AssetFactory.d.ts +13 -0
  6. package/dist/assets/AssetFactory.js +73 -0
  7. package/dist/assets/FT.d.ts +58 -0
  8. package/dist/assets/FT.js +199 -0
  9. package/dist/assets/NFT.d.ts +60 -0
  10. package/dist/assets/NFT.js +170 -0
  11. package/dist/assets/TON.d.ts +38 -0
  12. package/dist/assets/TON.js +91 -0
  13. package/dist/assets/index.d.ts +4 -0
  14. package/dist/assets/index.js +11 -0
  15. package/dist/errors/errors.d.ts +6 -0
  16. package/dist/errors/errors.js +15 -1
  17. package/dist/errors/index.d.ts +2 -2
  18. package/dist/errors/index.js +26 -21
  19. package/dist/errors/instances.d.ts +9 -4
  20. package/dist/errors/instances.js +19 -5
  21. package/dist/index.d.ts +12 -6
  22. package/dist/index.js +24 -13
  23. package/dist/sdk/Configuration.d.ts +21 -0
  24. package/dist/sdk/Configuration.js +90 -0
  25. package/dist/sdk/Consts.js +2 -2
  26. package/dist/sdk/LiteSequencerClient.d.ts +1 -1
  27. package/dist/sdk/LiteSequencerClient.js +5 -11
  28. package/dist/sdk/Logger.d.ts +13 -0
  29. package/dist/sdk/Logger.js +25 -0
  30. package/dist/sdk/OperationTracker.d.ts +21 -6
  31. package/dist/sdk/OperationTracker.js +155 -75
  32. package/dist/sdk/Simulator.d.ts +23 -0
  33. package/dist/sdk/Simulator.js +169 -0
  34. package/dist/sdk/StartTracking.d.ts +6 -0
  35. package/dist/sdk/StartTracking.js +66 -29
  36. package/dist/sdk/TacSdk.d.ts +12 -41
  37. package/dist/sdk/TacSdk.js +69 -717
  38. package/dist/sdk/TransactionManager.d.ts +22 -0
  39. package/dist/sdk/TransactionManager.js +257 -0
  40. package/dist/sdk/TxFinalizer.d.ts +10 -0
  41. package/dist/sdk/TxFinalizer.js +104 -0
  42. package/dist/sdk/Utils.d.ts +12 -4
  43. package/dist/sdk/Utils.js +80 -16
  44. package/dist/sdk/Validator.d.ts +9 -0
  45. package/dist/sdk/Validator.js +43 -0
  46. package/dist/sender/BatchSender.d.ts +7 -4
  47. package/dist/sender/BatchSender.js +18 -6
  48. package/dist/sender/RawSender.d.ts +9 -4
  49. package/dist/sender/RawSender.js +46 -18
  50. package/dist/sender/SenderAbstraction.d.ts +5 -3
  51. package/dist/sender/SenderFactory.d.ts +1 -1
  52. package/dist/sender/SenderFactory.js +5 -4
  53. package/dist/sender/TonConnectSender.d.ts +5 -3
  54. package/dist/sender/TonConnectSender.js +12 -8
  55. package/dist/sender/index.d.ts +1 -1
  56. package/dist/sender/index.js +1 -1
  57. package/dist/structs/InternalStruct.d.ts +36 -33
  58. package/dist/structs/Services.d.ts +40 -0
  59. package/dist/structs/Services.js +2 -0
  60. package/dist/structs/Struct.d.ts +98 -79
  61. package/dist/structs/Struct.js +11 -1
  62. package/dist/wrappers/HighloadQueryId.js +0 -1
  63. package/dist/wrappers/HighloadWalletV3.d.ts +3 -2
  64. package/dist/wrappers/HighloadWalletV3.js +5 -2
  65. package/dist/wrappers/JettonWallet.d.ts +11 -2
  66. package/dist/wrappers/JettonWallet.js +34 -17
  67. package/package.json +3 -3
@@ -1,749 +1,101 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.TacSdk = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const ton_1 = require("@ton/ton");
9
- const ethers_1 = require("ethers");
10
- // import structs
11
37
  const Struct_1 = require("../structs/Struct");
12
- // import internal structs
13
- const InternalStruct_1 = require("../structs/InternalStruct");
14
- // jetton imports
15
- const JettonMaster_1 = require("../wrappers/JettonMaster");
16
- const JettonWallet_1 = require("../wrappers/JettonWallet");
17
- // ton settings
18
- const Settings_1 = require("../wrappers/Settings");
38
+ const Configuration_1 = require("./Configuration");
19
39
  const Consts_1 = require("./Consts");
20
- const Utils_1 = require("./Utils");
21
- const artifacts_1 = require("@tonappchain/artifacts");
22
- const errors_1 = require("../errors");
23
- const wrappers_1 = require("@tonappchain/artifacts/dist/src/ton/wrappers");
24
- const instances_1 = require("../errors/instances");
40
+ const Logger_1 = require("./Logger");
41
+ const OperationTracker_1 = require("./OperationTracker");
42
+ const Simulator_1 = require("./Simulator");
43
+ const TransactionManager_1 = require("./TransactionManager");
25
44
  class TacSdk {
26
- constructor(network, delay, artifacts, TONParams, TACParams, liteSequencerEndpoints) {
27
- this.network = network;
28
- this.delay = delay;
29
- this.artifacts = artifacts;
30
- this.TONParams = TONParams;
31
- this.TACParams = TACParams;
32
- this.liteSequencerEndpoints = liteSequencerEndpoints;
45
+ constructor(config, simulator, transactionManager) {
46
+ this.config = config;
47
+ this.simulator = simulator;
48
+ this.transactionManager = transactionManager;
33
49
  }
34
- static async create(sdkParams) {
50
+ static async create(sdkParams, logger = new Logger_1.NoopLogger()) {
35
51
  const network = sdkParams.network;
36
52
  const delay = sdkParams.delay ?? Consts_1.DEFAULT_DELAY;
37
- const artifacts = network === Struct_1.Network.TESTNET ? artifacts_1.testnet : artifacts_1.mainnet;
38
- const TONParams = await this.prepareTONParams(network, delay, artifacts, sdkParams.TONParams);
39
- const TACParams = await this.prepareTACParams(artifacts, delay, sdkParams.TACParams);
40
- const liteSequencerEndpoints = sdkParams.customLiteSequencerEndpoints ??
41
- (network === Struct_1.Network.TESTNET
42
- ? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
43
- : artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
44
- return new TacSdk(network, delay, artifacts, TONParams, TACParams, liteSequencerEndpoints);
45
- }
46
- static async prepareTONParams(network, delay, artifacts, TONParams) {
47
- const contractOpener = TONParams?.contractOpener ??
48
- new ton_1.TonClient({
49
- endpoint: network == Struct_1.Network.TESTNET
50
- ? new URL('api/v2/jsonRPC', artifacts_1.testnet.TON_RPC_ENDPOINT_BY_TAC).toString()
51
- : artifacts_1.mainnet.TON_PUBLIC_RPC_ENDPOINT,
52
- });
53
- const settingsAddress = TONParams?.settingsAddress ?? artifacts.ton.addresses.TON_SETTINGS_ADDRESS;
54
- const settings = contractOpener.open(new Settings_1.Settings(ton_1.Address.parse(settingsAddress)));
55
- const jettonProxyAddress = await settings.getAddressSetting('JettonProxyAddress');
56
- await (0, Utils_1.sleep)(delay * 1000);
57
- const crossChainLayerAddress = await settings.getAddressSetting('CrossChainLayerAddress');
58
- await (0, Utils_1.sleep)(delay * 1000);
59
- const jettonMinterCode = await settings.getCellSetting('JettonMinterCode');
60
- await (0, Utils_1.sleep)(delay * 1000);
61
- const jettonWalletCode = await settings.getCellSetting('JettonWalletCode');
62
- await (0, Utils_1.sleep)(delay * 1000);
63
- const nftProxyAddress = await settings.getAddressSetting('NFTProxyAddress');
64
- await (0, Utils_1.sleep)(delay * 1000);
65
- const nftItemCode = await settings.getCellSetting('NFTItemCode');
66
- await (0, Utils_1.sleep)(delay * 1000);
67
- const nftCollectionCode = await settings.getCellSetting('NFTCollectionCode');
68
- await (0, Utils_1.sleep)(delay * 1000);
69
- return {
70
- contractOpener,
71
- jettonProxyAddress,
72
- crossChainLayerAddress,
73
- jettonMinterCode,
74
- jettonWalletCode,
75
- nftProxyAddress,
76
- nftItemCode,
77
- nftCollectionCode,
78
- };
79
- }
80
- static async prepareTACParams(artifacts, delay, TACParams) {
81
- const provider = TACParams?.provider ?? ethers_1.ethers.getDefaultProvider(artifacts.TAC_RPC_ENDPOINT);
82
- const settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.tac.addresses.TAC_SETTINGS_ADDRESS;
83
- const settings = artifacts.tac.wrappers.SettingsFactoryTAC.connect(settingsAddress, provider);
84
- const crossChainLayerABI = TACParams?.crossChainLayerABI ?? artifacts.tac.compilationArtifacts.CrossChainLayer.abi;
85
- const crossChainLayerAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress')));
86
- const crossChainLayer = artifacts.tac.wrappers.CrossChainLayerFactoryTAC.connect(crossChainLayerAddress, provider);
87
- await (0, Utils_1.sleep)(delay * 1000);
88
- const tokenUtilsAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress')));
89
- const tokenUtils = artifacts.tac.wrappers.TokenUtilsFactoryTAC.connect(tokenUtilsAddress, provider);
90
- await (0, Utils_1.sleep)(delay * 1000);
91
- const trustedTACExecutors = await settings.getTrustedEVMExecutors();
92
- await (0, Utils_1.sleep)(delay * 1000);
93
- const trustedTONExecutors = await settings.getTrustedTVMExecutors();
94
- const crossChainLayerTokenABI = TACParams?.crossChainLayerTokenABI ?? artifacts.tac.compilationArtifacts.CrossChainLayerToken.abi;
95
- const crossChainLayerTokenBytecode = TACParams?.crossChainLayerTokenBytecode ?? artifacts.tac.compilationArtifacts.CrossChainLayerToken.bytecode;
96
- const crossChainLayerNFTABI = TACParams?.crossChainLayerNFTABI ?? artifacts.tac.compilationArtifacts.CrossChainLayerNFT.abi;
97
- const crossChainLayerNFTBytecode = TACParams?.crossChainLayerNFTBytecode ?? artifacts.tac.compilationArtifacts.CrossChainLayerNFT.bytecode;
98
- return {
99
- provider,
100
- settings,
101
- tokenUtils,
102
- crossChainLayer,
103
- trustedTACExecutors,
104
- trustedTONExecutors,
105
- abiCoder: new ethers_1.ethers.AbiCoder(),
106
- crossChainLayerABI,
107
- crossChainLayerTokenABI,
108
- crossChainLayerTokenBytecode,
109
- crossChainLayerNFTABI,
110
- crossChainLayerNFTBytecode,
111
- };
53
+ const { testnet, mainnet } = await Promise.resolve().then(() => __importStar(require('@tonappchain/artifacts')));
54
+ const artifacts = network === Struct_1.Network.TESTNET ? testnet : mainnet;
55
+ const config = await Configuration_1.Configuration.create(network, artifacts, sdkParams.TONParams, sdkParams.TACParams, sdkParams.customLiteSequencerEndpoints, delay);
56
+ const simulator = new Simulator_1.Simulator(config, logger);
57
+ const operationTracker = new OperationTracker_1.OperationTracker(network, config.liteSequencerEndpoints);
58
+ const transactionManager = new TransactionManager_1.TransactionManager(config, simulator, operationTracker, logger);
59
+ return new TacSdk(config, simulator, transactionManager);
112
60
  }
113
61
  closeConnections() {
114
- return this.TONParams.contractOpener.closeConnections?.call(this);
62
+ return this.config.closeConnections();
115
63
  }
116
64
  get nativeTONAddress() {
117
- return 'NONE';
65
+ return this.config.nativeTONAddress;
118
66
  }
119
67
  async nativeTACAddress() {
120
- return this.TACParams.crossChainLayer.NATIVE_TOKEN_ADDRESS.staticCall();
121
- }
122
- async getUserJettonWalletAddress(userAddress, tokenAddress) {
123
- const jettonMaster = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(ton_1.Address.parse(tokenAddress)));
124
- return jettonMaster.getWalletAddress(userAddress);
125
- }
126
- async getUserJettonBalance(userAddress, tokenAddress) {
127
- const jettonMaster = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(ton_1.Address.parse(tokenAddress)));
128
- const userJettonWalletAddress = await jettonMaster.getWalletAddress(userAddress);
129
- await (0, Utils_1.sleep)(this.delay * 1000);
130
- const userJettonWallet = this.TONParams.contractOpener.open(new JettonWallet_1.JettonWallet(ton_1.Address.parse(userJettonWalletAddress)));
131
- return userJettonWallet.getJettonBalance();
132
- }
133
- async getUserJettonBalanceExtended(userAddress, tokenAddress) {
134
- const masterAddress = ton_1.Address.parse(tokenAddress);
135
- const masterState = await this.TONParams.contractOpener.getContractState(masterAddress);
136
- if (masterState.state !== 'active') {
137
- return { exists: false };
138
- }
139
- await (0, Utils_1.sleep)(this.delay * 1000);
140
- const jettonMaster = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(masterAddress));
141
- const userJettonWalletAddress = await jettonMaster.getWalletAddress(userAddress);
142
- await (0, Utils_1.sleep)(this.delay * 1000);
143
- const userJettonWallet = this.TONParams.contractOpener.open(new JettonWallet_1.JettonWallet(ton_1.Address.parse(userJettonWalletAddress)));
144
- const rawAmount = await userJettonWallet.getJettonBalance();
145
- const decimalsRaw = (await jettonMaster.getJettonData()).content.metadata.decimals;
146
- const decimals = decimalsRaw ? Number(decimalsRaw) : 9;
147
- return {
148
- rawAmount,
149
- decimals,
150
- amount: (0, Utils_1.calculateAmount)(rawAmount, decimals),
151
- exists: true,
152
- };
153
- }
154
- getJettonTransferPayload(jettonData, responseAddress, evmData, crossChainTonAmount, forwardFeeAmount, feeData) {
155
- const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
156
- return JettonWallet_1.JettonWallet.transferMessage(jettonData.rawAmount, this.TONParams.jettonProxyAddress, responseAddress, Consts_1.JETTON_TRANSFER_FORWARD_TON_AMOUNT + forwardFeeAmount + crossChainTonAmount, crossChainTonAmount, feeData, evmData, queryId);
157
- }
158
- getJettonBurnPayload(jettonData, evmData, crossChainTonAmount, feeData) {
159
- const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
160
- return JettonWallet_1.JettonWallet.burnMessage(jettonData.rawAmount, jettonData.notificationReceiverAddress, crossChainTonAmount, feeData, evmData, queryId);
161
- }
162
- getNFTBurnPayload(burnData) {
163
- const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
164
- return wrappers_1.NFTItem.burnMessage(queryId, (0, ton_1.address)(burnData.notificationReceiverAddress), burnData.crossChainTonAmount ?? 0, burnData.evmData, burnData.feeData);
165
- }
166
- getNFTTransferPayload(transferData, forwardFeeAmount) {
167
- const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
168
- const crossChainTonAmount = transferData.crossChainTonAmount ?? 0n;
169
- const forwardPayload = (0, ton_1.beginCell)()
170
- .storeCoins(crossChainTonAmount)
171
- .storeMaybeRef(transferData.feeData)
172
- .storeMaybeRef(transferData.evmData)
173
- .endCell();
174
- return wrappers_1.NFTItem.transferMessage(queryId, (0, ton_1.address)(transferData.to ?? this.TONParams.nftProxyAddress), (0, ton_1.address)(transferData.responseAddress), Number((0, ton_1.fromNano)(Consts_1.NFT_TRANSFER_FORWARD_TON_AMOUNT + forwardFeeAmount + crossChainTonAmount)), forwardPayload);
175
- }
176
- getTonTransferPayload(responseAddress, evmData, crossChainTonAmount, feeParams) {
177
- const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
178
- const feeData = (0, Utils_1.generateFeeData)(feeParams);
179
- return (0, ton_1.beginCell)()
180
- .storeUint(this.artifacts.ton.wrappers.CrossChainLayerOpCodes.anyone_tvmMsgToEVM, 32)
181
- .storeUint(queryId, 64)
182
- .storeUint(this.artifacts.ton.wrappers.OperationType.tonTransfer, 32)
183
- .storeCoins(crossChainTonAmount)
184
- .storeMaybeRef(feeData)
185
- .storeAddress(ton_1.Address.parse(responseAddress))
186
- .storeMaybeRef(evmData)
187
- .endCell();
188
- }
189
- async getJettonOpType(asset) {
190
- const { code: givenMinterCodeBOC } = await this.TONParams.contractOpener.getContractState((0, ton_1.address)(asset.address));
191
- if (!givenMinterCodeBOC) {
192
- throw errors_1.emptyContractError;
193
- }
194
- const givenMinterCode = ton_1.Cell.fromBoc(givenMinterCodeBOC)[0];
195
- await (0, Utils_1.sleep)(this.delay * 1000);
196
- if (!this.TONParams.jettonMinterCode.equals(givenMinterCode)) {
197
- return InternalStruct_1.AssetOpType.JETTON_TRANSFER;
198
- }
199
- const givenMinter = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster((0, ton_1.address)(asset.address)));
200
- const evmAddress = await givenMinter.getEVMAddress();
201
- await (0, Utils_1.sleep)(this.delay * 1000);
202
- const expectedMinterAddress = await (0, Utils_1.calculateContractAddress)(this.TONParams.jettonMinterCode, (0, ton_1.beginCell)()
203
- .storeCoins(0)
204
- .storeAddress((0, ton_1.address)(this.TONParams.crossChainLayerAddress))
205
- .storeAddress(null)
206
- .storeRef((0, ton_1.beginCell)().endCell())
207
- .storeRef(this.TONParams.jettonWalletCode)
208
- .storeStringTail(evmAddress)
209
- .endCell());
210
- if (!expectedMinterAddress.equals(givenMinter.address)) {
211
- return InternalStruct_1.AssetOpType.JETTON_TRANSFER;
212
- }
213
- return InternalStruct_1.AssetOpType.JETTON_BURN;
214
- }
215
- async getNFTOpType(asset) {
216
- const { code: itemCodeBOC } = await this.TONParams.contractOpener.getContractState((0, ton_1.address)(asset.address));
217
- if (!itemCodeBOC) {
218
- throw errors_1.emptyContractError;
219
- }
220
- const givenNFTItemCode = ton_1.Cell.fromBoc(itemCodeBOC)[0];
221
- await (0, Utils_1.sleep)(this.delay * 1000);
222
- if (!this.TONParams.nftItemCode.equals(givenNFTItemCode)) {
223
- return InternalStruct_1.AssetOpType.NFT_TRANSFER;
224
- }
225
- return InternalStruct_1.AssetOpType.NFT_BURN;
226
- }
227
- async getNFTItemAddressTON(collectionAddress, itemIndex) {
228
- (0, Utils_1.validateTVMAddress)(collectionAddress);
229
- const nftCollection = this.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromAddress((0, ton_1.address)(collectionAddress)));
230
- return (await nftCollection.getNFTAddressByIndex(itemIndex)).toString();
231
- }
232
- async getNFTItemData(itemAddress) {
233
- (0, Utils_1.validateTVMAddress)(itemAddress);
234
- const nftItem = this.TONParams.contractOpener.open(wrappers_1.NFTItem.createFromAddress((0, ton_1.address)(itemAddress)));
235
- return await nftItem.getNFTData();
236
- }
237
- async aggregateTokens(assets) {
238
- const uniqueAssetsMap = new Map();
239
- let crossChainTonAmount = 0n;
240
- for await (const asset of assets ?? []) {
241
- if (asset.rawAmount <= 0)
242
- continue;
243
- if (asset.type !== Struct_1.AssetType.FT)
244
- continue;
245
- if (asset.address) {
246
- (0, Utils_1.validateTVMAddress)(asset.address);
247
- uniqueAssetsMap.set(asset.address, (uniqueAssetsMap.get(asset.address) || 0n) + BigInt(asset.rawAmount));
248
- }
249
- else {
250
- crossChainTonAmount += BigInt(asset.rawAmount);
251
- }
252
- }
253
- const jettons = Array.from(uniqueAssetsMap.entries()).map(([address, rawAmount]) => ({
254
- address,
255
- rawAmount,
256
- type: Struct_1.AssetType.FT,
257
- }));
258
- uniqueAssetsMap.clear();
259
- for await (const asset of assets ?? []) {
260
- if (asset.type !== Struct_1.AssetType.NFT)
261
- continue;
262
- (0, Utils_1.validateTVMAddress)(asset.address);
263
- uniqueAssetsMap.set(asset.address, 1n);
264
- }
265
- const nfts = Array.from(uniqueAssetsMap.entries()).map(([address, rawAmount]) => ({
266
- address,
267
- rawAmount,
268
- type: Struct_1.AssetType.NFT,
269
- }));
270
- return {
271
- jettons,
272
- nfts,
273
- crossChainTonAmount,
274
- };
275
- }
276
- async generateJettonPayload(jetton, caller, evmData, crossChainTonAmount, forwardFeeTonAmount, feeParams) {
277
- const opType = await this.getJettonOpType(jetton);
278
- await (0, Utils_1.sleep)(this.delay * 1000);
279
- console.log(`***** Jetton ${jetton.address} requires ${opType} operation`);
280
- const feeData = (0, Utils_1.generateFeeData)(feeParams);
281
- let payload;
282
- switch (opType) {
283
- case InternalStruct_1.AssetOpType.JETTON_BURN:
284
- payload = this.getJettonBurnPayload({
285
- notificationReceiverAddress: this.TONParams.crossChainLayerAddress,
286
- ...jetton,
287
- }, evmData, crossChainTonAmount, feeData);
288
- break;
289
- case InternalStruct_1.AssetOpType.JETTON_TRANSFER:
290
- payload = this.getJettonTransferPayload(jetton, caller, evmData, crossChainTonAmount, forwardFeeTonAmount, feeData);
291
- break;
292
- }
293
- return payload;
68
+ return this.config.nativeTACAddress();
294
69
  }
295
- async generateNFTPayload(nft, caller, evmData, crossChainTonAmount, forwardFeeTonAmount, feeParams) {
296
- const opType = await this.getNFTOpType(nft);
297
- await (0, Utils_1.sleep)(this.delay * 1000);
298
- console.log(`***** NFT ${nft.address} requires ${opType} operation`);
299
- const feeData = (0, Utils_1.generateFeeData)(feeParams);
300
- let payload;
301
- switch (opType) {
302
- case InternalStruct_1.AssetOpType.NFT_BURN:
303
- payload = this.getNFTBurnPayload({
304
- notificationReceiverAddress: this.TONParams.crossChainLayerAddress,
305
- ...nft,
306
- evmData,
307
- crossChainTonAmount,
308
- feeData,
309
- });
310
- break;
311
- case InternalStruct_1.AssetOpType.NFT_TRANSFER:
312
- payload = this.getNFTTransferPayload({
313
- to: this.TONParams.nftProxyAddress,
314
- responseAddress: caller,
315
- evmData,
316
- crossChainTonAmount,
317
- feeData,
318
- ...nft,
319
- }, forwardFeeTonAmount);
320
- break;
321
- }
322
- return payload;
323
- }
324
- async generateCrossChainMessages(caller, evmData, aggregatedData, feeParams) {
325
- let crossChainTonAmount = aggregatedData.crossChainTonAmount;
326
- let feeTonAmount = feeParams.protocolFee + feeParams.evmExecutorFee + feeParams.tvmExecutorFee;
327
- if (aggregatedData.jettons.length == 0 && aggregatedData.nfts.length == 0) {
328
- return [
329
- {
330
- address: this.TONParams.crossChainLayerAddress,
331
- value: crossChainTonAmount + feeTonAmount + Consts_1.TRANSACTION_TON_AMOUNT,
332
- payload: this.getTonTransferPayload(caller, evmData, crossChainTonAmount, feeParams),
333
- },
334
- ];
335
- }
336
- const messages = [];
337
- let currentFeeParams = feeParams;
338
- for (const jetton of aggregatedData.jettons) {
339
- const payload = await this.generateJettonPayload(jetton, caller, evmData, crossChainTonAmount, feeTonAmount, currentFeeParams);
340
- await (0, Utils_1.sleep)(this.delay * 1000);
341
- const jettonWalletAddress = await this.getUserJettonWalletAddress(caller, jetton.address);
342
- await (0, Utils_1.sleep)(this.delay * 1000);
343
- messages.push({
344
- address: jettonWalletAddress,
345
- value: crossChainTonAmount + feeTonAmount + Consts_1.TRANSACTION_TON_AMOUNT,
346
- payload,
347
- });
348
- crossChainTonAmount = 0n;
349
- feeTonAmount = 0n;
350
- currentFeeParams = undefined;
351
- }
352
- for (const nft of aggregatedData.nfts) {
353
- const payload = await this.generateNFTPayload(nft, caller, evmData, crossChainTonAmount, feeTonAmount, currentFeeParams);
354
- await (0, Utils_1.sleep)(this.delay * 1000);
355
- messages.push({
356
- address: nft.address,
357
- value: crossChainTonAmount + feeTonAmount + Consts_1.TRANSACTION_TON_AMOUNT,
358
- payload,
359
- });
360
- crossChainTonAmount = 0n;
361
- feeTonAmount = 0n;
362
- currentFeeParams = undefined;
363
- }
364
- return messages;
365
- }
366
- async getRawAmount(asset, precalculatedAddress) {
367
- if ('rawAmount' in asset) {
368
- // User specified raw format amount
369
- return asset.rawAmount;
370
- }
371
- if (!precalculatedAddress) {
372
- // User specified TON Coin
373
- return (0, ton_1.toNano)(asset.amount);
374
- }
375
- if (typeof asset.decimals === 'number') {
376
- // User manually set decimals
377
- return (0, Utils_1.calculateRawAmount)(asset.amount, asset.decimals);
378
- }
379
- // Get decimals from chain
380
- (0, Utils_1.validateTVMAddress)(precalculatedAddress);
381
- const contract = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster((0, ton_1.address)(precalculatedAddress)));
382
- const { content } = await contract.getJettonData();
383
- await (0, Utils_1.sleep)(this.delay * 1000);
384
- if (!content.metadata.decimals) {
385
- // if decimals not specified use default value 9
386
- return (0, ton_1.toNano)(asset.amount);
387
- }
388
- return (0, Utils_1.calculateRawAmount)(asset.amount, Number(content.metadata.decimals));
389
- }
390
- async convertAssetsToRawFormat(assets) {
391
- return await Promise.all((assets ?? []).map(async (asset) => {
392
- if (asset.type === Struct_1.AssetType.FT) {
393
- const address = (0, ethers_1.isAddress)(asset.address)
394
- ? await this.getTVMTokenAddress(asset.address)
395
- : asset.address;
396
- return {
397
- address,
398
- rawAmount: await this.getRawAmount(asset, address),
399
- type: asset.type,
400
- };
401
- }
402
- if (asset.type === Struct_1.AssetType.NFT) {
403
- if ('collectionAddress' in asset) {
404
- const address = (0, ethers_1.isAddress)(asset.collectionAddress)
405
- ? await this.getTVMNFTAddress(asset.collectionAddress, asset.itemIndex)
406
- : await this.getNFTItemAddressTON(asset.collectionAddress, asset.itemIndex);
407
- await (0, Utils_1.sleep)(this.delay * 1000);
408
- return {
409
- address,
410
- rawAmount: 1n,
411
- type: asset.type,
412
- };
413
- }
414
- (0, Utils_1.validateTVMAddress)(asset.address);
415
- return {
416
- address: asset.address,
417
- rawAmount: 1n,
418
- type: asset.type,
419
- };
420
- }
421
- throw instances_1.invalidAssetType;
422
- }));
70
+ get getTrustedTACExecutors() {
71
+ return this.config.getTrustedTACExecutors;
423
72
  }
424
- async getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, evmValidExecutors, forceSend = false, isRoundTrip) {
425
- const crossChainLayer = this.TONParams.contractOpener.open(this.artifacts.ton.wrappers.CrossChainLayer.createFromAddress(ton_1.Address.parse(this.TONParams.crossChainLayerAddress)));
426
- const fullStateCCL = await crossChainLayer.getFullData();
427
- const tacSimulationBody = {
428
- tacCallParams: {
429
- arguments: evmProxyMsg.encodedParameters ?? '0x',
430
- methodName: (0, Utils_1.formatSolidityMethodName)(evmProxyMsg.methodName),
431
- target: evmProxyMsg.evmTargetAddress,
432
- },
433
- evmValidExecutors: evmValidExecutors,
434
- extraData: '0x',
435
- shardsKey: transactionLinker.shardsKey,
436
- tonAssets: rawAssets.map((asset) => ({
437
- amount: asset.rawAmount.toString(),
438
- tokenAddress: asset.address || '',
439
- assetType: asset.type,
440
- })),
441
- tonCaller: transactionLinker.caller,
442
- };
443
- const tacSimulationResult = await this.simulateTACMessage(tacSimulationBody);
444
- if (!tacSimulationResult.simulationStatus) {
445
- if (forceSend) {
446
- return {
447
- feeParams: {
448
- isRoundTrip: isRoundTrip ?? false,
449
- gasLimit: 0n,
450
- protocolFee: BigInt((0, ton_1.toNano)(fullStateCCL.tacProtocolFee)) +
451
- BigInt(isRoundTrip ?? false) * BigInt((0, ton_1.toNano)(fullStateCCL.tonProtocolFee)),
452
- evmExecutorFee: 0n,
453
- tvmExecutorFee: 0n,
454
- },
455
- simulation: tacSimulationResult,
456
- };
457
- }
458
- throw tacSimulationResult;
459
- }
460
- isRoundTrip = isRoundTrip ?? tacSimulationResult.outMessages != null;
461
- let tonExecutorFeeInTON = 0n;
462
- if (isRoundTrip) {
463
- tonExecutorFeeInTON = BigInt(tacSimulationResult.suggestedTonExecutionFee);
464
- }
465
- const protocolFee = BigInt((0, ton_1.toNano)(fullStateCCL.tacProtocolFee)) +
466
- BigInt(isRoundTrip) * BigInt((0, ton_1.toNano)(fullStateCCL.tonProtocolFee));
467
- const feeParams = {
468
- isRoundTrip: isRoundTrip,
469
- gasLimit: tacSimulationResult.estimatedGas,
470
- protocolFee: protocolFee,
471
- evmExecutorFee: BigInt(tacSimulationResult.suggestedTacExecutionFee),
472
- tvmExecutorFee: tonExecutorFeeInTON,
473
- };
474
- return { feeParams: feeParams, simulation: tacSimulationResult };
73
+ get getTrustedTONExecutors() {
74
+ return this.config.getTrustedTONExecutors;
475
75
  }
476
76
  async getTransactionSimulationInfo(evmProxyMsg, sender, assets) {
477
- const rawAssets = await this.convertAssetsToRawFormat(assets);
478
- const aggregatedData = await this.aggregateTokens(rawAssets);
479
- const transactionLinkerShardCount = aggregatedData.jettons.length == 0 ? 1 : aggregatedData.jettons.length;
480
- const transactionLinker = (0, Utils_1.generateTransactionLinker)(sender.getSenderAddress(), transactionLinkerShardCount);
481
- const evmValidExecutors = this.TACParams.trustedTACExecutors;
482
- return await this.getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, evmValidExecutors, false, undefined);
77
+ return this.simulator.getTransactionSimulationInfo(evmProxyMsg, sender, assets);
483
78
  }
484
79
  async getTVMExecutorFeeInfo(assets, feeSymbol) {
485
- const rawAssets = await this.convertAssetsToRawFormat(assets);
486
- const requestBody = {
487
- tonAssets: rawAssets.map((asset) => ({
488
- amount: asset.rawAmount.toString(),
489
- tokenAddress: asset.address || '',
490
- assetType: asset.type,
491
- })),
492
- feeSymbol: feeSymbol,
493
- };
494
- let lastError;
495
- for (const endpoint of this.liteSequencerEndpoints) {
496
- try {
497
- const response = await axios_1.default.post(`${endpoint}/ton/calculator/ton-executor-fee`, requestBody);
498
- return response.data.response;
499
- }
500
- catch (error) {
501
- console.error(`Error while calculating tvm executor fee ${endpoint}:`, error);
502
- lastError = error;
503
- }
504
- }
505
- throw (0, errors_1.simulationError)(lastError);
506
- }
507
- async prepareCrossChainTransaction(evmProxyMsg, caller, assets, options) {
508
- let { forceSend = false, isRoundTrip = undefined, protocolFee = undefined, evmValidExecutors = [], evmExecutorFee = undefined, tvmValidExecutors = [], tvmExecutorFee = undefined, } = options || {};
509
- const rawAssets = await this.convertAssetsToRawFormat(assets);
510
- const aggregatedData = await this.aggregateTokens(rawAssets);
511
- const tokensLength = aggregatedData.jettons.length + aggregatedData.nfts.length;
512
- let transactionLinkerShardCount = tokensLength == 0 ? 1 : tokensLength;
513
- const transactionLinker = (0, Utils_1.generateTransactionLinker)(caller, transactionLinkerShardCount);
514
- if (evmValidExecutors.length == 0) {
515
- evmValidExecutors = this.TACParams.trustedTACExecutors;
516
- }
517
- if (tvmValidExecutors.length == 0) {
518
- tvmValidExecutors = this.TACParams.trustedTONExecutors;
519
- }
520
- const { feeParams } = await this.getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, evmValidExecutors, forceSend, isRoundTrip);
521
- if (evmProxyMsg.gasLimit == undefined) {
522
- evmProxyMsg.gasLimit = feeParams.gasLimit;
523
- }
524
- if (evmExecutorFee != undefined) {
525
- feeParams.evmExecutorFee = evmExecutorFee;
526
- }
527
- if (feeParams.isRoundTrip && tvmExecutorFee != undefined) {
528
- feeParams.tvmExecutorFee = tvmExecutorFee;
529
- }
530
- if (protocolFee != undefined) {
531
- feeParams.protocolFee = protocolFee;
532
- }
533
- const validExecutors = {
534
- tac: evmValidExecutors,
535
- ton: tvmValidExecutors,
536
- };
537
- const evmData = (0, Utils_1.buildEvmDataCell)(transactionLinker, evmProxyMsg, validExecutors);
538
- const messages = await this.generateCrossChainMessages(caller, evmData, aggregatedData, feeParams);
539
- await (0, Utils_1.sleep)(this.delay * 1000);
540
- const transaction = {
541
- validUntil: +new Date() + 15 * 60 * 1000,
542
- messages,
543
- network: this.network,
544
- };
545
- return { transaction, transactionLinker };
80
+ return this.simulator.getTVMExecutorFeeInfo(assets, feeSymbol);
546
81
  }
547
- async sendCrossChainTransaction(evmProxyMsg, sender, assets, options) {
548
- const caller = sender.getSenderAddress();
549
- const { transaction, transactionLinker } = await this.prepareCrossChainTransaction(evmProxyMsg, caller, assets, options);
550
- console.log('*****Sending transaction: ', transaction);
551
- const sendTransactionResult = await sender.sendShardTransaction(transaction, this.delay, this.network, this.TONParams.contractOpener);
552
- return { sendTransactionResult, ...transactionLinker };
82
+ async sendCrossChainTransaction(evmProxyMsg, sender, assets, options, waitOptions) {
83
+ return this.transactionManager.sendCrossChainTransaction(evmProxyMsg, sender, assets, options, waitOptions);
553
84
  }
554
- async sendCrossChainTransactions(sender, txs) {
555
- const transactions = [];
556
- const transactionLinkers = [];
557
- const caller = sender.getSenderAddress();
558
- for (const { options, assets, evmProxyMsg } of txs) {
559
- const { transaction, transactionLinker } = await this.prepareCrossChainTransaction(evmProxyMsg, caller, assets, options);
560
- transactions.push(transaction);
561
- transactionLinkers.push(transactionLinker);
562
- }
563
- console.log('*****Sending transactions: ', transactions);
564
- await sender.sendShardTransactions(transactions, this.delay, this.network, this.TONParams.contractOpener);
565
- return transactionLinkers;
85
+ async sendCrossChainTransactions(sender, txs, waitOptions) {
86
+ return this.transactionManager.sendCrossChainTransactions(sender, txs, waitOptions);
566
87
  }
567
- // TODO move to sdk.TAC, sdk.TON
568
88
  async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee) {
569
- if (assets == undefined) {
570
- assets = [];
571
- }
572
- let tonAssets = [];
573
- for (const asset of assets) {
574
- if (asset.type == Struct_1.AssetType.FT) {
575
- const tvmAddress = await this.getTVMTokenAddress(asset.address);
576
- tonAssets.push({
577
- address: tvmAddress,
578
- rawAmount: asset.rawAmount,
579
- type: Struct_1.AssetType.FT,
580
- });
581
- }
582
- else {
583
- const nftItemAddress = await this.getTVMNFTAddress(asset.collectionAddress, asset.itemIndex);
584
- tonAssets.push({
585
- address: nftItemAddress,
586
- amount: 1,
587
- type: Struct_1.AssetType.NFT,
588
- });
589
- }
590
- }
591
- if (value > 0) {
592
- const tvmAddress = await this.getTVMTokenAddress(await this.nativeTACAddress());
593
- tonAssets.push({
594
- address: tvmAddress,
595
- rawAmount: value,
596
- type: Struct_1.AssetType.FT,
597
- });
598
- }
599
- const suggestedTONExecutorFee = await this.getTVMExecutorFeeInfo(tonAssets, Consts_1.TAC_SYMBOL);
600
- const crossChainLayerAddress = await this.TACParams.crossChainLayer.getAddress();
601
- for (const asset of assets) {
602
- if (asset.type == Struct_1.AssetType.FT) {
603
- const tokenContract = this.artifacts.tac.wrappers.ERC20FactoryTAC.connect(asset.address, this.TACParams.provider);
604
- const tx = await tokenContract.connect(signer).approve(crossChainLayerAddress, asset.rawAmount);
605
- await tx.wait();
606
- }
607
- if (asset.type == Struct_1.AssetType.NFT) {
608
- const tokenContract = this.artifacts.tac.wrappers.ERC721FactoryTAC.connect(asset.collectionAddress, this.TACParams.provider);
609
- const tx = await tokenContract.connect(signer).approve(crossChainLayerAddress, asset.itemIndex);
610
- await tx.wait();
611
- }
612
- }
613
- const shardsKey = BigInt(Math.round(Math.random() * 1e18));
614
- const protocolFee = await this.TACParams.crossChainLayer.getProtocolFee();
615
- const outMessage = {
616
- shardsKey: shardsKey,
617
- tvmTarget: tonTarget,
618
- tvmPayload: '',
619
- tvmProtocolFee: protocolFee,
620
- tvmExecutorFee: tvmExecutorFee ?? BigInt(suggestedTONExecutorFee.inTAC),
621
- tvmValidExecutors: this.TACParams.trustedTONExecutors,
622
- toBridge: assets
623
- .filter((asset) => asset.type === Struct_1.AssetType.FT)
624
- .map((asset) => ({
625
- evmAddress: asset.address,
626
- amount: asset.rawAmount,
627
- })),
628
- toBridgeNFT: assets
629
- .filter((asset) => asset.type === Struct_1.AssetType.NFT)
630
- .map((asset) => ({
631
- evmAddress: asset.collectionAddress,
632
- amount: 1n,
633
- tokenId: asset.itemIndex,
634
- })),
635
- };
636
- const encodedOutMessage = this.artifacts.tac.utils.encodeOutMessageV1(outMessage);
637
- const outMsgVersion = 1n;
638
- const totalValue = value + BigInt(outMessage.tvmProtocolFee) + BigInt(outMessage.tvmExecutorFee);
639
- const tx = await this.TACParams.crossChainLayer
640
- .connect(signer)
641
- .sendMessage(outMsgVersion, encodedOutMessage, { value: totalValue });
642
- await tx.wait();
643
- return tx.hash;
644
- }
645
- get getTrustedTACExecutors() {
646
- return this.TACParams.trustedTACExecutors;
647
- }
648
- get getTrustedTONExecutors() {
649
- return this.TACParams.trustedTONExecutors;
650
- }
651
- async getEVMTokenAddress(tvmTokenAddress) {
652
- if (tvmTokenAddress !== this.nativeTONAddress) {
653
- (0, Utils_1.validateTVMAddress)(tvmTokenAddress);
654
- tvmTokenAddress = ton_1.Address.parse(tvmTokenAddress).toString({ bounceable: true });
655
- const { code: givenMinterCodeBOC } = await this.TONParams.contractOpener.getContractState((0, ton_1.address)(tvmTokenAddress));
656
- await (0, Utils_1.sleep)(this.delay * 1000);
657
- if (givenMinterCodeBOC && this.TONParams.jettonMinterCode.equals(ton_1.Cell.fromBoc(givenMinterCodeBOC)[0])) {
658
- const givenMinter = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster((0, ton_1.address)(tvmTokenAddress)));
659
- const evmAddress = await givenMinter.getEVMAddress();
660
- await (0, Utils_1.sleep)(this.delay * 1000);
661
- return evmAddress;
662
- }
663
- }
664
- return this.TACParams.tokenUtils.computeAddress(tvmTokenAddress);
665
- }
666
- async getTVMTokenAddress(evmTokenAddress) {
667
- (0, Utils_1.validateEVMAddress)(evmTokenAddress);
668
- const exists = await this.TACParams.tokenUtils['exists(address)'](evmTokenAddress);
669
- if (exists) {
670
- const erc721Token = this.artifacts.tac.wrappers.CrossChainLayerERC20FactoryTAC.connect(evmTokenAddress, this.TACParams.provider);
671
- const info = await erc721Token.getInfo();
672
- return info.tvmAddress;
673
- }
674
- const jettonMaster = JettonMaster_1.JettonMaster.createFromConfig({
675
- evmTokenAddress,
676
- crossChainLayerAddress: (0, ton_1.address)(this.TONParams.crossChainLayerAddress),
677
- code: this.TONParams.jettonMinterCode,
678
- walletCode: this.TONParams.jettonWalletCode,
679
- });
680
- return jettonMaster.address.toString();
681
- }
682
- async getTVMNFTAddress(evmNFTAddress, tokenId) {
683
- (0, Utils_1.validateEVMAddress)(evmNFTAddress);
684
- let nftCollection;
685
- const exists = await this.TACParams.tokenUtils['exists(address)'](evmNFTAddress);
686
- if (exists) {
687
- const erc721Token = this.artifacts.tac.wrappers.CrossChainLayerERC721FactoryTAC.connect(evmNFTAddress, this.TACParams.provider);
688
- const info = await erc721Token.getInfo();
689
- nftCollection = this.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromAddress((0, ton_1.address)(info.tvmAddress)));
690
- return tokenId == undefined
691
- ? nftCollection.address.toString()
692
- : (await nftCollection.getNFTAddressByIndex(tokenId)).toString();
693
- }
694
- else {
695
- nftCollection = this.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromConfig({
696
- ownerAddress: (0, ton_1.address)(this.TONParams.crossChainLayerAddress),
697
- content: (0, ton_1.beginCell)().endCell(),
698
- nftItemCode: this.TONParams.nftItemCode,
699
- originalAddress: evmNFTAddress,
700
- }, this.TONParams.nftCollectionCode));
701
- return tokenId == undefined
702
- ? nftCollection.address.toString()
703
- : wrappers_1.NFTItem.createFromConfig({
704
- collectionAddress: nftCollection.address,
705
- cclAddress: (0, ton_1.address)(this.TONParams.crossChainLayerAddress),
706
- // @ts-ignore // bigint can be used, wrapper is not typed properly
707
- index: tokenId,
708
- }, this.TONParams.nftItemCode).address.toString();
709
- }
710
- }
711
- async getEVMNFTAddress(tvmNFTAddress, addressType) {
712
- (0, Utils_1.validateTVMAddress)(tvmNFTAddress);
713
- tvmNFTAddress = ton_1.Address.parse(tvmNFTAddress).toString({ bounceable: true });
714
- if (addressType == Struct_1.NFTAddressType.ITEM) {
715
- tvmNFTAddress = (await this.getNFTItemData(tvmNFTAddress)).collectionAddress.toString();
716
- addressType = Struct_1.NFTAddressType.COLLECTION;
717
- await (0, Utils_1.sleep)(this.delay * 1000);
718
- }
719
- const { code: givenNFTCollection } = await this.TONParams.contractOpener.getContractState((0, ton_1.address)(tvmNFTAddress));
720
- await (0, Utils_1.sleep)(this.delay * 1000);
721
- if (givenNFTCollection && this.TONParams.nftCollectionCode.equals(ton_1.Cell.fromBoc(givenNFTCollection)[0])) {
722
- const nftCollection = this.TONParams.contractOpener.open(wrappers_1.NFTCollection.createFromAddress((0, ton_1.address)(tvmNFTAddress)));
723
- const evmAddress = await nftCollection.getOriginalAddress();
724
- await (0, Utils_1.sleep)(this.delay * 1000);
725
- return evmAddress.toString();
726
- }
727
- return this.TACParams.tokenUtils.computeAddressERC721(tvmNFTAddress);
89
+ return this.transactionManager.bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee);
728
90
  }
729
91
  async isContractDeployedOnTVM(address) {
730
- return (await this.TONParams.contractOpener.getContractState(ton_1.Address.parse(address))).state === 'active';
92
+ return this.config.isContractDeployedOnTVM(address);
731
93
  }
732
94
  async simulateTACMessage(req) {
733
- let lastError;
734
- for (const endpoint of this.liteSequencerEndpoints) {
735
- try {
736
- const response = await axios_1.default.post(new URL('tac/simulator/simulate-message', endpoint).toString(), req, {
737
- transformResponse: [Utils_1.toCamelCaseTransformer],
738
- });
739
- return response.data.response;
740
- }
741
- catch (error) {
742
- console.error(`Error while simulating with ${endpoint}:`, error);
743
- lastError = error;
744
- }
745
- }
746
- throw (0, errors_1.simulationError)(lastError);
95
+ return this.simulator.simulateTACMessage(req);
96
+ }
97
+ async simulateTransactions(sender, txs) {
98
+ return this.simulator.simulateTransactions(sender, txs);
747
99
  }
748
100
  }
749
101
  exports.TacSdk = TacSdk;