@tonappchain/sdk 0.7.0-rc13 → 0.7.0-rc15

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 (57) hide show
  1. package/README.md +7 -7
  2. package/dist/adapters/contractOpener.js +33 -4
  3. package/dist/adapters/retryableContractOpener.js +1 -1
  4. package/dist/assets/AssetFactory.js +1 -1
  5. package/dist/assets/FT.d.ts +8 -12
  6. package/dist/assets/FT.js +69 -36
  7. package/dist/assets/NFT.d.ts +4 -2
  8. package/dist/assets/NFT.js +14 -2
  9. package/dist/assets/TON.d.ts +4 -10
  10. package/dist/assets/TON.js +17 -15
  11. package/dist/errors/index.d.ts +1 -1
  12. package/dist/errors/index.js +7 -2
  13. package/dist/errors/instances.d.ts +8 -1
  14. package/dist/errors/instances.js +22 -16
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +5 -3
  17. package/dist/interfaces/Asset.d.ts +22 -17
  18. package/dist/interfaces/ILiteSequencerClient.d.ts +14 -1
  19. package/dist/interfaces/IOperationTracker.d.ts +16 -1
  20. package/dist/interfaces/ISimulator.d.ts +7 -36
  21. package/dist/interfaces/ITACTransactionManager.d.ts +15 -0
  22. package/dist/interfaces/ITONTransactionManager.d.ts +21 -0
  23. package/dist/interfaces/ITONTransactionManager.js +2 -0
  24. package/dist/interfaces/ITacSDK.d.ts +51 -13
  25. package/dist/interfaces/index.d.ts +2 -1
  26. package/dist/interfaces/index.js +2 -1
  27. package/dist/sdk/Configuration.d.ts +1 -0
  28. package/dist/sdk/Configuration.js +67 -14
  29. package/dist/sdk/Consts.d.ts +1 -0
  30. package/dist/sdk/Consts.js +5 -4
  31. package/dist/sdk/LiteSequencerClient.d.ts +5 -3
  32. package/dist/sdk/LiteSequencerClient.js +27 -4
  33. package/dist/sdk/OperationTracker.d.ts +3 -1
  34. package/dist/sdk/OperationTracker.js +51 -11
  35. package/dist/sdk/Simulator.d.ts +6 -12
  36. package/dist/sdk/Simulator.js +30 -124
  37. package/dist/sdk/TACTransactionManager.d.ts +10 -0
  38. package/dist/sdk/TACTransactionManager.js +92 -0
  39. package/dist/sdk/TONTransactionManager.d.ts +17 -0
  40. package/dist/sdk/TONTransactionManager.js +209 -0
  41. package/dist/sdk/TacSdk.d.ts +16 -10
  42. package/dist/sdk/TacSdk.js +52 -19
  43. package/dist/sdk/TxFinalizer.d.ts +3 -2
  44. package/dist/sdk/TxFinalizer.js +8 -8
  45. package/dist/sdk/Utils.d.ts +9 -4
  46. package/dist/sdk/Utils.js +86 -12
  47. package/dist/sdk/Validator.d.ts +2 -2
  48. package/dist/sdk/Validator.js +1 -1
  49. package/dist/structs/InternalStruct.d.ts +6 -2
  50. package/dist/structs/Struct.d.ts +70 -16
  51. package/dist/wrappers/Settings.d.ts +5 -1
  52. package/dist/wrappers/Settings.js +17 -0
  53. package/package.json +4 -3
  54. package/dist/interfaces/ITransactionManager.d.ts +0 -35
  55. package/dist/sdk/TransactionManager.d.ts +0 -22
  56. package/dist/sdk/TransactionManager.js +0 -272
  57. /package/dist/interfaces/{ITransactionManager.js → ITACTransactionManager.js} +0 -0
