@tonappchain/sdk 0.7.3-rc7 → 0.7.3-rc8
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 +0 -3
- package/dist/src/errors/index.d.ts +1 -1
- package/dist/src/errors/index.js +4 -3
- package/dist/src/errors/instances.d.ts +1 -0
- package/dist/src/errors/instances.js +2 -1
- package/dist/src/interfaces/IOperationTracker.d.ts +14 -1
- package/dist/src/interfaces/ITacSDK.d.ts +1 -21
- package/dist/src/sdk/Configuration.js +5 -0
- package/dist/src/sdk/OperationTracker.d.ts +6 -3
- package/dist/src/sdk/OperationTracker.js +44 -19
- package/dist/src/sdk/StartTracking.d.ts +8 -0
- package/dist/src/sdk/StartTracking.js +19 -1
- package/dist/src/sdk/TONTransactionManager.d.ts +1 -0
- package/dist/src/sdk/TONTransactionManager.js +18 -7
- package/dist/src/sdk/TacSdk.d.ts +1 -5
- package/dist/src/sdk/TacSdk.js +3 -37
- package/dist/src/structs/InternalStruct.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,9 +67,6 @@ The TAC SDK enables you to create frontends that:
|
|
|
67
67
|
- [`TonConnectSender`](./docs/sdks/sender.md#tonconnectsender): Implements sending via TonConnect UI.
|
|
68
68
|
- [`RawSender`](./docs/sdks/sender.md#rawsender): Implements sending using a raw private key.
|
|
69
69
|
|
|
70
|
-
- **[`Utilities`](./docs/sdks/utilities.md)**: Helper functions and interfaces.
|
|
71
|
-
- [`startTracking`](./docs/sdks/utilities.md#starttracking): Utility function to poll and log operation status to the console.
|
|
72
|
-
|
|
73
70
|
- **[`AgnosticSdk`](./docs/sdks/agnostic_proxy_sdk.md)**: Agnostic SDK for cross-chain interactions.
|
|
74
71
|
|
|
75
72
|
- **[`Simulator`](./docs/sdks/simulator.md)**: Transaction simulation capabilities.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AddressError, BitError, ContractError, EVMCallError, FetchError, FormatError, KeyError, MetadataError, SettingError, TokenError, TransactionError, WalletError, } from './errors';
|
|
2
|
-
export { allEndpointsFailedError, blockGasLimitFetchError, emptyArrayError, emptyContractError, emptySettingError, estimatedGasExceedsBlockGasLimitError, evmAddressError,
|
|
2
|
+
export { allEndpointsFailedError, blockGasLimitFetchError, emptyArrayError, emptyContractError, emptySettingError, estimatedGasExceedsBlockGasLimitError, evmAddressError, executedInTONStageFailedError, externalInMessageRequiredError, gasPriceFetchError, indexRequiredError, insufficientBalanceError, insufficientFeeParamsError, invalidMethodNameError, invalidTonExternalMessageBocError, missingDecimals, missingFeeParamsError, missingGasLimitError, missingJettonDataError, missingTvmExecutorFeeError, notMultiplyOf8Error, operationFetchError, operationIdRequiredForFinalizationError, prefixError, profilingFetchError, simulationFetchError, statusFetchError, tonIndexerRequiredForTonTransactionBocError, tvmAddressError, txFinalizationError, unknownTokenTypeError, unknownWalletError, unsupportedFormatError, unsupportedKeyError, zeroRawAmountError, } from './instances';
|
package/dist/src/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zeroRawAmountError = exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.txFinalizationError = exports.tvmAddressError = exports.statusFetchError = exports.simulationFetchError = exports.profilingFetchError = exports.prefixError = exports.operationIdRequiredForFinalizationError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.missingTvmExecutorFeeError = exports.missingJettonDataError = exports.missingGasLimitError = exports.missingFeeParamsError = exports.missingDecimals = exports.
|
|
3
|
+
exports.zeroRawAmountError = exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.txFinalizationError = exports.tvmAddressError = exports.tonIndexerRequiredForTonTransactionBocError = exports.statusFetchError = exports.simulationFetchError = exports.profilingFetchError = exports.prefixError = exports.operationIdRequiredForFinalizationError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.missingTvmExecutorFeeError = exports.missingJettonDataError = exports.missingGasLimitError = exports.missingFeeParamsError = exports.missingDecimals = exports.invalidTonExternalMessageBocError = exports.invalidMethodNameError = exports.insufficientFeeParamsError = exports.insufficientBalanceError = exports.indexRequiredError = exports.gasPriceFetchError = exports.externalInMessageRequiredError = exports.executedInTONStageFailedError = exports.evmAddressError = exports.estimatedGasExceedsBlockGasLimitError = exports.emptySettingError = exports.emptyContractError = exports.emptyArrayError = exports.blockGasLimitFetchError = exports.allEndpointsFailedError = exports.WalletError = exports.TransactionError = exports.TokenError = exports.SettingError = exports.MetadataError = exports.KeyError = exports.FormatError = exports.FetchError = exports.EVMCallError = exports.ContractError = exports.BitError = exports.AddressError = void 0;
|
|
4
4
|
var errors_1 = require("./errors");
|
|
5
5
|
Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return errors_1.AddressError; } });
|
|
6
6
|
Object.defineProperty(exports, "BitError", { enumerable: true, get: function () { return errors_1.BitError; } });
|
|
@@ -22,14 +22,14 @@ Object.defineProperty(exports, "emptyContractError", { enumerable: true, get: fu
|
|
|
22
22
|
Object.defineProperty(exports, "emptySettingError", { enumerable: true, get: function () { return instances_1.emptySettingError; } });
|
|
23
23
|
Object.defineProperty(exports, "estimatedGasExceedsBlockGasLimitError", { enumerable: true, get: function () { return instances_1.estimatedGasExceedsBlockGasLimitError; } });
|
|
24
24
|
Object.defineProperty(exports, "evmAddressError", { enumerable: true, get: function () { return instances_1.evmAddressError; } });
|
|
25
|
-
Object.defineProperty(exports, "externalInMessageRequiredError", { enumerable: true, get: function () { return instances_1.externalInMessageRequiredError; } });
|
|
26
25
|
Object.defineProperty(exports, "executedInTONStageFailedError", { enumerable: true, get: function () { return instances_1.executedInTONStageFailedError; } });
|
|
26
|
+
Object.defineProperty(exports, "externalInMessageRequiredError", { enumerable: true, get: function () { return instances_1.externalInMessageRequiredError; } });
|
|
27
27
|
Object.defineProperty(exports, "gasPriceFetchError", { enumerable: true, get: function () { return instances_1.gasPriceFetchError; } });
|
|
28
28
|
Object.defineProperty(exports, "indexRequiredError", { enumerable: true, get: function () { return instances_1.indexRequiredError; } });
|
|
29
29
|
Object.defineProperty(exports, "insufficientBalanceError", { enumerable: true, get: function () { return instances_1.insufficientBalanceError; } });
|
|
30
30
|
Object.defineProperty(exports, "insufficientFeeParamsError", { enumerable: true, get: function () { return instances_1.insufficientFeeParamsError; } });
|
|
31
|
-
Object.defineProperty(exports, "invalidTonExternalMessageBocError", { enumerable: true, get: function () { return instances_1.invalidTonExternalMessageBocError; } });
|
|
32
31
|
Object.defineProperty(exports, "invalidMethodNameError", { enumerable: true, get: function () { return instances_1.invalidMethodNameError; } });
|
|
32
|
+
Object.defineProperty(exports, "invalidTonExternalMessageBocError", { enumerable: true, get: function () { return instances_1.invalidTonExternalMessageBocError; } });
|
|
33
33
|
Object.defineProperty(exports, "missingDecimals", { enumerable: true, get: function () { return instances_1.missingDecimals; } });
|
|
34
34
|
Object.defineProperty(exports, "missingFeeParamsError", { enumerable: true, get: function () { return instances_1.missingFeeParamsError; } });
|
|
35
35
|
Object.defineProperty(exports, "missingGasLimitError", { enumerable: true, get: function () { return instances_1.missingGasLimitError; } });
|
|
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "prefixError", { enumerable: true, get: function
|
|
|
42
42
|
Object.defineProperty(exports, "profilingFetchError", { enumerable: true, get: function () { return instances_1.profilingFetchError; } });
|
|
43
43
|
Object.defineProperty(exports, "simulationFetchError", { enumerable: true, get: function () { return instances_1.simulationFetchError; } });
|
|
44
44
|
Object.defineProperty(exports, "statusFetchError", { enumerable: true, get: function () { return instances_1.statusFetchError; } });
|
|
45
|
+
Object.defineProperty(exports, "tonIndexerRequiredForTonTransactionBocError", { enumerable: true, get: function () { return instances_1.tonIndexerRequiredForTonTransactionBocError; } });
|
|
45
46
|
Object.defineProperty(exports, "tvmAddressError", { enumerable: true, get: function () { return instances_1.tvmAddressError; } });
|
|
46
47
|
Object.defineProperty(exports, "txFinalizationError", { enumerable: true, get: function () { return instances_1.txFinalizationError; } });
|
|
47
48
|
Object.defineProperty(exports, "unknownTokenTypeError", { enumerable: true, get: function () { return instances_1.unknownTokenTypeError; } });
|
|
@@ -43,3 +43,4 @@ export declare const blockGasLimitFetchError: (msg: string, inner?: unknown) =>
|
|
|
43
43
|
export declare const estimatedGasExceedsBlockGasLimitError: (txName: string, estimatedGas: bigint, blockGasLimit: bigint) => TransactionError;
|
|
44
44
|
export declare const invalidTonExternalMessageBocError: (reason?: string) => FormatError;
|
|
45
45
|
export declare const externalInMessageRequiredError: (actualType: string) => FormatError;
|
|
46
|
+
export declare const tonIndexerRequiredForTonTransactionBocError: SettingError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.externalInMessageRequiredError = exports.invalidTonExternalMessageBocError = exports.estimatedGasExceedsBlockGasLimitError = exports.blockGasLimitFetchError = exports.executedInTONStageFailedError = exports.operationIdRequiredForFinalizationError = exports.insufficientFeeParamsError = exports.txFinalizationError = exports.gasPriceFetchError = exports.unknownAssetOriginError = exports.convertCurrencyNegativeOrZeroValueError = exports.sendCrossChainTransactionFailedError = exports.zeroRawAmountError = exports.missingJettonDataError = exports.missingDecimals = exports.missingGasLimitError = exports.missingTvmExecutorFeeError = exports.missingFeeParamsError = exports.getTONFeeInfoFetchError = exports.simulationFetchError = exports.convertCurrencyFetchError = exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
|
|
3
|
+
exports.tonIndexerRequiredForTonTransactionBocError = exports.externalInMessageRequiredError = exports.invalidTonExternalMessageBocError = exports.estimatedGasExceedsBlockGasLimitError = exports.blockGasLimitFetchError = exports.executedInTONStageFailedError = exports.operationIdRequiredForFinalizationError = exports.insufficientFeeParamsError = exports.txFinalizationError = exports.gasPriceFetchError = exports.unknownAssetOriginError = exports.convertCurrencyNegativeOrZeroValueError = exports.sendCrossChainTransactionFailedError = exports.zeroRawAmountError = exports.missingJettonDataError = exports.missingDecimals = exports.missingGasLimitError = exports.missingTvmExecutorFeeError = exports.missingFeeParamsError = exports.getTONFeeInfoFetchError = exports.simulationFetchError = exports.convertCurrencyFetchError = exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
exports.emptyContractError = new errors_1.ContractError('unexpected empty contract code of given jetton.', 100);
|
|
6
6
|
const operationFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch OperationId: ${msg}`, 101, inner);
|
|
@@ -131,3 +131,4 @@ const invalidTonExternalMessageBocError = (reason) => new errors_1.FormatError(`
|
|
|
131
131
|
exports.invalidTonExternalMessageBocError = invalidTonExternalMessageBocError;
|
|
132
132
|
const externalInMessageRequiredError = (actualType) => new errors_1.FormatError(`Expected external-in TON message, got ${actualType}`, 142);
|
|
133
133
|
exports.externalInMessageRequiredError = externalInMessageRequiredError;
|
|
134
|
+
exports.tonIndexerRequiredForTonTransactionBocError = new errors_1.SettingError('TON indexer is required to resolve operation ID by TON transaction BOC', 143);
|
|
@@ -32,10 +32,23 @@ export interface IOperationTracker {
|
|
|
32
32
|
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
33
33
|
/**
|
|
34
34
|
* Resolves an operation id by a TON transaction hash, optionally waiting until available.
|
|
35
|
-
*
|
|
35
|
+
* When OperationTracker config includes TONParams.tonIndexer, the hash may belong to any transaction in the linked
|
|
36
|
+
* TON transaction chain; the tracker resolves the sequencer-collected crossChainLayer transaction before querying
|
|
37
|
+
* the sequencer.
|
|
38
|
+
* Retries cover both the indexed crossChainLayer lookup and the sequencer request.
|
|
39
|
+
* @param transactionHash TON transaction hash.
|
|
36
40
|
* @param waitOptions Optional waiting settings. Pass `null` to disable retries and use a single attempt.
|
|
37
41
|
*/
|
|
38
42
|
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves an operation id by the BOC of an external TON message that was sent to the blockchain.
|
|
45
|
+
* The tracker resolves the root TON transaction that processed the external message, then resolves the
|
|
46
|
+
* sequencer-collected crossChainLayer transaction before querying the sequencer. Retries cover that whole lookup.
|
|
47
|
+
* Requires OperationTracker config to include TONParams.tonIndexer.
|
|
48
|
+
* @param boc BOC of the external TON message that was sent to the blockchain.
|
|
49
|
+
* @param waitOptions Optional waiting settings. Pass `null` to disable retries and use a single attempt.
|
|
50
|
+
*/
|
|
51
|
+
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
39
52
|
/**
|
|
40
53
|
* Resolves operation ids by shard keys for a particular caller, with optional batching and waiting.
|
|
41
54
|
* @param shardsKeys List of shard keys.
|
|
@@ -2,7 +2,7 @@ import { Wallet } from 'ethers';
|
|
|
2
2
|
import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
3
3
|
import { FT, NFT, TAC, TON } from '../assets';
|
|
4
4
|
import type { SenderAbstraction } from '../sender';
|
|
5
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended
|
|
5
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
|
|
6
6
|
import { Asset } from './Asset';
|
|
7
7
|
import { ContractOpener } from './ContractOpener';
|
|
8
8
|
import { IConfiguration } from './IConfiguration';
|
|
@@ -123,26 +123,6 @@ export interface ITacSDK {
|
|
|
123
123
|
* @returns Promise with an array of TransactionLinkerWithOperationId for each submitted transaction.
|
|
124
124
|
*/
|
|
125
125
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
126
|
-
/**
|
|
127
|
-
* Resolves operation id by any TON hash from a linked chain of TON transactions.
|
|
128
|
-
* The SDK first resolves indexed TON transaction context, traverses adjacent TON transactions
|
|
129
|
-
* until it finds the crossChainLayer transaction that the sequencer would collect as a TVM event,
|
|
130
|
-
* and only then queries the sequencer with that exact transaction hash.
|
|
131
|
-
* @param transactionHash Any TON transaction hash from the relevant linked chain of TON transactions.
|
|
132
|
-
* @param waitOptions Optional waiting settings for the final sequencer lookup. Pass `null` to disable retries.
|
|
133
|
-
* @returns Promise resolving to operation id, or empty string when the sequencer-collected crossChainLayer event transaction is not found.
|
|
134
|
-
*/
|
|
135
|
-
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
136
|
-
/**
|
|
137
|
-
* Resolves operation id by the BOC of an external TON message that was sent to the blockchain.
|
|
138
|
-
* The SDK derives the normalized external-in message hash from the BOC, finds the root TON transaction
|
|
139
|
-
* that processed that external message through the configured contract opener, and then reuses the same
|
|
140
|
-
* linked chain of TON transactions lookup as `getOperationIdByTonTransactionHash(...)`.
|
|
141
|
-
* @param boc BOC of the external TON message that was sent to the blockchain.
|
|
142
|
-
* @param waitOptions Optional waiting settings for the final sequencer lookup. Pass `null` to disable retries.
|
|
143
|
-
* @returns Promise resolving to operation id, or empty string when the sequencer-collected crossChainLayer event transaction is not found.
|
|
144
|
-
*/
|
|
145
|
-
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
146
126
|
/**
|
|
147
127
|
* Bridges tokens/value from EVM to TON chain via the executor.
|
|
148
128
|
* This is a low-level send-only method. It prepares the TAC -> TON message, performs approvals,
|
|
@@ -56,6 +56,10 @@ class Configuration {
|
|
|
56
56
|
(await (0, adapters_1.createDefaultRetryableOpener)(artifacts.TON_RPC_ENDPOINT_BY_TAC, network, Consts_1.DEFAULT_RETRY_MAX_COUNT, delay, passLoggerToOpeners ? logger : undefined, artifacts.TONCENTER_V3_INDEXER_ENDPOINT));
|
|
57
57
|
settingsAddress = TONParams?.settingsAddress ?? artifacts.TON_SETTINGS_ADDRESS;
|
|
58
58
|
}
|
|
59
|
+
const tonIndexer = TONParams?.tonIndexer ??
|
|
60
|
+
(artifacts.TONCENTER_V3_INDEXER_ENDPOINT
|
|
61
|
+
? new adapters_1.ToncenterV3Indexer(artifacts.TONCENTER_V3_INDEXER_ENDPOINT)
|
|
62
|
+
: undefined);
|
|
59
63
|
if (passLoggerToOpeners) {
|
|
60
64
|
contractOpener.setLogger(logger);
|
|
61
65
|
}
|
|
@@ -81,6 +85,7 @@ class Configuration {
|
|
|
81
85
|
const feesParams = await this.retrieveTONFeesParams(contractOpener);
|
|
82
86
|
return {
|
|
83
87
|
contractOpener,
|
|
88
|
+
tonIndexer,
|
|
84
89
|
jettonProxyAddress,
|
|
85
90
|
crossChainLayerAddress,
|
|
86
91
|
jettonMinterCode,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { ILiteSequencerClient, ILiteSequencerClientFactory, ILogger, IOperationTracker } from '../interfaces';
|
|
2
|
-
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams,
|
|
1
|
+
import { IConfiguration, ILiteSequencerClient, ILiteSequencerClientFactory, ILogger, IOperationTracker } from '../interfaces';
|
|
2
|
+
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, 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
|
}
|
|
6
6
|
export declare class OperationTracker implements IOperationTracker {
|
|
7
7
|
private readonly clients;
|
|
8
8
|
private readonly logger;
|
|
9
|
-
|
|
9
|
+
private readonly config;
|
|
10
|
+
constructor(config: IConfiguration, logger?: ILogger, clientFactory?: ILiteSequencerClientFactory);
|
|
10
11
|
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
11
12
|
getOperationIdByTacTransactionHash(transactionHash: string, waitOptions?: WaitOptions<OperationIdWithLogIndex[]> | null): Promise<OperationIdWithLogIndex[]>;
|
|
12
13
|
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
14
|
+
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
15
|
+
private getOperationIdByTonTransaction;
|
|
13
16
|
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType> | null): Promise<OperationType>;
|
|
14
17
|
getOperationTypeV2(operationId: string, waitOptions?: WaitOptions<OperationTypeV2Info> | null): Promise<OperationTypeV2Info>;
|
|
15
18
|
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationTracker = exports.DefaultLiteSequencerClientFactory = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ton_1 = require("@ton/ton");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
6
|
const instances_1 = require("../errors/instances");
|
|
7
7
|
const Struct_1 = require("../structs/Struct");
|
|
@@ -16,23 +16,10 @@ class DefaultLiteSequencerClientFactory {
|
|
|
16
16
|
}
|
|
17
17
|
exports.DefaultLiteSequencerClientFactory = DefaultLiteSequencerClientFactory;
|
|
18
18
|
class OperationTracker {
|
|
19
|
-
constructor(
|
|
20
|
-
|
|
21
|
-
if (network === Struct_1.Network.DEV) {
|
|
22
|
-
if (!customLiteSequencerEndpoints || customLiteSequencerEndpoints.length === 0) {
|
|
23
|
-
throw new Error('For DEV network, custom lite sequencer endpoints must be provided');
|
|
24
|
-
}
|
|
25
|
-
endpoints = customLiteSequencerEndpoints;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const artifacts = network === Struct_1.Network.MAINNET ? artifacts_1.mainnet : artifacts_1.testnet;
|
|
29
|
-
endpoints =
|
|
30
|
-
customLiteSequencerEndpoints && customLiteSequencerEndpoints.length !== 0
|
|
31
|
-
? customLiteSequencerEndpoints
|
|
32
|
-
: artifacts.PUBLIC_LITE_SEQUENCER_ENDPOINTS;
|
|
33
|
-
}
|
|
34
|
-
this.clients = clientFactory.createClients(endpoints);
|
|
19
|
+
constructor(config, logger = new Logger_1.NoopLogger(), clientFactory = new DefaultLiteSequencerClientFactory()) {
|
|
20
|
+
this.clients = clientFactory.createClients(config.liteSequencerEndpoints);
|
|
35
21
|
this.logger = logger;
|
|
22
|
+
this.config = config;
|
|
36
23
|
}
|
|
37
24
|
async getOperationIdByTransactionHash(transactionHash, waitOptions) {
|
|
38
25
|
const requestFn = async () => {
|
|
@@ -71,11 +58,49 @@ class OperationTracker {
|
|
|
71
58
|
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, `OperationTracker: Getting operation IDs by TAC transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
72
59
|
}
|
|
73
60
|
async getOperationIdByTonTransactionHash(transactionHash, waitOptions) {
|
|
61
|
+
return this.getOperationIdByTonTransaction(async () => transactionHash, `OperationTracker: Getting operation ID by TON transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`, waitOptions);
|
|
62
|
+
}
|
|
63
|
+
async getOperationIdByTonTransactionBoc(boc, waitOptions) {
|
|
64
|
+
if (!this.config.TONParams.tonIndexer) {
|
|
65
|
+
throw errors_1.tonIndexerRequiredForTonTransactionBocError;
|
|
66
|
+
}
|
|
67
|
+
let message;
|
|
68
|
+
try {
|
|
69
|
+
message = (0, ton_1.loadMessage)(ton_1.Cell.fromBase64(boc).beginParse());
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const reason = error instanceof Error ? error.message : undefined;
|
|
73
|
+
throw (0, errors_1.invalidTonExternalMessageBocError)(reason);
|
|
74
|
+
}
|
|
75
|
+
if (message.info.type !== 'external-in') {
|
|
76
|
+
throw (0, errors_1.externalInMessageRequiredError)(message.info.type);
|
|
77
|
+
}
|
|
78
|
+
const destination = ton_1.Address.parse(message.info.dest.toString());
|
|
79
|
+
const messageHash = (0, Utils_1.getNormalizedExtMessageHash)(message);
|
|
80
|
+
return this.getOperationIdByTonTransaction(async () => {
|
|
81
|
+
const transaction = await this.config.TONParams.contractOpener.getTransactionByHash(destination, messageHash);
|
|
82
|
+
return transaction?.hash().toString('base64') ?? '';
|
|
83
|
+
}, 'OperationTracker: Getting operation ID by TON transaction BOC', waitOptions);
|
|
84
|
+
}
|
|
85
|
+
async getOperationIdByTonTransaction(resolveTransactionHash, operationDescription, waitOptions) {
|
|
74
86
|
const requestFn = async () => {
|
|
87
|
+
const transactionHash = await resolveTransactionHash();
|
|
88
|
+
if (!transactionHash) {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
let eventTxHash = transactionHash;
|
|
92
|
+
const tonIndexer = this.config.TONParams.tonIndexer;
|
|
93
|
+
if (tonIndexer) {
|
|
94
|
+
const cclTransaction = await tonIndexer.findCollectibleCrossChainLayerTransaction(transactionHash, this.config.TONParams.crossChainLayerAddress);
|
|
95
|
+
if (!cclTransaction) {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
eventTxHash = `0x${(0, Utils_1.normalizeHashToHex)(cclTransaction.hash)}`;
|
|
99
|
+
}
|
|
75
100
|
let lastError;
|
|
76
101
|
for (const client of this.clients) {
|
|
77
102
|
try {
|
|
78
|
-
const id = await client.getOperationIdByTonTransactionHash(
|
|
103
|
+
const id = await client.getOperationIdByTonTransactionHash(eventTxHash);
|
|
79
104
|
return id;
|
|
80
105
|
}
|
|
81
106
|
catch (error) {
|
|
@@ -86,7 +111,7 @@ class OperationTracker {
|
|
|
86
111
|
};
|
|
87
112
|
return waitOptions === null
|
|
88
113
|
? await requestFn()
|
|
89
|
-
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn,
|
|
114
|
+
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, operationDescription);
|
|
90
115
|
}
|
|
91
116
|
async getOperationType(operationId, waitOptions) {
|
|
92
117
|
const requestFn = async () => {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ContractOpener, ILogger } from '../interfaces';
|
|
2
2
|
import { ITxFinalizer } from '../interfaces/ITxFinalizer';
|
|
3
3
|
import { ExecutionStages, Network, TransactionLinkerWithOperationId } from '../structs/Struct';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use `TacSdk.sendCrossChainTransaction(...)` instead. It already waits for operation ID
|
|
6
|
+
* and full cross-chain finalization by default via `waitOperationId` and `waitFinalization` options.
|
|
7
|
+
*/
|
|
4
8
|
export declare function startTracking(transactionLinker: TransactionLinkerWithOperationId, network: Network, options?: {
|
|
5
9
|
customLiteSequencerEndpoints?: string[];
|
|
6
10
|
delay?: number;
|
|
@@ -12,6 +16,10 @@ export declare function startTracking(transactionLinker: TransactionLinkerWithOp
|
|
|
12
16
|
contractOpener?: ContractOpener;
|
|
13
17
|
cclAddress?: string;
|
|
14
18
|
}): Promise<void | ExecutionStages>;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `TacSdk.sendCrossChainTransaction(...)` for new single-transaction flows. It already waits
|
|
21
|
+
* for operation ID and full cross-chain finalization by default via `waitOperationId` and `waitFinalization` options.
|
|
22
|
+
*/
|
|
15
23
|
export declare function startTrackingMultiple(transactionLinkers: TransactionLinkerWithOperationId[], network: Network, options?: {
|
|
16
24
|
customLiteSequencerEndpoints?: string[];
|
|
17
25
|
delay?: number;
|
|
@@ -3,14 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.startTracking = startTracking;
|
|
4
4
|
exports.startTrackingMultiple = startTrackingMultiple;
|
|
5
5
|
exports.printExecutionStagesTable = printExecutionStagesTable;
|
|
6
|
+
const artifacts_1 = require("../../artifacts");
|
|
6
7
|
const Struct_1 = require("../structs/Struct");
|
|
8
|
+
const Configuration_1 = require("./Configuration");
|
|
7
9
|
const Consts_1 = require("./Consts");
|
|
8
10
|
const Logger_1 = require("./Logger");
|
|
9
11
|
const OperationTracker_1 = require("./OperationTracker");
|
|
10
12
|
const Utils_1 = require("./Utils");
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `TacSdk.sendCrossChainTransaction(...)` instead. It already waits for operation ID
|
|
15
|
+
* and full cross-chain finalization by default via `waitOperationId` and `waitFinalization` options.
|
|
16
|
+
*/
|
|
11
17
|
async function startTracking(transactionLinker, network, options) {
|
|
12
18
|
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, logger = new Logger_1.NoopLogger(), txFinalizer, contractOpener, cclAddress, } = options || {};
|
|
13
|
-
const
|
|
19
|
+
const artifacts = network === Struct_1.Network.MAINNET ? artifacts_1.mainnet : network === Struct_1.Network.TESTNET ? artifacts_1.testnet : artifacts_1.dev;
|
|
20
|
+
const liteSequencerEndpoints = customLiteSequencerEndpoints && customLiteSequencerEndpoints.length !== 0
|
|
21
|
+
? customLiteSequencerEndpoints
|
|
22
|
+
: artifacts.PUBLIC_LITE_SEQUENCER_ENDPOINTS;
|
|
23
|
+
if (network === Struct_1.Network.DEV && liteSequencerEndpoints.length === 0) {
|
|
24
|
+
throw new Error('For DEV network, custom lite sequencer endpoints must be provided');
|
|
25
|
+
}
|
|
26
|
+
const trackerConfig = new Configuration_1.Configuration(network, artifacts, {}, {}, liteSequencerEndpoints, logger);
|
|
27
|
+
const tracker = new OperationTracker_1.OperationTracker(trackerConfig, logger);
|
|
14
28
|
logger.debug(`Start tracking operation\n` +
|
|
15
29
|
`caller: ${transactionLinker.caller}\n` +
|
|
16
30
|
`shardsKey: ${transactionLinker.shardsKey}\n` +
|
|
@@ -102,6 +116,10 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
102
116
|
logger.debug(formatExecutionStages(profilingData));
|
|
103
117
|
}
|
|
104
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated Use `TacSdk.sendCrossChainTransaction(...)` for new single-transaction flows. It already waits
|
|
121
|
+
* for operation ID and full cross-chain finalization by default via `waitOperationId` and `waitFinalization` options.
|
|
122
|
+
*/
|
|
105
123
|
async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
106
124
|
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, txFinalizer, contractOpener, cclAddress, logger = new Logger_1.NoopLogger(), } = options || {};
|
|
107
125
|
logger.debug(`Start tracking ${transactionLinkers.length} operations`);
|
|
@@ -11,6 +11,7 @@ export declare class TONTransactionManager implements ITONTransactionManager {
|
|
|
11
11
|
private prepareCrossChainTransaction;
|
|
12
12
|
private generateCrossChainMessages;
|
|
13
13
|
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<TransactionLinkerWithOperationId>;
|
|
14
|
+
private resolveOperationId;
|
|
14
15
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTx[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
15
16
|
private prepareBatchTransactions;
|
|
16
17
|
private waitForOperationIds;
|
|
@@ -191,15 +191,10 @@ class TONTransactionManager {
|
|
|
191
191
|
const waitOptions = tx.options?.waitOptions ?? {};
|
|
192
192
|
waitOptions.successCheck = waitOptions.successCheck ?? ((id) => !!id);
|
|
193
193
|
waitOptions.logger = waitOptions.logger ?? this.logger;
|
|
194
|
-
const operationId = await this.
|
|
195
|
-
.getOperationId(transactionLinker, waitOptions)
|
|
196
|
-
.catch((error) => {
|
|
197
|
-
this.logger.error(`Error while waiting for operation ID: ${error}`);
|
|
198
|
-
return undefined;
|
|
199
|
-
});
|
|
194
|
+
const operationId = await this.resolveOperationId(sendTransactionResult.boc, transactionLinker, waitOptions);
|
|
200
195
|
const shouldWaitForFinalization = tx.options?.waitFinalization ?? true;
|
|
201
196
|
if (!shouldWaitForFinalization) {
|
|
202
|
-
return { sendTransactionResult, ...transactionLinker };
|
|
197
|
+
return { sendTransactionResult, operationId, ...transactionLinker };
|
|
203
198
|
}
|
|
204
199
|
if (!operationId) {
|
|
205
200
|
throw errors_1.operationIdRequiredForFinalizationError;
|
|
@@ -224,6 +219,22 @@ class TONTransactionManager {
|
|
|
224
219
|
await this.operationTracker.getStageProfiling(operationId, finalizationWaitOptions);
|
|
225
220
|
return { sendTransactionResult, operationId, ...transactionLinker };
|
|
226
221
|
}
|
|
222
|
+
async resolveOperationId(boc, transactionLinker, waitOptions) {
|
|
223
|
+
const operationId = await this.operationTracker
|
|
224
|
+
.getOperationIdByTonTransactionBoc(boc, waitOptions)
|
|
225
|
+
.catch((error) => {
|
|
226
|
+
this.logger.error(`Error while waiting for operation ID by TON transaction BOC: ${error}`);
|
|
227
|
+
return undefined;
|
|
228
|
+
});
|
|
229
|
+
if (operationId) {
|
|
230
|
+
return operationId;
|
|
231
|
+
}
|
|
232
|
+
this.logger.debug('Operation ID by TON transaction BOC not found; trying transaction linker');
|
|
233
|
+
return this.operationTracker.getOperationId(transactionLinker, waitOptions).catch((error) => {
|
|
234
|
+
this.logger.error(`Error while waiting for operation ID by transaction linker: ${error}`);
|
|
235
|
+
return undefined;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
227
238
|
async sendCrossChainTransactions(sender, txs, options) {
|
|
228
239
|
const caller = sender.getSenderAddress();
|
|
229
240
|
this.logger.debug(`Preparing ${txs.length} cross-chain transactions for ${caller}`);
|
package/dist/src/sdk/TacSdk.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
|
3
3
|
import { FT, NFT, TAC, TON } from '../assets';
|
|
4
4
|
import { ContractOpener, IConfiguration, ILogger, IOperationTracker, ITacExplorerClient, ITacSDK } from '../interfaces';
|
|
5
5
|
import type { SenderAbstraction } from '../sender';
|
|
6
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended
|
|
6
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
|
|
7
7
|
export declare class TacSdk implements ITacSDK {
|
|
8
8
|
readonly config: IConfiguration;
|
|
9
9
|
readonly contactOpener: ContractOpener;
|
|
@@ -12,7 +12,6 @@ export declare class TacSdk implements ITacSDK {
|
|
|
12
12
|
private readonly simulator;
|
|
13
13
|
private readonly tonTransactionManager;
|
|
14
14
|
private readonly tacTransactionManager;
|
|
15
|
-
private readonly tonIndexer;
|
|
16
15
|
private constructor();
|
|
17
16
|
static create(sdkParams: SDKParams, logger?: ILogger): Promise<TacSdk>;
|
|
18
17
|
closeConnections(): unknown;
|
|
@@ -26,8 +25,6 @@ export declare class TacSdk implements ITacSDK {
|
|
|
26
25
|
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<TransactionLinkerWithOperationId>;
|
|
27
26
|
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: AssetLike[], options?: CrossChainTransactionToTONOptions): Promise<TACCrossChainTransactionResult>;
|
|
28
27
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
29
|
-
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
30
|
-
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
31
28
|
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: AssetLike[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
|
|
32
29
|
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
33
30
|
simulateTACMessage(req: TACSimulationParams): Promise<TACSimulationResult>;
|
|
@@ -51,5 +48,4 @@ export declare class TacSdk implements ITacSDK {
|
|
|
51
48
|
prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
|
|
52
49
|
getTACGasPrice(): Promise<TacGasPrice>;
|
|
53
50
|
getTonContractOpener(): ContractOpener;
|
|
54
|
-
private toSequencerTonTransactionHash;
|
|
55
51
|
}
|
package/dist/src/sdk/TacSdk.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TacSdk = void 0;
|
|
4
|
-
const ton_1 = require("@ton/ton");
|
|
5
4
|
const artifacts_1 = require("../../artifacts");
|
|
6
|
-
const adapters_1 = require("../adapters");
|
|
7
5
|
const assets_1 = require("../assets");
|
|
8
|
-
const errors_1 = require("../errors");
|
|
9
6
|
const Struct_1 = require("../structs/Struct");
|
|
10
7
|
const Configuration_1 = require("./Configuration");
|
|
11
8
|
const Consts_1 = require("./Consts");
|
|
@@ -17,7 +14,7 @@ const TACTransactionManager_1 = require("./TACTransactionManager");
|
|
|
17
14
|
const TONTransactionManager_1 = require("./TONTransactionManager");
|
|
18
15
|
const Utils_1 = require("./Utils");
|
|
19
16
|
class TacSdk {
|
|
20
|
-
constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient
|
|
17
|
+
constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient) {
|
|
21
18
|
this.config = config;
|
|
22
19
|
this.contactOpener = config.TONParams.contractOpener;
|
|
23
20
|
this.simulator = simulator;
|
|
@@ -25,7 +22,6 @@ class TacSdk {
|
|
|
25
22
|
this.tacTransactionManager = tacTransactionManager;
|
|
26
23
|
this.operationTracker = operationTracker;
|
|
27
24
|
this.explorerClient = explorerClient;
|
|
28
|
-
this.tonIndexer = tonIndexer;
|
|
29
25
|
}
|
|
30
26
|
static async create(sdkParams, logger = new Logger_1.NoopLogger()) {
|
|
31
27
|
const network = sdkParams.network;
|
|
@@ -46,13 +42,12 @@ class TacSdk {
|
|
|
46
42
|
throw new Error(`Unsupported network: ${network}`);
|
|
47
43
|
}
|
|
48
44
|
const config = await Configuration_1.Configuration.create(network, artifacts, sdkParams.TONParams, sdkParams.TACParams, sdkParams.customLiteSequencerEndpoints, delay, logger, passLoggerToOpeners);
|
|
49
|
-
const operationTracker = new OperationTracker_1.OperationTracker(
|
|
45
|
+
const operationTracker = new OperationTracker_1.OperationTracker(config, logger);
|
|
50
46
|
const explorerClient = new TacExplorerClient_1.TacExplorerClient(artifacts.TAC_EXPLORER_API_ENDPOINT);
|
|
51
47
|
const simulator = new Simulator_1.Simulator(config, operationTracker, logger);
|
|
52
48
|
const tonTransactionManager = new TONTransactionManager_1.TONTransactionManager(config, simulator, operationTracker, logger);
|
|
53
49
|
const tacTransactionManager = new TACTransactionManager_1.TACTransactionManager(config, operationTracker, logger);
|
|
54
|
-
|
|
55
|
-
return new TacSdk(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient, tonIndexer);
|
|
50
|
+
return new TacSdk(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient);
|
|
56
51
|
}
|
|
57
52
|
closeConnections() {
|
|
58
53
|
return this.config.closeConnections();
|
|
@@ -104,32 +99,6 @@ class TacSdk {
|
|
|
104
99
|
})));
|
|
105
100
|
return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, options);
|
|
106
101
|
}
|
|
107
|
-
async getOperationIdByTonTransactionHash(transactionHash, waitOptions) {
|
|
108
|
-
const cclTransaction = await this.tonIndexer.findCollectibleCrossChainLayerTransaction(transactionHash, this.config.TONParams.crossChainLayerAddress);
|
|
109
|
-
if (!cclTransaction) {
|
|
110
|
-
return '';
|
|
111
|
-
}
|
|
112
|
-
return this.operationTracker.getOperationIdByTonTransactionHash(this.toSequencerTonTransactionHash(cclTransaction), waitOptions);
|
|
113
|
-
}
|
|
114
|
-
async getOperationIdByTonTransactionBoc(boc, waitOptions) {
|
|
115
|
-
let message;
|
|
116
|
-
try {
|
|
117
|
-
message = (0, ton_1.loadMessage)(ton_1.Cell.fromBase64(boc).beginParse());
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
const reason = error instanceof Error ? error.message : undefined;
|
|
121
|
-
throw (0, errors_1.invalidTonExternalMessageBocError)(reason);
|
|
122
|
-
}
|
|
123
|
-
if (message.info.type !== 'external-in') {
|
|
124
|
-
throw (0, errors_1.externalInMessageRequiredError)(message.info.type);
|
|
125
|
-
}
|
|
126
|
-
const destination = message.info.dest;
|
|
127
|
-
const transaction = await this.contactOpener.getTransactionByHash(ton_1.Address.parse(destination.toString()), (0, Utils_1.getNormalizedExtMessageHash)(message));
|
|
128
|
-
if (!transaction) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
return this.getOperationIdByTonTransactionHash(transaction.hash().toString('base64'), waitOptions);
|
|
132
|
-
}
|
|
133
102
|
async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors) {
|
|
134
103
|
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
135
104
|
return this.tacTransactionManager.bridgeTokensToTON(signer, value, tonTarget, normalizedAssets, tvmExecutorFee, tvmValidExecutors);
|
|
@@ -235,8 +204,5 @@ class TacSdk {
|
|
|
235
204
|
getTonContractOpener() {
|
|
236
205
|
return this.contactOpener;
|
|
237
206
|
}
|
|
238
|
-
toSequencerTonTransactionHash(transaction) {
|
|
239
|
-
return `0x${(0, Utils_1.normalizeHashToHex)(transaction.hash)}`;
|
|
240
|
-
}
|
|
241
207
|
}
|
|
242
208
|
exports.TacSdk = TacSdk;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, Cell, Message } from '@ton/ton';
|
|
2
2
|
import { AbstractProvider, ethers } from 'ethers';
|
|
3
3
|
import { ICrossChainLayer, ISAFactory, ISettings, ITokenUtils } from '../../artifacts/tacTypes';
|
|
4
|
-
import { ContractOpener } from '../interfaces';
|
|
4
|
+
import { ContractOpener, IToncenterV3Indexer } from '../interfaces';
|
|
5
5
|
import { CurrencyType, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, ToncenterV3IndexedTransaction, TransactionLinker } from './Struct';
|
|
6
6
|
export type ShardMessage = {
|
|
7
7
|
address: string;
|
|
@@ -37,6 +37,7 @@ export type RandomNumberByTimestamp = {
|
|
|
37
37
|
};
|
|
38
38
|
export type InternalTONParams = {
|
|
39
39
|
contractOpener: ContractOpener;
|
|
40
|
+
tonIndexer?: IToncenterV3Indexer;
|
|
40
41
|
jettonProxyAddress: string;
|
|
41
42
|
nftProxyAddress: string;
|
|
42
43
|
crossChainLayerAddress: string;
|