@tonappchain/sdk 0.7.2-alpha-7 → 0.7.2-alpha-10

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 (88) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +198 -198
  3. package/dist/artifacts/dev/index.d.ts +2 -2
  4. package/dist/artifacts/dev/index.js +2 -1
  5. package/dist/artifacts/dev/tac/endpoints.d.ts +1 -0
  6. package/dist/artifacts/dev/tac/endpoints.js +2 -1
  7. package/dist/artifacts/dev/ton/internal/build/CrossChainLayer.compiled.json +1 -1
  8. package/dist/artifacts/dev/ton/internal/build/Executor.compiled.json +1 -1
  9. package/dist/artifacts/dev/ton/internal/build/JettonProxy.compiled.json +1 -1
  10. package/dist/artifacts/dev/ton/internal/build/JettonWallet.compiled.json +1 -1
  11. package/dist/artifacts/dev/ton/internal/build/NFTItem.compiled.json +1 -1
  12. package/dist/artifacts/dev/ton/internal/build/NFTProxy.compiled.json +1 -1
  13. package/dist/artifacts/dev/ton/internal/build/Settings.compiled.json +1 -1
  14. package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.d.ts +53 -6
  15. package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.js +126 -17
  16. package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.d.ts +6 -0
  17. package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.js +10 -1
  18. package/dist/artifacts/dev/ton/internal/wrappers/JettonProxy.d.ts +9 -0
  19. package/dist/artifacts/dev/ton/internal/wrappers/JettonProxy.js +10 -1
  20. package/dist/artifacts/dev/ton/internal/wrappers/JettonWallet.d.ts +7 -0
  21. package/dist/artifacts/dev/ton/internal/wrappers/JettonWallet.js +9 -2
  22. package/dist/artifacts/dev/ton/internal/wrappers/NFTCollection.d.ts +9 -0
  23. package/dist/artifacts/dev/ton/internal/wrappers/NFTCollection.js +9 -0
  24. package/dist/artifacts/dev/ton/internal/wrappers/NFTItem.d.ts +7 -0
  25. package/dist/artifacts/dev/ton/internal/wrappers/NFTItem.js +7 -0
  26. package/dist/artifacts/dev/ton/internal/wrappers/NFTProxy.d.ts +7 -0
  27. package/dist/artifacts/dev/ton/internal/wrappers/NFTProxy.js +8 -1
  28. package/dist/artifacts/dev/ton/internal/wrappers/Settings.d.ts +1 -0
  29. package/dist/artifacts/dev/ton/internal/wrappers/Settings.js +1 -0
  30. package/dist/artifacts/dev/ton/internal/wrappers/utils/CrossChainLayerPayload.d.ts +10 -0
  31. package/dist/artifacts/dev/ton/internal/wrappers/utils/CrossChainLayerPayload.js +24 -0
  32. package/dist/artifacts/dev/ton/internal/wrappers/utils/MerkleRoots.d.ts +2 -1
  33. package/dist/artifacts/dev/ton/internal/wrappers/utils/MerkleRoots.js +9 -1
  34. package/dist/artifacts/mainnet/index.d.ts +2 -2
  35. package/dist/artifacts/mainnet/index.js +2 -1
  36. package/dist/artifacts/mainnet/tac/endpoints.d.ts +1 -0
  37. package/dist/artifacts/mainnet/tac/endpoints.js +2 -1
  38. package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.d.ts +4 -0
  39. package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.js +7 -0
  40. package/dist/artifacts/testnet/index.d.ts +2 -2
  41. package/dist/artifacts/testnet/index.js +2 -1
  42. package/dist/artifacts/testnet/tac/endpoints.d.ts +1 -0
  43. package/dist/artifacts/testnet/tac/endpoints.js +2 -1
  44. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +4 -0
  45. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +7 -0
  46. package/dist/src/adapters/contractOpener.js +10 -19
  47. package/dist/src/assets/FT.d.ts +9 -0
  48. package/dist/src/assets/FT.js +48 -4
  49. package/dist/src/errors/errors.d.ts +3 -0
  50. package/dist/src/errors/errors.js +8 -1
  51. package/dist/src/errors/index.d.ts +2 -2
  52. package/dist/src/errors/index.js +3 -1
  53. package/dist/src/errors/instances.d.ts +2 -1
  54. package/dist/src/errors/instances.js +4 -2
  55. package/dist/src/index.d.ts +1 -0
  56. package/dist/src/index.js +3 -1
  57. package/dist/src/interfaces/Asset.d.ts +4 -0
  58. package/dist/src/interfaces/ILiteSequencerClient.d.ts +1 -6
  59. package/dist/src/interfaces/IOperationTracker.d.ts +1 -6
  60. package/dist/src/interfaces/ITacExplorerClient.d.ts +8 -0
  61. package/dist/src/interfaces/ITacExplorerClient.js +2 -0
  62. package/dist/src/interfaces/ITacSDK.d.ts +5 -0
  63. package/dist/src/interfaces/ITxFinalizer.d.ts +2 -3
  64. package/dist/src/interfaces/index.d.ts +1 -0
  65. package/dist/src/interfaces/index.js +1 -0
  66. package/dist/src/sdk/Configuration.d.ts +4 -3
  67. package/dist/src/sdk/Configuration.js +18 -6
  68. package/dist/src/sdk/Consts.d.ts +1 -0
  69. package/dist/src/sdk/Consts.js +2 -1
  70. package/dist/src/sdk/Fees.d.ts +20 -74
  71. package/dist/src/sdk/Fees.js +56 -53
  72. package/dist/src/sdk/LiteSequencerClient.d.ts +1 -2
  73. package/dist/src/sdk/LiteSequencerClient.js +0 -9
  74. package/dist/src/sdk/OperationTracker.d.ts +1 -2
  75. package/dist/src/sdk/OperationTracker.js +0 -20
  76. package/dist/src/sdk/Simulator.js +23 -21
  77. package/dist/src/sdk/StartTracking.js +4 -4
  78. package/dist/src/sdk/TacExplorerClient.d.ts +8 -0
  79. package/dist/src/sdk/TacExplorerClient.js +22 -0
  80. package/dist/src/sdk/TacSdk.d.ts +5 -7
  81. package/dist/src/sdk/TacSdk.js +10 -4
  82. package/dist/src/sdk/TxFinalizer.d.ts +3 -6
  83. package/dist/src/sdk/TxFinalizer.js +52 -42
  84. package/dist/src/sdk/Utils.d.ts +5 -0
  85. package/dist/src/sdk/Utils.js +11 -0
  86. package/dist/src/structs/InternalStruct.d.ts +66 -0
  87. package/dist/src/structs/Struct.d.ts +8 -6
  88. package/package.json +115 -116