@@ -6,28 +6,33 @@ export interface Asset {
6
6
  rawAmount: bigint;
7
7
  clone: Asset;
8
8
  /**
9
- * Returns a new asset instance with the specified transfer amount.
10
- * Use { rawAmount } for base units (e.g., nano units), or { amount } for human-readable units if supported by the implementation.
9
+ * Returns a new asset instance with the specified transfer amount in human-readable units.
11
10
  * Does not mutate the current asset instance.
12
- * @param amount Object specifying either rawAmount (bigint base units) or amount (number in human units).
13
- * @returns Promise that resolves to a new Asset reflecting the requested amount.
11
+ * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
12
+ * @returns A new Asset reflecting the requested amount.
14
13
  */
15
- withAmount(amount: {
16
- rawAmount: bigint;
17
- } | {
18
- amount: number;
19
- }): Promise<Asset>;
14
+ withAmount(amount: number): Asset;
20
15
  /**
21
- * Increases the transfer amount by the specified value and returns a new asset instance.
16
+ * Returns a new asset instance with the specified transfer amount in raw base units.
22
17
  * Does not mutate the current asset instance.
23
- * @param amount Object specifying either rawAmount (bigint base units) or amount (number in human units).
24
- * @returns Promise that resolves to a new Asset with the increased amount.
18
+ * @param rawAmount Amount in raw base units (bigint).
19
+ * @returns A new Asset reflecting the requested raw amount.
25
20
  */
26
- addAmount(amount: {
27
- rawAmount: bigint;
28
- } | {
29
- amount: number;
30
- }): Promise<Asset>;
21
+ withRawAmount(rawAmount: bigint): Asset;
22
+ /**
23
+ * Increases the transfer amount by the specified value (human-readable units) and returns a new asset instance.
24
+ * Does not mutate the current asset instance.
25
+ * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
26
+ * @returns A new Asset with the increased amount.
27
+ */
28
+ addAmount(amount: number): Asset;
29
+ /**
30
+ * Increases the transfer amount by the specified raw base units and returns a new asset instance.
31
+ * Does not mutate the current asset instance.
32
+ * @param rawAmount Amount in raw base units (bigint).
33
+ * @returns A new Asset with the increased amount in raw units.
34
+ */
35
+ addRawAmount(rawAmount: bigint): Asset;
31
36
  /**
32
37
  * Resolves the corresponding EVM token address for this asset.
33
38
  * Useful when bridging or interacting with EVM-compatible networks.
@@ -1,4 +1,4 @@
1
- import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, TransactionLinker } from '../structs/Struct';
1
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
2
2
  export interface ILiteSequencerClient {
3
3
  /** Retrieves the operation type by id. */
4
4
  getOperationType(operationId: string): Promise<OperationType>;
@@ -27,4 +27,17 @@ export interface ILiteSequencerClient {
27
27
  getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
28
28
  /** Converts currency amount using the sequencer-provided rate source. */
29
29
  convertCurrency(params: ConvertCurrencyParams): Promise<ConvertedCurrencyResult>;
30
+ /**
31
+ * Gets TVM executor fee information for cross-chain operations.
32
+ * @param params Parameters for fee calculation including assets and fee symbol.
33
+ * @returns Promise resolving to suggested TVM executor fee information.
34
+ */
35
+ getTVMExecutorFee(params: GetTVMExecutorFeeParams): Promise<SuggestedTVMExecutorFee>;
36
+ /**
37
+ * Simulates TAC message execution without broadcasting it on-chain.
38
+ * Useful for estimating fees and validating transaction inputs.
39
+ * @param params Simulation request with encoded message and context.
40
+ * @returns Promise resolving to detailed simulation result.
41
+ */
42
+ simulateTACMessage(params: TACSimulationParams): Promise<TACSimulationResult>;
30
43
  }
@@ -1,4 +1,4 @@
1
- import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, TransactionLinker, WaitOptions } from '../structs/Struct';
1
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
2
2
  export interface IOperationTracker {
3
3
  /**
4
4
  * Returns the operation type for the given id, optionally waiting according to the provided policy.
@@ -63,4 +63,19 @@ export interface IOperationTracker {
63
63
  * @param waitOptions Optional waiting settings.
64
64
  */
65
65
  convertCurrency(params: ConvertCurrencyParams, waitOptions?: WaitOptions<ConvertedCurrencyResult>): Promise<ConvertedCurrencyResult>;
66
+ /**
67
+ * Simulates execution of a TAC message without broadcasting it, optionally waiting until the result is available.
68
+ * Useful to validate inputs and estimate effects before sending a real transaction.
69
+ * @param params Simulation parameters and context.
70
+ * @param waitOptions Optional waiting settings (polling/timeout policy).
71
+ * @returns Promise with detailed simulation result.
72
+ */
73
+ simulateTACMessage(params: TACSimulationParams, waitOptions?: WaitOptions<TACSimulationResult>): Promise<TACSimulationResult>;
74
+ /**
75
+ * Suggests/calculates a TVM executor fee for the provided parameters, optionally waiting for completion.
76
+ * @param params Parameters affecting fee calculation.
77
+ * @param waitOptions Optional waiting settings (polling/timeout policy).
78
+ * @returns Promise with suggested fee information.
79
+ */
80
+ getTVMExecutorFee(params: GetTVMExecutorFeeParams, waitOptions?: WaitOptions<SuggestedTVMExecutorFee>): Promise<SuggestedTVMExecutorFee>;
66
81
  }
@@ -1,47 +1,18 @@
1
1
  import type { SenderAbstraction } from '../sender';
