@tonappchain/sdk 0.6.3 → 0.6.5-mainnet-alpha

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.
@@ -12,5 +12,5 @@ exports.SOLIDITY_METHOD_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
12
12
  exports.MAX_EXT_MSG_SIZE = 65535;
13
13
  exports.MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
14
14
  exports.MAX_MSG_DEPTH = 512;
15
- exports.TON_SYMBOL = "TON";
16
- exports.TAC_SYMBOL = "TAC";
15
+ exports.TON_SYMBOL = 'TON';
16
+ exports.TAC_SYMBOL = 'TAC';
@@ -35,7 +35,7 @@ class TacSdk {
35
35
  const network = sdkParams.network;
36
36
  const delay = sdkParams.delay ?? Consts_1.DEFAULT_DELAY;
37
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);
38
+ const TONParams = await this.prepareTONParams(delay, artifacts, sdkParams.TONParams);
39
39
  const TACParams = await this.prepareTACParams(artifacts, delay, sdkParams.TACParams);
40
40
  const liteSequencerEndpoints = sdkParams.customLiteSequencerEndpoints ??
41
41
  (network === Struct_1.Network.TESTNET
@@ -43,14 +43,13 @@ class TacSdk {
43
43
  : artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
44
44
  return new TacSdk(network, delay, artifacts, TONParams, TACParams, liteSequencerEndpoints);
45
45
  }
46
- static async prepareTONParams(network, delay, artifacts, TONParams) {
46
+ static async prepareTONParams(delay, artifacts, TONParams) {
47
47
  const contractOpener = TONParams?.contractOpener ??
48
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,
49
+ endpoint: new URL('api/v2/jsonRPC', artifacts.TON_RPC_ENDPOINT_BY_TAC).toString()
52
50
  });
53
- const settingsAddress = TONParams?.settingsAddress ?? artifacts.ton.addresses.TON_SETTINGS_ADDRESS;
51
+ const settingsAddress = TONParams?.settingsAddress
52
+ ?? artifacts.TON_SETTINGS_ADDRESS;
54
53
  const settings = contractOpener.open(new Settings_1.Settings(ton_1.Address.parse(settingsAddress)));
55
54
  const jettonProxyAddress = await settings.getAddressSetting('JettonProxyAddress');
56
55
  await (0, Utils_1.sleep)(delay * 1000);
@@ -79,7 +78,8 @@ class TacSdk {
79
78
  }
80
79
  static async prepareTACParams(artifacts, delay, TACParams) {
81
80
  const provider = TACParams?.provider ?? ethers_1.ethers.getDefaultProvider(artifacts.TAC_RPC_ENDPOINT);
82
- const settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.tac.addresses.TAC_SETTINGS_ADDRESS;
81
+ const settingsAddress = TACParams?.settingsAddress?.toString()
82
+ ?? artifacts.TAC_SETTINGS_ADDRESS;
83
83
  const settings = artifacts.tac.wrappers.SettingsFactoryTAC.connect(settingsAddress, provider);
84
84
  const crossChainLayerABI = TACParams?.crossChainLayerABI ?? artifacts.tac.compilationArtifacts.CrossChainLayer.abi;
85
85
  const crossChainLayerAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress')));
@@ -421,7 +421,7 @@ class TacSdk {
421
421
  throw instances_1.invalidAssetType;
422
422
  }));
423
423
  }
424
- async getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, evmValidExecutors, forceSend = false, isRoundTrip) {
424
+ async getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, forceSend = false, isRoundTrip = true, evmValidExecutors = this.TACParams.trustedTACExecutors) {
425
425
  const crossChainLayer = this.TONParams.contractOpener.open(this.artifacts.ton.wrappers.CrossChainLayer.createFromAddress(ton_1.Address.parse(this.TONParams.crossChainLayerAddress)));
426
426
  const fullStateCCL = await crossChainLayer.getFullData();
427
427
  const tacSimulationBody = {
@@ -440,28 +440,24 @@ class TacSdk {
440
440
  })),
441
441
  tonCaller: transactionLinker.caller,
442
442
  };
443
+ isRoundTrip = isRoundTrip ?? (rawAssets.length != 0);
443
444
  const tacSimulationResult = await this.simulateTACMessage(tacSimulationBody);
