@tonappchain/sdk 0.6.1-v3.0.4 → 0.6.1
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 +5 -2
- package/dist/errors/errors.d.ts +8 -1
- package/dist/errors/errors.js +17 -2
- package/dist/errors/instances.d.ts +4 -2
- package/dist/errors/instances.js +6 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -1
- package/dist/sdk/Consts.d.ts +5 -0
- package/dist/sdk/Consts.js +6 -1
- package/dist/sdk/LiteSequencerClient.d.ts +12 -0
- package/dist/sdk/LiteSequencerClient.js +127 -0
- package/dist/sdk/OperationTracker.d.ts +5 -6
- package/dist/sdk/OperationTracker.js +55 -89
- package/dist/sdk/StartTracking.d.ts +7 -0
- package/dist/sdk/StartTracking.js +30 -0
- package/dist/sdk/TacSdk.d.ts +3 -3
- package/dist/sdk/TacSdk.js +68 -40
- package/dist/sdk/Utils.d.ts +2 -1
- package/dist/sdk/Utils.js +17 -1
- package/dist/sender/BatchSender.d.ts +15 -0
- package/dist/sender/BatchSender.js +116 -0
- package/dist/sender/RawSender.d.ts +3 -5
- package/dist/sender/RawSender.js +25 -29
- package/dist/sender/SenderAbstraction.d.ts +3 -3
- package/dist/sender/SenderFactory.js +4 -0
- package/dist/sender/TonConnectSender.d.ts +4 -4
- package/dist/sender/TonConnectSender.js +43 -15
- package/dist/sender/index.d.ts +1 -0
- package/dist/sender/index.js +1 -0
- package/dist/structs/InternalStruct.d.ts +8 -1
- package/dist/structs/Struct.d.ts +8 -5
- package/dist/wrappers/HighloadWalletV3.d.ts +3 -0
- package/dist/wrappers/HighloadWalletV3.js +12 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,11 +155,14 @@ const evmProxyMsg: EvmProxyMsg = {
|
|
|
155
155
|
const assets: AssetBridgingData[] = [
|
|
156
156
|
{
|
|
157
157
|
address: TVMtokenAAddress,
|
|
158
|
-
amount: tokenAAmount
|
|
158
|
+
amount: tokenAAmount,
|
|
159
|
+
type: AssetType.FT,
|
|
160
|
+
|
|
159
161
|
},
|
|
160
162
|
{
|
|
161
163
|
address: TVMtokenBAddress,
|
|
162
|
-
amount: tokenBAmount
|
|
164
|
+
amount: tokenBAmount,
|
|
165
|
+
type: AssetType.FT,
|
|
163
166
|
}
|
|
164
167
|
];
|
|
165
168
|
|
package/dist/errors/errors.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export declare class ContractError extends ErrorWithStatusCode {
|
|
|
6
6
|
constructor(message: string, errorCode: number);
|
|
7
7
|
}
|
|
8
8
|
export declare class FetchError extends ErrorWithStatusCode {
|
|
9
|
-
|
|
9
|
+
readonly inner?: unknown;
|
|
10
|
+
constructor(message: string, errorCode: number, inner?: unknown);
|
|
10
11
|
}
|
|
11
12
|
export declare class AddressError extends ErrorWithStatusCode {
|
|
12
13
|
constructor(message: string, errorCode: number);
|
|
@@ -32,3 +33,9 @@ export declare class SettingError extends ErrorWithStatusCode {
|
|
|
32
33
|
export declare class EVMCallError extends ErrorWithStatusCode {
|
|
33
34
|
constructor(message: string, errorCode: number);
|
|
34
35
|
}
|
|
36
|
+
export declare class PrepareMessageGroupError extends ErrorWithStatusCode {
|
|
37
|
+
constructor(message: string, errorCode: number);
|
|
38
|
+
}
|
|
39
|
+
export declare class NoValidGroupFoundError extends ErrorWithStatusCode {
|
|
40
|
+
constructor(message: string, errorCode: number);
|
|
41
|
+
}
|
package/dist/errors/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVMCallError = exports.SettingError = exports.MetadataError = exports.BitError = exports.FormatError = exports.KeyError = exports.WalletError = exports.AddressError = exports.FetchError = exports.ContractError = exports.ErrorWithStatusCode = void 0;
|
|
3
|
+
exports.NoValidGroupFoundError = exports.PrepareMessageGroupError = exports.EVMCallError = exports.SettingError = exports.MetadataError = exports.BitError = exports.FormatError = exports.KeyError = exports.WalletError = exports.AddressError = exports.FetchError = exports.ContractError = exports.ErrorWithStatusCode = void 0;
|
|
4
4
|
class ErrorWithStatusCode extends Error {
|
|
5
5
|
constructor(message, errorCode) {
|
|
6
6
|
super(message);
|
|
@@ -16,9 +16,10 @@ class ContractError extends ErrorWithStatusCode {
|
|
|
16
16
|
}
|
|
17
17
|
exports.ContractError = ContractError;
|
|
18
18
|
class FetchError extends ErrorWithStatusCode {
|
|
19
|
-
constructor(message, errorCode) {
|
|
19
|
+
constructor(message, errorCode, inner) {
|
|
20
20
|
super(message, errorCode);
|
|
21
21
|
this.name = 'FetchError';
|
|
22
|
+
this.inner = inner;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.FetchError = FetchError;
|
|
@@ -78,3 +79,17 @@ class EVMCallError extends ErrorWithStatusCode {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
exports.EVMCallError = EVMCallError;
|
|
82
|
+
class PrepareMessageGroupError extends ErrorWithStatusCode {
|
|
83
|
+
constructor(message, errorCode) {
|
|
84
|
+
super(message, errorCode);
|
|
85
|
+
this.name = 'PrepareMessageGroupError';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.PrepareMessageGroupError = PrepareMessageGroupError;
|
|
89
|
+
class NoValidGroupFoundError extends ErrorWithStatusCode {
|
|
90
|
+
constructor(message, errorCode) {
|
|
91
|
+
super(message, errorCode);
|
|
92
|
+
this.name = 'NoValidGroupFoundError';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.NoValidGroupFoundError = NoValidGroupFoundError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractError, FetchError, AddressError, WalletError, KeyError, FormatError, BitError, MetadataError, SettingError, EVMCallError } from './errors';
|
|
1
|
+
import { ContractError, FetchError, AddressError, WalletError, KeyError, FormatError, BitError, MetadataError, SettingError, EVMCallError, NoValidGroupFoundError, PrepareMessageGroupError } from './errors';
|
|
2
2
|
export declare const emptyContractError: ContractError;
|
|
3
3
|
export declare const operationFetchError: FetchError;
|
|
4
4
|
export declare const statusFetchError: (msg: string) => FetchError;
|
|
@@ -11,7 +11,9 @@ export declare const notMultiplyOf8Error: BitError;
|
|
|
11
11
|
export declare const prefixError: MetadataError;
|
|
12
12
|
export declare const emptySettingError: (setting: string) => SettingError;
|
|
13
13
|
export declare const invalidMethodNameError: (methodName: string) => EVMCallError;
|
|
14
|
-
export declare const simulationError: FetchError;
|
|
14
|
+
export declare const simulationError: (inner: unknown) => FetchError;
|
|
15
15
|
export declare const profilingFetchError: (msg: string) => FetchError;
|
|
16
16
|
export declare const emptyArrayError: (msg: string) => FetchError;
|
|
17
17
|
export declare const invalidAssetType: FormatError;
|
|
18
|
+
export declare const prepareMessageGroupError: (isBocSizeValid: boolean, isDepthValid: boolean) => PrepareMessageGroupError;
|
|
19
|
+
export declare const noValidGroupFoundError: NoValidGroupFoundError;
|
package/dist/errors/instances.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.simulationError = 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.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.simulationError = 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
|
exports.operationFetchError = new errors_1.FetchError('failed to fetch OperationId', 101);
|
|
@@ -21,9 +21,13 @@ const emptySettingError = (setting) => new errors_1.SettingError(`unexpected emp
|
|
|
21
21
|
exports.emptySettingError = emptySettingError;
|
|
22
22
|
const invalidMethodNameError = (methodName) => new errors_1.EVMCallError(`Invalid Solidity method name: "${methodName}". Method must be either a valid identifier or have parameters (bytes,bytes).`, 111);
|
|
23
23
|
exports.invalidMethodNameError = invalidMethodNameError;
|
|
24
|
-
|
|
24
|
+
const simulationError = (inner) => new errors_1.FetchError(`Failed to simulate EVM call: ${inner}`, 112, inner);
|
|
25
|
+
exports.simulationError = simulationError;
|
|
25
26
|
const profilingFetchError = (msg) => new errors_1.FetchError(`failed to fetch stage profiling: ${msg}`, 113);
|
|
26
27
|
exports.profilingFetchError = profilingFetchError;
|
|
27
28
|
const emptyArrayError = (msg) => new errors_1.FetchError(`empty array: ${msg}`, 114);
|
|
28
29
|
exports.emptyArrayError = emptyArrayError;
|
|
29
30
|
exports.invalidAssetType = new errors_1.FormatError('Invalid asset type', 115);
|
|
31
|
+
const prepareMessageGroupError = (isBocSizeValid, isDepthValid) => new errors_1.PrepareMessageGroupError(`Failed to prepare message group: BOC size valid: ${isBocSizeValid}, depth valid: ${isDepthValid}`, 116);
|
|
32
|
+
exports.prepareMessageGroupError = prepareMessageGroupError;
|
|
33
|
+
exports.noValidGroupFoundError = new errors_1.NoValidGroupFoundError('Failed to prepare valid message group', 117);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export { TacSdk } from './sdk/TacSdk';
|
|
2
2
|
export { OperationTracker } from './sdk/OperationTracker';
|
|
3
|
-
export { startTracking } from './sdk/StartTracking';
|
|
3
|
+
export { startTracking, startTrackingMultiple } from './sdk/StartTracking';
|
|
4
4
|
export * from './sender';
|
|
5
5
|
export * from './structs/Struct';
|
|
6
6
|
export { Network, SimplifiedStatuses } from './structs/Struct';
|
|
7
7
|
export type { JettonWalletData } from './wrappers/JettonWallet';
|
|
8
8
|
export { JettonWallet, JettonWalletOpCodes } from './wrappers/JettonWallet';
|
|
9
|
+
export { HighloadWalletV3 } from './wrappers/HighloadWalletV3';
|
|
9
10
|
export { orbsOpener, liteClientOpener } from './adapters/contractOpener';
|
|
10
11
|
export * from './errors';
|
|
12
|
+
export { readJettonMetadata } from './wrappers/ContentUtils';
|
|
13
|
+
export { LiteSequencerClient } from './sdk/LiteSequencerClient';
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.liteClientOpener = exports.orbsOpener = exports.JettonWalletOpCodes = exports.JettonWallet = exports.SimplifiedStatuses = exports.Network = exports.startTracking = exports.OperationTracker = exports.TacSdk = void 0;
|
|
17
|
+
exports.LiteSequencerClient = exports.readJettonMetadata = exports.liteClientOpener = exports.orbsOpener = exports.HighloadWalletV3 = exports.JettonWalletOpCodes = exports.JettonWallet = exports.SimplifiedStatuses = exports.Network = exports.startTrackingMultiple = exports.startTracking = exports.OperationTracker = exports.TacSdk = void 0;
|
|
18
18
|
var TacSdk_1 = require("./sdk/TacSdk");
|
|
19
19
|
Object.defineProperty(exports, "TacSdk", { enumerable: true, get: function () { return TacSdk_1.TacSdk; } });
|
|
20
20
|
var OperationTracker_1 = require("./sdk/OperationTracker");
|
|
21
21
|
Object.defineProperty(exports, "OperationTracker", { enumerable: true, get: function () { return OperationTracker_1.OperationTracker; } });
|
|
22
22
|
var StartTracking_1 = require("./sdk/StartTracking");
|
|
23
23
|
Object.defineProperty(exports, "startTracking", { enumerable: true, get: function () { return StartTracking_1.startTracking; } });
|
|
24
|
+
Object.defineProperty(exports, "startTrackingMultiple", { enumerable: true, get: function () { return StartTracking_1.startTrackingMultiple; } });
|
|
24
25
|
__exportStar(require("./sender"), exports);
|
|
25
26
|
__exportStar(require("./structs/Struct"), exports);
|
|
26
27
|
var Struct_1 = require("./structs/Struct");
|
|
@@ -29,7 +30,13 @@ Object.defineProperty(exports, "SimplifiedStatuses", { enumerable: true, get: fu
|
|
|
29
30
|
var JettonWallet_1 = require("./wrappers/JettonWallet");
|
|
30
31
|
Object.defineProperty(exports, "JettonWallet", { enumerable: true, get: function () { return JettonWallet_1.JettonWallet; } });
|
|
31
32
|
Object.defineProperty(exports, "JettonWalletOpCodes", { enumerable: true, get: function () { return JettonWallet_1.JettonWalletOpCodes; } });
|
|
33
|
+
var HighloadWalletV3_1 = require("./wrappers/HighloadWalletV3");
|
|
34
|
+
Object.defineProperty(exports, "HighloadWalletV3", { enumerable: true, get: function () { return HighloadWalletV3_1.HighloadWalletV3; } });
|
|
32
35
|
var contractOpener_1 = require("./adapters/contractOpener");
|
|
33
36
|
Object.defineProperty(exports, "orbsOpener", { enumerable: true, get: function () { return contractOpener_1.orbsOpener; } });
|
|
34
37
|
Object.defineProperty(exports, "liteClientOpener", { enumerable: true, get: function () { return contractOpener_1.liteClientOpener; } });
|
|
35
38
|
__exportStar(require("./errors"), exports);
|
|
39
|
+
var ContentUtils_1 = require("./wrappers/ContentUtils");
|
|
40
|
+
Object.defineProperty(exports, "readJettonMetadata", { enumerable: true, get: function () { return ContentUtils_1.readJettonMetadata; } });
|
|
41
|
+
var LiteSequencerClient_1 = require("./sdk/LiteSequencerClient");
|
|
42
|
+
Object.defineProperty(exports, "LiteSequencerClient", { enumerable: true, get: function () { return LiteSequencerClient_1.LiteSequencerClient; } });
|
package/dist/sdk/Consts.d.ts
CHANGED
|
@@ -5,3 +5,8 @@ export declare const MAX_ITERATION_COUNT = 120;
|
|
|
5
5
|
export declare const DEFAULT_DELAY = 0;
|
|
6
6
|
export declare const SOLIDITY_SIGNATURE_REGEX: RegExp;
|
|
7
7
|
export declare const SOLIDITY_METHOD_NAME_REGEX: RegExp;
|
|
8
|
+
export declare const MAX_EXT_MSG_SIZE = 65535;
|
|
9
|
+
export declare const MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
|
|
10
|
+
export declare const MAX_MSG_DEPTH = 512;
|
|
11
|
+
export declare const TON_SYMBOL = "TON";
|
|
12
|
+
export declare const TAC_SYMBOL = "TAC";
|
package/dist/sdk/Consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = exports.TRANSACTION_TON_AMOUNT = void 0;
|
|
3
|
+
exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = exports.TRANSACTION_TON_AMOUNT = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.55);
|
|
6
6
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
@@ -9,3 +9,8 @@ exports.MAX_ITERATION_COUNT = 120;
|
|
|
9
9
|
exports.DEFAULT_DELAY = 0;
|
|
10
10
|
exports.SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
|
|
11
11
|
exports.SOLIDITY_METHOD_NAME_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
12
|
+
exports.MAX_EXT_MSG_SIZE = 65535;
|
|
13
|
+
exports.MAX_HIGHLOAD_GROUP_MSG_NUM = 254;
|
|
14
|
+
exports.MAX_MSG_DEPTH = 512;
|
|
15
|
+
exports.TON_SYMBOL = "TON";
|
|
16
|
+
exports.TAC_SYMBOL = "TAC";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TransactionLinker, StatusInfosByOperationId, OperationIdsByShardsKey, ExecutionStagesByOperationId, OperationType } from '../structs/Struct';
|
|
2
|
+
export declare class LiteSequencerClient {
|
|
3
|
+
private readonly endpoint;
|
|
4
|
+
private readonly maxChunkSize;
|
|
5
|
+
constructor(endpoint: string, maxChunkSize?: number);
|
|
6
|
+
getOperationType(operationId: string): Promise<OperationType>;
|
|
7
|
+
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
8
|
+
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
9
|
+
getStageProfilings(operationIds: string[], chunkSize?: number): Promise<ExecutionStagesByOperationId>;
|
|
10
|
+
getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
|
|
11
|
+
private processChunkedRequest;
|
|
12
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LiteSequencerClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
const Utils_1 = require("./Utils");
|
|
10
|
+
class LiteSequencerClient {
|
|
11
|
+
constructor(endpoint, maxChunkSize = 100) {
|
|
12
|
+
this.endpoint = endpoint;
|
|
13
|
+
this.maxChunkSize = maxChunkSize;
|
|
14
|
+
}
|
|
15
|
+
async getOperationType(operationId) {
|
|
16
|
+
try {
|
|
17
|
+
const response = await axios_1.default.get(new URL('operation-type', this.endpoint).toString(), {
|
|
18
|
+
params: {
|
|
19
|
+
operationId,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return response.data.response || '';
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error(`Failed to get operationType with ${this.endpoint}:`, error);
|
|
26
|
+
throw errors_1.operationFetchError;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async getOperationId(transactionLinker) {
|
|
30
|
+
const requestBody = {
|
|
31
|
+
shardsKey: transactionLinker.shardsKey,
|
|
32
|
+
caller: transactionLinker.caller,
|
|
33
|
+
shardCount: transactionLinker.shardCount,
|
|
34
|
+
timestamp: transactionLinker.timestamp,
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const response = await axios_1.default.post(new URL('ton/operation-id', this.endpoint).toString(), requestBody);
|
|
38
|
+
return response.data.response || '';
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
42
|
+
if (error.response?.status === 404) {
|
|
43
|
+
console.warn(`404 Not Found: ${new URL('ton/operation-id', this.endpoint).toString()}`);
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.error(`Failed to get OperationId with ${this.endpoint}:`, error);
|
|
48
|
+
throw errors_1.operationFetchError;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async getOperationIdsByShardsKeys(shardsKeys, caller, chunkSize = this.maxChunkSize) {
|
|
52
|
+
if (!shardsKeys || shardsKeys.length === 0) {
|
|
53
|
+
throw (0, errors_1.emptyArrayError)('shardsKeys');
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const response = await this.processChunkedRequest(shardsKeys, async (chunk) => {
|
|
57
|
+
const response = await axios_1.default.post(new URL('operation-ids-by-shards-keys', this.endpoint).toString(), {
|
|
58
|
+
shardsKeys: chunk,
|
|
59
|
+
caller: caller,
|
|
60
|
+
});
|
|
61
|
+
return response.data;
|
|
62
|
+
}, chunkSize);
|
|
63
|
+
return response.response;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error(`Failed to get OperationIds with ${this.endpoint}:`, error);
|
|
67
|
+
throw errors_1.operationFetchError;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getStageProfilings(operationIds, chunkSize = this.maxChunkSize) {
|
|
71
|
+
if (!operationIds || operationIds.length === 0) {
|
|
72
|
+
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const response = await this.processChunkedRequest(operationIds, async (chunk) => {
|
|
76
|
+
const response = await axios_1.default.post(new URL('stage-profiling', this.endpoint).toString(), {
|
|
77
|
+
operationIds: chunk,
|
|
78
|
+
}, {
|
|
79
|
+
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
80
|
+
});
|
|
81
|
+
return response.data;
|
|
82
|
+
}, chunkSize);
|
|
83
|
+
return response.response;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error(`Error fetching stage profiling with ${this.endpoint}:`, error);
|
|
87
|
+
throw (0, errors_1.profilingFetchError)('endpoint failed to complete request');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async getOperationStatuses(operationIds, chunkSize = this.maxChunkSize) {
|
|
91
|
+
if (!operationIds || operationIds.length === 0) {
|
|
92
|
+
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const response = await this.processChunkedRequest(operationIds, async (chunk) => {
|
|
96
|
+
const response = await axios_1.default.post(new URL('status', this.endpoint).toString(), {
|
|
97
|
+
operationIds: chunk,
|
|
98
|
+
}, {
|
|
99
|
+
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
100
|
+
});
|
|
101
|
+
return response.data;
|
|
102
|
+
}, chunkSize);
|
|
103
|
+
return response.response;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.error(`Error fetching status transaction with ${this.endpoint}:`, error);
|
|
107
|
+
throw (0, errors_1.statusFetchError)('endpoint failed to complete request');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async processChunkedRequest(identificators, requestFn, chunkSize = this.maxChunkSize) {
|
|
111
|
+
const results = [];
|
|
112
|
+
for (let i = 0; i < identificators.length; i += chunkSize) {
|
|
113
|
+
const chunk = identificators.slice(i, i + chunkSize);
|
|
114
|
+
const result = await requestFn(chunk);
|
|
115
|
+
results.push(result);
|
|
116
|
+
}
|
|
117
|
+
// Combine results based on the type
|
|
118
|
+
if (Array.isArray(results[0])) {
|
|
119
|
+
return results.flat();
|
|
120
|
+
}
|
|
121
|
+
else if (typeof results[0] === 'object') {
|
|
122
|
+
return Object.assign({}, ...results);
|
|
123
|
+
}
|
|
124
|
+
return results[0];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.LiteSequencerClient = LiteSequencerClient;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Network, TransactionLinker, SimplifiedStatuses,
|
|
1
|
+
import { Network, TransactionLinker, SimplifiedStatuses, OperationType, OperationIdsByShardsKey, ExecutionStages, ExecutionStagesByOperationId, StatusInfosByOperationId, StatusInfo } from '../structs/Struct';
|
|
2
2
|
export declare class OperationTracker {
|
|
3
|
-
readonly
|
|
4
|
-
readonly customLiteSequencerEndpoints: string[];
|
|
3
|
+
private readonly clients;
|
|
5
4
|
constructor(network: Network, customLiteSequencerEndpoints?: string[]);
|
|
6
5
|
getOperationType(operationId: string): Promise<OperationType>;
|
|
7
6
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
8
|
-
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string): Promise<OperationIdsByShardsKey>;
|
|
7
|
+
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
9
8
|
getStageProfiling(operationId: string): Promise<ExecutionStages>;
|
|
10
|
-
getStageProfilings(operationIds: string[]): Promise<ExecutionStagesByOperationId>;
|
|
11
|
-
getOperationStatuses(operationIds: string[]): Promise<StatusInfosByOperationId>;
|
|
9
|
+
getStageProfilings(operationIds: string[], chunkSize?: number): Promise<ExecutionStagesByOperationId>;
|
|
10
|
+
getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
|
|
12
11
|
getOperationStatus(operationId: string): Promise<StatusInfo>;
|
|
13
12
|
getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
|
|
14
13
|
}
|
|
@@ -1,137 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.OperationTracker = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
4
|
const Struct_1 = require("../structs/Struct");
|
|
9
|
-
const errors_1 = require("../errors");
|
|
10
|
-
const Utils_1 = require("./Utils");
|
|
11
5
|
const artifacts_1 = require("@tonappchain/artifacts");
|
|
6
|
+
const LiteSequencerClient_1 = require("./LiteSequencerClient");
|
|
12
7
|
class OperationTracker {
|
|
13
8
|
constructor(network, customLiteSequencerEndpoints) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
9
|
+
const endpoints = customLiteSequencerEndpoints ??
|
|
10
|
+
(network === Struct_1.Network.TESTNET
|
|
11
|
+
? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
|
|
12
|
+
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
13
|
+
this.clients = endpoints.map((endpoint) => new LiteSequencerClient_1.LiteSequencerClient(endpoint));
|
|
20
14
|
}
|
|
21
15
|
async getOperationType(operationId) {
|
|
22
|
-
for (const
|
|
16
|
+
for (const client of this.clients) {
|
|
23
17
|
try {
|
|
24
|
-
|
|
25
|
-
params: {
|
|
26
|
-
operationId,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return response.data.response || '';
|
|
18
|
+
return await client.getOperationType(operationId);
|
|
30
19
|
}
|
|
31
20
|
catch (error) {
|
|
32
|
-
console.error(
|
|
21
|
+
console.error('Failed to get operationType:', error);
|
|
33
22
|
}
|
|
34
23
|
}
|
|
35
|
-
throw
|
|
24
|
+
throw new Error('All endpoints failed to get operation type');
|
|
36
25
|
}
|
|
37
26
|
async getOperationId(transactionLinker) {
|
|
38
|
-
const
|
|
39
|
-
shardsKey: transactionLinker.shardsKey,
|
|
40
|
-
caller: transactionLinker.caller,
|
|
41
|
-
shardCount: transactionLinker.shardCount,
|
|
42
|
-
timestamp: transactionLinker.timestamp,
|
|
43
|
-
};
|
|
44
|
-
let operationId = undefined;
|
|
45
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
27
|
+
for (const client of this.clients) {
|
|
46
28
|
try {
|
|
47
|
-
|
|
48
|
-
return response.data.response || '';
|
|
29
|
+
return await client.getOperationId(transactionLinker);
|
|
49
30
|
}
|
|
50
31
|
catch (error) {
|
|
51
|
-
|
|
52
|
-
if (error.response?.status === 404) {
|
|
53
|
-
console.warn(`404 Not Found: ${endpoint}/ton/operation-id`);
|
|
54
|
-
operationId = '';
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
console.error(`Failed to get OperationId with ${endpoint}:`, error);
|
|
32
|
+
console.error('Failed to get OperationId:', error);
|
|
59
33
|
}
|
|
60
34
|
}
|
|
61
|
-
|
|
62
|
-
return operationId;
|
|
63
|
-
}
|
|
64
|
-
throw errors_1.operationFetchError;
|
|
35
|
+
throw new Error('All endpoints failed to get operation id');
|
|
65
36
|
}
|
|
66
|
-
async getOperationIdsByShardsKeys(shardsKeys, caller) {
|
|
67
|
-
const
|
|
68
|
-
shardsKeys: shardsKeys,
|
|
69
|
-
caller: caller,
|
|
70
|
-
};
|
|
71
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
37
|
+
async getOperationIdsByShardsKeys(shardsKeys, caller, chunkSize = 100) {
|
|
38
|
+
for (const client of this.clients) {
|
|
72
39
|
try {
|
|
73
|
-
|
|
74
|
-
return response.data.response;
|
|
40
|
+
return await client.getOperationIdsByShardsKeys(shardsKeys, caller, chunkSize);
|
|
75
41
|
}
|
|
76
42
|
catch (error) {
|
|
77
|
-
console.error(
|
|
43
|
+
console.error('Failed to get OperationIds:', error);
|
|
78
44
|
}
|
|
79
45
|
}
|
|
80
|
-
throw
|
|
46
|
+
throw new Error('All endpoints failed to get operation ids by shards keys');
|
|
81
47
|
}
|
|
82
48
|
async getStageProfiling(operationId) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
49
|
+
for (const client of this.clients) {
|
|
50
|
+
try {
|
|
51
|
+
const map = await client.getStageProfilings([operationId]);
|
|
52
|
+
const result = map[operationId];
|
|
53
|
+
if (!result) {
|
|
54
|
+
throw new Error(`No stageProfiling data for operationId=${operationId}`);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error('Failed to get stage profiling:', error);
|
|
60
|
+
}
|
|
87
61
|
}
|
|
88
|
-
|
|
62
|
+
throw new Error('All endpoints failed to get stage profiling');
|
|
89
63
|
}
|
|
90
|
-
async getStageProfilings(operationIds) {
|
|
91
|
-
|
|
92
|
-
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
93
|
-
}
|
|
94
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
64
|
+
async getStageProfilings(operationIds, chunkSize = 100) {
|
|
65
|
+
for (const client of this.clients) {
|
|
95
66
|
try {
|
|
96
|
-
|
|
97
|
-
operationIds,
|
|
98
|
-
}, {
|
|
99
|
-
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
100
|
-
});
|
|
101
|
-
return response.data.response;
|
|
67
|
+
return await client.getStageProfilings(operationIds, chunkSize);
|
|
102
68
|
}
|
|
103
69
|
catch (error) {
|
|
104
|
-
console.error(
|
|
70
|
+
console.error('Failed to get stage profilings:', error);
|
|
105
71
|
}
|
|
106
72
|
}
|
|
107
|
-
throw
|
|
73
|
+
throw new Error('All endpoints failed to get stage profilings');
|
|
108
74
|
}
|
|
109
|
-
async getOperationStatuses(operationIds) {
|
|
110
|
-
|
|
111
|
-
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
112
|
-
}
|
|
113
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
75
|
+
async getOperationStatuses(operationIds, chunkSize = 100) {
|
|
76
|
+
for (const client of this.clients) {
|
|
114
77
|
try {
|
|
115
|
-
|
|
116
|
-
operationIds,
|
|
117
|
-
}, {
|
|
118
|
-
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
119
|
-
});
|
|
120
|
-
return response.data.response;
|
|
78
|
+
return await client.getOperationStatuses(operationIds, chunkSize);
|
|
121
79
|
}
|
|
122
80
|
catch (error) {
|
|
123
|
-
console.error(
|
|
81
|
+
console.error('Failed to get operation statuses:', error);
|
|
124
82
|
}
|
|
125
83
|
}
|
|
126
|
-
throw
|
|
84
|
+
throw new Error('All endpoints failed to get operation statuses');
|
|
127
85
|
}
|
|
128
86
|
async getOperationStatus(operationId) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
87
|
+
for (const client of this.clients) {
|
|
88
|
+
try {
|
|
89
|
+
const map = await client.getOperationStatuses([operationId]);
|
|
90
|
+
const result = map[operationId];
|
|
91
|
+
if (!result) {
|
|
92
|
+
throw new Error(`No operation status for operationId=${operationId}`);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('Failed to get operation status:', error);
|
|
98
|
+
}
|
|
133
99
|
}
|
|
134
|
-
|
|
100
|
+
throw new Error('All endpoints failed to get operation status');
|
|
135
101
|
}
|
|
136
102
|
async getSimplifiedOperationStatus(transactionLinker) {
|
|
137
103
|
const operationId = await this.getOperationId(transactionLinker);
|
|
@@ -6,3 +6,10 @@ export declare function startTracking(transactionLinker: TransactionLinker, netw
|
|
|
6
6
|
returnValue?: boolean;
|
|
7
7
|
tableView?: boolean;
|
|
8
8
|
}): Promise<void | ExecutionStages>;
|
|
9
|
+
export declare function startTrackingMultiple(transactionLinkers: TransactionLinker[], network: Network, options?: {
|
|
10
|
+
customLiteSequencerEndpoints?: string[];
|
|
11
|
+
delay?: number;
|
|
12
|
+
maxIterationCount?: number;
|
|
13
|
+
returnValue?: boolean;
|
|
14
|
+
tableView?: boolean;
|
|
15
|
+
}): Promise<void | ExecutionStages[]>;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.startTracking = startTracking;
|
|
7
|
+
exports.startTrackingMultiple = startTrackingMultiple;
|
|
7
8
|
const Struct_1 = require("../structs/Struct");
|
|
8
9
|
const Consts_1 = require("./Consts");
|
|
9
10
|
const OperationTracker_1 = require("./OperationTracker");
|
|
@@ -74,6 +75,35 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
74
75
|
console.log(formatExecutionStages(profilingData));
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
79
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, } = options || {};
|
|
80
|
+
console.log(`Start tracking ${transactionLinkers.length} operations`);
|
|
81
|
+
const results = await Promise.all(transactionLinkers.map((linker, index) => {
|
|
82
|
+
console.log(`\nProcessing operation ${index + 1}/${transactionLinkers.length}`);
|
|
83
|
+
return startTracking(linker, network, {
|
|
84
|
+
customLiteSequencerEndpoints,
|
|
85
|
+
delay,
|
|
86
|
+
maxIterationCount,
|
|
87
|
+
returnValue: true,
|
|
88
|
+
tableView: false,
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
if (returnValue) {
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
if (tableView) {
|
|
95
|
+
results.forEach((result, index) => {
|
|
96
|
+
console.log(`\nResults for operation ${index + 1}:`);
|
|
97
|
+
printExecutionStagesTable(result);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
results.forEach((result, index) => {
|
|
102
|
+
console.log(`\nResults for operation ${index + 1}:`);
|
|
103
|
+
console.log(formatExecutionStages(result));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
77
107
|
function formatExecutionStages(stages) {
|
|
78
108
|
const { operationType, metaInfo, ...stagesData } = stages;
|
|
79
109
|
return Object.entries(stagesData).map(([stage, data]) => ({
|
package/dist/sdk/TacSdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, RawAssetBridgingData, UserWalletBalanceExtended, TACSimulationResult, TACSimulationRequest, CrossChainTransactionOptions, ExecutionFeeEstimationResult, CrosschainTx,
|
|
3
|
+
import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, RawAssetBridgingData, UserWalletBalanceExtended, TACSimulationResult, TACSimulationRequest, SuggestedTONExecutorFee, CrossChainTransactionOptions, ExecutionFeeEstimationResult, CrosschainTx, WithAddressNFTCollectionItem, NFTAddressType, NFTItemData } from '../structs/Struct';
|
|
4
4
|
import { InternalTONParams, InternalTACParams } from '../structs/InternalStruct';
|
|
5
5
|
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
6
6
|
export declare class TacSdk {
|
|
@@ -24,7 +24,6 @@ export declare class TacSdk {
|
|
|
24
24
|
private getJettonBurnPayload;
|
|
25
25
|
private getNFTBurnPayload;
|
|
26
26
|
private getNFTTransferPayload;
|
|
27
|
-
private generateFeeData;
|
|
28
27
|
private getTonTransferPayload;
|
|
29
28
|
private getJettonOpType;
|
|
30
29
|
private getNFTOpType;
|
|
@@ -38,10 +37,11 @@ export declare class TacSdk {
|
|
|
38
37
|
private convertAssetsToRawFormat;
|
|
39
38
|
private getFeeInfo;
|
|
40
39
|
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[]): Promise<ExecutionFeeEstimationResult>;
|
|
40
|
+
getTVMExecutorFeeInfo(assets: AssetBridgingData[], feeSymbol: String): Promise<SuggestedTONExecutorFee>;
|
|
41
41
|
private prepareCrossChainTransaction;
|
|
42
42
|
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], options?: CrossChainTransactionOptions): Promise<TransactionLinker>;
|
|
43
43
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TransactionLinker[]>;
|
|
44
|
-
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: RawAssetBridgingData<
|
|
44
|
+
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: RawAssetBridgingData<WithAddressNFTCollectionItem>[], tvmExecutorFee?: bigint): Promise<string>;
|
|
45
45
|
get getTrustedTACExecutors(): string[];
|
|
46
46
|
get getTrustedTONExecutors(): string[];
|
|
47
47
|
getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
|