@@ -0,0 +1,8 @@
1
+ import { IHttpClient, ITacExplorerClient } from '../interfaces';
2
+ import { TacGasPriceResponse } from '../structs/InternalStruct';
3
+ export declare class TacExplorerClient implements ITacExplorerClient {
4
+ private readonly explorerApiEndpoint;
5
+ private readonly httpClient;
6
+ constructor(explorerApiEndpoint: string, httpClient?: IHttpClient);
7
+ getTACGasPrice(): Promise<TacGasPriceResponse>;
8
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TacExplorerClient = void 0;
4
+ const instances_1 = require("../errors/instances");
5
+ const AxiosHttpClient_1 = require("./AxiosHttpClient");
6
+ const Utils_1 = require("./Utils");
7
+ class TacExplorerClient {
8
+ constructor(explorerApiEndpoint, httpClient = new AxiosHttpClient_1.AxiosHttpClient()) {
9
+ this.explorerApiEndpoint = explorerApiEndpoint;
10
+ this.httpClient = httpClient;
11
+ }
12
+ async getTACGasPrice() {
13
+ try {
14
+ const response = await this.httpClient.get(new URL('stats', this.explorerApiEndpoint).toString(), { transformResponse: [Utils_1.toCamelCaseTransformer] });
15
+ return response.data;
16
+ }
17
+ catch (error) {
18
+ throw (0, instances_1.gasPriceFetchError)(`endpoint ${this.explorerApiEndpoint} failed to complete request`, error);
19
+ }
20
+ }
21
+ }
22
+ exports.TacExplorerClient = TacExplorerClient;
@@ -1,12 +1,13 @@
1
1
  import { Wallet } from 'ethers';
2
2
  import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
3
3
  import { FT, NFT } from '../assets';
4
- import { IConfiguration, ILogger, IOperationTracker, ITacSDK } from '../interfaces';
4
+ import { IConfiguration, ILogger, IOperationTracker, ITacExplorerClient, ITacSDK } from '../interfaces';
5
5
  import type { SenderAbstraction } from '../sender';
6
- import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
6
+ import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
7
7
  export declare class TacSdk implements ITacSDK {
8
8
  readonly config: IConfiguration;
9
9
  readonly operationTracker: IOperationTracker;
10
+ readonly explorerClient: ITacExplorerClient;
10
11
  private readonly simulator;
11
12
  private readonly tonTransactionManager;
12
13
  private readonly tacTransactionManager;
@@ -41,10 +42,7 @@ export declare class TacSdk implements ITacSDK {
41
42
  getTVMNFTAddress(evmNFTAddress: string, tokenId?: number | bigint): Promise<string>;
42
43
  getEVMNFTAddress(tvmNFTAddress: string, addressType: NFTAddressType): Promise<string>;
43
44
  getOperationTracker(): IOperationTracker;
45
+ getTacExplorerClient(): ITacExplorerClient;
44
46
  prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
45
- getTACGasPrice(): Promise<{
46
- average: number;
47
- fast: number;
48
- slow: number;
49
- }>;
47
+ getTACGasPrice(): Promise<TacGasPrice>;
50
48
  }
@@ -9,17 +9,19 @@ const Consts_1 = require("./Consts");
9
9
  const Logger_1 = require("./Logger");
10
10
  const OperationTracker_1 = require("./OperationTracker");
11
11
  const Simulator_1 = require("./Simulator");
12
+ const TacExplorerClient_1 = require("./TacExplorerClient");
12
13
  const TACTransactionManager_1 = require("./TACTransactionManager");
13
14
  const TONTransactionManager_1 = require("./TONTransactionManager");
14
15
  const TxFinalizer_1 = require("./TxFinalizer");
15
16
  const Utils_1 = require("./Utils");
16
17
  class TacSdk {
17
- constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker) {
18
+ constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient) {
18
19
  this.config = config;
19
20
  this.simulator = simulator;
20
21
  this.tonTransactionManager = tonTransactionManager;
21
22
  this.tacTransactionManager = tacTransactionManager;
22
23
  this.operationTracker = operationTracker;
24
+ this.explorerClient = explorerClient;
23
25
  }
24
26
  static async create(sdkParams, logger = new Logger_1.NoopLogger()) {
25
27
  const network = sdkParams.network;
@@ -38,13 +40,14 @@ class TacSdk {
38
40
  default:
39
41
  throw new Error(`Unsupported network: ${network}`);
40
42
  }
41
- const config = await Configuration_1.Configuration.create(network, artifacts, sdkParams.TONParams, sdkParams.TACParams, sdkParams.customLiteSequencerEndpoints, delay);
43
+ const config = await Configuration_1.Configuration.create(network, artifacts, sdkParams.TONParams, sdkParams.TACParams, sdkParams.customLiteSequencerEndpoints, delay, logger);
42
44
  const operationTracker = new OperationTracker_1.OperationTracker(network, config.liteSequencerEndpoints);
45
+ const explorerClient = new TacExplorerClient_1.TacExplorerClient(artifacts.TAC_EXPLORER_API_ENDPOINT);
43
46
  const simulator = new Simulator_1.Simulator(config, operationTracker, logger);
44
47
  const txFinalizer = sdkParams.TONParams?.txFinalizer ?? new TxFinalizer_1.TonTxFinalizer(config.TONParams.contractOpener, logger);
45
48
  const tonTransactionManager = new TONTransactionManager_1.TONTransactionManager(config, simulator, operationTracker, logger, txFinalizer);
46
49
  const tacTransactionManager = new TACTransactionManager_1.TACTransactionManager(config, operationTracker, logger);
47
- return new TacSdk(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker);
50
+ return new TacSdk(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient);
48
51
  }
49
52
  closeConnections() {
50
53
  return this.config.closeConnections();
@@ -179,12 +182,15 @@ class TacSdk {
179
182
  getOperationTracker() {
180
183
  return this.operationTracker;
181
184
  }
185
+ getTacExplorerClient() {
186
+ return this.explorerClient;
187
+ }
182
188
  async prepareCrossChainTransactionPayload(evmProxyMsg, senderAddress, assets = [], options) {
183
189
  const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
184
190
  return this.tonTransactionManager.prepareCrossChainTransactionPayload(evmProxyMsg, senderAddress, normalizedAssets, options);
185
191
  }
186
192
  async getTACGasPrice() {
187
- const response = await this.operationTracker.getTACGasPrice();
193
+ const response = await this.explorerClient.getTACGasPrice();
188
194
  return {
189
195
  average: response.gasPrices.average,
190
196
  fast: response.gasPrices.fast,
@@ -1,14 +1,13 @@
1
1
  import { ContractOpener, IHttpClient, ILogger } from '../interfaces';
2
2
  import { ITxFinalizer } from '../interfaces/ITxFinalizer';
3
3
  import { TxFinalizerConfig } from '../structs/InternalStruct';
4
+ import { TrackTransactionTreeParams } from '../structs/Struct';
4
5
  export declare class TonTxFinalizer implements ITxFinalizer {
5
6
  private logger;
6
7
  private contractOpener;
7
8
  constructor(contractOpener: ContractOpener, logger?: ILogger);
8
9
  private fetchAdjacentTransactions;
9
- trackTransactionTree(address: string, hash: string, params?: {
10
- maxDepth?: number;
11
- }): Promise<void>;
10
+ trackTransactionTree(address: string, hash: string, params?: TrackTransactionTreeParams): Promise<void>;
12
11
  }
13
12
  export declare class TonIndexerTxFinalizer implements ITxFinalizer {
14
13
  private logger;
@@ -16,7 +15,5 @@ export declare class TonIndexerTxFinalizer implements ITxFinalizer {
16
15
  private readonly httpClient;
17
16
  constructor(apiConfig: TxFinalizerConfig, logger?: ILogger, httpClient?: IHttpClient);
18
17
  private fetchAdjacentTransactions;
19
- trackTransactionTree(_: string, hash: string, params?: {
20
- maxDepth?: number;
21
- }): Promise<void>;
18
+ trackTransactionTree(_: string, hash: string, params?: TrackTransactionTreeParams): Promise<void>;
22
19
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TonIndexerTxFinalizer = exports.TonTxFinalizer = void 0;
4
4
  const ton_1 = require("@ton/ton");
5
+ const errors_1 = require("../errors");
5
6
  const AxiosHttpClient_1 = require("./AxiosHttpClient");
6
7
  const Consts_1 = require("./Consts");
7
8
  const Logger_1 = require("./Logger");
@@ -43,8 +44,8 @@ class TonTxFinalizer {
43
44
  return [];
44
45
  }
45
46
  // Checks if all transactions in the tree are successful
46
- async trackTransactionTree(address, hash, params = { maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH }) {
47
- const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH } = params;
47
+ async trackTransactionTree(address, hash, params = { maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList: IGNORE_OPCODE }) {
48
+ const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList = IGNORE_OPCODE } = params;
48
49
  const parsedAddress = ton_1.Address.parse(address);
49
50
  const visitedHashes = new Set();
50
51
  const queue = [{ address: parsedAddress, hash, depth: 0 }];
@@ -71,18 +72,34 @@ class TonTxFinalizer {
71
72
  if (bodySlice.remainingBits < 32)
72
73
  continue;
73
74
  const opcode = bodySlice.loadUint(32);
74
- if (!IGNORE_OPCODE.includes(opcode)) {
75
+ if (!ignoreOpcodeList.includes(opcode)) {
75
76
  const { aborted, computePhase, actionPhase } = tx.description;
76
- if (aborted ||
77
- computePhase.type == 'skipped' ||
78
- !computePhase.success ||
79
- computePhase.exitCode !== 0 ||
80
- (actionPhase && (!actionPhase.success || actionPhase.resultCode !== 0))) {
81
- throw new Error(`Transaction failed:\n` +
82
- `hash = ${currentHash}, ` +
83
- `aborted = ${aborted}, ` +
84
- `compute phase: ${computePhase.type === 'skipped' ? 'skipped' : `success = ${computePhase.success}, exit code = ${computePhase.exitCode}`}, ` +
85
- `action phase: ${!actionPhase ? 'skipped' : `success = ${actionPhase.success}, result code = ${actionPhase.resultCode}`} `);
77
+ const failureCase = (() => {
78
+ if (aborted) {
79
+ return 'Transaction was aborted';
80
+ }
81
+ if (!computePhase) {
82
+ return 'computePhase not present';
83
+ }
84
+ if (computePhase.type === 'skipped') {
85
+ return 'computePhase was skipped';
86
+ }
87
+ if (!computePhase.success) {
88
+ return 'computePhase not successful';
89
+ }
90
+ if (computePhase.exitCode !== 0) {
91
+ return `computePhase.exitCode was not zero (exitCode=${computePhase.exitCode})`;
92
+ }
93
+ if (actionPhase && !actionPhase.success) {
94
+ return 'actionPhase not successful';
95
+ }
96
+ if (actionPhase && actionPhase.resultCode !== 0) {
97
+ return `actionPhase.resultCode was not zero (resultCode=${actionPhase.resultCode})`;
98
+ }
99
+ return null;
100
+ })();
101
+ if (failureCase) {
102
+ throw (0, errors_1.txFinalizationError)(`${tx.hash().toString('base64')}: ${failureCase}`);
86
103
  }
87
104
  if (currentDepth + 1 < maxDepth) {
88
105
  if (tx.outMessages.size > 0) {
@@ -144,8 +161,8 @@ class TonIndexerTxFinalizer {
144
161
  return [];
145
162
  }
146
163
  // Checks if all transactions in the tree are successful
147
- async trackTransactionTree(_, hash, params = { maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH }) {
148
- const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH } = params;
164
+ async trackTransactionTree(_, hash, params = { maxDepth: Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList: IGNORE_OPCODE }) {
165
+ const { maxDepth = Consts_1.DEFAULT_FIND_TX_MAX_DEPTH, ignoreOpcodeList = IGNORE_OPCODE } = params;
149
166
  const visitedHashes = new Set();
150
167
  const queue = [{ hash, depth: 0 }];
151
168
  while (queue.length > 0) {
@@ -161,38 +178,31 @@ class TonIndexerTxFinalizer {
161
178
  for (const tx of transactions) {
162
179
  if (tx.inMsg.value === Consts_1.IGNORE_MSG_VALUE_1_NANO.toString())
163
180
  continue; // we ignore messages with 1 nanoton value as they are for notification purpose only
164
- if (!IGNORE_OPCODE.includes(Number(tx.inMsg.opcode)) && tx.inMsg.opcode !== null) {
181
+ if (!ignoreOpcodeList.includes(Number(tx.inMsg.opcode)) && tx.inMsg.opcode !== null) {
165
182
  const { aborted, computePh, action } = tx.description;
166
183
  const failureCase = (() => {
167
- switch (true) {
168
- case aborted:
169
- return 'Transaction was aborted';
170
- case !computePh:
171
- return 'computePh not present';
172
- case !computePh.success:
173
- return 'computePh not successful';
174
- case !action:
175
- return 'action not present';
176
- case !action.success:
177
- return 'action not successful';
178
- case computePh.exitCode !== 0:
179
- return `computePh.exitCode was not zero (exitCode=${computePh.exitCode})`;
180
- case action.resultCode !== 0:
181
- return `action.resultCode was not zero (resultCode=${action.resultCode})`;
182
- default:
183
- return null;
184
+ if (aborted) {
185
+ return 'Transaction was aborted';
186
+ }
187
+ if (!computePh) {
188
+ return 'computePh not present';
189
+ }
190
+ if (!computePh.success) {
191
+ return 'computePh not successful';
192
+ }
193
+ if (computePh.exitCode !== 0) {
194
+ return `computePh.exitCode was not zero (exitCode=${computePh.exitCode})`;
195
+ }
196
+ if (action && !action.success) {
197
+ return 'action not successful';
198
+ }
199
+ if (action && action.resultCode !== 0) {
200
+ return `action.resultCode was not zero (resultCode=${action.resultCode})`;
184
201
  }
202
+ return null;
185
203
  })();
186
204
  if (failureCase) {
187
- throw new Error(`Transaction failed [${failureCase}]:\n` +
188
- `hash = ${currentHash}, ` +
189
- `aborted = ${aborted}, ` +
190
- `computePh = ${computePh}, ` +
191
- `action = ${action}, ` +
192
- `computePh.success = ${computePh?.success}, ` +
193
- `computePh.exitCode = ${computePh?.exitCode}, ` +
194
- `action.success = ${action?.success}, ` +
195
- `action.resultCode = ${action?.resultCode}`);
205
+ throw (0, errors_1.txFinalizationError)(`${tx.hash}: ${failureCase}`);
196
206
  }
197
207
  if (currentDepth + 1 < maxDepth) {
198
208
  if (tx.outMsgs.length > 0) {
@@ -32,6 +32,11 @@ export declare function normalizeAssets(config: IConfiguration, assets?: AssetLi
32
32
  export declare function getAddressString(cell?: Cell): string;
33
33
  export declare function getNumber(len: number, cell?: Cell): number;
34
34
  export declare function getString(cell?: Cell): string;
35
+ /**
36
+ * Multiply-divide with rounding (muldivr)
37
+ * Calculates (a * b + c / 2) / c with proper rounding
38
+ */
39
+ export declare function muldivr(a: bigint, b: bigint, c: bigint): bigint;
35
40
  export declare function getNormalizedExtMessageHash(message: Message): string;
36
41
  export declare function retry<T>(fn: () => Promise<T>, options: {
37
42
  retries: number;
@@ -19,6 +19,7 @@ exports.normalizeAssets = normalizeAssets;
19
19
  exports.getAddressString = getAddressString;
20
20
  exports.getNumber = getNumber;
21
21
  exports.getString = getString;
22
+ exports.muldivr = muldivr;
22
23
  exports.getNormalizedExtMessageHash = getNormalizedExtMessageHash;
23
24
  exports.retry = retry;
24
25
  exports.recurisivelyCollectCellStats = recurisivelyCollectCellStats;
@@ -305,6 +306,16 @@ function getNumber(len, cell) {
305
306
  function getString(cell) {
306
307
  return cell?.beginParse().loadStringTail() ?? '';
307
308
  }
309
+ /**
310
+ * Multiply-divide with rounding (muldivr)
311
+ * Calculates (a * b + c / 2) / c with proper rounding
312
+ */
313
+ function muldivr(a, b, c) {
314
+ if (c === 0n) {
315
+ throw new Error('Division by zero in muldivr');
316
+ }
317
+ return (a * b + c / 2n) / c;
318
+ }
308
319
  function getNormalizedExtMessageHash(message) {
309
320
  if (message.info.type !== 'external-in') {
310
321
  throw new Error(`Message must be "external-in", got ${message.info.type}`);
@@ -37,6 +37,7 @@ export type InternalTONParams = {
37
37
  nftItemCode: Cell;
38
38
  nftCollectionCode: Cell;
39
39
  feesParams: TONFeesParams;
40
+ contractFeeUsageParams: ContractFeeUsageParams;
40
41
  };
41
42
  export type InternalTACParams = {
42
43
  provider: AbstractProvider;
@@ -148,6 +149,64 @@ export type TONFeesParams = {
148
149
  msgBitPrice: number;
149
150
  msgCellPrice: number;
150
151
  };
152
+ export type ContractFeeUsageParams = {
153
+ crossChainLayer: {
154
+ accountBits: number;
155
+ accountCells: number;
156
+ gas: {
157
+ tvmMsgToEvm: number;
158
+ };
159
+ };
160
+ jettonWallet: {
161
+ accountBits: number;
162
+ accountCells: number;
163
+ estimatedAccountBits: number;
164
+ estimatedAccountCells: number;
165
+ initStateBits: number;
166
+ initStateCells: number;
167
+ gas: {
168
+ internalTransfer: number;
169
+ receive: number;
170
+ burn: number;
171
+ estimatedSendTransfer: number;
172
+ estimatedReceiveTransfer: number;
173
+ };
174
+ };
175
+ jettonProxy: {
176
+ accountBits: number;
177
+ accountCells: number;
178
+ gas: {
179
+ ownershipAssigned: number;
180
+ transferNotification: number;
181
+ errorNotification: number;
182
+ };
183
+ };
184
+ jettonMinter: {
185
+ accountBits: number;
186
+ accountCells: number;
187
+ gas: {
188
+ burnNotification: number;
189
+ mintAfterError: number;
190
+ };
191
+ };
192
+ nftItem: {
193
+ accountBits: number;
194
+ accountCells: number;
195
+ gas: {
196
+ send: number;
197
+ burn: number;
198
+ errorNotification: number;
199
+ };
200
+ };
201
+ nftProxy: {
202
+ accountBits: number;
203
+ accountCells: number;
204
+ gas: {
205
+ ownershipAssigned: number;
206
+ errorNotification: number;
207
+ };
208
+ };
209
+ };
151
210
  export type TransactionFeeCalculationStep = {
152
211
  accountBits: number;
153
212
  accountCells: number;
@@ -157,3 +216,10 @@ export type TransactionFeeCalculationStep = {
157
216
  timeDelta: number;
158
217
  };
159
218
  export type TONFeeCalculationParams = TransactionFeeCalculationStep & TONFeesParams;
219
+ export type TacGasPriceResponse = {
220
+ gasPrices: {
221
+ average: number;
222
+ fast: number;
223
+ slow: number;
224
+ };
225
+ };
@@ -446,10 +446,12 @@ export type GeneratePayloadParams = {
446
446
  forwardFeeTonAmount?: bigint;
447
447
  feeParams?: FeeParams;
448
448
  };
449
- export type TacGasPriceResponse = {
450
- gasPrices: {
451
- average: number;
452
- fast: number;
453
- slow: number;
454
- };
449
+ export type TacGasPrice = {
450
+ average: number;
451
+ fast: number;
452
+ slow: number;
453
+ };
454
+ export type TrackTransactionTreeParams = {
455
+ maxDepth?: number;
456
+ ignoreOpcodeList?: number[];
455
457
  };