@tonappchain/sdk 0.7.3-rc7 → 0.8.0
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/artifacts/dev/tac/internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json +0 -7
- package/dist/artifacts/dev/tac/internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json +0 -7
- package/dist/artifacts/dev/tac/internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json +0 -7
- package/dist/artifacts/dev/tac/internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json +0 -7
- package/dist/artifacts/dev/tac/internal/typechain-types/contracts/interfaces/ICrossChainLayer.d.ts +1 -5
- package/dist/artifacts/dev/tac/internal/typechain-types/contracts/interfaces/ISettings.d.ts +1 -5
- package/dist/artifacts/dev/tac/internal/typechain-types/contracts/interfaces/ITokenUtils.d.ts +1 -5
- package/dist/artifacts/dev/tac/internal/typechain-types/contracts/smart-account/interfaces/ISAFactory.d.ts +1 -5
- package/dist/artifacts/dev/ton/internal/build/Settings.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/wrappers/Settings.d.ts +1 -0
- package/dist/artifacts/dev/ton/internal/wrappers/Settings.js +11 -7
- package/dist/artifacts/index.d.ts +5 -3
- package/dist/artifacts/index.js +6 -3
- package/dist/artifacts/mainnet/tac/internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json +0 -7
- package/dist/artifacts/mainnet/tac/internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json +0 -7
- package/dist/artifacts/mainnet/tac/internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json +0 -7
- package/dist/artifacts/mainnet/tac/internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json +0 -7
- package/dist/artifacts/mainnet/tac/internal/typechain-types/contracts/interfaces/ICrossChainLayer.d.ts +1 -5
- package/dist/artifacts/mainnet/tac/internal/typechain-types/contracts/interfaces/ISettings.d.ts +1 -5
- package/dist/artifacts/mainnet/tac/internal/typechain-types/contracts/interfaces/ITokenUtils.d.ts +1 -5
- package/dist/artifacts/mainnet/tac/internal/typechain-types/contracts/smart-account/interfaces/ISAFactory.d.ts +1 -5
- package/dist/artifacts/mainnet/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonMinter.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonProxy.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonWallet.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/NFTCollection.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/NFTItem.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/NFTProxy.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/Settings.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.d.ts +65 -6
- package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.js +169 -18
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.d.ts +4 -2
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.js +5 -3
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonProxy.d.ts +9 -0
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonProxy.js +11 -2
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonWallet.d.ts +7 -0
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonWallet.js +9 -2
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTCollection.d.ts +11 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTCollection.js +17 -5
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTItem.d.ts +9 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTItem.js +15 -5
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTProxy.d.ts +9 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/NFTProxy.js +16 -6
- package/dist/artifacts/mainnet/ton/internal/wrappers/Settings.d.ts +2 -0
- package/dist/artifacts/mainnet/ton/internal/wrappers/Settings.js +11 -6
- package/dist/artifacts/mainnet/ton/internal/wrappers/utils/CrossChainLayerPayload.d.ts +10 -0
- package/dist/artifacts/mainnet/ton/internal/wrappers/utils/CrossChainLayerPayload.js +24 -0
- package/dist/artifacts/mainnet/ton/internal/wrappers/utils/MerkleRoots.d.ts +2 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/utils/MerkleRoots.js +9 -1
- package/dist/artifacts/testnet/tac/internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json +0 -7
- package/dist/artifacts/testnet/tac/internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json +0 -7
- package/dist/artifacts/testnet/tac/internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json +0 -7
- package/dist/artifacts/testnet/tac/internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json +0 -7
- package/dist/artifacts/testnet/tac/internal/typechain-types/contracts/interfaces/ICrossChainLayer.d.ts +1 -5
- package/dist/artifacts/testnet/tac/internal/typechain-types/contracts/interfaces/ISettings.d.ts +1 -5
- package/dist/artifacts/testnet/tac/internal/typechain-types/contracts/interfaces/ITokenUtils.d.ts +1 -5
- package/dist/artifacts/testnet/tac/internal/typechain-types/contracts/smart-account/interfaces/ISAFactory.d.ts +1 -5
- package/dist/artifacts/testnet/ton/internal/build/Settings.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/Settings.d.ts +1 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/Settings.js +11 -7
- package/dist/src/adapters/RetryableContractOpener.js +5 -2
- package/dist/src/adapters/ToncenterV3Indexer.js +1 -1
- package/dist/src/assets/AssetCache.d.ts +4 -4
- package/dist/src/assets/AssetCache.js +11 -6
- package/dist/src/assets/AssetFactory.js +2 -2
- package/dist/src/errors/index.d.ts +1 -1
- package/dist/src/errors/index.js +5 -3
- package/dist/src/errors/instances.d.ts +2 -0
- package/dist/src/errors/instances.js +4 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +3 -1
- package/dist/src/interfaces/IConfiguration.d.ts +2 -2
- package/dist/src/interfaces/IOperationTracker.d.ts +14 -1
- package/dist/src/interfaces/ITacSDK.d.ts +1 -21
- package/dist/src/sdk/Artifacts.d.ts +3 -0
- package/dist/src/sdk/Artifacts.js +17 -0
- package/dist/src/sdk/Configuration.d.ts +4 -4
- package/dist/src/sdk/Configuration.js +8 -3
- package/dist/src/sdk/Consts.d.ts +0 -1
- package/dist/src/sdk/Consts.js +1 -2
- package/dist/src/sdk/LiteSequencerClient.js +2 -1
- 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/TACTransactionManager.js +5 -5
- package/dist/src/sdk/TONTransactionManager.d.ts +1 -0
- package/dist/src/sdk/TONTransactionManager.js +29 -16
- package/dist/src/sdk/TacExplorerClient.js +4 -3
- package/dist/src/sdk/TacSdk.d.ts +1 -5
- package/dist/src/sdk/TacSdk.js +5 -52
- package/dist/src/sdk/TxFinalizer.js +1 -1
- package/dist/src/sdk/Utils.js +37 -4
- package/dist/src/structs/InternalStruct.d.ts +2 -1
- package/dist/src/structs/Struct.d.ts +4 -4
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Settings = exports.SettingsErrors = exports.SettingsOpCodes = void 0;
|
|
4
4
|
exports.settingsConfigToCell = settingsConfigToCell;
|
|
5
|
+
exports.createSettingsSetValueBody = createSettingsSetValueBody;
|
|
5
6
|
const core_1 = require("@ton/core");
|
|
6
7
|
const GasUtils_1 = require("./utils/GasUtils");
|
|
7
8
|
exports.SettingsOpCodes = {
|
|
@@ -29,6 +30,14 @@ function settingsConfigToCell(config) {
|
|
|
29
30
|
.storeDict(config.settings)
|
|
30
31
|
.endCell();
|
|
31
32
|
}
|
|
33
|
+
function createSettingsSetValueBody(params) {
|
|
34
|
+
return (0, core_1.beginCell)()
|
|
35
|
+
.storeUint(exports.SettingsOpCodes.admin_setValue, 32)
|
|
36
|
+
.storeUint(params.queryId ?? 0, 64)
|
|
37
|
+
.storeUint(params.key, 256)
|
|
38
|
+
.storeRef(params.value)
|
|
39
|
+
.endCell();
|
|
40
|
+
}
|
|
32
41
|
class Settings {
|
|
33
42
|
constructor(address, init, configuration) {
|
|
34
43
|
this.address = address;
|
|
@@ -54,12 +63,7 @@ class Settings {
|
|
|
54
63
|
await provider.internal(via, {
|
|
55
64
|
value,
|
|
56
65
|
sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
|
|
57
|
-
body: (
|
|
58
|
-
.storeUint(exports.SettingsOpCodes.admin_setValue, 32)
|
|
59
|
-
.storeUint(params.queryId ?? 0, 64)
|
|
60
|
-
.storeUint(params.key, 256)
|
|
61
|
-
.storeRef(params.value)
|
|
62
|
-
.endCell(),
|
|
66
|
+
body: createSettingsSetValueBody(params),
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
async sendGetValue(provider, via, value, params) {
|
|
@@ -148,6 +152,6 @@ class Settings {
|
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
exports.Settings = Settings;
|
|
151
|
-
Settings.storageStats = new GasUtils_1.StorageStats(
|
|
155
|
+
Settings.storageStats = new GasUtils_1.StorageStats(39175n, 118n);
|
|
152
156
|
Settings.minStorageDuration = 10 * 365 * 24 * 3600; // 10 years
|
|
153
157
|
Settings.minStorageStats = new GasUtils_1.StorageStats(29557n, 104n);
|
|
@@ -146,7 +146,7 @@ class RetryableContractOpener {
|
|
|
146
146
|
const openerLabel = `opener ${index + 1}/${this.openerConfigs.length}`;
|
|
147
147
|
this.logger?.debug(`[RetryableContractOpener] ${operationName}: trying ${openerLabel}`);
|
|
148
148
|
const result = useRetries
|
|
149
|
-
? await this.tryWithRetries(() => operation(config), config, `${operationName} ${openerLabel}
|
|
149
|
+
? await this.tryWithRetries(() => operation(config), config, `${operationName} ${openerLabel}`, shouldFallbackOnError)
|
|
150
150
|
: await this.trySingleAttempt(() => operation(config));
|
|
151
151
|
if (result.success) {
|
|
152
152
|
return { success: true, data: result.data };
|
|
@@ -186,7 +186,7 @@ class RetryableContractOpener {
|
|
|
186
186
|
return { success: false, lastError: error };
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
async tryWithRetries(operation, config, operationContext = 'operation') {
|
|
189
|
+
async tryWithRetries(operation, config, operationContext = 'operation', shouldRetryError) {
|
|
190
190
|
let lastError;
|
|
191
191
|
for (let attempt = 0; attempt <= config.retries; attempt++) {
|
|
192
192
|
try {
|
|
@@ -198,6 +198,9 @@ class RetryableContractOpener {
|
|
|
198
198
|
if (lastError instanceof errors_1.TransactionError || this.isContractExecutionError(lastError)) {
|
|
199
199
|
return { success: false, lastError };
|
|
200
200
|
}
|
|
201
|
+
if (shouldRetryError && !shouldRetryError(lastError)) {
|
|
202
|
+
return { success: false, lastError };
|
|
203
|
+
}
|
|
201
204
|
if (attempt < config.retries) {
|
|
202
205
|
const retryDelay = this.getRetryDelay(config, attempt);
|
|
203
206
|
this.logger?.debug(`[RetryableContractOpener] ${operationContext}: attempt ${attempt + 1}/${config.retries + 1} failed (${lastError.message}), retrying in ${retryDelay}ms`);
|
|
@@ -11,7 +11,7 @@ const Utils_1 = require("../sdk/Utils");
|
|
|
11
11
|
* traversing a linked chain of TON transactions until it finds the sequencer-collected event transaction on CCL.
|
|
12
12
|
*/
|
|
13
13
|
class ToncenterV3Indexer {
|
|
14
|
-
constructor(endpoint, httpClient = new AxiosHttpClient_1.AxiosHttpClient()) {
|
|
14
|
+
constructor(endpoint, httpClient = new AxiosHttpClient_1.AxiosHttpClient({ timeout: Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS })) {
|
|
15
15
|
this.endpoint = endpoint;
|
|
16
16
|
this.httpClient = httpClient;
|
|
17
17
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Asset } from '../interfaces';
|
|
1
|
+
import type { Asset, IConfiguration } from '../interfaces';
|
|
2
2
|
type AssetCacheToken = {
|
|
3
3
|
address: string;
|
|
4
4
|
index?: bigint;
|
|
5
5
|
tokenType?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare class AssetCache {
|
|
8
|
-
private static
|
|
8
|
+
private static cache;
|
|
9
9
|
/**
|
|
10
10
|
* Get asset from cache
|
|
11
11
|
*/
|
|
12
|
-
static get(token: AssetCacheToken): Asset | undefined;
|
|
12
|
+
static get(configuration: IConfiguration, token: AssetCacheToken): Asset | undefined;
|
|
13
13
|
/**
|
|
14
14
|
* Set asset in cache
|
|
15
15
|
*/
|
|
16
|
-
static set(token: AssetCacheToken, asset: Asset): void;
|
|
16
|
+
static set(configuration: IConfiguration, token: AssetCacheToken, asset: Asset): void;
|
|
17
17
|
/**
|
|
18
18
|
* Clear the cache
|
|
19
19
|
*/
|
|
@@ -5,22 +5,27 @@ class AssetCache {
|
|
|
5
5
|
/**
|
|
6
6
|
* Get asset from cache
|
|
7
7
|
*/
|
|
8
|
-
static get(token) {
|
|
8
|
+
static get(configuration, token) {
|
|
9
9
|
const key = this.generateKey(token);
|
|
10
|
-
return this.cache.get(key);
|
|
10
|
+
return this.cache.get(configuration)?.get(key);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Set asset in cache
|
|
14
14
|
*/
|
|
15
|
-
static set(token, asset) {
|
|
15
|
+
static set(configuration, token, asset) {
|
|
16
16
|
const key = this.generateKey(token);
|
|
17
|
-
this.cache.
|
|
17
|
+
let scopedCache = this.cache.get(configuration);
|
|
18
|
+
if (!scopedCache) {
|
|
19
|
+
scopedCache = new Map();
|
|
20
|
+
this.cache.set(configuration, scopedCache);
|
|
21
|
+
}
|
|
22
|
+
scopedCache.set(key, asset);
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Clear the cache
|
|
21
26
|
*/
|
|
22
27
|
static clear() {
|
|
23
|
-
this.cache
|
|
28
|
+
this.cache = new WeakMap();
|
|
24
29
|
}
|
|
25
30
|
static generateKey(token) {
|
|
26
31
|
// Normalize address to lowercase for consistency
|
|
@@ -36,4 +41,4 @@ class AssetCache {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
exports.AssetCache = AssetCache;
|
|
39
|
-
AssetCache.cache = new
|
|
44
|
+
AssetCache.cache = new WeakMap();
|
|
@@ -18,14 +18,14 @@ class AssetFactory {
|
|
|
18
18
|
throw (0, errors_1.unknownTokenTypeError)(token.address, 'detected TON, but token type is not FT');
|
|
19
19
|
return TON_1.TON.create(configuration);
|
|
20
20
|
}
|
|
21
|
-
const cachedAsset = AssetCache_1.AssetCache.get(token);
|
|
21
|
+
const cachedAsset = AssetCache_1.AssetCache.get(configuration, token);
|
|
22
22
|
if (cachedAsset) {
|
|
23
23
|
return cachedAsset.clone.withRawAmount(0n);
|
|
24
24
|
}
|
|
25
25
|
const asset = token.tokenType === Struct_1.AssetType.FT
|
|
26
26
|
? await this.createFTAsset(configuration, token.address)
|
|
27
27
|
: await this.createNFTAsset(configuration, token.address, token.addressType, token.addressType === Struct_1.NFTAddressType.COLLECTION ? token.index : undefined);
|
|
28
|
-
AssetCache_1.AssetCache.set(token, asset);
|
|
28
|
+
AssetCache_1.AssetCache.set(configuration, token, asset);
|
|
29
29
|
return asset;
|
|
30
30
|
}
|
|
31
31
|
static async createFTAsset(configuration, address) {
|
|
@@ -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, invalidAmountError, 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.invalidMethodNameError = 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.invalidAmountError = 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,15 @@ 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, "
|
|
31
|
+
Object.defineProperty(exports, "invalidAmountError", { enumerable: true, get: function () { return instances_1.invalidAmountError; } });
|
|
32
32
|
Object.defineProperty(exports, "invalidMethodNameError", { enumerable: true, get: function () { return instances_1.invalidMethodNameError; } });
|
|
33
|
+
Object.defineProperty(exports, "invalidTonExternalMessageBocError", { enumerable: true, get: function () { return instances_1.invalidTonExternalMessageBocError; } });
|
|
33
34
|
Object.defineProperty(exports, "missingDecimals", { enumerable: true, get: function () { return instances_1.missingDecimals; } });
|
|
34
35
|
Object.defineProperty(exports, "missingFeeParamsError", { enumerable: true, get: function () { return instances_1.missingFeeParamsError; } });
|
|
35
36
|
Object.defineProperty(exports, "missingGasLimitError", { enumerable: true, get: function () { return instances_1.missingGasLimitError; } });
|
|
@@ -42,6 +43,7 @@ Object.defineProperty(exports, "prefixError", { enumerable: true, get: function
|
|
|
42
43
|
Object.defineProperty(exports, "profilingFetchError", { enumerable: true, get: function () { return instances_1.profilingFetchError; } });
|
|
43
44
|
Object.defineProperty(exports, "simulationFetchError", { enumerable: true, get: function () { return instances_1.simulationFetchError; } });
|
|
44
45
|
Object.defineProperty(exports, "statusFetchError", { enumerable: true, get: function () { return instances_1.statusFetchError; } });
|
|
46
|
+
Object.defineProperty(exports, "tonIndexerRequiredForTonTransactionBocError", { enumerable: true, get: function () { return instances_1.tonIndexerRequiredForTonTransactionBocError; } });
|
|
45
47
|
Object.defineProperty(exports, "tvmAddressError", { enumerable: true, get: function () { return instances_1.tvmAddressError; } });
|
|
46
48
|
Object.defineProperty(exports, "txFinalizationError", { enumerable: true, get: function () { return instances_1.txFinalizationError; } });
|
|
47
49
|
Object.defineProperty(exports, "unknownTokenTypeError", { enumerable: true, get: function () { return instances_1.unknownTokenTypeError; } });
|
|
@@ -43,3 +43,5 @@ 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;
|
|
47
|
+
export declare const invalidAmountError: (reason: string) => FormatError;
|
|
@@ -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.invalidAmountError = 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,6 @@ 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);
|
|
135
|
+
const invalidAmountError = (reason) => new errors_1.FormatError(`Invalid amount: ${reason}`, 144);
|
|
136
|
+
exports.invalidAmountError = invalidAmountError;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * as AgnosticStructs from './agnosticSdk/AgnosticStructs';
|
|
|
4
4
|
export * from './assets';
|
|
5
5
|
export * from './errors';
|
|
6
6
|
export * from './interfaces';
|
|
7
|
+
export { getArtifacts } from './sdk/Artifacts';
|
|
7
8
|
export { AxiosHttpClient } from './sdk/AxiosHttpClient';
|
|
8
9
|
export { Configuration } from './sdk/Configuration';
|
|
9
10
|
export { LiteSequencerClient } from './sdk/LiteSequencerClient';
|
package/dist/src/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TonTxFinalizer = exports.TONTransactionManager = exports.TACTransactionManager = exports.TacSdk = exports.TacExplorerClient = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.AgnosticStructs = exports.AgnosticProxySDK = void 0;
|
|
39
|
+
exports.TonTxFinalizer = exports.TONTransactionManager = exports.TACTransactionManager = exports.TacSdk = exports.TacExplorerClient = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.getArtifacts = exports.AgnosticStructs = exports.AgnosticProxySDK = void 0;
|
|
40
40
|
__exportStar(require("./adapters"), exports);
|
|
41
41
|
var AgnosticSdk_1 = require("./agnosticSdk/AgnosticSdk");
|
|
42
42
|
Object.defineProperty(exports, "AgnosticProxySDK", { enumerable: true, get: function () { return AgnosticSdk_1.AgnosticProxySDK; } });
|
|
@@ -44,6 +44,8 @@ exports.AgnosticStructs = __importStar(require("./agnosticSdk/AgnosticStructs"))
|
|
|
44
44
|
__exportStar(require("./assets"), exports);
|
|
45
45
|
__exportStar(require("./errors"), exports);
|
|
46
46
|
__exportStar(require("./interfaces"), exports);
|
|
47
|
+
var Artifacts_1 = require("./sdk/Artifacts");
|
|
48
|
+
Object.defineProperty(exports, "getArtifacts", { enumerable: true, get: function () { return Artifacts_1.getArtifacts; } });
|
|
47
49
|
var AxiosHttpClient_1 = require("./sdk/AxiosHttpClient");
|
|
48
50
|
Object.defineProperty(exports, "AxiosHttpClient", { enumerable: true, get: function () { return AxiosHttpClient_1.AxiosHttpClient; } });
|
|
49
51
|
var Configuration_1 = require("./sdk/Configuration");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NetworkArtifacts } from '../../artifacts';
|
|
2
2
|
import { InternalTACParams, InternalTONParams } from '../structs/InternalStruct';
|
|
3
3
|
import { Network } from '../structs/Struct';
|
|
4
4
|
export interface IConfiguration {
|
|
5
5
|
/** Current network the SDK is configured for (e.g., MAINNET/TESTNET). */
|
|
6
6
|
readonly network: Network;
|
|
7
7
|
/** Resolved artifacts bundle for the selected network (contract ABIs/addresses). */
|
|
8
|
-
readonly artifacts:
|
|
8
|
+
readonly artifacts: NetworkArtifacts;
|
|
9
9
|
/** Low-level TON client parameters and dependencies. */
|
|
10
10
|
readonly TONParams: InternalTONParams;
|
|
11
11
|
/** Low-level TAC (EVM-side) client parameters and dependencies. */
|
|
@@ -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,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getArtifacts = getArtifacts;
|
|
4
|
+
const artifacts_1 = require("../../artifacts");
|
|
5
|
+
const Struct_1 = require("../structs/Struct");
|
|
6
|
+
function getArtifacts(network) {
|
|
7
|
+
switch (network) {
|
|
8
|
+
case Struct_1.Network.MAINNET:
|
|
9
|
+
return artifacts_1.mainnet;
|
|
10
|
+
case Struct_1.Network.TESTNET:
|
|
11
|
+
return artifacts_1.testnet;
|
|
12
|
+
case Struct_1.Network.DEV:
|
|
13
|
+
return artifacts_1.dev;
|
|
14
|
+
default:
|
|
15
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NetworkArtifacts } from '../../artifacts';
|
|
2
2
|
import { IConfiguration, ILogger } from '../interfaces';
|
|
3
3
|
import { InternalTACParams, InternalTONParams } from '../structs/InternalStruct';
|
|
4
4
|
import { Network, TACParams, TONParams } from '../structs/Struct';
|
|
5
5
|
export declare class Configuration implements IConfiguration {
|
|
6
6
|
readonly network: Network;
|
|
7
|
-
readonly artifacts:
|
|
7
|
+
readonly artifacts: NetworkArtifacts;
|
|
8
8
|
readonly TONParams: InternalTONParams;
|
|
9
9
|
readonly TACParams: InternalTACParams;
|
|
10
10
|
readonly liteSequencerEndpoints: string[];
|
|
11
11
|
readonly logger: ILogger;
|
|
12
|
-
constructor(network: Network, artifacts:
|
|
13
|
-
static create(network: Network, artifacts:
|
|
12
|
+
constructor(network: Network, artifacts: NetworkArtifacts, TONParams: InternalTONParams, TACParams: InternalTACParams, liteSequencerEndpoints: string[], logger: ILogger);
|
|
13
|
+
static create(network: Network, artifacts: NetworkArtifacts, TONParams?: TONParams, TACParams?: TACParams, customLiteSequencerEndpoints?: string[], delay?: number, logger?: ILogger, passLoggerToOpeners?: boolean): Promise<Configuration>;
|
|
14
14
|
private static prepareTONParams;
|
|
15
15
|
private static prepareTACParams;
|
|
16
16
|
private static loadTACSettingsViaMulticall;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Configuration = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
|
-
const artifacts_1 = require("../../artifacts");
|
|
7
6
|
const adapters_1 = require("../adapters");
|
|
8
7
|
const Struct_1 = require("../structs/Struct");
|
|
8
|
+
const Artifacts_1 = require("./Artifacts");
|
|
9
9
|
const Consts_1 = require("./Consts");
|
|
10
10
|
const Fees_1 = require("./Fees");
|
|
11
11
|
const Logger_1 = require("./Logger");
|
|
@@ -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,
|
|
@@ -93,7 +98,7 @@ class Configuration {
|
|
|
93
98
|
};
|
|
94
99
|
}
|
|
95
100
|
static async prepareTACParams(network, TACParams) {
|
|
96
|
-
const artifacts =
|
|
101
|
+
const artifacts = (0, Artifacts_1.getArtifacts)(network);
|
|
97
102
|
let provider;
|
|
98
103
|
let settingsAddress;
|
|
99
104
|
let saFactoryAddress;
|
|
@@ -158,7 +163,7 @@ class Configuration {
|
|
|
158
163
|
// skip multicall in dev, because it's not guaranteed that multicall contract is deployed
|
|
159
164
|
return null;
|
|
160
165
|
}
|
|
161
|
-
const artifacts =
|
|
166
|
+
const artifacts = (0, Artifacts_1.getArtifacts)(network);
|
|
162
167
|
const multicallAddress = artifacts.MULTICALL_3_ADDRESS;
|
|
163
168
|
const multicallAbi = artifacts.tac.multicall.MULTICALL_ABI_ETHERS;
|
|
164
169
|
try {
|
package/dist/src/sdk/Consts.d.ts
CHANGED
|
@@ -49,6 +49,5 @@ export declare const IGNORE_MSG_VALUE_1_NANO = 1n;
|
|
|
49
49
|
export declare const CROSS_CHAIN_MESSAGE_VERSION_V1 = 1n;
|
|
50
50
|
export declare const NFT_BRIDGE_AMOUNT = 1n;
|
|
51
51
|
export declare const DEFAULT_EIP1559_PRIORITY_FEE = 0n;
|
|
52
|
-
export declare const SHARDS_KEY_RANDOM_RANGE = 1000000000000000000;
|
|
53
52
|
export declare const IGNORE_OPCODE: number[];
|
|
54
53
|
export declare const HTTP_NOT_FOUND_STATUS_CODE = 404;
|
package/dist/src/sdk/Consts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NFT_BRIDGE_AMOUNT = exports.CROSS_CHAIN_MESSAGE_VERSION_V1 = exports.IGNORE_MSG_VALUE_1_NANO = exports.DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = exports.DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = exports.DEFAULT_RETRY_ON_NOT_FOUND = exports.DEFAULT_FIND_TX_MAX_DEPTH = exports.DEFAULT_MAX_SCANNED_TRANSACTIONS = exports.DEFAULT_FIND_TX_LIMIT = exports.DEFAULT_WAIT_DELAY_MS = exports.DEFAULT_WAIT_MAX_ATTEMPTS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.DEFAULT_RETRY_BACKOFF_MULTIPLIER = exports.DEFAULT_RETRY_MAX_DELAY_MS = exports.DEFAULT_RETRY_DELAY_MS = exports.DEFAULT_RETRY_MAX_COUNT = exports.DEFAULT_HTTP_CLIENT_TIMEOUT_MS = exports.TON_BURN_ADDRESS = exports.MINUTE = exports.FIVE_MINUTES = exports.TAC_DECIMALS = exports.TON_DECIMALS = exports.ONE_YEAR_SECONDS = 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.FIXED_POINT_SHIFT = exports.DYNAMIC_JETTON_WALLET_CODE_HASHES = exports.USDT_JETTON_WALLET_CODE_HASH = exports.LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = exports.LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE = exports.LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION = exports.LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = exports.LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = exports.LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = exports.LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = void 0;
|
|
4
|
-
exports.HTTP_NOT_FOUND_STATUS_CODE = exports.IGNORE_OPCODE = exports.
|
|
4
|
+
exports.HTTP_NOT_FOUND_STATUS_CODE = exports.IGNORE_OPCODE = exports.DEFAULT_EIP1559_PRIORITY_FEE = void 0;
|
|
5
5
|
const ton_1 = require("@ton/ton");
|
|
6
6
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
7
7
|
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
|
|
@@ -55,7 +55,6 @@ exports.IGNORE_MSG_VALUE_1_NANO = 1n;
|
|
|
55
55
|
exports.CROSS_CHAIN_MESSAGE_VERSION_V1 = 1n;
|
|
56
56
|
exports.NFT_BRIDGE_AMOUNT = 1n;
|
|
57
57
|
exports.DEFAULT_EIP1559_PRIORITY_FEE = 0n;
|
|
58
|
-
exports.SHARDS_KEY_RANDOM_RANGE = 1e18;
|
|
59
58
|
exports.IGNORE_OPCODE = [
|
|
60
59
|
0xd53276db, // Excess
|
|
61
60
|
];
|
|
@@ -4,9 +4,10 @@ exports.LiteSequencerClient = void 0;
|
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
const instances_1 = require("../errors/instances");
|
|
6
6
|
const AxiosHttpClient_1 = require("./AxiosHttpClient");
|
|
7
|
+
const Consts_1 = require("./Consts");
|
|
7
8
|
const Utils_1 = require("./Utils");
|
|
8
9
|
class LiteSequencerClient {
|
|
9
|
-
constructor(endpoint, maxChunkSize = 100, httpClient = new AxiosHttpClient_1.AxiosHttpClient()) {
|
|
10
|
+
constructor(endpoint, maxChunkSize = 100, httpClient = new AxiosHttpClient_1.AxiosHttpClient({ timeout: Consts_1.DEFAULT_HTTP_CLIENT_TIMEOUT_MS })) {
|
|
10
11
|
this.endpoint = endpoint;
|
|
11
12
|
this.maxChunkSize = maxChunkSize;
|
|
12
13
|
this.httpClient = httpClient;
|
|
@@ -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 () => {
|