@tonappchain/sdk 0.5.0 → 0.5.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.
@@ -17,7 +17,7 @@ function intToIP(int) {
17
17
  return part4 + '.' + part3 + '.' + part2 + '.' + part1;
18
18
  }
19
19
  async function getDefaultLiteServers(network) {
20
- const url = network === Struct_1.Network.Testnet ? artifacts_1.testnet.DEFAULT_LITESERVERS : artifacts_1.mainnet.DEFAULT_LITESERVERS;
20
+ const url = network === Struct_1.Network.TESTNET ? artifacts_1.testnet.DEFAULT_LITESERVERS : artifacts_1.mainnet.DEFAULT_LITESERVERS;
21
21
  const resp = await fetch(url);
22
22
  const liteClients = await resp.json();
23
23
  return liteClients.liteservers;
@@ -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, isBridgeOperation?: boolean): Promise<SimplifiedStatuses>;
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.Testnet
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 getOperationId(transactionLinker) {
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-id`, {
24
+ const response = await axios_1.default.get(`${endpoint}/operation-type`, {
27
25
  params: {
28
- shardsKey: transactionLinker.shardsKey,
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, isBridgeOperation = false) {
125
+ async getSimplifiedOperationStatus(transactionLinker) {
113
126
  const operationId = await this.getOperationId(transactionLinker);
114
127
  if (operationId == '') {
115
- return Struct_1.SimplifiedStatuses.OperationIdNotFound;
128
+ return Struct_1.SimplifiedStatuses.OPERATION_ID_NOT_FOUND;
116
129
  }
117
- const status = await this.getOperationStatus(operationId);
118
- if (!status.success) {
119
- return Struct_1.SimplifiedStatuses.Failed;
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
- const finalStatus = isBridgeOperation ? this.BRIDGE_TERMINATED_STATUS : this.TERMINATED_STATUS;
122
- if (status.stage == finalStatus) {
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.Pending;
137
+ return Struct_1.SimplifiedStatuses.SUCCESSFUL;
126
138
  }
127
139
  }
128
140
  exports.OperationTracker = OperationTracker;
@@ -1,2 +1,2 @@
1
- import { Network, TransactionLinker } from '../structs/Struct';
2
- export declare function startTracking(transactionLinker: TransactionLinker, network: Network, isBridgeOperation?: boolean, customLiteSequencerEndpoints?: string[]): Promise<void>;
1
+ import { Network, TrackingOperationResult, TransactionLinker } from '../structs/Struct';
2
+ export declare function startTracking(transactionLinker: TransactionLinker, network: Network, customLiteSequencerEndpoints?: string[], delay?: number, maxIterationCount?: number, returnValue?: boolean): Promise<void | TrackingOperationResult>;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startTracking = startTracking;
4
+ const Struct_1 = require("../structs/Struct");
4
5
  const Consts_1 = require("./Consts");
5
6
  const OperationTracker_1 = require("./OperationTracker");
6
7
  const Utils_1 = require("./Utils");
7
- async function startTracking(transactionLinker, network, isBridgeOperation = false, customLiteSequencerEndpoints) {
8
+ async function startTracking(transactionLinker, network, customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false) {
8
9
  const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints);
9
10
  console.log('Start tracking operation');
10
11
  console.log('caller: ', transactionLinker.caller);
@@ -12,80 +13,72 @@ async function startTracking(transactionLinker, network, isBridgeOperation = fal
12
13
  console.log('shardCount: ', transactionLinker.shardCount);
13
14
  console.log('timestamp: ', transactionLinker.timestamp);
14
15
  let operationId = '';
15
- let currentStatus = '';
16
16
  let iteration = 0; // number of iterations
17
+ let operationType = '';
17
18
  let ok = true; // finished successfully
18
19
  let errorMessage;
19
20
  while (true) {
20
21
  ++iteration;
21
- if (iteration >= Consts_1.MAX_ITERATION_COUNT) {
22
+ if (iteration >= maxIterationCount) {
22
23
  ok = false;
23
24
  errorMessage = 'maximum number of iterations has been exceeded';
24
25
  break;
25
26
  }
26
27
  console.log();
27
- const finalStatus = isBridgeOperation ? tracker.BRIDGE_TERMINATED_STATUS : tracker.TERMINATED_STATUS;
28
- if (currentStatus == finalStatus) {
29
- break;
30
- }
31
28
  if (operationId == '') {
32
29
  console.log('request operationId');
33
30
  try {
34
31
  operationId = await tracker.getOperationId(transactionLinker);
35
32
  }
36
- catch {
33
+ catch (err) {
37
34
  console.log('get operationId error');
38
35
  }
39
36
  }
40
37
  else {
41
- console.log('request operationStatus');
38
+ console.log('request operationType');
42
39
  try {
43
- const status = await tracker.getOperationStatuses([operationId]);
44
- currentStatus = status[operationId].stage;
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 : '';
40
+ operationType = await tracker.getOperationType(operationId);
41
+ if (operationType != Struct_1.OperationType.PENDING && operationType != Struct_1.OperationType.UNKNOWN) {
52
42
  break;
53
43
  }
54
44
  }
55
45
  catch (err) {
56
- console.log('get status error:', err);
46
+ console.log('failed to get operation type:', err);
57
47
  }
58
48
  console.log('operationId:', operationId);
59
- console.log('status: ', currentStatus);
49
+ console.log('operationType:', operationType);
60
50
  console.log('time: ', Math.floor(+new Date() / 1000));
61
51
  }
62
- await (0, Utils_1.sleep)(10 * 1000);
52
+ await (0, Utils_1.sleep)(delay * 1000);
63
53
  }
54
+ console.log('Tracking finished');
64
55
  if (!ok) {
65
- console.log(`Finished with error: ${errorMessage}`);
56
+ console.log(errorMessage);
66
57
  }
67
- else {
68
- console.log('Tracking successfully finished');
58
+ const profilingData = await tracker.getStageProfiling(operationId);
59
+ const tableData = formatExecutionStages(profilingData);
60
+ if (returnValue) {
61
+ return { profilingData, tableData };
69
62
  }
70
- const stages = await tracker.getStageProfiling(operationId);
71
- formatExecutionStages(stages);
63
+ console.log(profilingData.operationType);
64
+ console.table(tableData);
72
65
  }
73
- const formatExecutionStages = (stages) => {
74
- const tableData = Object.entries(stages).map(([stage, data]) => ({
75
- Stage: stage,
76
- Exists: data.exists ? 'Yes' : 'No',
77
- Success: data.exists && data.stageData ? (data.stageData.success ? 'Yes' : 'No') : '-',
78
- Timestamp: data.exists && data.stageData ? new Date(data.stageData.timestamp * 1000).toLocaleString() : '-',
79
- Transactions: data.exists &&
66
+ function formatExecutionStages(stages) {
67
+ const { operationType, ...stagesData } = stages;
68
+ return Object.entries(stagesData).map(([stage, data]) => ({
69
+ stage: stage,
70
+ exists: data.exists ? 'Yes' : 'No',
71
+ success: data.exists && data.stageData ? (data.stageData.success ? 'Yes' : 'No') : '-',
72
+ timestamp: data.exists && data.stageData ? new Date(data.stageData.timestamp * 1000).toLocaleString() : '-',
73
+ transactions: data.exists &&
80
74
  data.stageData &&
81
75
  data.stageData.transactions != null &&
82
76
  data.stageData.transactions.length > 0
83
77
  ? data.stageData.transactions.map((t) => t.hash).join(', ')
84
78
  : '-',
85
- 'Note Content': data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.content : '-',
86
- 'Error Name': data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.errorName : '-',
87
- 'Internal Msg': data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalMsg : '-',
88
- 'Bytes Error': data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
79
+ noteContent: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.content : '-',
80
+ errorName: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.errorName : '-',
81
+ internalMsg: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalMsg : '-',
82
+ bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
89
83
  }));
90
- console.table(tableData);
91
- };
84
+ }
@@ -1,5 +1,5 @@
1
1
  import type { SenderAbstraction } from '../sender';
2
- import { AssetBridgingData, EvmProxyMsg, Network, SDKParams, TransactionLinker, UserWalletBalanceExtended, EVMSimulationResults, EVMSimulationRequest } from '../structs/Struct';
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
- simulateEVMMessage(req: EVMSimulationRequest): Promise<EVMSimulationResults>;
35
+ simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResults>;
36
36
  }
@@ -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.Testnet ? artifacts_1.testnet : artifacts_1.mainnet;
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.Testnet
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.JettonTransfer;
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.JettonTransfer;
167
+ return InternalStruct_1.AssetOpType.JETTON_TRANSFER;
168
168
  }
169
- return InternalStruct_1.AssetOpType.JettonBurn;
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.JettonBurn:
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.JettonTransfer:
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 evmSimulationBody = {
274
- evmCallParams: {
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: Number(transactionLinker.shardsKey),
282
- tvmAssets: rawAssets.map((asset) => ({
281
+ shardsKey: transactionLinker.shardsKey,
282
+ tonAssets: rawAssets.map((asset) => ({
283
283
  amount: asset.rawAmount.toString(),
284
284
  tokenAddress: asset.address || '',
285
285
  })),
286
- tvmCaller: transactionLinker.caller,
286
+ tonCaller: transactionLinker.caller,
287
287
  };
288
- const evmSimulationResult = await this.simulateEVMMessage(evmSimulationBody);
289
- if (!evmSimulationResult.simulationStatus) {
290
- throw evmSimulationResult;
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(evmSimulationResult.estimatedGas) * 120n) / 100n;
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 simulateEVMMessage(req) {
349
+ async simulateTACMessage(req) {
347
350
  for (const endpoint of this.liteSequencerEndpoints) {
348
351
  try {
349
- const response = await axios_1.default.post(`${endpoint}/evm/simulator/simulate-message`, req, {
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 = 'v2r1' | 'v2r2' | 'v3r1' | 'v3r2' | 'v4' | 'v5r1' | 'highloadV3';
6
+ export type WalletVersion = 'V2R1' | 'V2R2' | 'V3R1' | 'V3R2' | 'V4' | 'V5R1' | 'HIGHLOAD_V3';
7
7
  export declare const wallets: {
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
- highloadV3: typeof HighloadWalletV3;
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
- 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
- highloadV3: HighloadWalletV3_1.HighloadWalletV3,
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 === 'v5r1') {
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.Testnet ? -3 : -239,
40
- context: { walletVersion: 'v5r1', workchain: 0, subwalletNumber: params.options?.v5r1?.subwalletNumber ?? 0 },
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 === 'highloadV3') {
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<void>;
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.Testnet ? ui_1.CHAIN.TESTNET : ui_1.CHAIN.MAINNET,
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
- await this.tonConnect.sendTransaction(transaction);
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, EVMSimulationResults, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, RawAssetBridgingData, StatusInfosByOperationId } from './Struct';
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
- JettonBurn = "JettonBurn",
16
- JettonTransfer = "JettonTransfer"
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 EVMSimulationResponse = ResponseBase<EVMSimulationResults>;
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["JettonBurn"] = "JettonBurn";
7
- AssetOpType["JettonTransfer"] = "JettonTransfer";
6
+ AssetOpType["JETTON_BURN"] = "JETTON_BURN";
7
+ AssetOpType["JETTON_TRANSFER"] = "JETTON_TRANSFER";
8
8
  })(AssetOpType || (exports.AssetOpType = AssetOpType = {}));
@@ -11,14 +11,26 @@ export interface ContractOpener {
11
11
  closeConnections?: () => unknown;
12
12
  }
13
13
  export declare enum SimplifiedStatuses {
14
- Pending = 0,
15
- Failed = 1,
16
- Successful = 2,
17
- OperationIdNotFound = 3
14
+ PENDING = "PENDING",
15
+ FAILED = "FAILED",
16
+ SUCCESSFUL = "SUCCESSFUL",
17
+ OPERATION_ID_NOT_FOUND = "OPERATION_ID_NOT_FOUND"
18
18
  }
19
19
  export declare enum Network {
20
- Testnet = "testnet",
21
- Mainnet = "mainnet"
20
+ TESTNET = "testnet",
21
+ MAINNET = "mainnet"
22
+ }
23
+ export declare enum BlockchainType {
24
+ TAC = "TAC",
25
+ TON = "TON"
26
+ }
27
+ export declare enum OperationType {
28
+ PENDING = "PENDING",
29
+ TON_TAC_TON = "TON-TAC-TON",
30
+ ROLLBACK = "ROLLBACK",
31
+ TON_TAC = "TON-TAC",
32
+ TAC_TON = "TAC-TON",
33
+ UNKNOWN = "UNKNOWN"
22
34
  }
23
35
  export type TACParams = {
24
36
  /**
@@ -124,23 +136,32 @@ export type TransactionLinker = {
124
136
  timestamp: number;
125
137
  sendTransactionResult?: unknown;
126
138
  };
127
- export type EVMSimulationRequest = {
128
- evmCallParams: {
139
+ export type TACSimulationRequest = {
140
+ tacCallParams: {
129
141
  arguments: string;
130
142
  methodName: string;
131
143
  target: string;
132
144
  };
133
145
  extraData: string;
134
146
  feeAssetAddress: string;
135
- shardsKey: number;
136
- tvmAssets: {
147
+ shardsKey: string;
148
+ tonAssets: {
137
149
  amount: string;
138
150
  tokenAddress: string;
139
151
  }[];
140
- tvmCaller: string;
141
- };
152
+ tonCaller: string;
153
+ };
154
+ export declare enum StageName {
155
+ COLLECTED_IN_TAC = "COLLECTED_IN_TAC",
156
+ INCLUDED_IN_TAC_CONSENSUS = "INCLUDED_IN_TAC_CONSENSUS",
157
+ EXECUTED_IN_TAC = "EXECUTED_IN_TAC",
158
+ COLLECTED_IN_TON = "COLLECTED_IN_TON",
159
+ INCLUDED_IN_TON_CONSENSUS = "INCLUDED_IN_TON_CONSENSUS",
160
+ EXECUTED_IN_TON = "EXECUTED_IN_TON"
161
+ }
142
162
  export type TransactionData = {
143
163
  hash: string;
164
+ blockchainType: BlockchainType;
144
165
  };
145
166
  export type NoteInfo = {
146
167
  content: string;
@@ -155,18 +176,29 @@ export type StageData = {
155
176
  note: NoteInfo | null;
156
177
  };
157
178
  export type StatusInfo = StageData & {
158
- stage: string;
179
+ stage: StageName;
159
180
  };
160
181
  export type ProfilingStageData = {
161
182
  exists: boolean;
162
183
  stageData: StageData | null;
163
184
  };
164
185
  export type ExecutionStages = {
165
- evmMerkleMsgCollected: ProfilingStageData;
166
- evmMerkleRootSet: ProfilingStageData;
167
- evmMerkleMsgExecuted: ProfilingStageData;
168
- tvmMerkleMsgCollected: ProfilingStageData;
169
- tvmMerkleMsgExecuted: ProfilingStageData;
186
+ operationType: OperationType;
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[];
170
202
  };
171
203
  export type ExecutionStagesByOperationId = Record<string, ExecutionStages>;
172
204
  export type StatusInfosByOperationId = Record<string, StatusInfo>;
@@ -174,7 +206,7 @@ export type OperationIds = {
174
206
  operationIds: string[];
175
207
  };
176
208
  export type OperationIdsByShardsKey = Record<string, OperationIds>;
177
- export type EVMSimulationResults = {
209
+ export type TACSimulationResults = {
178
210
  estimatedGas: bigint;
179
211
  estimatedJettonFeeAmount: string;
180
212
  feeParams: {