@tonappchain/sdk 0.7.0-rc25 → 0.7.0-rc27

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/README.md CHANGED
@@ -11,6 +11,8 @@ The TAC SDK makes it possible to create hybrid dApps that let TON users interact
11
11
 
12
12
  For full documentation and examples, please visit [TAC SDK Documentation](https://docs.tac.build/build/sdk/introduction).
13
13
 
14
+ For practical examples and usage patterns, see [Examples Documentation](./docs/examples/examples.md).
15
+
14
16
  ### Installation
15
17
 
16
18
  ```bash
@@ -100,7 +100,14 @@ class AbiHandler {
100
100
  // Handle struct/tuple types
101
101
  if (param.components && Array.isArray(param.components)) {
102
102
  const componentTypes = param.components
103
- .map((component) => this._buildParameterType(component))
103
+ .map((component) => {
104
+ const baseType = this._buildParameterType(component);
105
+ // Include parameter name for struct components if available
106
+ if (component.name) {
107
+ return `${baseType} ${component.name}`;
108
+ }
109
+ return baseType;
110
+ })
104
111
  .join(',');
105
112
  return `(${componentTypes})`;
106
113
  }
@@ -110,7 +117,14 @@ class AbiHandler {
110
117
  // Handle array of structs
111
118
  if (param.components && Array.isArray(param.components)) {
112
119
  const componentTypes = param.components
113
- .map((component) => this._buildParameterType(component))
120
+ .map((component) => {
121
+ const baseType = this._buildParameterType(component);
122
+ // Include parameter name for struct components if available
123
+ if (component.name) {
124
+ return `${baseType} ${component.name}`;
125
+ }
126
+ return baseType;
127
+ })
114
128
  .join(',');
115
129
  return `(${componentTypes})[]`;
116
130
  }
@@ -1,21 +1,20 @@
1
1
  import type { SenderAbstraction } from '../sender';
2
- import { CrosschainTx, EvmProxyMsg, OperationIdsByShardsKey, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
2
+ import { BatchCrossChainTx, CrossChainTransactionsOptions, CrosschainTx, EvmProxyMsg, TransactionLinkerWithOperationId } from '../structs/Struct';
3
3
  export interface ITONTransactionManager {
4
4
  /**
5
5
  * Sends a single cross-chain transaction.
6
6
  * @param evmProxyMsg Encoded EVM proxy message to bridge.
7
7
  * @param sender Sender abstraction for TVM message sending.
8
8
  * @param tx cross-chain transaction to bridge.
9
- * @param waitOptions Optional policy to wait for operation id resolution.
10
9
  * @returns Transaction linker with operation id for tracking.
11
10
  */
12
- sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
11
+ sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<TransactionLinkerWithOperationId>;
13
12
  /**
14
13
  * Sends multiple cross-chain transactions in a batch.
15
14
  * @param sender Sender abstraction for TVM message sending.
16
15
  * @param txs List of cross-chain transactions to bridge.
17
- * @param waitOptions Optional policy for waiting on operation ids by shard keys.
16
+ * @param options Optional options controlling waiting behavior for operation ids.
18
17
  * @returns Array of transaction linkers, one per submitted transaction.
19
18
  */
20
- sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
19
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTx[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
21
20
  }
@@ -2,7 +2,7 @@ import { Wallet } from 'ethers';
2
2
  import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
3
3
  import { FT, NFT } from '../assets';
4
4
  import type { SenderAbstraction } from '../sender';
5
- import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, CrossChainTransactionOptions, CrosschainTx, CrosschainTxWithAssetLike, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, OperationIdsByShardsKey, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
5
+ import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
6
6
  import { Asset } from './Asset';
7
7
  import { IConfiguration } from './IConfiguration';
8
8
  import { IOperationTracker } from './IOperationTracker';
@@ -98,10 +98,10 @@ export interface ITacSDK {
98
98
  * Sends multiple cross-chain transactions in one batch and optionally waits for tracking info.
99
99
  * @param sender Sender abstraction for signing/sending TVM messages.
100
100
  * @param txs Array of cross-chain transactions to broadcast.
101
- * @param waitOptions Optional waiting policy for operation ids by shard keys.
101
+ * @param options Optional options controlling waiting behavior for operation ids.
102
102
  * @returns Promise with an array of TransactionLinkerWithOperationId for each submitted transaction.
103
103
  */
104
- sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTxWithAssetLike[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
104
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
105
105
  /**
106
106
  * Bridges tokens/value from EVM to TON chain via the executor.
107
107
  * @param signer Ethers Wallet used to sign the EVM-side transaction.
@@ -15,10 +15,18 @@ class LiteSequencerClient {
15
15
  const isEthHash = /^0x[a-fA-F0-9]{64}$/.test(transactionHash);
16
16
  const path = isEthHash ? 'tac/operation-id' : 'ton/operation-id';
17
17
  try {
18
- const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
19
- params: { transactionHash },
20
- });
21
- return response.data.response || '';
18
+ if (isEthHash) {
19
+ const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
20
+ params: { transactionHash },
21
+ });
22
+ return response.data.response?.operationId || '';
23
+ }
24
+ else {
25
+ const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
26
+ params: { transactionHash },
27
+ });
28
+ return response.data.response || '';
29
+ }
22
30
  }
23
31
  catch (error) {
24
32
  if (error?.response?.status === 404) {
@@ -1,6 +1,6 @@
1
1
  import { IConfiguration, ILogger, IOperationTracker, ISimulator, ITONTransactionManager } from '../interfaces';
2
2
  import type { SenderAbstraction } from '../sender';
3
- import { CrosschainTx, EvmProxyMsg, OperationIdsByShardsKey, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
3
+ import { BatchCrossChainTx, CrossChainTransactionsOptions, CrosschainTx, EvmProxyMsg, TransactionLinkerWithOperationId } from '../structs/Struct';
4
4
  export declare class TONTransactionManager implements ITONTransactionManager {
5
5
  private readonly config;
6
6
  private readonly simulator;
@@ -10,8 +10,8 @@ export declare class TONTransactionManager implements ITONTransactionManager {
10
10
  private buildFeeParams;
11
11
  private prepareCrossChainTransaction;
12
12
  private generateCrossChainMessages;
13
- sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
14
- sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
13
+ sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<TransactionLinkerWithOperationId>;
14
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTx[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
15
15
  private prepareBatchTransactions;
16
16
  private waitForOperationIds;
17
17
  }
@@ -136,17 +136,18 @@ class TONTransactionManager {
136
136
  this.logger.debug('Cross-chain messages generated successfully');
137
137
  return messages;
138
138
  }
139
- async sendCrossChainTransaction(evmProxyMsg, sender, tx, waitOptions) {
139
+ async sendCrossChainTransaction(evmProxyMsg, sender, tx) {
140
140
  const { transaction, transactionLinker } = await this.prepareCrossChainTransaction(evmProxyMsg, sender, tx.assets, tx.options);
141
141
  await assets_1.TON.checkBalance(sender, this.config, [transaction]);
142
142
  this.logger.debug(`Sending transaction: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
143
143
  const sendTransactionResult = await sender.sendShardTransaction(transaction, this.config.network, this.config.TONParams.contractOpener);
144
- if (!waitOptions) {
144
+ const shouldWaitForOperationId = tx.options?.waitOperationId ?? true;
145
+ if (!shouldWaitForOperationId) {
145
146
  return { sendTransactionResult, ...transactionLinker };
146
147
  }
147
148
  const operationId = await this.operationTracker
148
149
  .getOperationId(transactionLinker, {
149
- ...waitOptions,
150
+ ...(tx.options?.waitOptions ?? {}),
150
151
  successCheck: (id) => !!id,
151
152
  logger: this.logger,
152
153
  })
@@ -156,15 +157,16 @@ class TONTransactionManager {
156
157
  });
157
158
  return { sendTransactionResult, operationId, ...transactionLinker };
158
159
  }
