@tonappchain/sdk 0.5.1 → 0.5.3
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 +9 -26
- package/dist/sdk/StartTracking.d.ts +8 -2
- package/dist/sdk/StartTracking.js +50 -6
- package/dist/sender/SenderFactory.js +1 -1
- package/dist/structs/Struct.d.ts +6 -21
- package/dist/structs/Struct.js +6 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -688,22 +688,22 @@ Fetches the current status information for multiple operations based on their op
|
|
|
688
688
|
|
|
689
689
|
Track the execution of crosschain operation with `startTracking` method
|
|
690
690
|
|
|
691
|
-
#### Method: `async function startTracking(transactionLinker: TransactionLinker, network: Network, customLiteSequencerEndpoints?: string[]
|
|
691
|
+
#### Method: `async function startTracking(transactionLinker: TransactionLinker, network: Network, options?: { customLiteSequencerEndpoints?: string[]; delay?: number; maxIterationCount?: number; returnValue?: boolean; tableView?: boolean; }): Promise<void | ExecutionStages>`
|
|
692
692
|
|
|
693
693
|
#### **Parameters**:
|
|
694
694
|
- `transactionLinker`: A `TransactionLinker` object returned from `sendCrossChainTransaction` function.
|
|
695
695
|
- `network`: TON network (`Network` type).
|
|
696
|
-
- `
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
696
|
+
- `options` *(optional)*:
|
|
697
|
+
- `customLiteSequencerEndpoints` *(optional)*: specify custom lite sequencer API URL for sending requests there. Default is `undefined`
|
|
698
|
+
- `delay` *(optional)*: specify custom delay after requests there. Default is `10`
|
|
699
|
+
- `maxIterationCount` *(optional)*: specify custom max iteration count there. Default is `120`
|
|
700
|
+
- `returnValue` *(optional)*: specify whether to return the data to you after tracking. When `false` will write to the console. Default is `false`
|
|
701
|
+
- `tableView` *(optional)*: specify data display in the table. Default is `true`
|
|
700
702
|
|
|
701
703
|
#### **Returns**:
|
|
702
704
|
- Will stop requesting status once the final status of crosschain operation has been reached.
|
|
703
705
|
- if returnValue is `false` return `Promise<void>`
|
|
704
|
-
- if `true` return `Promise<
|
|
705
|
-
- **`profilingData`**: `ExecutionStages` - execution stages profiling data;
|
|
706
|
-
- **`tableData`**: `ExecutionStagesTableData[]` - execution stages profiling data in table format;
|
|
706
|
+
- if `true` return `Promise<ExecutionStages>` - execution stages profiling data.
|
|
707
707
|
|
|
708
708
|
#### **Possible exceptions**
|
|
709
709
|
|
|
@@ -1028,6 +1028,7 @@ Combines `StageData` with an additional stage identifier.
|
|
|
1028
1028
|
- **`stage`**: Current stage in `StageName` enum.
|
|
1029
1029
|
- **Other Properties from `StageData`**
|
|
1030
1030
|
|
|
1031
|
+
|
|
1031
1032
|
### `OperationType`
|
|
1032
1033
|
|
|
1033
1034
|
```typescript
|
|
@@ -1088,24 +1089,6 @@ Represents the profiling data for all execution stages within an operation.
|
|
|
1088
1089
|
- **`INCLUDED_IN_TON_CONSENSUS`**.
|
|
1089
1090
|
- **`EXECUTED_IN_TON`**.
|
|
1090
1091
|
|
|
1091
|
-
### `ExecutionStagesTableData`
|
|
1092
|
-
|
|
1093
|
-
```typescript
|
|
1094
|
-
export type ExecutionStagesTableData = {
|
|
1095
|
-
stage: string;
|
|
1096
|
-
exists: string;
|
|
1097
|
-
success: string;
|
|
1098
|
-
timestamp: string;
|
|
1099
|
-
transactions: string;
|
|
1100
|
-
noteContent: string;
|
|
1101
|
-
errorName: string;
|
|
1102
|
-
internalMsg: string;
|
|
1103
|
-
bytesError: string;
|
|
1104
|
-
};
|
|
1105
|
-
```
|
|
1106
|
-
|
|
1107
|
-
Represents the profiling data for all execution stages in table format.
|
|
1108
|
-
|
|
1109
1092
|
|
|
1110
1093
|
### `ExecutionStagesByOperationId`
|
|
1111
1094
|
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function startTracking(transactionLinker: TransactionLinker, network: Network,
|
|
1
|
+
import { ExecutionStages, Network, TransactionLinker } from '../structs/Struct';
|
|
2
|
+
export declare function startTracking(transactionLinker: TransactionLinker, network: Network, options?: {
|
|
3
|
+
customLiteSequencerEndpoints?: string[];
|
|
4
|
+
delay?: number;
|
|
5
|
+
maxIterationCount?: number;
|
|
6
|
+
returnValue?: boolean;
|
|
7
|
+
tableView?: boolean;
|
|
8
|
+
}): Promise<void | ExecutionStages>;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.startTracking = startTracking;
|
|
4
7
|
const Struct_1 = require("../structs/Struct");
|
|
5
8
|
const Consts_1 = require("./Consts");
|
|
6
9
|
const OperationTracker_1 = require("./OperationTracker");
|
|
7
10
|
const Utils_1 = require("./Utils");
|
|
8
|
-
|
|
11
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
12
|
+
async function startTracking(transactionLinker, network, options) {
|
|
13
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, } = options || {};
|
|
9
14
|
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints);
|
|
10
15
|
console.log('Start tracking operation');
|
|
11
16
|
console.log('caller: ', transactionLinker.caller);
|
|
@@ -16,7 +21,7 @@ async function startTracking(transactionLinker, network, customLiteSequencerEndp
|
|
|
16
21
|
let iteration = 0; // number of iterations
|
|
17
22
|
let operationType = '';
|
|
18
23
|
let ok = true; // finished successfully
|
|
19
|
-
let errorMessage;
|
|
24
|
+
let errorMessage = '';
|
|
20
25
|
while (true) {
|
|
21
26
|
++iteration;
|
|
22
27
|
if (iteration >= maxIterationCount) {
|
|
@@ -53,15 +58,22 @@ async function startTracking(transactionLinker, network, customLiteSequencerEndp
|
|
|
53
58
|
}
|
|
54
59
|
console.log('Tracking finished');
|
|
55
60
|
if (!ok) {
|
|
61
|
+
if (returnValue) {
|
|
62
|
+
throw Error(errorMessage);
|
|
63
|
+
}
|
|
56
64
|
console.log(errorMessage);
|
|
57
65
|
}
|
|
58
66
|
const profilingData = await tracker.getStageProfiling(operationId);
|
|
59
|
-
const tableData = formatExecutionStages(profilingData);
|
|
60
67
|
if (returnValue) {
|
|
61
|
-
return
|
|
68
|
+
return profilingData;
|
|
62
69
|
}
|
|
63
70
|
console.log(profilingData.operationType);
|
|
64
|
-
|
|
71
|
+
if (tableView) {
|
|
72
|
+
printExecutionStagesTable(profilingData);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.log(formatExecutionStages(profilingData));
|
|
76
|
+
}
|
|
65
77
|
}
|
|
66
78
|
function formatExecutionStages(stages) {
|
|
67
79
|
const { operationType, ...stagesData } = stages;
|
|
@@ -74,7 +86,7 @@ function formatExecutionStages(stages) {
|
|
|
74
86
|
data.stageData &&
|
|
75
87
|
data.stageData.transactions != null &&
|
|
76
88
|
data.stageData.transactions.length > 0
|
|
77
|
-
? data.stageData.transactions.map((t) => t.hash).join('
|
|
89
|
+
? data.stageData.transactions.map((t) => t.hash).join(' \n')
|
|
78
90
|
: '-',
|
|
79
91
|
noteContent: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.content : '-',
|
|
80
92
|
errorName: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.errorName : '-',
|
|
@@ -82,3 +94,35 @@ function formatExecutionStages(stages) {
|
|
|
82
94
|
bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
|
|
83
95
|
}));
|
|
84
96
|
}
|
|
97
|
+
function printExecutionStagesTable(stages) {
|
|
98
|
+
const table = new cli_table3_1.default({
|
|
99
|
+
head: [
|
|
100
|
+
'Stage',
|
|
101
|
+
'Exists',
|
|
102
|
+
'Success',
|
|
103
|
+
'Timestamp',
|
|
104
|
+
'Transactions',
|
|
105
|
+
'NoteContent',
|
|
106
|
+
'ErrorName',
|
|
107
|
+
'InternalMsg',
|
|
108
|
+
'BytesError',
|
|
109
|
+
],
|
|
110
|
+
colWidths: [30, 8, 9, 13, 70, 13, 13, 13, 13],
|
|
111
|
+
wordWrap: true,
|
|
112
|
+
});
|
|
113
|
+
const tableData = formatExecutionStages(stages);
|
|
114
|
+
tableData.forEach((row) => {
|
|
115
|
+
table.push([
|
|
116
|
+
row.stage,
|
|
117
|
+
row.exists,
|
|
118
|
+
row.success,
|
|
119
|
+
row.timestamp,
|
|
120
|
+
row.transactions,
|
|
121
|
+
row.noteContent,
|
|
122
|
+
row.errorName,
|
|
123
|
+
row.internalMsg,
|
|
124
|
+
row.bytesError,
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
console.log(table.toString());
|
|
128
|
+
}
|
|
@@ -38,7 +38,7 @@ class SenderFactory {
|
|
|
38
38
|
config.walletId = {
|
|
39
39
|
networkGlobalId: params.network === Struct_1.Network.TESTNET ? -3 : -239,
|
|
40
40
|
context: {
|
|
41
|
-
walletVersion: '
|
|
41
|
+
walletVersion: 'v5r1',
|
|
42
42
|
workchain: 0,
|
|
43
43
|
subwalletNumber: params.options?.v5r1?.subwalletNumber ?? 0,
|
|
44
44
|
},
|
package/dist/structs/Struct.d.ts
CHANGED
|
@@ -152,12 +152,12 @@ export type TACSimulationRequest = {
|
|
|
152
152
|
tonCaller: string;
|
|
153
153
|
};
|
|
154
154
|
export declare enum StageName {
|
|
155
|
-
COLLECTED_IN_TAC = "
|
|
156
|
-
INCLUDED_IN_TAC_CONSENSUS = "
|
|
157
|
-
EXECUTED_IN_TAC = "
|
|
158
|
-
COLLECTED_IN_TON = "
|
|
159
|
-
INCLUDED_IN_TON_CONSENSUS = "
|
|
160
|
-
EXECUTED_IN_TON = "
|
|
155
|
+
COLLECTED_IN_TAC = "collectedInTAC",
|
|
156
|
+
INCLUDED_IN_TAC_CONSENSUS = "includedInTACConsensus",
|
|
157
|
+
EXECUTED_IN_TAC = "executedInTAC",
|
|
158
|
+
COLLECTED_IN_TON = "collectedInTON",
|
|
159
|
+
INCLUDED_IN_TON_CONSENSUS = "includedInTONConsensus",
|
|
160
|
+
EXECUTED_IN_TON = "executedInTON"
|
|
161
161
|
}
|
|
162
162
|
export type TransactionData = {
|
|
163
163
|
hash: string;
|
|
@@ -185,21 +185,6 @@ export type ProfilingStageData = {
|
|
|
185
185
|
export type ExecutionStages = {
|
|
186
186
|
operationType: OperationType;
|
|
187
187
|
} & Record<StageName, ProfilingStageData>;
|
|
188
|
-
export type ExecutionStagesTableData = {
|
|
189
|
-
stage: string;
|
|
190
|
-
exists: string;
|
|
191
|
-
success: string;
|
|
192
|
-
timestamp: string;
|
|
193
|
-
transactions: string;
|
|
194
|
-
noteContent: string;
|
|
195
|
-
errorName: string;
|
|
196
|
-
internalMsg: string;
|
|
197
|
-
bytesError: string;
|
|
198
|
-
};
|
|
199
|
-
export type TrackingOperationResult = {
|
|
200
|
-
profilingData: ExecutionStages;
|
|
201
|
-
tableData: ExecutionStagesTableData[];
|
|
202
|
-
};
|
|
203
188
|
export type ExecutionStagesByOperationId = Record<string, ExecutionStages>;
|
|
204
189
|
export type StatusInfosByOperationId = Record<string, StatusInfo>;
|
|
205
190
|
export type OperationIds = {
|
package/dist/structs/Struct.js
CHANGED
|
@@ -29,10 +29,10 @@ var OperationType;
|
|
|
29
29
|
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
30
30
|
var StageName;
|
|
31
31
|
(function (StageName) {
|
|
32
|
-
StageName["COLLECTED_IN_TAC"] = "
|
|
33
|
-
StageName["INCLUDED_IN_TAC_CONSENSUS"] = "
|
|
34
|
-
StageName["EXECUTED_IN_TAC"] = "
|
|
35
|
-
StageName["COLLECTED_IN_TON"] = "
|
|
36
|
-
StageName["INCLUDED_IN_TON_CONSENSUS"] = "
|
|
37
|
-
StageName["EXECUTED_IN_TON"] = "
|
|
32
|
+
StageName["COLLECTED_IN_TAC"] = "collectedInTAC";
|
|
33
|
+
StageName["INCLUDED_IN_TAC_CONSENSUS"] = "includedInTACConsensus";
|
|
34
|
+
StageName["EXECUTED_IN_TAC"] = "executedInTAC";
|
|
35
|
+
StageName["COLLECTED_IN_TON"] = "collectedInTON";
|
|
36
|
+
StageName["INCLUDED_IN_TON_CONSENSUS"] = "includedInTONConsensus";
|
|
37
|
+
StageName["EXECUTED_IN_TON"] = "executedInTON";
|
|
38
38
|
})(StageName || (exports.StageName = StageName = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonappchain/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
5
|
"author": "TAC. <developers@tac>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@tonappchain/ton-lite-client": "3.0.6",
|
|
25
25
|
"@tonconnect/ui": "^2.0.11",
|
|
26
26
|
"bn.js": "^5.2.1",
|
|
27
|
+
"cli-table3": "^0.6.5",
|
|
27
28
|
"dotenv": "^16.4.7",
|
|
28
29
|
"ethers": "^6.13.5",
|
|
29
30
|
"ton-crypto": "^3.2.0"
|