@tonappchain/sdk 0.5.0 → 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 +228 -149
- package/dist/adapters/contractOpener.js +1 -1
- package/dist/sdk/OperationTracker.d.ts +3 -4
- package/dist/sdk/OperationTracker.js +30 -18
- package/dist/sdk/StartTracking.d.ts +8 -2
- package/dist/sdk/StartTracking.js +77 -40
- package/dist/sdk/TacSdk.d.ts +3 -3
- package/dist/sdk/TacSdk.js +24 -21
- package/dist/sender/SenderFactory.d.ts +8 -8
- package/dist/sender/SenderFactory.js +15 -11
- package/dist/sender/TonConnectSender.d.ts +2 -1
- package/dist/sender/TonConnectSender.js +2 -2
- package/dist/structs/InternalStruct.d.ts +6 -4
- package/dist/structs/InternalStruct.js +2 -2
- package/dist/structs/Struct.d.ts +37 -20
- package/dist/structs/Struct.js +30 -7
- package/package.json +2 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { Network, TransactionLinker, SimplifiedStatuses, StatusInfosByOperationId, StatusInfo, OperationIdsByShardsKey, ExecutionStages, ExecutionStagesByOperationId } from '../structs/Struct';
|
|
1
|
+
import { Network, TransactionLinker, SimplifiedStatuses, StatusInfosByOperationId, StatusInfo, OperationIdsByShardsKey, ExecutionStages, ExecutionStagesByOperationId, OperationType } from '../structs/Struct';
|
|
2
2
|
export declare class OperationTracker {
|
|
3
|
-
readonly TERMINATED_STATUS = "TVMMerkleMessageExecuted";
|
|
4
|
-
readonly BRIDGE_TERMINATED_STATUS = "EVMMerkleMessageExecuted";
|
|
5
3
|
readonly network: Network;
|
|
6
4
|
readonly customLiteSequencerEndpoints: string[];
|
|
7
5
|
constructor(network: Network, customLiteSequencerEndpoints?: string[]);
|
|
6
|
+
getOperationType(operationId: string): Promise<OperationType>;
|
|
8
7
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
9
8
|
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string): Promise<OperationIdsByShardsKey>;
|
|
10
9
|
getStageProfiling(operationId: string): Promise<ExecutionStages>;
|
|
11
10
|
getStageProfilings(operationIds: string[]): Promise<ExecutionStagesByOperationId>;
|
|
12
11
|
getOperationStatuses(operationIds: string[]): Promise<StatusInfosByOperationId>;
|
|
13
12
|
getOperationStatus(operationId: string): Promise<StatusInfo>;
|
|
14
|
-
getSimplifiedOperationStatus(transactionLinker: TransactionLinker
|
|
13
|
+
getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
|
|
15
14
|
}
|
|
@@ -11,28 +11,41 @@ const Utils_1 = require("./Utils");
|
|
|
11
11
|
const artifacts_1 = require("@tonappchain/artifacts");
|
|
12
12
|
class OperationTracker {
|
|
13
13
|
constructor(network, customLiteSequencerEndpoints) {
|
|
14
|
-
this.TERMINATED_STATUS = 'TVMMerkleMessageExecuted';
|
|
15
|
-
this.BRIDGE_TERMINATED_STATUS = 'EVMMerkleMessageExecuted';
|
|
16
14
|
this.network = network;
|
|
17
15
|
this.customLiteSequencerEndpoints =
|
|
18
16
|
customLiteSequencerEndpoints ??
|
|
19
|
-
(this.network === Struct_1.Network.
|
|
17
|
+
(this.network === Struct_1.Network.TESTNET
|
|
20
18
|
? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
|
|
21
19
|
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
22
20
|
}
|
|
23
|
-
async
|
|
21
|
+
async getOperationType(operationId) {
|
|
24
22
|
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
25
23
|
try {
|
|
26
|
-
const response = await axios_1.default.get(`${endpoint}/operation-
|
|
24
|
+
const response = await axios_1.default.get(`${endpoint}/operation-type`, {
|
|
27
25
|
params: {
|
|
28
|
-
|
|
29
|
-
caller: transactionLinker.caller,
|
|
30
|
-
shardCount: transactionLinker.shardCount,
|
|
31
|
-
timestamp: transactionLinker.timestamp,
|
|
26
|
+
operationId,
|
|
32
27
|
},
|
|
33
28
|
});
|
|
34
29
|
return response.data.response || '';
|
|
35
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
|
+
for (const endpoint of this.customLiteSequencerEndpoints) {
|
|
39
|
+
try {
|
|
40
|
+
const requestBody = {
|
|
41
|
+
shardsKey: transactionLinker.shardsKey,
|
|
42
|
+
caller: transactionLinker.caller,
|
|
43
|
+
shardCount: transactionLinker.shardCount,
|
|
44
|
+
timestamp: transactionLinker.timestamp,
|
|
45
|
+
};
|
|
46
|
+
const response = await axios_1.default.post(`${endpoint}/ton/operation-id`, requestBody);
|
|
47
|
+
return response.data.response || '';
|
|
48
|
+
}
|
|
36
49
|
catch (error) {
|
|
37
50
|
console.error(`Failed to get OperationId with ${endpoint}:`, error);
|
|
38
51
|
}
|
|
@@ -109,20 +122,19 @@ class OperationTracker {
|
|
|
109
122
|
}
|
|
110
123
|
return currentStatus;
|
|
111
124
|
}
|
|
112
|
-
async getSimplifiedOperationStatus(transactionLinker
|
|
125
|
+
async getSimplifiedOperationStatus(transactionLinker) {
|
|
113
126
|
const operationId = await this.getOperationId(transactionLinker);
|
|
114
127
|
if (operationId == '') {
|
|
115
|
-
return Struct_1.SimplifiedStatuses.
|
|
128
|
+
return Struct_1.SimplifiedStatuses.OPERATION_ID_NOT_FOUND;
|
|
116
129
|
}
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
return Struct_1.SimplifiedStatuses.
|
|
130
|
+
const operationType = await this.getOperationType(operationId);
|
|
131
|
+
if (operationType == Struct_1.OperationType.PENDING || operationType == Struct_1.OperationType.UNKNOWN) {
|
|
132
|
+
return Struct_1.SimplifiedStatuses.PENDING;
|
|
120
133
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return Struct_1.SimplifiedStatuses.Successful;
|
|
134
|
+
if (operationType == Struct_1.OperationType.ROLLBACK) {
|
|
135
|
+
return Struct_1.SimplifiedStatuses.FAILED;
|
|
124
136
|
}
|
|
125
|
-
return Struct_1.SimplifiedStatuses.
|
|
137
|
+
return Struct_1.SimplifiedStatuses.SUCCESSFUL;
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
exports.OperationTracker = OperationTracker;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import { Network, TransactionLinker } from '../structs/Struct';
|
|
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,10 +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;
|
|
7
|
+
const Struct_1 = require("../structs/Struct");
|
|
4
8
|
const Consts_1 = require("./Consts");
|
|
5
9
|
const OperationTracker_1 = require("./OperationTracker");
|
|
6
10
|
const Utils_1 = require("./Utils");
|
|
7
|
-
|
|
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 || {};
|
|
8
14
|
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints);
|
|
9
15
|
console.log('Start tracking operation');
|
|
10
16
|
console.log('caller: ', transactionLinker.caller);
|
|
@@ -12,80 +18,111 @@ async function startTracking(transactionLinker, network, isBridgeOperation = fal
|
|
|
12
18
|
console.log('shardCount: ', transactionLinker.shardCount);
|
|
13
19
|
console.log('timestamp: ', transactionLinker.timestamp);
|
|
14
20
|
let operationId = '';
|
|
15
|
-
let currentStatus = '';
|
|
16
21
|
let iteration = 0; // number of iterations
|
|
22
|
+
let operationType = '';
|
|
17
23
|
let ok = true; // finished successfully
|
|
18
|
-
let errorMessage;
|
|
24
|
+
let errorMessage = '';
|
|
19
25
|
while (true) {
|
|
20
26
|
++iteration;
|
|
21
|
-
if (iteration >=
|
|
27
|
+
if (iteration >= maxIterationCount) {
|
|
22
28
|
ok = false;
|
|
23
29
|
errorMessage = 'maximum number of iterations has been exceeded';
|
|
24
30
|
break;
|
|
25
31
|
}
|
|
26
32
|
console.log();
|
|
27
|
-
const finalStatus = isBridgeOperation ? tracker.BRIDGE_TERMINATED_STATUS : tracker.TERMINATED_STATUS;
|
|
28
|
-
if (currentStatus == finalStatus) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
33
|
if (operationId == '') {
|
|
32
34
|
console.log('request operationId');
|
|
33
35
|
try {
|
|
34
36
|
operationId = await tracker.getOperationId(transactionLinker);
|
|
35
37
|
}
|
|
36
|
-
catch {
|
|
38
|
+
catch (err) {
|
|
37
39
|
console.log('get operationId error');
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
|
-
console.log('request
|
|
43
|
+
console.log('request operationType');
|
|
42
44
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!status[operationId].success) {
|
|
46
|
-
if (status[operationId].transactions != null && status[operationId].transactions.length > 0) {
|
|
47
|
-
console.log('transactionHash: ', status[operationId].transactions[0]);
|
|
48
|
-
}
|
|
49
|
-
console.log(status[operationId]);
|
|
50
|
-
ok = false;
|
|
51
|
-
errorMessage = status[operationId].note != null ? status[operationId].note.errorName : '';
|
|
45
|
+
operationType = await tracker.getOperationType(operationId);
|
|
46
|
+
if (operationType != Struct_1.OperationType.PENDING && operationType != Struct_1.OperationType.UNKNOWN) {
|
|
52
47
|
break;
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
50
|
catch (err) {
|
|
56
|
-
console.log('get
|
|
51
|
+
console.log('failed to get operation type:', err);
|
|
57
52
|
}
|
|
58
53
|
console.log('operationId:', operationId);
|
|
59
|
-
console.log('
|
|
54
|
+
console.log('operationType:', operationType);
|
|
60
55
|
console.log('time: ', Math.floor(+new Date() / 1000));
|
|
61
56
|
}
|
|
62
|
-
await (0, Utils_1.sleep)(
|
|
57
|
+
await (0, Utils_1.sleep)(delay * 1000);
|
|
63
58
|
}
|
|
59
|
+
console.log('Tracking finished');
|
|
64
60
|
if (!ok) {
|
|
65
|
-
|
|
61
|
+
if (returnValue) {
|
|
62
|
+
throw Error(errorMessage);
|
|
63
|
+
}
|
|
64
|
+
console.log(errorMessage);
|
|
65
|
+
}
|
|
66
|
+
const profilingData = await tracker.getStageProfiling(operationId);
|
|
67
|
+
if (returnValue) {
|
|
68
|
+
return profilingData;
|
|
69
|
+
}
|
|
70
|
+
console.log(profilingData.operationType);
|
|
71
|
+
if (tableView) {
|
|
72
|
+
printExecutionStagesTable(profilingData);
|
|
66
73
|
}
|
|
67
74
|
else {
|
|
68
|
-
console.log(
|
|
75
|
+
console.log(formatExecutionStages(profilingData));
|
|
69
76
|
}
|
|
70
|
-
const stages = await tracker.getStageProfiling(operationId);
|
|
71
|
-
formatExecutionStages(stages);
|
|
72
77
|
}
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
function formatExecutionStages(stages) {
|
|
79
|
+
const { operationType, ...stagesData } = stages;
|
|
80
|
+
return Object.entries(stagesData).map(([stage, data]) => ({
|
|
81
|
+
stage: stage,
|
|
82
|
+
exists: data.exists ? 'Yes' : 'No',
|
|
83
|
+
success: data.exists && data.stageData ? (data.stageData.success ? 'Yes' : 'No') : '-',
|
|
84
|
+
timestamp: data.exists && data.stageData ? new Date(data.stageData.timestamp * 1000).toLocaleString() : '-',
|
|
85
|
+
transactions: data.exists &&
|
|
80
86
|
data.stageData &&
|
|
81
87
|
data.stageData.transactions != null &&
|
|
82
88
|
data.stageData.transactions.length > 0
|
|
83
|
-
? data.stageData.transactions.map((t) => t.hash).join('
|
|
89
|
+
? data.stageData.transactions.map((t) => t.hash).join(' \n')
|
|
84
90
|
: '-',
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
noteContent: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.content : '-',
|
|
92
|
+
errorName: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.errorName : '-',
|
|
93
|
+
internalMsg: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalMsg : '-',
|
|
94
|
+
bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
|
|
89
95
|
}));
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
package/dist/sdk/TacSdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SenderAbstraction } from '../sender';
|
|
2
|
-
import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, UserWalletBalanceExtended,
|
|
2
|
+
import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, UserWalletBalanceExtended, TACSimulationResults, TACSimulationRequest } from '../structs/Struct';
|
|
3
3
|
import { InternalTONParams, InternalTACParams } from '../structs/InternalStruct';
|
|
4
4
|
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
5
5
|
export declare class TacSdk {
|
|
@@ -29,8 +29,8 @@ export declare class TacSdk {
|
|
|
29
29
|
private getRawAmount;
|
|
30
30
|
private convertAssetsToRawFormat;
|
|
31
31
|
private getGasLimit;
|
|
32
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[]): Promise<TransactionLinker>;
|
|
32
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetBridgingData[], forceSend?: boolean): Promise<TransactionLinker>;
|
|
33
33
|
getEVMTokenAddress(tvmTokenAddress: string): Promise<string>;
|
|
34
34
|
getTVMTokenAddress(evmTokenAddress: string): Promise<string>;
|
|
35
|
-
|
|
35
|
+
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResults>;
|
|
36
36
|
}
|
package/dist/sdk/TacSdk.js
CHANGED
|
@@ -33,11 +33,11 @@ class TacSdk {
|
|
|
33
33
|
static async create(sdkParams) {
|
|
34
34
|
const network = sdkParams.network;
|
|
35
35
|
const delay = sdkParams.delay ?? Consts_1.DEFAULT_DELAY;
|
|
36
|
-
const artifacts = network === Struct_1.Network.
|
|
36
|
+
const artifacts = network === Struct_1.Network.TESTNET ? artifacts_1.testnet : artifacts_1.mainnet;
|
|
37
37
|
const TONParams = await this.prepareTONParams(network, delay, artifacts, sdkParams.TONParams);
|
|
38
38
|
const TACParams = await this.prepareTACParams(artifacts, sdkParams.TACParams);
|
|
39
39
|
const liteSequencerEndpoints = sdkParams.customLiteSequencerEndpoints ??
|
|
40
|
-
(network === Struct_1.Network.
|
|
40
|
+
(network === Struct_1.Network.TESTNET
|
|
41
41
|
? artifacts_1.testnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS
|
|
42
42
|
: artifacts_1.mainnet.PUBLIC_LITE_SEQUENCER_ENDPOINTS);
|
|
43
43
|
return new TacSdk(network, delay, artifacts, TONParams, TACParams, liteSequencerEndpoints);
|
|
@@ -151,7 +151,7 @@ class TacSdk {
|
|
|
151
151
|
const givenMinterCode = ton_1.Cell.fromBoc(givenMinterCodeBOC)[0];
|
|
152
152
|
await (0, Utils_1.sleep)(this.delay * 1000);
|
|
153
153
|
if (!this.TONParams.jettonMinterCode.equals(givenMinterCode)) {
|
|
154
|
-
return InternalStruct_1.AssetOpType.
|
|
154
|
+
return InternalStruct_1.AssetOpType.JETTON_TRANSFER;
|
|
155
155
|
}
|
|
156
156
|
const givenMinter = this.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster((0, ton_1.address)(asset.address)));
|
|
157
157
|
const l2Address = await givenMinter.getL2Address();
|
|
@@ -164,9 +164,9 @@ class TacSdk {
|
|
|
164
164
|
.storeStringTail(l2Address)
|
|
165
165
|
.endCell());
|
|
166
166
|
if (!expectedMinterAddress.equals(givenMinter.address)) {
|
|
167
|
-
return InternalStruct_1.AssetOpType.
|
|
167
|
+
return InternalStruct_1.AssetOpType.JETTON_TRANSFER;
|
|
168
168
|
}
|
|
169
|
-
return InternalStruct_1.AssetOpType.
|
|
169
|
+
return InternalStruct_1.AssetOpType.JETTON_BURN;
|
|
170
170
|
}
|
|
171
171
|
async aggregateJettons(assets) {
|
|
172
172
|
const uniqueAssetsMap = new Map();
|
|
@@ -197,13 +197,13 @@ class TacSdk {
|
|
|
197
197
|
console.log(`***** Jetton ${jetton.address} requires ${opType} operation`);
|
|
198
198
|
let payload;
|
|
199
199
|
switch (opType) {
|
|
200
|
-
case InternalStruct_1.AssetOpType.
|
|
200
|
+
case InternalStruct_1.AssetOpType.JETTON_BURN:
|
|
201
201
|
payload = this.getJettonBurnPayload({
|
|
202
202
|
notificationReceiverAddress: this.TONParams.crossChainLayerAddress,
|
|
203
203
|
...jetton,
|
|
204
204
|
}, evmData, crossChainTonAmount);
|
|
205
205
|
break;
|
|
206
|
-
case InternalStruct_1.AssetOpType.
|
|
206
|
+
case InternalStruct_1.AssetOpType.JETTON_TRANSFER:
|
|
207
207
|
payload = this.getJettonTransferPayload(jetton, caller, evmData, crossChainTonAmount);
|
|
208
208
|
break;
|
|
209
209
|
}
|
|
@@ -269,35 +269,38 @@ class TacSdk {
|
|
|
269
269
|
};
|
|
270
270
|
}));
|
|
271
271
|
}
|
|
272
|
-
async getGasLimit(evmProxyMsg, transactionLinker, rawAssets) {
|
|
273
|
-
const
|
|
274
|
-
|
|
272
|
+
async getGasLimit(evmProxyMsg, transactionLinker, rawAssets, forceSend = false) {
|
|
273
|
+
const tacSimulationBody = {
|
|
274
|
+
tacCallParams: {
|
|
275
275
|
arguments: evmProxyMsg.encodedParameters ?? '0x',
|
|
276
276
|
methodName: (0, Utils_1.formatSolidityMethodName)(evmProxyMsg.methodName),
|
|
277
277
|
target: evmProxyMsg.evmTargetAddress,
|
|
278
278
|
},
|
|
279
279
|
extraData: '0x',
|
|
280
280
|
feeAssetAddress: '',
|
|
281
|
-
shardsKey:
|
|
282
|
-
|
|
281
|
+
shardsKey: transactionLinker.shardsKey,
|
|
282
|
+
tonAssets: rawAssets.map((asset) => ({
|
|
283
283
|
amount: asset.rawAmount.toString(),
|
|
284
284
|
tokenAddress: asset.address || '',
|
|
285
285
|
})),
|
|
286
|
-
|
|
286
|
+
tonCaller: transactionLinker.caller,
|
|
287
287
|
};
|
|
288
|
-
const
|
|
289
|
-
if (!
|
|
290
|
-
|
|
288
|
+
const tacSimulationResult = await this.simulateTACMessage(tacSimulationBody);
|
|
289
|
+
if (!tacSimulationResult.simulationStatus) {
|
|
290
|
+
if (forceSend) {
|
|
291
|
+
return 0n;
|
|
292
|
+
}
|
|
293
|
+
throw tacSimulationResult;
|
|
291
294
|
}
|
|
292
|
-
return (BigInt(
|
|
295
|
+
return (BigInt(tacSimulationResult.estimatedGas) * 120n) / 100n;
|
|
293
296
|
}
|
|
294
|
-
async sendCrossChainTransaction(evmProxyMsg, sender, assets) {
|
|
297
|
+
async sendCrossChainTransaction(evmProxyMsg, sender, assets, forceSend = false) {
|
|
295
298
|
const rawAssets = await this.convertAssetsToRawFormat(assets);
|
|
296
299
|
const aggregatedData = await this.aggregateJettons(rawAssets);
|
|
297
300
|
const transactionLinkerShardCount = aggregatedData.jettons.length == 0 ? 1 : aggregatedData.jettons.length;
|
|
298
301
|
const caller = sender.getSenderAddress();
|
|
299
302
|
const transactionLinker = (0, Utils_1.generateTransactionLinker)(caller, transactionLinkerShardCount);
|
|
300
|
-
const gasLimit = await this.getGasLimit(evmProxyMsg, transactionLinker, rawAssets);
|
|
303
|
+
const gasLimit = await this.getGasLimit(evmProxyMsg, transactionLinker, rawAssets, forceSend);
|
|
301
304
|
if (evmProxyMsg.gasLimit == 0n || evmProxyMsg.gasLimit == undefined) {
|
|
302
305
|
evmProxyMsg.gasLimit = gasLimit;
|
|
303
306
|
}
|
|
@@ -343,10 +346,10 @@ class TacSdk {
|
|
|
343
346
|
});
|
|
344
347
|
return jettonMaster.address.toString();
|
|
345
348
|
}
|
|
346
|
-
async
|
|
349
|
+
async simulateTACMessage(req) {
|
|
347
350
|
for (const endpoint of this.liteSequencerEndpoints) {
|
|
348
351
|
try {
|
|
349
|
-
const response = await axios_1.default.post(`${endpoint}/
|
|
352
|
+
const response = await axios_1.default.post(`${endpoint}/tac/simulator/simulate-message`, req, {
|
|
350
353
|
transformResponse: [Utils_1.toCamelCaseTransformer],
|
|
351
354
|
});
|
|
352
355
|
return response.data.response;
|
|
@@ -3,15 +3,15 @@ import { TonConnectUI } from '@tonconnect/ui';
|
|
|
3
3
|
import { SenderAbstraction } from './SenderAbstraction';
|
|
4
4
|
import { Network } from '../structs/Struct';
|
|
5
5
|
import { HighloadWalletV3 } from '../wrappers/HighloadWalletV3';
|
|
6
|
-
export type WalletVersion = '
|
|
6
|
+
export type WalletVersion = 'V2R1' | 'V2R2' | 'V3R1' | 'V3R2' | 'V4' | 'V5R1' | 'HIGHLOAD_V3';
|
|
7
7
|
export declare const wallets: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
V2R1: typeof WalletContractV2R1;
|
|
9
|
+
V2R2: typeof WalletContractV2R2;
|
|
10
|
+
V3R1: typeof WalletContractV3R1;
|
|
11
|
+
V3R2: typeof WalletContractV3R2;
|
|
12
|
+
V4: typeof WalletContractV4;
|
|
13
|
+
V5R1: typeof WalletContractV5R1;
|
|
14
|
+
HIGHLOAD_V3: typeof HighloadWalletV3;
|
|
15
15
|
};
|
|
16
16
|
export declare class SenderFactory {
|
|
17
17
|
static getSender(params: {
|
|
@@ -9,13 +9,13 @@ const errors_1 = require("../errors");
|
|
|
9
9
|
const Struct_1 = require("../structs/Struct");
|
|
10
10
|
const HighloadWalletV3_1 = require("../wrappers/HighloadWalletV3");
|
|
11
11
|
exports.wallets = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
V2R1: ton_1.WalletContractV2R1,
|
|
13
|
+
V2R2: ton_1.WalletContractV2R2,
|
|
14
|
+
V3R1: ton_1.WalletContractV3R1,
|
|
15
|
+
V3R2: ton_1.WalletContractV3R2,
|
|
16
|
+
V4: ton_1.WalletContractV4,
|
|
17
|
+
V5R1: ton_1.WalletContractV5R1,
|
|
18
|
+
HIGHLOAD_V3: HighloadWalletV3_1.HighloadWalletV3,
|
|
19
19
|
};
|
|
20
20
|
class SenderFactory {
|
|
21
21
|
static async getSender(params) {
|
|
@@ -33,14 +33,18 @@ class SenderFactory {
|
|
|
33
33
|
subwalletId: undefined, // for highload v3
|
|
34
34
|
timeout: undefined, // for highload v3
|
|
35
35
|
};
|
|
36
|
-
if (params.version === '
|
|
36
|
+
if (params.version === 'V5R1') {
|
|
37
37
|
// manual setup of wallet id required to support wallet w5 both on mainnet and testnet
|
|
38
38
|
config.walletId = {
|
|
39
|
-
networkGlobalId: params.network === Struct_1.Network.
|
|
40
|
-
context: {
|
|
39
|
+
networkGlobalId: params.network === Struct_1.Network.TESTNET ? -3 : -239,
|
|
40
|
+
context: {
|
|
41
|
+
walletVersion: 'v5r1',
|
|
42
|
+
workchain: 0,
|
|
43
|
+
subwalletNumber: params.options?.v5r1?.subwalletNumber ?? 0,
|
|
44
|
+
},
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
if (params.version === '
|
|
47
|
+
if (params.version === 'HIGHLOAD_V3') {
|
|
44
48
|
config.subwalletId = params.options?.highloadV3?.subwalletId ?? HighloadWalletV3_1.DEFAULT_SUBWALLET_ID;
|
|
45
49
|
config.timeout = params.options?.highloadV3?.timeout ?? HighloadWalletV3_1.DEFAULT_TIMEOUT;
|
|
46
50
|
}
|
|
@@ -2,9 +2,10 @@ import { TonConnectUI } from '@tonconnect/ui';
|
|
|
2
2
|
import type { ShardTransaction } from '../structs/InternalStruct';
|
|
3
3
|
import { Network } from '../structs/Struct';
|
|
4
4
|
import { SenderAbstraction } from './SenderAbstraction';
|
|
5
|
+
import { SendTransactionResponse } from '@tonconnect/sdk';
|
|
5
6
|
export declare class TonConnectSender implements SenderAbstraction {
|
|
6
7
|
readonly tonConnect: TonConnectUI;
|
|
7
8
|
constructor(tonConnect: TonConnectUI);
|
|
8
9
|
getSenderAddress(): string;
|
|
9
|
-
sendShardTransaction(shardTransaction: ShardTransaction, delay: number, chain: Network): Promise<
|
|
10
|
+
sendShardTransaction(shardTransaction: ShardTransaction, delay: number, chain: Network): Promise<SendTransactionResponse>;
|
|
10
11
|
}
|
|
@@ -24,10 +24,10 @@ class TonConnectSender {
|
|
|
24
24
|
const transaction = {
|
|
25
25
|
validUntil: shardTransaction.validUntil,
|
|
26
26
|
messages,
|
|
27
|
-
network: chain == Struct_1.Network.
|
|
27
|
+
network: chain == Struct_1.Network.TESTNET ? ui_1.CHAIN.TESTNET : ui_1.CHAIN.MAINNET,
|
|
28
28
|
};
|
|
29
29
|
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
30
|
-
|
|
30
|
+
return this.tonConnect.sendTransaction(transaction);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.TonConnectSender = TonConnectSender;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cell } from '@ton/ton';
|
|
2
|
-
import { ContractOpener,
|
|
2
|
+
import { ContractOpener, TACSimulationResults, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, RawAssetBridgingData, StatusInfosByOperationId, OperationType } from './Struct';
|
|
3
3
|
import { AbstractProvider, ethers, Interface, InterfaceAbi } from 'ethers';
|
|
4
4
|
export type ShardMessage = {
|
|
5
5
|
address: string;
|
|
@@ -12,8 +12,8 @@ export type ShardTransaction = {
|
|
|
12
12
|
network: Network;
|
|
13
13
|
};
|
|
14
14
|
export declare enum AssetOpType {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
JETTON_BURN = "JETTON_BURN",
|
|
16
|
+
JETTON_TRANSFER = "JETTON_TRANSFER"
|
|
17
17
|
}
|
|
18
18
|
export type RandomNumberByTimestamp = {
|
|
19
19
|
timestamp: number;
|
|
@@ -46,7 +46,9 @@ export type InternalTACParams = {
|
|
|
46
46
|
export type ResponseBase<T> = {
|
|
47
47
|
response: T;
|
|
48
48
|
};
|
|
49
|
+
export type StringResponse = ResponseBase<string>;
|
|
50
|
+
export type OperationTypeResponse = ResponseBase<OperationType>;
|
|
49
51
|
export type StatusesResponse = ResponseBase<StatusInfosByOperationId>;
|
|
50
52
|
export type OperationIdsByShardsKeyResponse = ResponseBase<OperationIdsByShardsKey>;
|
|
51
53
|
export type StageProfilingResponse = ResponseBase<ExecutionStagesByOperationId>;
|
|
52
|
-
export type
|
|
54
|
+
export type TACSimulationResponse = ResponseBase<TACSimulationResults>;
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AssetOpType = void 0;
|
|
4
4
|
var AssetOpType;
|
|
5
5
|
(function (AssetOpType) {
|
|
6
|
-
AssetOpType["
|
|
7
|
-
AssetOpType["
|
|
6
|
+
AssetOpType["JETTON_BURN"] = "JETTON_BURN";
|
|
7
|
+
AssetOpType["JETTON_TRANSFER"] = "JETTON_TRANSFER";
|
|
8
8
|
})(AssetOpType || (exports.AssetOpType = AssetOpType = {}));
|