444
445
  if (!tacSimulationResult.simulationStatus) {
445
446
  if (forceSend) {
446
447
  return {
447
448
  feeParams: {
448
- isRoundTrip: isRoundTrip ?? false,
449
+ isRoundTrip,
449
450
  gasLimit: 0n,
450
451
  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,
452
+ BigInt(isRoundTrip) * BigInt((0, ton_1.toNano)(fullStateCCL.tonProtocolFee)),
453
+ evmExecutorFee: BigInt(tacSimulationResult.suggestedTacExecutionFee),
454
+ tvmExecutorFee: BigInt(tacSimulationResult.suggestedTonExecutionFee) * BigInt(isRoundTrip),
454
455
  },
455
456
  simulation: tacSimulationResult,
456
457
  };
457
458
  }
458
459
  throw tacSimulationResult;
459
460
  }
460
- isRoundTrip = isRoundTrip ?? tacSimulationResult.outMessages != null;
461
- let tonExecutorFeeInTON = 0n;
462
- if (isRoundTrip) {
463
- tonExecutorFeeInTON = BigInt(tacSimulationResult.suggestedTonExecutionFee);
464
- }
465
461
  const protocolFee = BigInt((0, ton_1.toNano)(fullStateCCL.tacProtocolFee)) +
466
462
  BigInt(isRoundTrip) * BigInt((0, ton_1.toNano)(fullStateCCL.tonProtocolFee));
467
463
  const feeParams = {
@@ -469,7 +465,7 @@ class TacSdk {
469
465
  gasLimit: tacSimulationResult.estimatedGas,
470
466
  protocolFee: protocolFee,
471
467
  evmExecutorFee: BigInt(tacSimulationResult.suggestedTacExecutionFee),
472
- tvmExecutorFee: tonExecutorFeeInTON,
468
+ tvmExecutorFee: BigInt(tacSimulationResult.suggestedTonExecutionFee) * BigInt(isRoundTrip),
473
469
  };
474
470
  return { feeParams: feeParams, simulation: tacSimulationResult };
475
471
  }
@@ -478,8 +474,7 @@ class TacSdk {
478
474
  const aggregatedData = await this.aggregateTokens(rawAssets);
479
475
  const transactionLinkerShardCount = aggregatedData.jettons.length == 0 ? 1 : aggregatedData.jettons.length;
480
476
  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);
477
+ return await this.getFeeInfo(evmProxyMsg, transactionLinker, rawAssets);
483
478
  }
484
479
  async getTVMExecutorFeeInfo(assets, feeSymbol) {
485
480
  const rawAssets = await this.convertAssetsToRawFormat(assets);
@@ -517,7 +512,7 @@ class TacSdk {
517
512
  if (tvmValidExecutors.length == 0) {
518
513
  tvmValidExecutors = this.TACParams.trustedTONExecutors;
519
514
  }
520
- const { feeParams } = await this.getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, evmValidExecutors, forceSend, isRoundTrip);
515
+ const { feeParams } = await this.getFeeInfo(evmProxyMsg, transactionLinker, rawAssets, forceSend, isRoundTrip, evmValidExecutors);
521
516
  if (evmProxyMsg.gasLimit == undefined) {
522
517
  evmProxyMsg.gasLimit = feeParams.gasLimit;
523
518
  }
@@ -62,7 +62,7 @@ class JettonWallet {
62
62
  .storeAddress(ton_1.Address.parse(to))
63
63
  .storeAddress(responseAddress ? ton_1.Address.parse(responseAddress) : null)
64
64
  .storeMaybeRef(null)
65
- .storeCoins((forwardTonAmount || 0n))
65
+ .storeCoins(forwardTonAmount || 0n)
66
66
  .storeMaybeRef((0, ton_1.beginCell)()
67
67
  .storeCoins(crossChainTonAmount ?? 0n)
68
68
  .storeMaybeRef(feeData)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonappchain/sdk",
3
- "version": "0.6.3",
3
+ "version": "0.6.5-mainnet-alpha",
4
4
  "repository": "https://github.com/TacBuild/tac-sdk.git",
5
5
  "author": "TAC. <developers@tac>",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "@aws-crypto/sha256-js": "^5.2.0",
21
21
  "@orbs-network/ton-access": "^2.3.3",
22
22
  "@ton/ton": "15.1.0",
23
- "@tonappchain/artifacts": "0.0.17-test",
23
+ "@tonappchain/artifacts": "0.0.19-mainnet-rc2",
24
24
  "@tonappchain/ton-lite-client": "3.0.6",
25
25
  "@tonconnect/ui": "^2.0.11",
26
26
  "bn.js": "^5.2.1",