@tonappchain/sdk 0.6.5-mainnet-alpha → 0.7.0-rc7
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/dist/adapters/contractOpener.d.ts +1 -1
- package/dist/adapters/contractOpener.js +7 -8
- package/dist/adapters/retryableContractOpener.d.ts +21 -0
- package/dist/adapters/retryableContractOpener.js +101 -0
- package/dist/assets/AssetCache.d.ts +23 -0
- package/dist/assets/AssetCache.js +36 -0
- package/dist/assets/AssetFactory.d.ts +19 -0
- package/dist/assets/AssetFactory.js +45 -0
- package/dist/assets/FT.d.ts +55 -0
- package/dist/assets/FT.js +206 -0
- package/dist/assets/NFT.d.ts +69 -0
- package/dist/assets/NFT.js +200 -0
- package/dist/assets/TON.d.ts +38 -0
- package/dist/assets/TON.js +91 -0
- package/dist/assets/index.d.ts +4 -0
- package/dist/assets/index.js +11 -0
- package/dist/errors/errors.d.ts +6 -0
- package/dist/errors/errors.js +15 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +26 -21
- package/dist/errors/instances.d.ts +9 -4
- package/dist/errors/instances.js +19 -5
- package/dist/index.d.ts +12 -6
- package/dist/index.js +24 -13
- package/dist/sdk/Configuration.d.ts +21 -0
- package/dist/sdk/Configuration.js +90 -0
- package/dist/sdk/LiteSequencerClient.d.ts +1 -1
- package/dist/sdk/LiteSequencerClient.js +5 -11
- package/dist/sdk/Logger.d.ts +13 -0
- package/dist/sdk/Logger.js +25 -0
- package/dist/sdk/OperationTracker.d.ts +21 -6
- package/dist/sdk/OperationTracker.js +155 -75
- package/dist/sdk/Simulator.d.ts +23 -0
- package/dist/sdk/Simulator.js +169 -0
- package/dist/sdk/StartTracking.d.ts +6 -0
- package/dist/sdk/StartTracking.js +66 -29
- package/dist/sdk/TacSdk.d.ts +12 -41
- package/dist/sdk/TacSdk.js +69 -712
- package/dist/sdk/TransactionManager.d.ts +22 -0
- package/dist/sdk/TransactionManager.js +264 -0
- package/dist/sdk/TxFinalizer.d.ts +10 -0
- package/dist/sdk/TxFinalizer.js +104 -0
- package/dist/sdk/Utils.d.ts +12 -4
- package/dist/sdk/Utils.js +80 -16
- package/dist/sdk/Validator.d.ts +9 -0
- package/dist/sdk/Validator.js +43 -0
- package/dist/sender/BatchSender.d.ts +7 -4
- package/dist/sender/BatchSender.js +18 -6
- package/dist/sender/RawSender.d.ts +9 -4
- package/dist/sender/RawSender.js +46 -18
- package/dist/sender/SenderAbstraction.d.ts +5 -3
- package/dist/sender/SenderFactory.d.ts +1 -1
- package/dist/sender/SenderFactory.js +5 -4
- package/dist/sender/TonConnectSender.d.ts +5 -3
- package/dist/sender/TonConnectSender.js +12 -8
- package/dist/sender/index.d.ts +1 -1
- package/dist/sender/index.js +1 -1
- package/dist/structs/InternalStruct.d.ts +36 -33
- package/dist/structs/Services.d.ts +40 -0
- package/dist/structs/Services.js +2 -0
- package/dist/structs/Struct.d.ts +100 -79
- package/dist/structs/Struct.js +11 -1
- package/dist/wrappers/HighloadQueryId.js +0 -1
- package/dist/wrappers/HighloadWalletV3.d.ts +3 -2
- package/dist/wrappers/HighloadWalletV3.js +5 -2
- package/dist/wrappers/JettonWallet.d.ts +11 -2
- package/dist/wrappers/JettonWallet.js +33 -16
- package/package.json +2 -2
|
@@ -0,0 +1,169 @@
|
|
|
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.Simulator = exports.AxiosHttpClient = void 0;
|
|
7
|
+
const ton_1 = require("@ton/ton");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
const Logger_1 = require("./Logger");
|
|
11
|
+
const Utils_1 = require("./Utils");
|
|
12
|
+
const Validator_1 = require("./Validator");
|
|
13
|
+
class AxiosHttpClient {
|
|
14
|
+
async post(url, data, config) {
|
|
15
|
+
return axios_1.default.post(url, data, config);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AxiosHttpClient = AxiosHttpClient;
|
|
19
|
+
class Simulator {
|
|
20
|
+
constructor(config, logger = new Logger_1.NoopLogger(), httpClient = new AxiosHttpClient()) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
this.logger = logger;
|
|
23
|
+
this.httpClient = httpClient;
|
|
24
|
+
}
|
|
25
|
+
async simulateTACMessage(req) {
|
|
26
|
+
Validator_1.Validator.validateTACSimulationRequest(req);
|
|
27
|
+
this.logger.debug('Simulating TAC message');
|
|
28
|
+
let lastError;
|
|
29
|
+
for (const endpoint of this.config.liteSequencerEndpoints) {
|
|
30
|
+
try {
|
|
31
|
+
const response = await this.httpClient.post(new URL('tac/simulator/simulate-message', endpoint).toString(), req, {
|
|
32
|
+
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
33
|
+
});
|
|
34
|
+
this.logger.debug('TAC message simulation success');
|
|
35
|
+
return response.data.response;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
this.logger.error(`Error while simulating with ${endpoint}: ${error}`);
|
|
39
|
+
lastError = error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw (0, errors_1.simulationError)(lastError);
|
|
43
|
+
}
|
|
44
|
+
async simulateTransactions(sender, txs) {
|
|
45
|
+
this.logger.debug(`Simulating ${txs.length} TAC messages`);
|
|
46
|
+
const results = [];
|
|
47
|
+
for (const tx of txs) {
|
|
48
|
+
const req = await this.buildTACSimulationRequest(sender, tx);
|
|
49
|
+
const result = await this.simulateTACMessage(req);
|
|
50
|
+
results.push(result);
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
}
|
|
54
|
+
async buildTACSimulationRequest(sender, tx) {
|
|
55
|
+
const { evmProxyMsg, assets = [], options = {} } = tx;
|
|
56
|
+
const { evmValidExecutors = this.config.TACParams.trustedTACExecutors, tvmValidExecutors = this.config.TACParams.trustedTONExecutors, } = options;
|
|
57
|
+
Validator_1.Validator.validateEVMAddresses(evmValidExecutors);
|
|
58
|
+
Validator_1.Validator.validateTVMAddresses(tvmValidExecutors);
|
|
59
|
+
const aggregatedData = await (0, Utils_1.aggregateTokens)(assets);
|
|
60
|
+
const transactionLinkerShardCount = aggregatedData.jettons.length == 0 ? 1 : aggregatedData.jettons.length;
|
|
61
|
+
const transactionLinker = (0, Utils_1.generateTransactionLinker)(sender.getSenderAddress(), transactionLinkerShardCount);
|
|
62
|
+
return {
|
|
63
|
+
tacCallParams: {
|
|
64
|
+
arguments: evmProxyMsg.encodedParameters ?? '0x',
|
|
65
|
+
methodName: (0, Utils_1.formatSolidityMethodName)(evmProxyMsg.methodName),
|
|
66
|
+
target: evmProxyMsg.evmTargetAddress,
|
|
67
|
+
},
|
|
68
|
+
evmValidExecutors: evmValidExecutors,
|
|
69
|
+
tvmValidExecutors: tvmValidExecutors,
|
|
70
|
+
extraData: '0x',
|
|
71
|
+
shardsKey: transactionLinker.shardsKey,
|
|
72
|
+
tonAssets: assets.map((asset) => ({
|
|
73
|
+
amount: asset.rawAmount.toString(),
|
|
74
|
+
tokenAddress: asset.address || '',
|
|
75
|
+
assetType: asset.type,
|
|
76
|
+
})),
|
|
77
|
+
tonCaller: transactionLinker.caller,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async getTVMExecutorFeeInfo(assets, feeSymbol) {
|
|
81
|
+
this.logger.debug('Getting TVM executor fee info');
|
|
82
|
+
const requestBody = {
|
|
83
|
+
tonAssets: assets.map((asset) => ({
|
|
84
|
+
amount: asset.rawAmount.toString(),
|
|
85
|
+
tokenAddress: asset.address || '',
|
|
86
|
+
assetType: asset.type,
|
|
87
|
+
})),
|
|
88
|
+
feeSymbol: feeSymbol,
|
|
89
|
+
};
|
|
90
|
+
let lastError;
|
|
91
|
+
for (const endpoint of this.config.liteSequencerEndpoints) {
|
|
92
|
+
try {
|
|
93
|
+
const response = await this.httpClient.post(`${endpoint}/ton/calculator/ton-executor-fee`, requestBody);
|
|
94
|
+
return response.data.response;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.logger.error(`Error while calculating tvm executor fee ${endpoint}: ${error}`);
|
|
98
|
+
lastError = error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.logger.error('Error while calculating tvm executor fee on all endpoints');
|
|
102
|
+
throw (0, errors_1.simulationError)(lastError);
|
|
103
|
+
}
|
|
104
|
+
async getFeeInfo(evmProxyMsg, transactionLinker, assets, allowSimulationError = false, isRoundTrip = true, evmValidExecutors = this.config.TACParams.trustedTACExecutors, tvmValidExecutors = this.config.TACParams.trustedTONExecutors) {
|
|
105
|
+
this.logger.debug('Getting fee info');
|
|
106
|
+
Validator_1.Validator.validateEVMAddress(evmProxyMsg.evmTargetAddress);
|
|
107
|
+
Validator_1.Validator.validateEVMAddresses(evmValidExecutors);
|
|
108
|
+
Validator_1.Validator.validateTVMAddresses(tvmValidExecutors);
|
|
109
|
+
const crossChainLayer = this.config.TONParams.contractOpener.open(this.config.artifacts.ton.wrappers.CrossChainLayer.createFromAddress(ton_1.Address.parse(this.config.TONParams.crossChainLayerAddress)));
|
|
110
|
+
const fullStateCCL = await crossChainLayer.getFullData();
|
|
111
|
+
this.logger.debug(`Full state CCL: ${(0, Utils_1.formatObjectForLogging)(fullStateCCL)}`);
|
|
112
|
+
const tacSimulationBody = {
|
|
113
|
+
tacCallParams: {
|
|
114
|
+
arguments: evmProxyMsg.encodedParameters ?? '0x',
|
|
115
|
+
methodName: (0, Utils_1.formatSolidityMethodName)(evmProxyMsg.methodName),
|
|
116
|
+
target: evmProxyMsg.evmTargetAddress,
|
|
117
|
+
},
|
|
118
|
+
evmValidExecutors: evmValidExecutors,
|
|
119
|
+
tvmValidExecutors: tvmValidExecutors,
|
|
120
|
+
extraData: '0x',
|
|
121
|
+
shardsKey: transactionLinker.shardsKey,
|
|
122
|
+
tonAssets: assets.map((asset) => ({
|
|
123
|
+
amount: asset.rawAmount.toString(),
|
|
124
|
+
tokenAddress: asset.address || '',
|
|
125
|
+
assetType: asset.type,
|
|
126
|
+
})),
|
|
127
|
+
tonCaller: transactionLinker.caller,
|
|
128
|
+
};
|
|
129
|
+
isRoundTrip = isRoundTrip ?? assets.length != 0;
|
|
130
|
+
this.logger.debug(`Is round trip: ${isRoundTrip}`);
|
|
131
|
+
const tacSimulationResult = await this.simulateTACMessage(tacSimulationBody);
|
|
132
|
+
this.logger.debug(`TAC simulation ${tacSimulationResult.simulationStatus ? 'success' : 'failed'}`);
|
|
133
|
+
const protocolFee = BigInt((0, ton_1.toNano)(fullStateCCL.tacProtocolFee)) +
|
|
134
|
+
BigInt(isRoundTrip) * BigInt((0, ton_1.toNano)(fullStateCCL.tonProtocolFee));
|
|
135
|
+
const feeParams = {
|
|
136
|
+
isRoundTrip: isRoundTrip,
|
|
137
|
+
gasLimit: !tacSimulationResult.simulationStatus ? 0n : tacSimulationResult.estimatedGas,
|
|
138
|
+
protocolFee: protocolFee,
|
|
139
|
+
evmExecutorFee: BigInt(tacSimulationResult.suggestedTacExecutionFee),
|
|
140
|
+
tvmExecutorFee: BigInt(tacSimulationResult.suggestedTonExecutionFee) * BigInt(isRoundTrip),
|
|
141
|
+
};
|
|
142
|
+
if (!tacSimulationResult.simulationStatus) {
|
|
143
|
+
if (allowSimulationError) {
|
|
144
|
+
this.logger.info('Force send is true, returning fee params');
|
|
145
|
+
return {
|
|
146
|
+
feeParams,
|
|
147
|
+
simulation: tacSimulationResult,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
throw tacSimulationResult;
|
|
151
|
+
}
|
|
152
|
+
this.logger.debug(`Collected fee params: ${(0, Utils_1.formatObjectForLogging)(feeParams)}`);
|
|
153
|
+
return { feeParams, simulation: tacSimulationResult };
|
|
154
|
+
}
|
|
155
|
+
async getTransactionSimulationInfo(evmProxyMsg, sender, assets) {
|
|
156
|
+
this.logger.debug('Getting transaction simulation info');
|
|
157
|
+
Validator_1.Validator.validateEVMAddress(evmProxyMsg.evmTargetAddress);
|
|
158
|
+
const aggregatedData = await (0, Utils_1.aggregateTokens)(assets);
|
|
159
|
+
const transactionLinkerShardCount = aggregatedData.jettons.length == 0 ? 1 : aggregatedData.jettons.length;
|
|
160
|
+
this.logger.debug(`Transaction linker shard count: ${transactionLinkerShardCount}`);
|
|
161
|
+
const transactionLinker = (0, Utils_1.generateTransactionLinker)(sender.getSenderAddress(), transactionLinkerShardCount);
|
|
162
|
+
this.logger.debug(`Transaction linker: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
163
|
+
return await this.getFeeInfo(evmProxyMsg, transactionLinker, assets ?? []);
|
|
164
|
+
}
|
|
165
|
+
async getSimulationInfoForTransaction(evmProxyMsg, transactionLinker, assets, allowSimulationError = false, isRoundTrip, evmValidExecutors, tvmValidExecutors) {
|
|
166
|
+
return await this.getFeeInfo(evmProxyMsg, transactionLinker, assets, allowSimulationError, isRoundTrip, evmValidExecutors, tvmValidExecutors);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.Simulator = Simulator;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TxFinalizerConfig } from '../structs/InternalStruct';
|
|
2
|
+
import { ILogger } from '../structs/Services';
|
|
1
3
|
import { ExecutionStages, Network, TransactionLinker } from '../structs/Struct';
|
|
2
4
|
export declare function startTracking(transactionLinker: TransactionLinker, network: Network, options?: {
|
|
3
5
|
customLiteSequencerEndpoints?: string[];
|
|
@@ -5,6 +7,8 @@ export declare function startTracking(transactionLinker: TransactionLinker, netw
|
|
|
5
7
|
maxIterationCount?: number;
|
|
6
8
|
returnValue?: boolean;
|
|
7
9
|
tableView?: boolean;
|
|
10
|
+
txFinalizerConfig?: TxFinalizerConfig;
|
|
11
|
+
logger?: ILogger;
|
|
8
12
|
}): Promise<void | ExecutionStages>;
|
|
9
13
|
export declare function startTrackingMultiple(transactionLinkers: TransactionLinker[], network: Network, options?: {
|
|
10
14
|
customLiteSequencerEndpoints?: string[];
|
|
@@ -12,4 +16,6 @@ export declare function startTrackingMultiple(transactionLinkers: TransactionLin
|
|
|
12
16
|
maxIterationCount?: number;
|
|
13
17
|
returnValue?: boolean;
|
|
14
18
|
tableView?: boolean;
|
|
19
|
+
txFinalizerConfig?: TxFinalizerConfig;
|
|
20
|
+
logger?: ILogger;
|
|
15
21
|
}): Promise<void | ExecutionStages[]>;
|
|
@@ -5,19 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.startTracking = startTracking;
|
|
7
7
|
exports.startTrackingMultiple = startTrackingMultiple;
|
|
8
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
8
9
|
const Struct_1 = require("../structs/Struct");
|
|
9
10
|
const Consts_1 = require("./Consts");
|
|
11
|
+
const Logger_1 = require("./Logger");
|
|
10
12
|
const OperationTracker_1 = require("./OperationTracker");
|
|
13
|
+
const TxFinalizer_1 = require("./TxFinalizer");
|
|
11
14
|
const Utils_1 = require("./Utils");
|
|
12
|
-
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
13
15
|
async function startTracking(transactionLinker, network, options) {
|
|
14
|
-
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, } = options || {};
|
|
15
|
-
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, txFinalizerConfig, logger = new Logger_1.NoopLogger(), } = options || {};
|
|
17
|
+
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints, logger);
|
|
18
|
+
logger.debug('Start tracking operation');
|
|
19
|
+
logger.debug('caller: ' + transactionLinker.caller);
|
|
20
|
+
logger.debug('shardsKey: ' + transactionLinker.shardsKey);
|
|
21
|
+
logger.debug('shardCount: ' + transactionLinker.shardCount);
|
|
22
|
+
logger.debug('timestamp: ' + transactionLinker.timestamp);
|
|
21
23
|
let operationId = '';
|
|
22
24
|
let iteration = 0; // number of iterations
|
|
23
25
|
let operationType = '';
|
|
@@ -31,11 +33,13 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
31
33
|
break;
|
|
32
34
|
}
|
|
33
35
|
if (operationId == '') {
|
|
34
|
-
|
|
36
|
+
logger.debug('request operationId');
|
|
35
37
|
try {
|
|
36
38
|
operationId = await tracker.getOperationId(transactionLinker);
|
|
37
39
|
}
|
|
38
|
-
catch
|
|
40
|
+
catch {
|
|
41
|
+
// Ignore error and continue
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
else {
|
|
41
45
|
try {
|
|
@@ -45,9 +49,9 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
catch (err) {
|
|
48
|
-
|
|
52
|
+
logger.debug('failed to get operation type: ' + err);
|
|
49
53
|
}
|
|
50
|
-
|
|
54
|
+
logger.debug(`
|
|
51
55
|
operationId: ${operationId}
|
|
52
56
|
operationType: ${operationType}
|
|
53
57
|
time: ${new Date().toISOString()} (${Math.floor(+new Date() / 1000)})
|
|
@@ -55,37 +59,63 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
55
59
|
}
|
|
56
60
|
await (0, Utils_1.sleep)(delay * 1000);
|
|
57
61
|
}
|
|
58
|
-
|
|
62
|
+
logger.debug('Tracking finished');
|
|
59
63
|
if (!ok) {
|
|
60
64
|
if (returnValue) {
|
|
61
65
|
throw Error(errorMessage);
|
|
62
66
|
}
|
|
63
|
-
|
|
67
|
+
logger.debug(errorMessage);
|
|
64
68
|
}
|
|
65
69
|
const profilingData = await tracker.getStageProfiling(operationId);
|
|
70
|
+
// Check if EXECUTED_IN_TON stage exists and use TxFinalizer to verify transaction success
|
|
71
|
+
if (profilingData.executedInTON.exists && profilingData.executedInTON.stageData?.transactions) {
|
|
72
|
+
logger.debug('EXECUTED_IN_TON stage found, verifying transaction success in TON...');
|
|
73
|
+
if (txFinalizerConfig) {
|
|
74
|
+
const txFinalizer = new TxFinalizer_1.TonTxFinalizer(txFinalizerConfig, logger);
|
|
75
|
+
const transactions = profilingData.executedInTON.stageData.transactions;
|
|
76
|
+
for (const tx of transactions) {
|
|
77
|
+
try {
|
|
78
|
+
logger.debug(`Verifying transaction: ${tx.hash}`);
|
|
79
|
+
await txFinalizer.trackTransactionTree(tx.hash);
|
|
80
|
+
logger.debug(`Transaction ${tx.hash} verified successfully in TON`);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
logger.debug(`Transaction ${tx.hash} failed verification in TON: ${error}`);
|
|
84
|
+
if (returnValue) {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
logger.debug('TxFinalizer config not provided, skipping TON transaction verification');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
66
94
|
if (returnValue) {
|
|
67
95
|
return profilingData;
|
|
68
96
|
}
|
|
69
|
-
|
|
70
|
-
|
|
97
|
+
logger.debug(profilingData.operationType);
|
|
98
|
+
logger.debug(profilingData.metaInfo);
|
|
71
99
|
if (tableView) {
|
|
72
|
-
printExecutionStagesTable(profilingData);
|
|
100
|
+
printExecutionStagesTable(profilingData, logger);
|
|
73
101
|
}
|
|
74
102
|
else {
|
|
75
|
-
|
|
103
|
+
logger.debug(formatExecutionStages(profilingData));
|
|
76
104
|
}
|
|
77
105
|
}
|
|
78
106
|
async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
79
|
-
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, } = options || {};
|
|
80
|
-
|
|
107
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, txFinalizerConfig, logger = new Logger_1.NoopLogger(), } = options || {};
|
|
108
|
+
logger.debug(`Start tracking ${transactionLinkers.length} operations`);
|
|
81
109
|
const results = await Promise.all(transactionLinkers.map((linker, index) => {
|
|
82
|
-
|
|
110
|
+
logger.debug(`\nProcessing operation ${index + 1}/${transactionLinkers.length}`);
|
|
83
111
|
return startTracking(linker, network, {
|
|
84
112
|
customLiteSequencerEndpoints,
|
|
85
113
|
delay,
|
|
86
114
|
maxIterationCount,
|
|
87
115
|
returnValue: true,
|
|
88
116
|
tableView: false,
|
|
117
|
+
txFinalizerConfig,
|
|
118
|
+
logger,
|
|
89
119
|
});
|
|
90
120
|
}));
|
|
91
121
|
if (returnValue) {
|
|
@@ -93,20 +123,27 @@ async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
|
93
123
|
}
|
|
94
124
|
if (tableView) {
|
|
95
125
|
results.forEach((result, index) => {
|
|
96
|
-
|
|
97
|
-
printExecutionStagesTable(result);
|
|
126
|
+
logger.debug(`\nResults for operation ${index + 1}:`);
|
|
127
|
+
printExecutionStagesTable(result, logger);
|
|
98
128
|
});
|
|
99
129
|
}
|
|
100
130
|
else {
|
|
101
131
|
results.forEach((result, index) => {
|
|
102
|
-
|
|
103
|
-
|
|
132
|
+
logger.debug(`\nResults for operation ${index + 1}:`);
|
|
133
|
+
logger.debug(formatExecutionStages(result));
|
|
104
134
|
});
|
|
105
135
|
}
|
|
106
136
|
}
|
|
107
137
|
function formatExecutionStages(stages) {
|
|
108
|
-
const {
|
|
109
|
-
return Object.entries(
|
|
138
|
+
const { collectedInTAC, includedInTACConsensus, executedInTAC, collectedInTON, includedInTONConsensus, executedInTON, } = stages;
|
|
139
|
+
return Object.entries({
|
|
140
|
+
collectedInTAC,
|
|
141
|
+
includedInTACConsensus,
|
|
142
|
+
executedInTAC,
|
|
143
|
+
collectedInTON,
|
|
144
|
+
includedInTONConsensus,
|
|
145
|
+
executedInTON,
|
|
146
|
+
}).map(([stage, data]) => ({
|
|
110
147
|
stage: stage,
|
|
111
148
|
exists: data.exists ? 'Yes' : 'No',
|
|
112
149
|
success: data.exists && data.stageData ? (data.stageData.success ? 'Yes' : 'No') : '-',
|
|
@@ -123,7 +160,7 @@ function formatExecutionStages(stages) {
|
|
|
123
160
|
bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
|
|
124
161
|
}));
|
|
125
162
|
}
|
|
126
|
-
function printExecutionStagesTable(stages) {
|
|
163
|
+
function printExecutionStagesTable(stages, logger) {
|
|
127
164
|
const table = new cli_table3_1.default({
|
|
128
165
|
head: [
|
|
129
166
|
'Stage',
|
|
@@ -153,5 +190,5 @@ function printExecutionStagesTable(stages) {
|
|
|
153
190
|
row.bytesError,
|
|
154
191
|
]);
|
|
155
192
|
});
|
|
156
|
-
|
|
193
|
+
logger.debug(table.toString());
|
|
157
194
|
}
|
package/dist/sdk/TacSdk.d.ts
CHANGED
|
@@ -1,53 +1,24 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
3
|
+
import { IConfiguration, ILogger } from '../structs/Services';
|
|
4
|
+
import { Asset, CrossChainTransactionOptions, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, OperationIdsByShardsKey, SDKParams, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
|
|
6
5
|
export declare class TacSdk {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly TONParams: InternalTONParams;
|
|
11
|
-
readonly TACParams: InternalTACParams;
|
|
12
|
-
readonly liteSequencerEndpoints: string[];
|
|
6
|
+
readonly config: IConfiguration;
|
|
7
|
+
private readonly simulator;
|
|
8
|
+
private readonly transactionManager;
|
|
13
9
|
private constructor();
|
|
14
|
-
static create(sdkParams: SDKParams): Promise<TacSdk>;
|
|
15
|
-
private static prepareTONParams;
|
|
16
|
-
private static prepareTACParams;
|
|
10
|
+
static create(sdkParams: SDKParams, logger?: ILogger): Promise<TacSdk>;
|
|
17
11
|
closeConnections(): unknown;
|
|
18
12
|
get nativeTONAddress(): string;
|
|
19
13
|
nativeTACAddress(): Promise<string>;
|
|
20
|
-
getUserJettonWalletAddress(userAddress: string, tokenAddress: string): Promise<string>;
|
|
21
|
-
getUserJettonBalance(userAddress: string, tokenAddress: string): Promise<bigint>;
|
|
22
|
-
getUserJettonBalanceExtended(userAddress: string, tokenAddress: string): Promise<UserWalletBalanceExtended>;
|
|
23
|
-
private getJettonTransferPayload;
|
|
24
|
-
private getJettonBurnPayload;
|
|
25
|
-
private getNFTBurnPayload;
|
|
26
|
-
private getNFTTransferPayload;
|
|
27
|
-
private getTonTransferPayload;
|
|
28
|
-
private getJettonOpType;
|
|
29
|
-
private getNFTOpType;
|
|
30
|
-
private getNFTItemAddressTON;
|
|
31
|
-
getNFTItemData(itemAddress: string): Promise<NFTItemData>;
|
|
32
|
-
private aggregateTokens;
|
|
33
|
-
private generateJettonPayload;
|
|
34
|
-
private generateNFTPayload;
|
|
35
|
-
private generateCrossChainMessages;
|
|
36
|
-
private getRawAmount;
|
|
37
|
-
private convertAssetsToRawFormat;
|
|
38
|
-
private getFeeInfo;
|
|
39
|
-
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[]): Promise<ExecutionFeeEstimationResult>;
|
|
40
|
-
getTVMExecutorFeeInfo(assets: AssetBridgingData[], feeSymbol: String): Promise<SuggestedTONExecutorFee>;
|
|
41
|
-
private prepareCrossChainTransaction;
|
|
42
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], options?: CrossChainTransactionOptions): Promise<TransactionLinker>;
|
|
43
|
-
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TransactionLinker[]>;
|
|
44
|
-
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: RawAssetBridgingData<WithAddressNFTCollectionItem>[], tvmExecutorFee?: bigint): Promise<string>;
|
|
45
14
|
get getTrustedTACExecutors(): string[];
|
|
46
15
|
get getTrustedTONExecutors(): string[];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
16
|
+
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[]): Promise<ExecutionFeeEstimationResult>;
|
|
17
|
+
getTVMExecutorFeeInfo(assets: Asset[], feeSymbol: string): Promise<SuggestedTONExecutorFee>;
|
|
18
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
|
|
19
|
+
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
|
|
20
|
+
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: Asset[], tvmExecutorFee?: bigint): Promise<string>;
|
|
51
21
|
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
52
22
|
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
|
|
23
|
+
simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
|
|
53
24
|
}
|