2
- import { CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinker } from '../structs/Struct';
3
- import { Asset } from './Asset';
2
+ import { CrosschainTx, ExecutionFeeEstimationResult } from '../structs/Struct';
4
3
  export interface ISimulator {
5
- /**
6
- * Simulates a TAC message execution without sending it to the chain.
7
- * @param req Simulation request that encapsulates the message and context.
8
- * @returns Promise with detailed simulation output.
9
- */
10
- simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
11
4
  /**
12
5
  * Simulates a list of cross-chain transactions for a given sender.
13
6
  * @param sender Sender abstraction used to provide context (e.g., wallet state).
14
7
  * @param txs Cross-chain transactions to simulate.
15
- * @returns Promise with results, one for each input transaction.
16
- */
17
- simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
18
- /**
19
- * Suggests the TON executor fee for a given set of assets and target fee symbol.
20
- * @param assets Assets involved in execution.
21
- * @param feeSymbol Symbol that represents the fee denomination (e.g., TON).
22
- * @param tvmValidExecutors Whitelist of permitted TVM executors (optional).
23
- * @returns Promise with suggested fee information.
8
+ * @returns Promise with fee estimation results, one for each input transaction.
24
9
  */
25
- getTVMExecutorFeeInfo(assets: Asset[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTONExecutorFee>;
10
+ getSimulationsInfo(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
26
11
  /**
27
- * Computes simulation info and fees for a single transaction, using the provided sender context.
28
- * @param evmProxyMsg Encoded EVM proxy message.
29
- * @param sender Sender abstraction.
30
- * @param assets Optional list of assets to attach to the transaction.
31
- * @returns Promise with execution fee estimation details.
32
- */
33
- getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[]): Promise<ExecutionFeeEstimationResult>;
34
- /**
35
- * Computes simulation info for a transaction tied to an existing TransactionLinker.
36
- * @param evmProxyMsg Encoded EVM proxy message.
37
- * @param transactionLinker Linker referencing the originating transaction.
38
- * @param assets Assets to be included in the transaction.
39
- * @param allowSimulationError If true, returns partial info even if simulation fails.
40
- * @param isRoundTrip If true, includes round-trip (rollback) considerations.
41
- * @param evmValidExecutors Optional whitelist of EVM-side executors.
42
- * @param tvmValidExecutors Optional whitelist of TVM-side executors.
43
- * @param calculateRollbackFee If true, includes rollback fee in estimation.
12
+ * Get tvm fees and simulation info for a tvm transaction using sender abstraction.
13
+ * @param sender Sender abstraction used to provide context (e.g., wallet state).
14
+ * @param tx Cross-chain transaction to simulate.
44
15
  * @returns Promise with fee estimation and execution info.
45
16
  */
46
- getSimulationInfoForTransaction(evmProxyMsg: EvmProxyMsg, transactionLinker: TransactionLinker, assets: Asset[], allowSimulationError?: boolean, isRoundTrip?: boolean, evmValidExecutors?: string[], tvmValidExecutors?: string[], calculateRollbackFee?: boolean): Promise<ExecutionFeeEstimationResult>;
17
+ getSimulationInfo(sender: SenderAbstraction, tx: CrosschainTx): Promise<ExecutionFeeEstimationResult>;
47
18
  }
@@ -0,0 +1,15 @@
1
+ import { Wallet } from 'ethers';
2
+ import { Asset } from './Asset';
3
+ export interface ITACTransactionManager {
4
+ /**
5
+ * Bridges native EVM value and optional assets to TON chain via executor.
6
+ * @param signer Ethers Wallet used to sign EVM transaction.
7
+ * @param value Amount of native EVM currency (wei as bigint).
8
+ * @param tonTarget Recipient TVM address on TON.
9
+ * @param assets Optional list of TAC assets to include.
10
+ * @param tvmExecutorFee Optional explicit TON-side executor fee.
11
+ * @param tvmValidExecutors Optional whitelist of allowed TVM executors.
12
+ * @returns EVM transaction hash or bridge identifier.
13
+ */
14
+ bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: Asset[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
15
+ }
@@ -0,0 +1,21 @@
1
+ import type { SenderAbstraction } from '../sender';
2
+ import { CrosschainTx, EvmProxyMsg, OperationIdsByShardsKey, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
3
+ export interface ITONTransactionManager {
4
+ /**
5
+ * Sends a single cross-chain transaction.
6
+ * @param evmProxyMsg Encoded EVM proxy message to bridge.
7
+ * @param sender Sender abstraction for TVM message sending.
8
+ * @param tx cross-chain transaction to bridge.
9
+ * @param waitOptions Optional policy to wait for operation id resolution.
10
+ * @returns Transaction linker with operation id for tracking.
11
+ */
12
+ sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
13
+ /**
14
+ * Sends multiple cross-chain transactions in a batch.
15
+ * @param sender Sender abstraction for TVM message sending.
16
+ * @param txs List of cross-chain transactions to bridge.
17
+ * @param waitOptions Optional policy for waiting on operation ids by shard keys.
18
+ * @returns Array of transaction linkers, one per submitted transaction.
19
+ */
20
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,11 @@
1
1
  import { Wallet } from 'ethers';
2
2
  import { FT, NFT } from '../assets';
3
3
  import type { SenderAbstraction } from '../sender';
4
- import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, CrossChainTransactionOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, NFTItemData, OperationIdsByShardsKey, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
4
+ import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, CrossChainTransactionOptions, CrosschainTx, CrosschainTxWithAssetLike, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, NFTItemData, OperationIdsByShardsKey, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
5
5
  import { JettonMasterData } from '../wrappers/JettonMaster';
6
6
  import { Asset } from './Asset';
7
7
  import { IConfiguration } from './IConfiguration';
8
+ import { IOperationTracker } from './IOperationTracker';
8
9
  export interface ITacSDK {
9
10
  readonly config: IConfiguration;
10
11
  /**
@@ -58,22 +59,23 @@ export interface ITacSDK {
58
59
  * @param req Simulation request with encoded message and context.
59
60
  * @returns Promise with the detailed simulation result.
60
61
  */
61
- simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
62
+ simulateTACMessage(req: TACSimulationParams): Promise<TACSimulationResult>;
62
63
  /**
63
64
  * Simulates a batch of cross-chain transactions from a given sender.
64
65
  * @param sender Abstracted sender used for simulation context (not broadcasting).
65
66
  * @param txs Array of cross-chain transactions to simulate.
66
- * @returns Promise with an array of results matching the input order.
67
+ * @returns Promise with an array of fee estimation results matching the input order.
67
68
  */
68
- simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
69
+ simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
69
70
  /**
70
- * Computes fee and execution information for a prospective transaction.
71
+ * Get tvm fees and simulation info for a tvm transaction using sender abstraction.
71
72
  * @param evmProxyMsg Encoded EVM proxy message.
72
- * @param sender Sender abstraction providing context (e.g., seqno, wallet info).
73
- * @param assets Optional list of assets attached to the transaction.
74
- * @returns Promise with the fee estimation and execution breakdown.
73
+ * @param sender Sender abstraction used to provide context (e.g., wallet state).
74
+ * @param assets Assets to be included in the transaction.
75
+ * @param options Optional transaction configuration including error handling and executor settings.
76
+ * @returns Promise with fee estimation and execution info.
75
77
  */
76
- getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[]): Promise<ExecutionFeeEstimationResult>;
78
+ getSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<ExecutionFeeEstimationResult>;
77
79
  /**
78
80
  * Suggests optimal TON-side executor fee for a given asset set and fee symbol.
79
81
  * @param assets Assets to be processed on TON side.
@@ -81,7 +83,7 @@ export interface ITacSDK {
81
83
  * @param tvmValidExecutors Optional whitelist of allowed TVM executors.
82
84
  * @returns Promise with suggested fee details.
83
85
  */
84
- getTVMExecutorFeeInfo(assets: Asset[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTONExecutorFee>;
86
+ getTVMExecutorFeeInfo(assets: AssetLike[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTVMExecutorFee>;
85
87
  /**
86
88
  * Sends a single cross-chain transaction and optionally waits for tracking information.
87
89
  * @param evmProxyMsg Encoded EVM proxy message to be bridged.
@@ -91,7 +93,7 @@ export interface ITacSDK {
91
93
  * @param waitOptions Optional waiting policy for operation id resolution.
92
94
  * @returns Promise with a TransactionLinkerWithOperationId to track the operation across chains.
93
95
  */
94
- sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
96
+ sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
95
97
  /**
96
98
  * Sends multiple cross-chain transactions in one batch and optionally waits for tracking info.
97
99
  * @param sender Sender abstraction for signing/sending TVM messages.
@@ -99,7 +101,7 @@ export interface ITacSDK {
99
101
  * @param waitOptions Optional waiting policy for operation ids by shard keys.
100
102
  * @returns Promise with an array of TransactionLinkerWithOperationId for each submitted transaction.
101
103
  */
102
- sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
104
+ sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTxWithAssetLike[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
103
105
  /**
104
106
  * Bridges tokens/value from EVM to TON chain via the executor.
105
107
  * @param signer Ethers Wallet used to sign the EVM-side transaction.
@@ -110,7 +112,7 @@ export interface ITacSDK {
110
112
  * @param tvmValidExecutors Optional whitelist of allowed TVM executors.
111
113
  * @returns Promise resolving to the EVM transaction hash or bridge identifier.
112
114
  */
113
- bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: Asset[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
115
+ bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: AssetLike[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
114
116
  /**
115
117
  * Returns the user's Jetton wallet address for a given Jetton master (token) address.
116
118
  * @param userAddress TVM user address.
@@ -138,10 +140,46 @@ export interface ITacSDK {
138
140
  * @returns Promise resolving to JettonMasterData.
139
141
  */
140
142
  getJettonData(itemAddress: TVMAddress): Promise<JettonMasterData>;
143
+ /**
144
+ * Returns NFT item data for the specified TVM address.
145
+ * @param itemAddress TVM address of the NFT item.
146
+ * @returns Promise resolving to the NFT item data.
147
+ */
141
148
  getNFTItemData(itemAddress: TVMAddress): Promise<NFTItemData>;
149
+ /**
150
+ * Resolves the EVM token address that corresponds to the provided TVM token address.
151
+ * @param tvmTokenAddress TVM token (Jetton) master address.
152
+ * @returns Promise resolving to the EVM token address.
153
+ */
142
154
  getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
155
+ /**
156
+ * Resolves the TVM token address that corresponds to the provided EVM token address.
157
+ * @param evmTokenAddress EVM token contract address (checksum string).
158
+ * @returns Promise resolving to the TVM token (Jetton) master address.
159
+ */
143
160
  getTVMTokenAddress(evmTokenAddress: string): Promise<string>;
161
+ /**
162
+ * Resolves the TVM NFT address for a given EVM NFT contract and optional token id.
163
+ * @param evmNFTAddress EVM NFT contract address.
164
+ * @param tokenId Optional NFT token id; when omitted, returns the collection address if applicable.
165
+ * @returns Promise resolving to the TVM NFT address.
166
+ */
144
167
  getTVMNFTAddress(evmNFTAddress: string, tokenId?: number | bigint): Promise<string>;
168
+ /**
169
+ * Resolves the EVM NFT address for a given TVM NFT address and desired address type.
170
+ * @param tvmNFTAddress TVM NFT item or collection address.
171
+ * @param addressType Desired address type on EVM side (collection or item).
172
+ * @returns Promise resolving to the EVM NFT address.
173
+ */
145
174
  getEVMNFTAddress(tvmNFTAddress: string, addressType: NFTAddressType): Promise<string>;
175
+ /**
176
+ * Checks whether a contract is deployed at the provided TVM address on the current network.
177
+ * @param address TVM address to check.
178
+ * @returns Promise resolving to true if deployed, false otherwise.
179
+ */
146
180
  isContractDeployedOnTVM(address: string): Promise<boolean>;
181
+ /**
182
+ * Returns the operation tracker instance used for querying operation statuses and utilities.
183
+ */
184
+ getOperationTracker(): IOperationTracker;
147
185
  }
@@ -8,6 +8,7 @@ export * from './ILogger';
8
8
  export * from './IOperationTracker';
9
9
  export * from './ISimulator';
10
10
  export * from './ITacSDK';
11
- export * from './ITransactionManager';
11
+ export * from './ITACTransactionManager';
12
+ export * from './ITONTransactionManager';
12
13
  export * from './SenderAbstraction';
13
14
  export * from './WalletInstanse';
@@ -24,6 +24,7 @@ __exportStar(require("./ILogger"), exports);
24
24
  __exportStar(require("./IOperationTracker"), exports);
25
25
  __exportStar(require("./ISimulator"), exports);
26
26
  __exportStar(require("./ITacSDK"), exports);
27
- __exportStar(require("./ITransactionManager"), exports);
27
+ __exportStar(require("./ITACTransactionManager"), exports);
28
+ __exportStar(require("./ITONTransactionManager"), exports);
28
29
  __exportStar(require("./SenderAbstraction"), exports);
29
30
  __exportStar(require("./WalletInstanse"), exports);
@@ -12,6 +12,7 @@ export declare class Configuration implements IConfiguration {
12
12
  static create(network: Network, artifacts: typeof testnet | typeof mainnet, TONParams?: TONParams, TACParams?: TACParams, customLiteSequencerEndpoints?: string[], delay?: number): Promise<Configuration>;
13
13
  private static prepareTONParams;
14
14
  private static prepareTACParams;
15
+ private static loadSettingsViaMulticall;
15
16
  get nativeTONAddress(): string;
16
17
  nativeTACAddress(): Promise<string>;
17
18
  get getTrustedTACExecutors(): string[];
@@ -7,6 +7,7 @@ const ethers_1 = require("ethers");
7
7
  const retryableContractOpener_1 = require("../adapters/retryableContractOpener");
8
8
  const Struct_1 = require("../structs/Struct");
9
9
  const Settings_1 = require("../wrappers/Settings");
10
+ const Utils_1 = require("./Utils");
10
11
  const Validator_1 = require("./Validator");
11
12
  class Configuration {
12
13
  constructor(network, artifacts, TONParams, TACParams, liteSequencerEndpoints) {
@@ -17,8 +18,10 @@ class Configuration {
17
18
  this.liteSequencerEndpoints = liteSequencerEndpoints;
18
19
  }
19
20
  static async create(network, artifacts, TONParams, TACParams, customLiteSequencerEndpoints, delay) {
20
- const internalTONParams = await this.prepareTONParams(artifacts, TONParams, delay);
21
- const internalTACParams = await this.prepareTACParams(artifacts, TACParams);
21
+ const [internalTONParams, internalTACParams] = await Promise.all([
22
+ this.prepareTONParams(artifacts, TONParams, delay),
23
+ this.prepareTACParams(artifacts, TACParams),
24
+ ]);
22
25
  const liteSequencerEndpoints = customLiteSequencerEndpoints ??
23
26
  (network === Struct_1.Network.TESTNET
24
27
  ? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
@@ -28,14 +31,16 @@ class Configuration {
28
31
  static async prepareTONParams(artifacts, TONParams, delay) {
29
32
  const contractOpener = TONParams?.contractOpener ?? (await (0, retryableContractOpener_1.createDefaultRetryableOpener)(artifacts, 3, delay));
30
33
  const settingsAddress = TONParams?.settingsAddress ?? artifacts.TON_SETTINGS_ADDRESS;
31
- const settings = contractOpener.open(new Settings_1.Settings(ton_1.Address.parse(settingsAddress)));
32
- const jettonProxyAddress = await settings.getAddressSetting('JettonProxyAddress');
33
- const crossChainLayerAddress = await settings.getAddressSetting('CrossChainLayerAddress');
34
- const jettonMinterCode = await settings.getCellSetting('JettonMinterCode');
35
- const jettonWalletCode = await settings.getCellSetting('JettonWalletCode');
36
- const nftProxyAddress = await settings.getAddressSetting('NFTProxyAddress');
37
- const nftItemCode = await settings.getCellSetting('NFTItemCode');
38
- const nftCollectionCode = await settings.getCellSetting('NFTCollectionCode');
34
+ const settings = contractOpener.open(Settings_1.Settings.create(ton_1.Address.parse(settingsAddress)));
35
+ const allSettingsSlice = (await settings.getAll()).beginParse();
36
+ const allSettings = allSettingsSlice.loadDictDirect(ton_1.Dictionary.Keys.BigUint(256), ton_1.Dictionary.Values.Cell());
37
+ const crossChainLayerAddress = (0, Settings_1.getAddressString)(allSettings.get((0, Utils_1.sha256toBigInt)('CrossChainLayerAddress')));
38
+ const jettonProxyAddress = (0, Settings_1.getAddressString)(allSettings.get((0, Utils_1.sha256toBigInt)('JettonProxyAddress')));
39
+ const nftProxyAddress = (0, Settings_1.getAddressString)(allSettings.get((0, Utils_1.sha256toBigInt)('NFTProxyAddress')));
40
+ const jettonWalletCode = allSettings.get((0, Utils_1.sha256toBigInt)('JettonWalletCode'));
41
+ const jettonMinterCode = allSettings.get((0, Utils_1.sha256toBigInt)('JettonMinterCode'));
42
+ const nftItemCode = allSettings.get((0, Utils_1.sha256toBigInt)('NFTItemCode'));
43
+ const nftCollectionCode = allSettings.get((0, Utils_1.sha256toBigInt)('NFTCollectionCode'));
39
44
  return {
40
45
  contractOpener,
41
46
  jettonProxyAddress,
@@ -52,22 +57,70 @@ class Configuration {
52
57
  const settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.TAC_SETTINGS_ADDRESS;
53
58
  Validator_1.Validator.validateEVMAddress(settingsAddress);
54
59
  const settings = artifacts.tac.wrappers.SettingsFactoryTAC.connect(settingsAddress, provider);
55
- const crossChainLayerAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress')));
60
+ const loaded = await this.loadSettingsViaMulticall(artifacts, provider, settingsAddress, TACParams);
61
+ let crossChainLayerAddress;
62
+ let tokenUtilsAddress;
63
+ let trustedTACExecutors;
64
+ let trustedTONExecutors;
65
+ if (loaded) {
66
+ crossChainLayerAddress = loaded.crossChainLayerAddress;
67
+ tokenUtilsAddress = loaded.tokenUtilsAddress;
68
+ trustedTACExecutors = loaded.trustedTACExecutors;
69
+ trustedTONExecutors = loaded.trustedTONExecutors;
70
+ }
71
+ else {
72
+ crossChainLayerAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress')));
73
+ tokenUtilsAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress')));
74
+ trustedTACExecutors = await settings.getTrustedEVMExecutors();
75
+ trustedTONExecutors = await settings.getTrustedTVMExecutors();
76
+ }
56
77
  const crossChainLayer = artifacts.tac.wrappers.CrossChainLayerFactoryTAC.connect(crossChainLayerAddress, provider);
57
- const tokenUtilsAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress')));
58
78
  const tokenUtils = artifacts.tac.wrappers.TokenUtilsFactoryTAC.connect(tokenUtilsAddress, provider);
59
- const trustedTACExecutors = await settings.getTrustedEVMExecutors();
60
- const trustedTONExecutors = await settings.getTrustedTVMExecutors();
79
+ const smartAccountFactory = artifacts.tac.wrappers.TacSAFactory_factoryTAC.connect(artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS, provider);
61
80
  return {
62
81
  provider,
63
82
  settings,
64
83
  tokenUtils,
84
+ smartAccountFactory,
65
85
  crossChainLayer,
66
86
  trustedTACExecutors,
67
87
  trustedTONExecutors,
68
88
  abiCoder: new ethers_1.ethers.AbiCoder(),
69
89
  };
70
90
  }
91
+ static async loadSettingsViaMulticall(artifacts, provider, settingsAddress, TACParams) {
92
+ const multicallAddress = TACParams?.multicallAddress?.toString() ?? artifacts.MULTICALL_3_ADDRESS;
93
+ const multicallAbi = TACParams?.multicallABI ?? artifacts.tac.multicall.MULTICALL_ABI_ETHERS;
94
+ try {
95
+ Validator_1.Validator.validateEVMAddress(multicallAddress);
96
+ const multicall = new ethers_1.ethers.Contract(multicallAddress, multicallAbi, provider);
97
+ const abiCoder = new ethers_1.ethers.AbiCoder();
98
+ const selectorGetAddressSetting = ethers_1.ethers.id('getAddressSetting(bytes32)').slice(0, 10);
99
+ const selectorGetTrustedEVMExecutors = ethers_1.ethers.id('getTrustedEVMExecutors()').slice(0, 10);
100
+ const selectorGetTrustedTVMExecutors = ethers_1.ethers.id('getTrustedTVMExecutors()').slice(0, 10);
101
+ const crossChainLayerKey = (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress'));
102
+ const tokenUtilsKey = (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress'));
103
+ const encodeGetAddressSetting = (key) => selectorGetAddressSetting + abiCoder.encode(['bytes32'], [key]).slice(2);
104
+ const calls = [
105
+ { target: settingsAddress, allowFailure: false, callData: encodeGetAddressSetting(crossChainLayerKey) },
106
+ { target: settingsAddress, allowFailure: false, callData: encodeGetAddressSetting(tokenUtilsKey) },
107
+ { target: settingsAddress, allowFailure: false, callData: selectorGetTrustedEVMExecutors },
108
+ { target: settingsAddress, allowFailure: false, callData: selectorGetTrustedTVMExecutors },
109
+ ];
110
+ const results = (await multicall.aggregate3.staticCall(calls));
111
+ if (results.some((result) => !result.success))
112
+ return null;
113
+ return {
114
+ crossChainLayerAddress: abiCoder.decode(['address'], results[0].returnData)[0],
115
+ tokenUtilsAddress: abiCoder.decode(['address'], results[1].returnData)[0],
116
+ trustedTACExecutors: abiCoder.decode(['address[]'], results[2].returnData)[0],
117
+ trustedTONExecutors: abiCoder.decode(['string[]'], results[3].returnData)[0],
118
+ };
119
+ }
120
+ catch {
121
+ return null;
122
+ }
123
+ }
71
124
  get nativeTONAddress() {
72
125
  return 'NONE';
73
126
  }
@@ -10,3 +10,4 @@ export declare const MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
10
10
  export declare const MAX_MSG_DEPTH = 512;
11
11
  export declare const TON_SYMBOL = "TON";
12
12
  export declare const TAC_SYMBOL = "TAC";
13
+ export declare const FIFTEEN_MINUTES: number;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = exports.TRANSACTION_TON_AMOUNT = void 0;
3
+ exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = exports.TRANSACTION_TON_AMOUNT = void 0;
4
4
  const ton_1 = require("@ton/ton");
5
- exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.55);
6
- exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
7
- exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
5
+ exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.01);
6
+ exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.06);
7
+ exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.06);
8
8
  exports.MAX_ITERATION_COUNT = 120;
9
9
  exports.DEFAULT_DELAY = 0;
10
10
  exports.SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
@@ -14,3 +14,4 @@ exports.MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
14
14
  exports.MAX_MSG_DEPTH = 512;
15
15
  exports.TON_SYMBOL = 'TON';
16
16
  exports.TAC_SYMBOL = 'TAC';
17
+ exports.FIFTEEN_MINUTES = 15 * 60 * 1000;
@@ -1,6 +1,6 @@
1
- import { IHttpClient } from '../interfaces';
2
- import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, TransactionLinker } from '../structs/Struct';
3
- export declare class LiteSequencerClient {
1
+ import { IHttpClient, ILiteSequencerClient } from '../interfaces';
2
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
3
+ export declare class LiteSequencerClient implements ILiteSequencerClient {
4
4
  private readonly endpoint;
5
5
  private readonly maxChunkSize;
6
6
  private readonly httpClient;
@@ -12,5 +12,7 @@ export declare class LiteSequencerClient {
12
12
  getStageProfilings(operationIds: string[], chunkSize?: number): Promise<ExecutionStagesByOperationId>;
13
13
  getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
14
14
  convertCurrency(params: ConvertCurrencyParams): Promise<ConvertedCurrencyResult>;
15
+ simulateTACMessage(params: TACSimulationParams): Promise<TACSimulationResult>;
16
+ getTVMExecutorFee(params: GetTVMExecutorFeeParams): Promise<SuggestedTVMExecutorFee>;
15
17
  private processChunkedRequest;
16
18
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LiteSequencerClient = void 0;
4
4
  const errors_1 = require("../errors");
5
+ const instances_1 = require("../errors/instances");
5
6
  const AxiosHttpClient_1 = require("./AxiosHttpClient");
6
7
  const Utils_1 = require("./Utils");
7
8
  class LiteSequencerClient {
@@ -141,13 +142,35 @@ class LiteSequencerClient {
141
142
  };
142
143
  }
143
144
  catch (error) {
144
- throw (0, errors_1.operationFetchError)(`endpoint ${this.endpoint} failed to complete request`, error);
145
+ throw (0, instances_1.convertCurrencyFetchError)(`endpoint ${this.endpoint} failed to complete request`, error);
146
+ }
147
+ }
148
+ async simulateTACMessage(params) {
149
+ try {
150
+ const response = await this.httpClient.post(new URL('tac/simulator/simulate-message', this.endpoint).toString(), params, {
151
+ transformResponse: [Utils_1.toCamelCaseTransformer],
152
+ });
153
+ return response.data.response;
154
+ }
155
+ catch (error) {
156
+ throw (0, instances_1.simulationFetchError)(`endpoint ${this.endpoint} failed to complete request`, error);
157
+ }
158
+ }
159
+ async getTVMExecutorFee(params) {
160
+ try {
161
+ const response = await this.httpClient.post(new URL('/ton/calculator/ton-executor-fee', this.endpoint).toString(), params, {
162
+ transformResponse: [Utils_1.toCamelCaseTransformer],
163
+ });
164
+ return response.data.response;
165
+ }
166
+ catch (error) {
167
+ throw (0, instances_1.getTONFeeInfoFetchError)(`endpoint ${this.endpoint} failed to complete request`, error);
145
168
  }
146
169
  }
147
- async processChunkedRequest(identificators, requestFn, chunkSize = this.maxChunkSize) {
170
+ async processChunkedRequest(identifiers, requestFn, chunkSize = this.maxChunkSize) {
148
171
  const results = [];
149
- for (let i = 0; i < identificators.length; i += chunkSize) {
150
- const chunk = identificators.slice(i, i + chunkSize);
172
+ for (let i = 0; i < identifiers.length; i += chunkSize) {
173
+ const chunk = identifiers.slice(i, i + chunkSize);
151
174
  const result = await requestFn(chunk);
152
175
  results.push(result);
153
176
  }
@@ -1,5 +1,5 @@
1
1
  import { ILiteSequencerClient, ILiteSequencerClientFactory, ILogger, IOperationTracker } from '../interfaces';
2
- import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, TransactionLinker, WaitOptions } from '../structs/Struct';
2
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, GetTVMExecutorFeeParams, Network, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
3
3
  export declare class DefaultLiteSequencerClientFactory implements ILiteSequencerClientFactory {
4
4
  createClients(endpoints: string[]): ILiteSequencerClient[];
5
5
  }
@@ -17,4 +17,6 @@ export declare class OperationTracker implements IOperationTracker {
17
17
  getOperationStatus(operationId: string, waitOptions?: WaitOptions<StatusInfo>): Promise<StatusInfo>;
18
18
  getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
19
19
  convertCurrency(params: ConvertCurrencyParams, waitOptions?: WaitOptions<ConvertedCurrencyResult>): Promise<ConvertedCurrencyResult>;
20
+ simulateTACMessage(params: TACSimulationParams, waitOptions?: WaitOptions<TACSimulationResult>): Promise<TACSimulationResult>;
21
+ getTVMExecutorFee(params: GetTVMExecutorFeeParams, waitOptions?: WaitOptions<SuggestedTVMExecutorFee>): Promise<SuggestedTVMExecutorFee>;
20
22
  }