@tonappchain/sdk 0.6.4 → 0.6.5-smart-accounts-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 +1 -0
- package/dist/adapters/contractOpener.js +1 -2
- package/dist/adapters/retryableContractOpener.d.ts +21 -0
- package/dist/adapters/retryableContractOpener.js +101 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +2 -1
- package/dist/errors/instances.d.ts +5 -3
- package/dist/errors/instances.js +9 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +13 -13
- package/dist/sdk/Consts.js +2 -2
- package/dist/sdk/LiteSequencerClient.d.ts +1 -1
- package/dist/sdk/LiteSequencerClient.js +5 -11
- package/dist/sdk/OperationTracker.d.ts +11 -9
- package/dist/sdk/OperationTracker.js +150 -72
- package/dist/sdk/TacSdk.d.ts +11 -6
- package/dist/sdk/TacSdk.js +176 -53
- package/dist/sdk/Utils.d.ts +4 -2
- package/dist/sdk/Utils.js +46 -1
- package/dist/structs/InternalStruct.d.ts +2 -1
- package/dist/structs/Struct.d.ts +41 -5
- package/dist/structs/Struct.js +6 -1
- package/dist/wrappers/ContentUtils.js +1 -1
- package/dist/wrappers/JettonWallet.d.ts +11 -2
- package/dist/wrappers/JettonWallet.js +34 -17
- package/package.json +3 -2
|
@@ -1,110 +1,188 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationTracker = void 0;
|
|
4
|
-
const Struct_1 = require("../structs/Struct");
|
|
5
4
|
const artifacts_1 = require("@tonappchain/artifacts");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const Struct_1 = require("../structs/Struct");
|
|
6
7
|
const LiteSequencerClient_1 = require("./LiteSequencerClient");
|
|
8
|
+
const Utils_1 = require("./Utils");
|
|
7
9
|
class OperationTracker {
|
|
8
|
-
constructor(network, customLiteSequencerEndpoints) {
|
|
10
|
+
constructor(network, customLiteSequencerEndpoints, debug = false) {
|
|
9
11
|
const endpoints = customLiteSequencerEndpoints ??
|
|
10
12
|
(network === Struct_1.Network.TESTNET
|
|
11
13
|
? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
|
|
12
14
|
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
13
15
|
this.clients = endpoints.map((endpoint) => new LiteSequencerClient_1.LiteSequencerClient(endpoint));
|
|
16
|
+
this.debug = debug;
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return await client.getOperationType(operationId);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error('Failed to get operationType:', error);
|
|
22
|
-
}
|
|
18
|
+
debugLog(message) {
|
|
19
|
+
if (this.debug) {
|
|
20
|
+
console.log(`[OperationTracker Debug] ${message}`);
|
|
23
21
|
}
|
|
24
|
-
throw new Error('All endpoints failed to get operation type');
|
|
25
22
|
}
|
|
26
|
-
async
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
async getOperationType(operationId, waitOptions) {
|
|
24
|
+
this.debugLog(`Getting operation type for ${(0, Utils_1.formatObjectForLogging)(operationId)}`);
|
|
25
|
+
const requestFn = async () => {
|
|
26
|
+
let lastError;
|
|
27
|
+
for (const client of this.clients) {
|
|
28
|
+
try {
|
|
29
|
+
const type = await client.getOperationType(operationId);
|
|
30
|
+
this.debugLog(`Operation retrieved successfully`);
|
|
31
|
+
return type;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
this.debugLog(`Failed to get operationType using one of the endpoints`);
|
|
35
|
+
lastError = error;
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
this.debugLog('All endpoints failed to get operation type');
|
|
39
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
40
|
+
};
|
|
41
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
36
42
|
}
|
|
37
|
-
async
|
|
38
|
-
for
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
async getOperationId(transactionLinker, waitOptions) {
|
|
44
|
+
this.debugLog(`Getting operation ID for transaction linker: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
45
|
+
const requestFn = async () => {
|
|
46
|
+
let lastError;
|
|
47
|
+
for (const client of this.clients) {
|
|
48
|
+
try {
|
|
49
|
+
const id = await client.getOperationId(transactionLinker);
|
|
50
|
+
this.debugLog(`Operation ID ${id == '' ? 'does not exist' : 'retrieved successfully'}`);
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.debugLog(`Failed to get OperationId using one of the endpoints`);
|
|
55
|
+
lastError = error;
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
this.debugLog('All endpoints failed to get operation id');
|
|
59
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
60
|
+
};
|
|
61
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
47
62
|
}
|
|
48
|
-
async
|
|
49
|
-
for
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
async getOperationIdsByShardsKeys(shardsKeys, caller, waitOptions, chunkSize = 100) {
|
|
64
|
+
this.debugLog(`Getting operation IDs for shards keys: ${(0, Utils_1.formatObjectForLogging)(shardsKeys)}`);
|
|
65
|
+
this.debugLog(`Caller: ${caller}, Chunk size: ${chunkSize}`);
|
|
66
|
+
const requestFn = async () => {
|
|
67
|
+
let lastError;
|
|
68
|
+
for (const client of this.clients) {
|
|
69
|
+
try {
|
|
70
|
+
const result = await client.getOperationIdsByShardsKeys(shardsKeys, caller, chunkSize);
|
|
71
|
+
this.debugLog(`Operation IDs by shards keys retrieved successfully`);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.debugLog(`Failed to get OperationIds using one of the endpoints`);
|
|
76
|
+
lastError = error;
|
|
55
77
|
}
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error('Failed to get stage profiling:', error);
|
|
60
78
|
}
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
this.debugLog('All endpoints failed to get operation ids by shards keys');
|
|
80
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
81
|
+
};
|
|
82
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
63
83
|
}
|
|
64
|
-
async
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
async getStageProfiling(operationId, waitOptions) {
|
|
85
|
+
this.debugLog(`Getting stage profiling for operation ${operationId}`);
|
|
86
|
+
const requestFn = async () => {
|
|
87
|
+
let lastError;
|
|
88
|
+
for (const client of this.clients) {
|
|
89
|
+
try {
|
|
90
|
+
const map = await client.getStageProfilings([operationId]);
|
|
91
|
+
const result = map[operationId];
|
|
92
|
+
if (!result) {
|
|
93
|
+
this.debugLog(`No stageProfiling data for operationId=${operationId}`);
|
|
94
|
+
throw new Error(`No stageProfiling data for operationId=${operationId}`);
|
|
95
|
+
}
|
|
96
|
+
this.debugLog(`Stage profiling retrieved successfully`);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
this.debugLog(`Failed to get stage profiling using one of the endpoints`);
|
|
101
|
+
lastError = error;
|
|
102
|
+
}
|
|
71
103
|
}
|
|
72
|
-
|
|
73
|
-
|
|
104
|
+
this.debugLog('All endpoints failed to get stage profiling');
|
|
105
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
106
|
+
};
|
|
107
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
74
108
|
}
|
|
75
|
-
async
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
async getStageProfilings(operationIds, waitOptions, chunkSize = 100) {
|
|
110
|
+
this.debugLog(`Getting stage profilings for operations: ${operationIds.join(', ')}`);
|
|
111
|
+
this.debugLog(`Chunk size: ${chunkSize}`);
|
|
112
|
+
const requestFn = async () => {
|
|
113
|
+
let lastError;
|
|
114
|
+
for (const client of this.clients) {
|
|
115
|
+
try {
|
|
116
|
+
const result = await client.getStageProfilings(operationIds, chunkSize);
|
|
117
|
+
this.debugLog(`Stage profilings retrieved successfully`);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
this.debugLog(`Failed to get stage profilings using one of the endpoints`);
|
|
122
|
+
lastError = error;
|
|
123
|
+
}
|
|
82
124
|
}
|
|
83
|
-
|
|
84
|
-
|
|
125
|
+
this.debugLog('All endpoints failed to get stage profilings');
|
|
126
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
127
|
+
};
|
|
128
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
85
129
|
}
|
|
86
|
-
async
|
|
87
|
-
for (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
130
|
+
async getOperationStatuses(operationIds, waitOptions, chunkSize = 100) {
|
|
131
|
+
this.debugLog(`Getting operation statuses for operations: ${(0, Utils_1.formatObjectForLogging)(operationIds)}`);
|
|
132
|
+
this.debugLog(`Chunk size: ${chunkSize}`);
|
|
133
|
+
const requestFn = async () => {
|
|
134
|
+
let lastError;
|
|
135
|
+
for (const client of this.clients) {
|
|
136
|
+
try {
|
|
137
|
+
const result = await client.getOperationStatuses(operationIds, chunkSize);
|
|
138
|
+
this.debugLog(`Operation statuses retrieved successfully`);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
this.debugLog(`Failed to get operation statuses using one of the endpoints`);
|
|
143
|
+
lastError = error;
|
|
93
144
|
}
|
|
94
|
-
return result;
|
|
95
145
|
}
|
|
96
|
-
|
|
97
|
-
|
|
146
|
+
this.debugLog('All endpoints failed to get operation statuses');
|
|
147
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
148
|
+
};
|
|
149
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
150
|
+
}
|
|
151
|
+
async getOperationStatus(operationId, waitOptions) {
|
|
152
|
+
this.debugLog(`Getting operation status for ${(0, Utils_1.formatObjectForLogging)(operationId)}`);
|
|
153
|
+
const requestFn = async () => {
|
|
154
|
+
let lastError;
|
|
155
|
+
for (const client of this.clients) {
|
|
156
|
+
try {
|
|
157
|
+
const map = await client.getOperationStatuses([operationId]);
|
|
158
|
+
const result = map[operationId];
|
|
159
|
+
if (!result) {
|
|
160
|
+
this.debugLog(`No operation status for operationId=${operationId}`);
|
|
161
|
+
throw new Error(`No operation status for operationId=${operationId}`);
|
|
162
|
+
}
|
|
163
|
+
this.debugLog(`Operation status retrieved successfully`);
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
this.debugLog(`Failed to get operation status using one of the endpoints`);
|
|
168
|
+
lastError = error;
|
|
169
|
+
}
|
|
98
170
|
}
|
|
99
|
-
|
|
100
|
-
|
|
171
|
+
this.debugLog('All endpoints failed to get operation status');
|
|
172
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError);
|
|
173
|
+
};
|
|
174
|
+
return waitOptions ? await (0, Utils_1.waitUntilSuccess)(waitOptions, requestFn) : await requestFn();
|
|
101
175
|
}
|
|
102
176
|
async getSimplifiedOperationStatus(transactionLinker) {
|
|
177
|
+
this.debugLog(`Getting simplified operation status for transaction linker: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
103
178
|
const operationId = await this.getOperationId(transactionLinker);
|
|
104
179
|
if (operationId == '') {
|
|
180
|
+
this.debugLog('Operation ID not found');
|
|
105
181
|
return Struct_1.SimplifiedStatuses.OPERATION_ID_NOT_FOUND;
|
|
106
182
|
}
|
|
183
|
+
this.debugLog(`Operation ID: ${operationId}`);
|
|
107
184
|
const operationType = await this.getOperationType(operationId);
|
|
185
|
+
this.debugLog(`Operation type: ${operationType}`);
|
|
108
186
|
if (operationType == Struct_1.OperationType.PENDING || operationType == Struct_1.OperationType.UNKNOWN) {
|
|
109
187
|
return Struct_1.SimplifiedStatuses.PENDING;
|
|
110
188
|
}
|
package/dist/sdk/TacSdk.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
1
2
|
import { Wallet } from 'ethers';
|
|
2
3
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { InternalTACParams, InternalTONParams } from '../structs/InternalStruct';
|
|
5
|
+
import { AssetBridgingData, CrossChainTransactionOptions, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, Network, NFTAddressType, NFTItemData, OperationIdsByShardsKey, RawAssetBridgingData, SDKParams, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinkerWithOperationId, UserWalletBalanceExtended, WaitOptions, WithAddressNFTCollectionItem } from '../structs/Struct';
|
|
6
|
+
import { OperationTracker } from './OperationTracker';
|
|
6
7
|
export declare class TacSdk {
|
|
7
8
|
readonly network: Network;
|
|
8
9
|
readonly delay: number;
|
|
@@ -10,6 +11,8 @@ export declare class TacSdk {
|
|
|
10
11
|
readonly TONParams: InternalTONParams;
|
|
11
12
|
readonly TACParams: InternalTACParams;
|
|
12
13
|
readonly liteSequencerEndpoints: string[];
|
|
14
|
+
readonly operationTracker: OperationTracker;
|
|
15
|
+
readonly debug: boolean;
|
|
13
16
|
private constructor();
|
|
14
17
|
static create(sdkParams: SDKParams): Promise<TacSdk>;
|
|
15
18
|
private static prepareTONParams;
|
|
@@ -19,12 +22,14 @@ export declare class TacSdk {
|
|
|
19
22
|
nativeTACAddress(): Promise<string>;
|
|
20
23
|
getUserJettonWalletAddress(userAddress: string, tokenAddress: string): Promise<string>;
|
|
21
24
|
getUserJettonBalance(userAddress: string, tokenAddress: string): Promise<bigint>;
|
|
25
|
+
getTacSmartAccountAddress(tvmUserAddress: string, evmApplicationAddress: string): Promise<string>;
|
|
22
26
|
getUserJettonBalanceExtended(userAddress: string, tokenAddress: string): Promise<UserWalletBalanceExtended>;
|
|
23
27
|
private getJettonTransferPayload;
|
|
24
28
|
private getJettonBurnPayload;
|
|
25
29
|
private getNFTBurnPayload;
|
|
26
30
|
private getNFTTransferPayload;
|
|
27
31
|
private getTonTransferPayload;
|
|
32
|
+
private debugLog;
|
|
28
33
|
private getJettonOpType;
|
|
29
34
|
private getNFTOpType;
|
|
30
35
|
private getNFTItemAddressTON;
|
|
@@ -37,10 +42,10 @@ export declare class TacSdk {
|
|
|
37
42
|
private convertAssetsToRawFormat;
|
|
38
43
|
private getFeeInfo;
|
|
39
44
|
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[]): Promise<ExecutionFeeEstimationResult>;
|
|
40
|
-
getTVMExecutorFeeInfo(assets: AssetBridgingData[], feeSymbol:
|
|
45
|
+
getTVMExecutorFeeInfo(assets: AssetBridgingData[], feeSymbol: string): Promise<SuggestedTONExecutorFee>;
|
|
41
46
|
private prepareCrossChainTransaction;
|
|
42
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], options?: CrossChainTransactionOptions): Promise<
|
|
43
|
-
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<
|
|
47
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
|
|
48
|
+
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
|
|
44
49
|
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: RawAssetBridgingData<WithAddressNFTCollectionItem>[], tvmExecutorFee?: bigint): Promise<string>;
|
|
45
50
|
get getTrustedTACExecutors(): string[];
|
|
46
51
|
get getTrustedTONExecutors(): string[];
|