@tonappchain/sdk 0.5.6 → 0.6.1-v3.0.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/LICENSE +20 -20
- package/README.md +189 -1276
- package/package.json +67 -67
- package/dist/adapters/contractOpener.d.ts +0 -19
- package/dist/adapters/contractOpener.js +0 -94
- package/dist/errors/errors.d.ts +0 -34
- package/dist/errors/errors.js +0 -80
- package/dist/errors/index.d.ts +0 -2
- package/dist/errors/index.js +0 -30
- package/dist/errors/instances.d.ts +0 -16
- package/dist/errors/instances.js +0 -28
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -35
- package/dist/sdk/Consts.d.ts +0 -6
- package/dist/sdk/Consts.js +0 -10
- package/dist/sdk/OperationTracker.d.ts +0 -14
- package/dist/sdk/OperationTracker.js +0 -151
- package/dist/sdk/StartTracking.d.ts +0 -8
- package/dist/sdk/StartTracking.js +0 -126
- package/dist/sdk/TacSdk.d.ts +0 -36
- package/dist/sdk/TacSdk.js +0 -364
- package/dist/sdk/Utils.d.ts +0 -18
- package/dist/sdk/Utils.js +0 -126
- package/dist/sender/RawSender.d.ts +0 -13
- package/dist/sender/RawSender.js +0 -37
- package/dist/sender/SenderAbstraction.d.ts +0 -19
- package/dist/sender/SenderAbstraction.js +0 -5
- package/dist/sender/SenderFactory.d.ts +0 -33
- package/dist/sender/SenderFactory.js +0 -55
- package/dist/sender/TonConnectSender.d.ts +0 -11
- package/dist/sender/TonConnectSender.js +0 -33
- package/dist/sender/index.d.ts +0 -2
- package/dist/sender/index.js +0 -18
- package/dist/structs/InternalStruct.d.ts +0 -54
- package/dist/structs/InternalStruct.js +0 -8
- package/dist/structs/Struct.d.ts +0 -227
- package/dist/structs/Struct.js +0 -38
- package/dist/wrappers/ContentUtils.d.ts +0 -25
- package/dist/wrappers/ContentUtils.js +0 -160
- package/dist/wrappers/HighloadQueryId.d.ts +0 -17
- package/dist/wrappers/HighloadQueryId.js +0 -72
- package/dist/wrappers/HighloadWalletV3.d.ts +0 -61
- package/dist/wrappers/HighloadWalletV3.js +0 -161
- package/dist/wrappers/JettonMaster.d.ts +0 -24
- package/dist/wrappers/JettonMaster.js +0 -53
- package/dist/wrappers/JettonWallet.d.ts +0 -46
- package/dist/wrappers/JettonWallet.js +0 -103
- package/dist/wrappers/Settings.d.ts +0 -10
- package/dist/wrappers/Settings.js +0 -38
|
@@ -1,151 +0,0 @@
|
|
|
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.OperationTracker = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const Struct_1 = require("../structs/Struct");
|
|
9
|
-
const errors_1 = require("../errors");
|
|
10
|
-
const Utils_1 = require("./Utils");
|
|
11
|
-
const artifacts_1 = require("@tonappchain/artifacts");
|
|
12
|
-
class OperationTracker {
|
|
13
|
-
constructor(network, customLiteSequencerEndpoints) {
|
|
14
|
-
this.network = network;
|
|
15
|
-
this.customLiteSequencerEndpoints =
|
|
16
|
-
customLiteSequencerEndpoints ??
|
|
17
|
-
(this.network === Struct_1.Network.TESTNET
|
|
18
|
-
? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
|
|
19
|
-
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
20
|
-
}
|
|
21
|
-
async getOperationType(operationId) {
|
|
22
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
23
|
-
try {
|
|
24
|
-
const response = await axios_1.default.get(`${endpoint}/operation-type`, {
|
|
25
|
-
params: {
|
|
26
|
-
operationId,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return response.data.response || '';
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error(`Failed to get operationType with ${endpoint}:`, error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
throw errors_1.operationFetchError;
|
|
36
|
-
}
|
|
37
|
-
async getOperationId(transactionLinker) {
|
|
38
|
-
const requestBody = {
|
|
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) {
|
|
46
|
-
try {
|
|
47
|
-
const response = await axios_1.default.post(`${endpoint}/ton/operation-id`, requestBody);
|
|
48
|
-
return response.data.response || '';
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (axios_1.default.isAxiosError(error)) {
|
|
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);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (operationId !== undefined) {
|
|
62
|
-
return operationId;
|
|
63
|
-
}
|
|
64
|
-
throw errors_1.operationFetchError;
|
|
65
|
-
}
|
|
66
|
-
async getOperationIdsByShardsKeys(shardsKeys, caller) {
|
|
67
|
-
const requestBody = {
|
|
68
|
-
shardsKeys: shardsKeys,
|
|
69
|
-
caller: caller,
|
|
70
|
-
};
|
|
71
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
72
|
-
try {
|
|
73
|
-
const response = await axios_1.default.post(`${endpoint}/operation-ids-by-shards-keys`, requestBody);
|
|
74
|
-
return response.data.response;
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
console.error(`Failed to get OperationIds with ${endpoint}:`, error);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
throw errors_1.operationFetchError;
|
|
81
|
-
}
|
|
82
|
-
async getStageProfiling(operationId) {
|
|
83
|
-
const map = await this.getStageProfilings([operationId]);
|
|
84
|
-
const result = map[operationId];
|
|
85
|
-
if (!result) {
|
|
86
|
-
throw new Error(`No stageProfiling data for operationId=${operationId}`);
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
async getStageProfilings(operationIds) {
|
|
91
|
-
if (!operationIds || operationIds.length === 0) {
|
|
92
|
-
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
93
|
-
}
|
|
94
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
95
|
-
try {
|
|
96
|
-
const response = await axios_1.default.post(`${endpoint}/stage-profiling`, {
|
|
97
|
-
operationIds,
|
|
98
|
-
}, {
|
|
99
|
-
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
100
|
-
});
|
|
101
|
-
return response.data.response;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
console.error(`Error fetching status transaction with ${endpoint}:`, error);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
throw (0, errors_1.profilingFetchError)('all endpoints failed to complete request');
|
|
108
|
-
}
|
|
109
|
-
async getOperationStatuses(operationIds) {
|
|
110
|
-
if (!operationIds || operationIds.length === 0) {
|
|
111
|
-
throw (0, errors_1.emptyArrayError)('operationIds');
|
|
112
|
-
}
|
|
113
|
-
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
114
|
-
try {
|
|
115
|
-
const response = await axios_1.default.post(`${endpoint}/status`, {
|
|
116
|
-
operationIds,
|
|
117
|
-
}, {
|
|
118
|
-
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
119
|
-
});
|
|
120
|
-
return response.data.response;
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.error(`Error fetching status transaction with ${endpoint}:`, error);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
throw (0, errors_1.statusFetchError)('all endpoints failed to complete request');
|
|
127
|
-
}
|
|
128
|
-
async getOperationStatus(operationId) {
|
|
129
|
-
const result = await this.getOperationStatuses([operationId]);
|
|
130
|
-
const currentStatus = result[operationId];
|
|
131
|
-
if (!currentStatus) {
|
|
132
|
-
throw (0, errors_1.statusFetchError)('operation is not found in response');
|
|
133
|
-
}
|
|
134
|
-
return currentStatus;
|
|
135
|
-
}
|
|
136
|
-
async getSimplifiedOperationStatus(transactionLinker) {
|
|
137
|
-
const operationId = await this.getOperationId(transactionLinker);
|
|
138
|
-
if (operationId == '') {
|
|
139
|
-
return Struct_1.SimplifiedStatuses.OPERATION_ID_NOT_FOUND;
|
|
140
|
-
}
|
|
141
|
-
const operationType = await this.getOperationType(operationId);
|
|
142
|
-
if (operationType == Struct_1.OperationType.PENDING || operationType == Struct_1.OperationType.UNKNOWN) {
|
|
143
|
-
return Struct_1.SimplifiedStatuses.PENDING;
|
|
144
|
-
}
|
|
145
|
-
if (operationType == Struct_1.OperationType.ROLLBACK) {
|
|
146
|
-
return Struct_1.SimplifiedStatuses.FAILED;
|
|
147
|
-
}
|
|
148
|
-
return Struct_1.SimplifiedStatuses.SUCCESSFUL;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.OperationTracker = OperationTracker;
|
|
@@ -1,8 +0,0 @@
|
|
|
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,126 +0,0 @@
|
|
|
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.startTracking = startTracking;
|
|
7
|
-
const Struct_1 = require("../structs/Struct");
|
|
8
|
-
const Consts_1 = require("./Consts");
|
|
9
|
-
const OperationTracker_1 = require("./OperationTracker");
|
|
10
|
-
const Utils_1 = require("./Utils");
|
|
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 || {};
|
|
14
|
-
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints);
|
|
15
|
-
console.log('Start tracking operation');
|
|
16
|
-
console.log('caller: ', transactionLinker.caller);
|
|
17
|
-
console.log('shardsKey: ', transactionLinker.shardsKey);
|
|
18
|
-
console.log('shardCount: ', transactionLinker.shardCount);
|
|
19
|
-
console.log('timestamp: ', transactionLinker.timestamp);
|
|
20
|
-
let operationId = '';
|
|
21
|
-
let iteration = 0; // number of iterations
|
|
22
|
-
let operationType = '';
|
|
23
|
-
let ok = true; // finished successfully
|
|
24
|
-
let errorMessage = '';
|
|
25
|
-
while (true) {
|
|
26
|
-
++iteration;
|
|
27
|
-
if (iteration >= maxIterationCount) {
|
|
28
|
-
ok = false;
|
|
29
|
-
errorMessage = 'maximum number of iterations has been exceeded';
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
console.log();
|
|
33
|
-
if (operationId == '') {
|
|
34
|
-
console.log('request operationId');
|
|
35
|
-
try {
|
|
36
|
-
operationId = await tracker.getOperationId(transactionLinker);
|
|
37
|
-
}
|
|
38
|
-
catch (err) { }
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
console.log('request operationType');
|
|
42
|
-
try {
|
|
43
|
-
operationType = await tracker.getOperationType(operationId);
|
|
44
|
-
if (operationType != Struct_1.OperationType.PENDING && operationType != Struct_1.OperationType.UNKNOWN) {
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
console.log('failed to get operation type:', err);
|
|
50
|
-
}
|
|
51
|
-
console.log('operationId:', operationId);
|
|
52
|
-
console.log('operationType:', operationType);
|
|
53
|
-
console.log('time: ', Math.floor(+new Date() / 1000));
|
|
54
|
-
}
|
|
55
|
-
await (0, Utils_1.sleep)(delay * 1000);
|
|
56
|
-
}
|
|
57
|
-
console.log('Tracking finished');
|
|
58
|
-
if (!ok) {
|
|
59
|
-
if (returnValue) {
|
|
60
|
-
throw Error(errorMessage);
|
|
61
|
-
}
|
|
62
|
-
console.log(errorMessage);
|
|
63
|
-
}
|
|
64
|
-
const profilingData = await tracker.getStageProfiling(operationId);
|
|
65
|
-
if (returnValue) {
|
|
66
|
-
return profilingData;
|
|
67
|
-
}
|
|
68
|
-
console.log(profilingData.operationType);
|
|
69
|
-
if (tableView) {
|
|
70
|
-
printExecutionStagesTable(profilingData);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
console.log(formatExecutionStages(profilingData));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function formatExecutionStages(stages) {
|
|
77
|
-
const { operationType, ...stagesData } = stages;
|
|
78
|
-
return Object.entries(stagesData).map(([stage, data]) => ({
|
|
79
|
-
stage: stage,
|
|
80
|
-
exists: data.exists ? 'Yes' : 'No',
|
|
81
|
-
success: data.exists && data.stageData ? (data.stageData.success ? 'Yes' : 'No') : '-',
|
|
82
|
-
timestamp: data.exists && data.stageData ? new Date(data.stageData.timestamp * 1000).toLocaleString() : '-',
|
|
83
|
-
transactions: data.exists &&
|
|
84
|
-
data.stageData &&
|
|
85
|
-
data.stageData.transactions != null &&
|
|
86
|
-
data.stageData.transactions.length > 0
|
|
87
|
-
? data.stageData.transactions.map((t) => t.hash).join(' \n')
|
|
88
|
-
: '-',
|
|
89
|
-
noteContent: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.content : '-',
|
|
90
|
-
errorName: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.errorName : '-',
|
|
91
|
-
internalMsg: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalMsg : '-',
|
|
92
|
-
bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
function printExecutionStagesTable(stages) {
|
|
96
|
-
const table = new cli_table3_1.default({
|
|
97
|
-
head: [
|
|
98
|
-
'Stage',
|
|
99
|
-
'Exists',
|
|
100
|
-
'Success',
|
|
101
|
-
'Timestamp',
|
|
102
|
-
'Transactions',
|
|
103
|
-
'NoteContent',
|
|
104
|
-
'ErrorName',
|
|
105
|
-
'InternalMsg',
|
|
106
|
-
'BytesError',
|
|
107
|
-
],
|
|
108
|
-
colWidths: [30, 8, 9, 13, 70, 13, 13, 13, 13],
|
|
109
|
-
wordWrap: true,
|
|
110
|
-
});
|
|
111
|
-
const tableData = formatExecutionStages(stages);
|
|
112
|
-
tableData.forEach((row) => {
|
|
113
|
-
table.push([
|
|
114
|
-
row.stage,
|
|
115
|
-
row.exists,
|
|
116
|
-
row.success,
|
|
117
|
-
row.timestamp,
|
|
118
|
-
row.transactions,
|
|
119
|
-
row.noteContent,
|
|
120
|
-
row.errorName,
|
|
121
|
-
row.internalMsg,
|
|
122
|
-
row.bytesError,
|
|
123
|
-
]);
|
|
124
|
-
});
|
|
125
|
-
console.log(table.toString());
|
|
126
|
-
}
|
package/dist/sdk/TacSdk.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { SenderAbstraction } from '../sender';
|
|
2
|
-
import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, UserWalletBalanceExtended, TACSimulationResults, TACSimulationRequest } from '../structs/Struct';
|
|
3
|
-
import { InternalTONParams, InternalTACParams } from '../structs/InternalStruct';
|
|
4
|
-
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
5
|
-
export declare class TacSdk {
|
|
6
|
-
readonly network: Network;
|
|
7
|
-
readonly delay: number;
|
|
8
|
-
readonly artifacts: typeof testnet | typeof mainnet;
|
|
9
|
-
readonly TONParams: InternalTONParams;
|
|
10
|
-
readonly TACParams: InternalTACParams;
|
|
11
|
-
readonly liteSequencerEndpoints: string[];
|
|
12
|
-
private constructor();
|
|
13
|
-
static create(sdkParams: SDKParams): Promise<TacSdk>;
|
|
14
|
-
private static prepareTONParams;
|
|
15
|
-
private static prepareTACParams;
|
|
16
|
-
closeConnections(): unknown;
|
|
17
|
-
get nativeTONAddress(): string;
|
|
18
|
-
get nativeTACAddress(): Promise<string>;
|
|
19
|
-
getUserJettonWalletAddress(userAddress: string, tokenAddress: string): Promise<string>;
|
|
20
|
-
getUserJettonBalance(userAddress: string, tokenAddress: string): Promise<bigint>;
|
|
21
|
-
getUserJettonBalanceExtended(userAddress: string, tokenAddress: string): Promise<UserWalletBalanceExtended>;
|
|
22
|
-
private getJettonTransferPayload;
|
|
23
|
-
private getJettonBurnPayload;
|
|
24
|
-
private getTonTransferPayload;
|
|
25
|
-
private getJettonOpType;
|
|
26
|
-
private aggregateJettons;
|
|
27
|
-
private generatePayload;
|
|
28
|
-
private generateCrossChainMessages;
|
|
29
|
-
private getRawAmount;
|
|
30
|
-
private convertAssetsToRawFormat;
|
|
31
|
-
private getGasLimit;
|
|
32
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], forceSend?: boolean): Promise<TransactionLinker>;
|
|
33
|
-
getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
|
|
34
|
-
getTVMTokenAddress(evmTokenAddress: string): Promise<string>;
|
|
35
|
-
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResults>;
|
|
36
|
-
}
|