@tonappchain/sdk 0.7.0-rc14 → 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.
- package/README.md +7 -7
- package/dist/adapters/retryableContractOpener.js +1 -1
- package/dist/assets/AssetFactory.js +1 -1
- package/dist/assets/FT.d.ts +8 -12
- package/dist/assets/FT.js +69 -36
- package/dist/assets/NFT.d.ts +4 -2
- package/dist/assets/NFT.js +14 -2
- package/dist/assets/TON.d.ts +4 -10
- package/dist/assets/TON.js +17 -15
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +7 -2
- package/dist/errors/instances.d.ts +8 -1
- package/dist/errors/instances.js +22 -16
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -3
- package/dist/interfaces/Asset.d.ts +22 -17
- package/dist/interfaces/ILiteSequencerClient.d.ts +14 -1
- package/dist/interfaces/IOperationTracker.d.ts +16 -1
- package/dist/interfaces/ISimulator.d.ts +7 -36
- package/dist/interfaces/ITACTransactionManager.d.ts +15 -0
- package/dist/interfaces/ITONTransactionManager.d.ts +21 -0
- package/dist/interfaces/ITONTransactionManager.js +2 -0
- package/dist/interfaces/ITacSDK.d.ts +51 -13
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/index.js +2 -1
- package/dist/sdk/Configuration.d.ts +1 -0
- package/dist/sdk/Configuration.js +52 -4
- package/dist/sdk/Consts.d.ts +1 -0
- package/dist/sdk/Consts.js +5 -4
- package/dist/sdk/LiteSequencerClient.d.ts +5 -3
- package/dist/sdk/LiteSequencerClient.js +27 -4
- package/dist/sdk/OperationTracker.d.ts +3 -1
- package/dist/sdk/OperationTracker.js +51 -11
- package/dist/sdk/Simulator.d.ts +6 -12
- package/dist/sdk/Simulator.js +30 -124
- package/dist/sdk/TACTransactionManager.d.ts +10 -0
- package/dist/sdk/TACTransactionManager.js +92 -0
- package/dist/sdk/TONTransactionManager.d.ts +17 -0
- package/dist/sdk/TONTransactionManager.js +209 -0
- package/dist/sdk/TacSdk.d.ts +16 -10
- package/dist/sdk/TacSdk.js +52 -19
- package/dist/sdk/TxFinalizer.d.ts +3 -2
- package/dist/sdk/TxFinalizer.js +8 -8
- package/dist/sdk/Utils.d.ts +8 -4
- package/dist/sdk/Utils.js +80 -12
- package/dist/sdk/Validator.d.ts +2 -2
- package/dist/sdk/Validator.js +1 -1
- package/dist/structs/InternalStruct.d.ts +6 -2
- package/dist/structs/Struct.d.ts +70 -16
- package/package.json +4 -3
- package/dist/interfaces/ITransactionManager.d.ts +0 -35
- package/dist/sdk/TransactionManager.d.ts +0 -22
- package/dist/sdk/TransactionManager.js +0 -272
- /package/dist/interfaces/{ITransactionManager.js → ITACTransactionManager.js} +0 -0
|
@@ -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,
|
|
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
|
-
|
|
10
|
+
getSimulationsInfo(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
|
|
26
11
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -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,
|
|
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:
|
|
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<
|
|
69
|
+
simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
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
|
|
73
|
-
* @param assets
|
|
74
|
-
* @
|
|
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
|
-
|
|
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:
|
|
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?:
|
|
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:
|
|
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?:
|
|
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 './
|
|
11
|
+
export * from './ITACTransactionManager';
|
|
12
|
+
export * from './ITONTransactionManager';
|
|
12
13
|
export * from './SenderAbstraction';
|
|
13
14
|
export * from './WalletInstanse';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -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("./
|
|
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[];
|
|
@@ -57,22 +57,70 @@ class Configuration {
|
|
|
57
57
|
const settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.TAC_SETTINGS_ADDRESS;
|
|
58
58
|
Validator_1.Validator.validateEVMAddress(settingsAddress);
|
|
59
59
|
const settings = artifacts.tac.wrappers.SettingsFactoryTAC.connect(settingsAddress, provider);
|
|
60
|
-
const
|
|
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
|
+
}
|
|
61
77
|
const crossChainLayer = artifacts.tac.wrappers.CrossChainLayerFactoryTAC.connect(crossChainLayerAddress, provider);
|
|
62
|
-
const tokenUtilsAddress = await settings.getAddressSetting((0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress')));
|
|
63
78
|
const tokenUtils = artifacts.tac.wrappers.TokenUtilsFactoryTAC.connect(tokenUtilsAddress, provider);
|
|
64
|
-
const
|
|
65
|
-
const trustedTONExecutors = await settings.getTrustedTVMExecutors();
|
|
79
|
+
const smartAccountFactory = artifacts.tac.wrappers.TacSAFactory_factoryTAC.connect(artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS, provider);
|
|
66
80
|
return {
|
|
67
81
|
provider,
|
|
68
82
|
settings,
|
|
69
83
|
tokenUtils,
|
|
84
|
+
smartAccountFactory,
|
|
70
85
|
crossChainLayer,
|
|
71
86
|
trustedTACExecutors,
|
|
72
87
|
trustedTONExecutors,
|
|
73
88
|
abiCoder: new ethers_1.ethers.AbiCoder(),
|
|
74
89
|
};
|
|
75
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
|
+
}
|
|
76
124
|
get nativeTONAddress() {
|
|
77
125
|
return 'NONE';
|
|
78
126
|
}
|
package/dist/sdk/Consts.d.ts
CHANGED
package/dist/sdk/Consts.js
CHANGED
|
@@ -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.
|
|
6
|
-
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.
|
|
7
|
-
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.
|
|
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,
|
|
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(
|
|
170
|
+
async processChunkedRequest(identifiers, requestFn, chunkSize = this.maxChunkSize) {
|
|
148
171
|
const results = [];
|
|
149
|
-
for (let i = 0; i <
|
|
150
|
-
const chunk =
|
|
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
|
}
|
|
@@ -7,6 +7,7 @@ const Struct_1 = require("../structs/Struct");
|
|
|
7
7
|
const LiteSequencerClient_1 = require("./LiteSequencerClient");
|
|
8
8
|
const Logger_1 = require("./Logger");
|
|
9
9
|
const Utils_1 = require("./Utils");
|
|
10
|
+
const Validator_1 = require("./Validator");
|
|
10
11
|
class DefaultLiteSequencerClientFactory {
|
|
11
12
|
createClients(endpoints) {
|
|
12
13
|
return endpoints.map((endpoint) => new LiteSequencerClient_1.LiteSequencerClient(endpoint));
|
|
@@ -40,7 +41,7 @@ class OperationTracker {
|
|
|
40
41
|
this.logger.error('All endpoints failed to get operation id by transactionHash');
|
|
41
42
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
42
43
|
};
|
|
43
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
44
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation ID by transaction hash") : await requestFn();
|
|
44
45
|
}
|
|
45
46
|
async getOperationType(operationId, waitOptions) {
|
|
46
47
|
this.logger.debug(`Getting operation type for ${(0, Utils_1.formatObjectForLogging)(operationId)}`);
|
|
@@ -60,7 +61,7 @@ class OperationTracker {
|
|
|
60
61
|
this.logger.error('All endpoints failed to get operation type');
|
|
61
62
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
62
63
|
};
|
|
63
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
64
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation type") : await requestFn();
|
|
64
65
|
}
|
|
65
66
|
async getOperationId(transactionLinker, waitOptions) {
|
|
66
67
|
this.logger.debug(`Getting operation ID for transaction linker: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
@@ -80,7 +81,7 @@ class OperationTracker {
|
|
|
80
81
|
this.logger.error('All endpoints failed to get operation id');
|
|
81
82
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
82
83
|
};
|
|
83
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
84
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation ID by transaction linker") : await requestFn();
|
|
84
85
|
}
|
|
85
86
|
async getOperationIdsByShardsKeys(shardsKeys, caller, waitOptions, chunkSize = 100) {
|
|
86
87
|
this.logger.debug(`Getting operation IDs for shards keys: ${(0, Utils_1.formatObjectForLogging)(shardsKeys)}`);
|
|
@@ -101,7 +102,7 @@ class OperationTracker {
|
|
|
101
102
|
this.logger.error('All endpoints failed to get operation ids by shards keys');
|
|
102
103
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
103
104
|
};
|
|
104
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
105
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation IDs by shards keys") : await requestFn();
|
|
105
106
|
}
|
|
106
107
|
async getStageProfiling(operationId, waitOptions) {
|
|
107
108
|
this.logger.debug(`Getting stage profiling for operation ${operationId}`);
|
|
@@ -126,7 +127,7 @@ class OperationTracker {
|
|
|
126
127
|
this.logger.error('All endpoints failed to get stage profiling');
|
|
127
128
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
128
129
|
};
|
|
129
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
130
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting stage profiling") : await requestFn();
|
|
130
131
|
}
|
|
131
132
|
async getStageProfilings(operationIds, waitOptions, chunkSize = 100) {
|
|
132
133
|
this.logger.debug(`Getting stage profilings for operations: ${operationIds.join(', ')}`);
|
|
@@ -147,7 +148,7 @@ class OperationTracker {
|
|
|
147
148
|
this.logger.error('All endpoints failed to get stage profilings');
|
|
148
149
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
149
150
|
};
|
|
150
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
151
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting stage profilings") : await requestFn();
|
|
151
152
|
}
|
|
152
153
|
async getOperationStatuses(operationIds, waitOptions, chunkSize = 100) {
|
|
153
154
|
this.logger.debug(`Getting operation statuses for operations: ${(0, Utils_1.formatObjectForLogging)(operationIds)}`);
|
|
@@ -168,7 +169,7 @@ class OperationTracker {
|
|
|
168
169
|
this.logger.error('All endpoints failed to get operation statuses');
|
|
169
170
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
170
171
|
};
|
|
171
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
172
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation statuses") : await requestFn();
|
|
172
173
|
}
|
|
173
174
|
async getOperationStatus(operationId, waitOptions) {
|
|
174
175
|
this.logger.debug(`Getting operation status for ${(0, Utils_1.formatObjectForLogging)(operationId)}`);
|
|
@@ -193,7 +194,7 @@ class OperationTracker {
|
|
|
193
194
|
this.logger.error('All endpoints failed to get operation status');
|
|
194
195
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
195
196
|
};
|
|
196
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
197
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting operation status") : await requestFn();
|
|
197
198
|
}
|
|
198
199
|
async getSimplifiedOperationStatus(transactionLinker) {
|
|
199
200
|
this.logger.debug(`Getting simplified operation status for transaction linker: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
@@ -202,9 +203,7 @@ class OperationTracker {
|
|
|
202
203
|
this.logger.warn('Operation ID not found');
|
|
203
204
|
return Struct_1.SimplifiedStatuses.OPERATION_ID_NOT_FOUND;
|
|
204
205
|
}
|
|
205
|
-
this.logger.debug(`Operation ID: ${operationId}`);
|
|
206
206
|
const operationType = await this.getOperationType(operationId);
|
|
207
|
-
this.logger.debug(`Operation type: ${operationType}`);
|
|
208
207
|
if (operationType == Struct_1.OperationType.PENDING || operationType == Struct_1.OperationType.UNKNOWN) {
|
|
209
208
|
return Struct_1.SimplifiedStatuses.PENDING;
|
|
210
209
|
}
|
|
@@ -231,7 +230,48 @@ class OperationTracker {
|
|
|
231
230
|
this.logger.error('All endpoints failed to convert currency');
|
|
232
231
|
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
233
232
|
};
|
|
234
|
-
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
233
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Converting currency") : await requestFn();
|
|
234
|
+
}
|
|
235
|
+
async simulateTACMessage(params, waitOptions) {
|
|
236
|
+
Validator_1.Validator.validateTACSimulationParams(params);
|
|
237
|
+
this.logger.debug(`Simulating TAC message: ${(0, Utils_1.formatObjectForLogging)(params)}`);
|
|
238
|
+
const requestFn = async () => {
|
|
239
|
+
let lastError;
|
|
240
|
+
for (const client of this.clients) {
|
|
241
|
+
try {
|
|
242
|
+
const result = await client.simulateTACMessage(params);
|
|
243
|
+
this.logger.debug(`Simulation result retrieved successfully`);
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
this.logger.warn(`Failed to simulate TAC message using one of the endpoints`);
|
|
248
|
+
lastError = error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
this.logger.error('All endpoints failed to simulate TAC message');
|
|
252
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
253
|
+
};
|
|
254
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Simulating TAC message") : await requestFn();
|
|
255
|
+
}
|
|
256
|
+
async getTVMExecutorFee(params, waitOptions) {
|
|
257
|
+
this.logger.debug(`get TVM executor fee: ${(0, Utils_1.formatObjectForLogging)(params)}`);
|
|
258
|
+
const requestFn = async () => {
|
|
259
|
+
let lastError;
|
|
260
|
+
for (const client of this.clients) {
|
|
261
|
+
try {
|
|
262
|
+
const result = await client.getTVMExecutorFee(params);
|
|
263
|
+
this.logger.debug(`Suggested TVM executor fee retrieved successfully`);
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
this.logger.warn(`Failed to get TVM executor fee using one of the endpoints`);
|
|
268
|
+
lastError = error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.logger.error('All endpoints failed to get TVM executor fee');
|
|
272
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
273
|
+
};
|
|
274
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn, "OperationTracker: Getting TVM executor fee") : await requestFn();
|
|
235
275
|
}
|
|
236
276
|
}
|
|
237
277
|
exports.OperationTracker = OperationTracker;
|