159
- async sendCrossChainTransactions(sender, txs, waitOptions) {
160
+ async sendCrossChainTransactions(sender, txs, options) {
160
161
  const caller = sender.getSenderAddress();
161
162
  this.logger.debug(`Preparing ${txs.length} cross-chain transactions for ${caller}`);
162
163
  const { transactions, transactionLinkers } = await this.prepareBatchTransactions(txs, sender);
163
164
  await assets_1.TON.checkBalance(sender, this.config, transactions);
164
165
  this.logger.debug(`Sending transactions: ${(0, Utils_1.formatObjectForLogging)(transactionLinkers)}`);
165
166
  await sender.sendShardTransactions(transactions, this.config.network, this.config.TONParams.contractOpener);
166
- return waitOptions
167
- ? await this.waitForOperationIds(transactionLinkers, caller, waitOptions)
167
+ const shouldWaitForOperationIds = options?.waitOperationIds ?? true;
168
+ return shouldWaitForOperationIds
169
+ ? await this.waitForOperationIds(transactionLinkers, caller, options?.waitOptions ?? {})
168
170
  : transactionLinkers;
169
171
  }
170
172
  async prepareBatchTransactions(txs, sender) {
@@ -3,7 +3,7 @@ import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
3
3
  import { FT, NFT } from '../assets';
4
4
  import { IConfiguration, ILogger, IOperationTracker, ITacSDK } from '../interfaces';
5
5
  import type { SenderAbstraction } from '../sender';
6
- import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, CrossChainTransactionOptions, CrosschainTx, CrosschainTxWithAssetLike, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, OperationIdsByShardsKey, SDKParams, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
6
+ import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, 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;
@@ -20,8 +20,8 @@ export declare class TacSdk implements ITacSDK {
20
20
  get getTrustedTONExecutors(): string[];
21
21
  getSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<ExecutionFeeEstimationResult>;
22
22
  getTVMExecutorFeeInfo(assets: AssetLike[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTVMExecutorFee>;
23
- sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
24
- sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTxWithAssetLike[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
23
+ sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<TransactionLinkerWithOperationId>;
24
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
25
25
  bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: AssetLike[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
26
26
  isContractDeployedOnTVM(address: string): Promise<boolean>;
27
27
  simulateTACMessage(req: TACSimulationParams): Promise<TACSimulationResult>;
@@ -77,18 +77,18 @@ class TacSdk {
77
77
  };
78
78
  return this.operationTracker.getTVMExecutorFee(params);
79
79
  }
80
- async sendCrossChainTransaction(evmProxyMsg, sender, assets = [], options, waitOptions) {
80
+ async sendCrossChainTransaction(evmProxyMsg, sender, assets = [], options) {
81
81
  const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
82
82
  const tx = { evmProxyMsg, assets: normalizedAssets, options };
83
- return this.tonTransactionManager.sendCrossChainTransaction(evmProxyMsg, sender, tx, waitOptions);
83
+ return this.tonTransactionManager.sendCrossChainTransaction(evmProxyMsg, sender, tx);
84
84
  }
85
- async sendCrossChainTransactions(sender, txs, waitOptions) {
85
+ async sendCrossChainTransactions(sender, txs, options) {
86
86
  const normalizedTxs = await Promise.all(txs.map(async (tx) => ({
87
87
  evmProxyMsg: tx.evmProxyMsg,
88
88
  options: tx.options,
89
89
  assets: await (0, Utils_1.normalizeAssets)(this.config, tx.assets),
90
90
  })));
91
- return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, waitOptions);
91
+ return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, options);
92
92
  }
93
93
  async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors) {
94
94
  const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
@@ -54,6 +54,11 @@ export type StageProfilingResponse = ResponseBase<ExecutionStagesByOperationId>;
54
54
  export type TACSimulationResponse = ResponseBase<TACSimulationResult>;
55
55
  export type SuggestedTVMExecutorFeeResponse = ResponseBase<SuggestedTVMExecutorFee>;
56
56
  export type ConvertCurrencyResponse = ResponseBase<ConvertedCurrencyRawResult>;
57
+ export type OperationIdWithLogIndex = {
58
+ operationId: string;
59
+ logIndex: number;
60
+ };
61
+ export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex>;
57
62
  export interface SendResult {
58
63
  success: boolean;
59
64
  result?: unknown;
@@ -287,6 +287,13 @@ export type CrossChainTransactionOptions = {
287
287
  calculateRollbackFee?: boolean;
288
288
  withoutSimulation?: boolean;
289
289
  validateAssetsBalance?: boolean;
290
+ waitOperationId?: boolean;
291
+ waitOptions?: WaitOptions<string>;
292
+ };
293
+ export type BatchCrossChainTransactionOptions = Omit<CrossChainTransactionOptions, 'waitOperationId' | 'waitOptions'>;
294
+ export type CrossChainTransactionsOptions = {
295
+ waitOperationIds?: boolean;
296
+ waitOptions?: WaitOptions<OperationIdsByShardsKey>;
290
297
  };
291
298
  export type ExecutionFeeEstimationResult = {
292
299
  feeParams: FeeParams;
@@ -297,6 +304,11 @@ export type CrosschainTx = {
297
304
  assets?: Asset[];
298
305
  options?: CrossChainTransactionOptions;
299
306
  };
307
+ export type BatchCrossChainTx = {
308
+ evmProxyMsg: EvmProxyMsg;
309
+ assets?: Asset[];
310
+ options?: BatchCrossChainTransactionOptions;
311
+ };
300
312
  export type AssetLike = Asset | FT | NFT | {
301
313
  rawAmount: bigint;
302
314
  } | {
@@ -313,7 +325,7 @@ export type AssetLike = Asset | FT | NFT | {
313
325
  address: TVMAddress | EVMAddress;
314
326
  itemIndex: bigint;
315
327
  };
316
- export type CrosschainTxWithAssetLike = Omit<CrosschainTx, 'assets'> & {
328
+ export type BatchCrossChainTxWithAssetLike = Omit<BatchCrossChainTx, 'assets'> & {
317
329
  assets?: AssetLike[];
318
330
  };
319
331
  export interface WaitOptions<T = unknown, TContext = unknown> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonappchain/sdk",
3
- "version": "0.7.0-rc25",
3
+ "version": "0.7.0-rc27",
4
4
  "repository": "https://github.com/TacBuild/tac-sdk.git",
5
5
  "author": "TAC. <developers@tac>",
6
6
  "license": "MIT",
@@ -51,16 +51,16 @@
51
51
  "scripts": {
52
52
  "prebuild": "git submodule update --init --recursive --remote",
53
53
  "litebuild": "rm -rf dist && tsc --declaration",
54
- "build": "rm -rf dist && yarn build:artifacts && tsc --declaration",
54
+ "build": "rm -rf dist && npm run build:artifacts && tsc --declaration",
55
55
  "build:artifacts:tac:dev": "cd artifacts/dev/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
56
56
  "build:artifacts:ton:dev": "cd artifacts/dev/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
57
57
  "build:artifacts:tac:testnet": "cd artifacts/testnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
58
58
  "build:artifacts:ton:testnet": "cd artifacts/testnet/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
59
59
  "build:artifacts:tac:mainnet": "cd artifacts/mainnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
60
60
  "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
- "build:artifacts:ton:all": "yarn build:artifacts:ton:dev && yarn build:artifacts:ton:testnet && yarn build:artifacts:ton:mainnet",
62
- "build:artifacts:tac:all": "yarn build:artifacts:tac:dev && yarn build:artifacts:tac:testnet && yarn build:artifacts:tac:mainnet",
63
- "build:artifacts": "yarn prebuild && yarn build:artifacts:ton:all && yarn build:artifacts:tac:all",
61
+ "build:artifacts:ton:all": "npm run build:artifacts:ton:dev && npm run build:artifacts:ton:testnet && npm run build:artifacts:ton:mainnet",
62
+ "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 prebuild && npm run build:artifacts:ton:all && npm run build:artifacts:tac:all",
64
64
  "test": "jest --verbose --runInBand",
65
65
  "release": "yarn build && yarn release-it --npm.yarn1",
66
66
  "lint": "eslint .",
@@ -77,8 +77,7 @@
77
77
  "cli-table3": "^0.6.5",
78
78
  "dotenv": "^16.4.7",
79
79
  "ethers": "^6.13.5",
80
- "ton-crypto": "^3.2.0",
81
- "yarn": "^1.22.22"
80
+ "ton-crypto": "^3.2.0"
82
81
  },
83
82
  "keywords": [],
84
83
  "description": "",
@@ -98,7 +97,8 @@
98
97
  "ts-jest": "^29.2.6",
99
98
  "ts-node": "^10.9.2",
100
99
  "typescript": "^5.7.3",
101
- "typescript-eslint": "^8.17.0"
100
+ "typescript-eslint": "^8.17.0",
101
+ "yarn": "^1.22.22"
102
102
  },
103
103
  "publishConfig": {
104
104
  "access": "public",