@tonappchain/sdk 0.7.2 → 0.7.3-rc2
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 +203 -199
- package/dist/artifacts/dev/index.d.ts +2 -2
- package/dist/artifacts/dev/index.js +2 -1
- package/dist/artifacts/dev/ton/endpoints.d.ts +1 -0
- package/dist/artifacts/dev/ton/endpoints.js +2 -1
- package/dist/artifacts/mainnet/index.d.ts +2 -2
- package/dist/artifacts/mainnet/index.js +2 -1
- package/dist/artifacts/mainnet/ton/endpoints.d.ts +1 -0
- package/dist/artifacts/mainnet/ton/endpoints.js +2 -1
- package/dist/artifacts/testnet/index.d.ts +2 -2
- package/dist/artifacts/testnet/index.js +2 -1
- package/dist/artifacts/testnet/ton/endpoints.d.ts +1 -0
- package/dist/artifacts/testnet/ton/endpoints.js +2 -1
- package/dist/src/adapters/BaseContractOpener.js +8 -5
- package/dist/src/adapters/RetryableContractOpener.d.ts +6 -1
- package/dist/src/adapters/RetryableContractOpener.js +35 -8
- package/dist/src/adapters/ToncenterV3Indexer.d.ts +34 -0
- package/dist/src/adapters/ToncenterV3Indexer.js +123 -0
- package/dist/src/adapters/index.d.ts +1 -0
- package/dist/src/adapters/index.js +1 -0
- package/dist/src/assets/AssetFactory.d.ts +4 -1
- package/dist/src/assets/AssetFactory.js +4 -0
- package/dist/src/assets/FT.d.ts +3 -3
- package/dist/src/assets/FT.js +28 -15
- package/dist/src/assets/NFT.d.ts +3 -3
- package/dist/src/assets/NFT.js +10 -4
- package/dist/src/assets/TAC.d.ts +24 -0
- package/dist/src/assets/TAC.js +74 -0
- package/dist/src/assets/TON.d.ts +3 -3
- package/dist/src/assets/TON.js +12 -5
- package/dist/src/assets/index.d.ts +1 -0
- package/dist/src/assets/index.js +3 -1
- package/dist/src/errors/index.d.ts +1 -1
- package/dist/src/errors/index.js +8 -1
- package/dist/src/errors/instances.d.ts +6 -0
- package/dist/src/errors/instances.js +11 -1
- package/dist/src/interfaces/Asset.d.ts +11 -6
- package/dist/src/interfaces/ContractOpener.d.ts +1 -1
- package/dist/src/interfaces/IConfiguration.d.ts +1 -3
- package/dist/src/interfaces/ILiteSequencerClient.d.ts +14 -2
- package/dist/src/interfaces/IOperationTracker.d.ts +26 -1
- package/dist/src/interfaces/ITACTransactionManager.d.ts +20 -1
- package/dist/src/interfaces/ITacSDK.d.ts +52 -10
- package/dist/src/interfaces/IToncenterV3Indexer.d.ts +35 -0
- package/dist/src/interfaces/IToncenterV3Indexer.js +2 -0
- package/dist/src/interfaces/index.d.ts +1 -0
- package/dist/src/interfaces/index.js +1 -0
- package/dist/src/sdk/Consts.d.ts +6 -0
- package/dist/src/sdk/Consts.js +7 -1
- package/dist/src/sdk/LiteSequencerClient.d.ts +5 -2
- package/dist/src/sdk/LiteSequencerClient.js +59 -1
- package/dist/src/sdk/OperationTracker.d.ts +5 -1
- package/dist/src/sdk/OperationTracker.js +76 -0
- package/dist/src/sdk/TACTransactionManager.d.ts +4 -0
- package/dist/src/sdk/TACTransactionManager.js +181 -35
- package/dist/src/sdk/TONTransactionManager.js +28 -6
- package/dist/src/sdk/TacSdk.d.ts +8 -3
- package/dist/src/sdk/TacSdk.js +40 -2
- package/dist/src/sdk/Utils.d.ts +2 -1
- package/dist/src/sdk/Utils.js +5 -1
- package/dist/src/structs/InternalStruct.d.ts +41 -2
- package/dist/src/structs/Struct.d.ts +209 -6
- package/dist/src/structs/Struct.js +12 -1
- package/dist/src/wrappers/ContentUtils.d.ts +36 -13
- package/dist/src/wrappers/ContentUtils.js +197 -98
- package/package.json +121 -121
package/dist/src/sdk/TacSdk.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TacSdk = void 0;
|
|
4
|
+
const ton_1 = require("@ton/ton");
|
|
4
5
|
const artifacts_1 = require("../../artifacts");
|
|
6
|
+
const adapters_1 = require("../adapters");
|
|
5
7
|
const assets_1 = require("../assets");
|
|
8
|
+
const errors_1 = require("../errors");
|
|
6
9
|
const Struct_1 = require("../structs/Struct");
|
|
7
10
|
const Configuration_1 = require("./Configuration");
|
|
8
11
|
const Consts_1 = require("./Consts");
|
|
@@ -14,7 +17,7 @@ const TACTransactionManager_1 = require("./TACTransactionManager");
|
|
|
14
17
|
const TONTransactionManager_1 = require("./TONTransactionManager");
|
|
15
18
|
const Utils_1 = require("./Utils");
|
|
16
19
|
class TacSdk {
|
|
17
|
-
constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient) {
|
|
20
|
+
constructor(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient, tonIndexer) {
|
|
18
21
|
this.config = config;
|
|
19
22
|
this.contactOpener = config.TONParams.contractOpener;
|
|
20
23
|
this.simulator = simulator;
|
|
@@ -22,6 +25,7 @@ class TacSdk {
|
|
|
22
25
|
this.tacTransactionManager = tacTransactionManager;
|
|
23
26
|
this.operationTracker = operationTracker;
|
|
24
27
|
this.explorerClient = explorerClient;
|
|
28
|
+
this.tonIndexer = tonIndexer;
|
|
25
29
|
}
|
|
26
30
|
static async create(sdkParams, logger = new Logger_1.NoopLogger()) {
|
|
27
31
|
const network = sdkParams.network;
|
|
@@ -47,7 +51,8 @@ class TacSdk {
|
|
|
47
51
|
const simulator = new Simulator_1.Simulator(config, operationTracker, logger);
|
|
48
52
|
const tonTransactionManager = new TONTransactionManager_1.TONTransactionManager(config, simulator, operationTracker, logger);
|
|
49
53
|
const tacTransactionManager = new TACTransactionManager_1.TACTransactionManager(config, operationTracker, logger);
|
|
50
|
-
|
|
54
|
+
const tonIndexer = sdkParams.TONParams?.tonIndexer ?? new adapters_1.ToncenterV3Indexer(artifacts.TONCENTER_V3_INDEXER_ENDPOINT);
|
|
55
|
+
return new TacSdk(config, simulator, tonTransactionManager, tacTransactionManager, operationTracker, explorerClient, tonIndexer);
|
|
51
56
|
}
|
|
52
57
|
closeConnections() {
|
|
53
58
|
return this.config.closeConnections();
|
|
@@ -87,6 +92,10 @@ class TacSdk {
|
|
|
87
92
|
const tx = { evmProxyMsg, assets: normalizedAssets, options };
|
|
88
93
|
return this.tonTransactionManager.sendCrossChainTransaction(evmProxyMsg, sender, tx);
|
|
89
94
|
}
|
|
95
|
+
async sendCrossChainTransactionToTON(signer, tonTarget, assets, options) {
|
|
96
|
+
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
97
|
+
return this.tacTransactionManager.sendCrossChainTransactionToTON(signer, tonTarget, normalizedAssets, options);
|
|
98
|
+
}
|
|
90
99
|
async sendCrossChainTransactions(sender, txs, options) {
|
|
91
100
|
const normalizedTxs = await Promise.all(txs.map(async (tx) => ({
|
|
92
101
|
evmProxyMsg: tx.evmProxyMsg,
|
|
@@ -95,6 +104,32 @@ class TacSdk {
|
|
|
95
104
|
})));
|
|
96
105
|
return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, options);
|
|
97
106
|
}
|
|
107
|
+
async getOperationIdByTonTransactionHash(transactionHash, waitOptions) {
|
|
108
|
+
const cclTransaction = await this.tonIndexer.findCollectibleCrossChainLayerTransaction(transactionHash, this.config.TONParams.crossChainLayerAddress);
|
|
109
|
+
if (!cclTransaction) {
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
return this.operationTracker.getOperationIdByTonTransactionHash(this.toSequencerTonTransactionHash(cclTransaction), waitOptions);
|
|
113
|
+
}
|
|
114
|
+
async getOperationIdByTonTransactionBoc(boc, waitOptions) {
|
|
115
|
+
let message;
|
|
116
|
+
try {
|
|
117
|
+
message = (0, ton_1.loadMessage)(ton_1.Cell.fromBase64(boc).beginParse());
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const reason = error instanceof Error ? error.message : undefined;
|
|
121
|
+
throw (0, errors_1.invalidTonExternalMessageBocError)(reason);
|
|
122
|
+
}
|
|
123
|
+
if (message.info.type !== 'external-in') {
|
|
124
|
+
throw (0, errors_1.externalInMessageRequiredError)(message.info.type);
|
|
125
|
+
}
|
|
126
|
+
const destination = message.info.dest;
|
|
127
|
+
const transaction = await this.contactOpener.getTransactionByHash(ton_1.Address.parse(destination.toString()), (0, Utils_1.getNormalizedExtMessageHash)(message));
|
|
128
|
+
if (!transaction) {
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
return this.getOperationIdByTonTransactionHash(transaction.hash().toString('base64'), waitOptions);
|
|
132
|
+
}
|
|
98
133
|
async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors) {
|
|
99
134
|
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
100
135
|
return this.tacTransactionManager.bridgeTokensToTON(signer, value, tonTarget, normalizedAssets, tvmExecutorFee, tvmValidExecutors);
|
|
@@ -200,5 +235,8 @@ class TacSdk {
|
|
|
200
235
|
getTonContractOpener() {
|
|
201
236
|
return this.contactOpener;
|
|
202
237
|
}
|
|
238
|
+
toSequencerTonTransactionHash(transaction) {
|
|
239
|
+
return `0x${(0, Utils_1.normalizeHashToHex)(transaction.hash)}`;
|
|
240
|
+
}
|
|
203
241
|
}
|
|
204
242
|
exports.TacSdk = TacSdk;
|
package/dist/src/sdk/Utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AbiCoder } from 'ethers';
|
|
|
3
3
|
import type { FT, NFT, TON } from '../assets';
|
|
4
4
|
import { Asset, IConfiguration } from '../interfaces';
|
|
5
5
|
import { RandomNumberByTimestamp } from '../structs/InternalStruct';
|
|
6
|
-
import { AssetLike, EvmProxyMsg, FeeParams, TONAsset, TransactionLinker, ValidExecutors, WaitOptions } from '../structs/Struct';
|
|
6
|
+
import { AssetLike, EvmProxyMsg, ExecutionStages, FeeParams, TONAsset, TransactionLinker, ValidExecutors, WaitOptions } from '../structs/Struct';
|
|
7
7
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
8
8
|
export declare function generateRandomNumber(interval: number): number;
|
|
9
9
|
export declare function generateRandomNumberByTimestamp(): RandomNumberByTimestamp;
|
|
@@ -56,3 +56,4 @@ export declare function recurisivelyCollectCellStats(cell: Cell): {
|
|
|
56
56
|
bits: number;
|
|
57
57
|
cells: number;
|
|
58
58
|
};
|
|
59
|
+
export declare function isFinalProfiling(profilingData: ExecutionStages): boolean;
|
package/dist/src/sdk/Utils.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.normalizeHashToHex = normalizeHashToHex;
|
|
|
25
25
|
exports.getNormalizedExtMessageHash = getNormalizedExtMessageHash;
|
|
26
26
|
exports.retry = retry;
|
|
27
27
|
exports.recurisivelyCollectCellStats = recurisivelyCollectCellStats;
|
|
28
|
+
exports.isFinalProfiling = isFinalProfiling;
|
|
28
29
|
const ton_1 = require("@ton/ton");
|
|
29
30
|
const ethers_1 = require("ethers");
|
|
30
31
|
const ton_crypto_1 = require("ton-crypto");
|
|
@@ -415,7 +416,7 @@ function decodeBase64Like(input) {
|
|
|
415
416
|
}
|
|
416
417
|
function getNormalizedExtMessageHash(message) {
|
|
417
418
|
if (message.info.type !== 'external-in') {
|
|
418
|
-
throw
|
|
419
|
+
throw (0, errors_1.externalInMessageRequiredError)(message.info.type);
|
|
419
420
|
}
|
|
420
421
|
const info = {
|
|
421
422
|
...message.info,
|
|
@@ -458,3 +459,6 @@ function recurisivelyCollectCellStats(cell) {
|
|
|
458
459
|
}
|
|
459
460
|
return { bits, cells };
|
|
460
461
|
}
|
|
462
|
+
function isFinalProfiling(profilingData) {
|
|
463
|
+
return (profilingData.operationType !== Struct_1.OperationType.PENDING && profilingData.operationType !== Struct_1.OperationType.UNKNOWN);
|
|
464
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Address, Cell } from '@ton/ton';
|
|
|
2
2
|
import { AbstractProvider, ethers } from 'ethers';
|
|
3
3
|
import { ICrossChainLayer, ISAFactory, ISettings, ITokenUtils } from '../../artifacts/tacTypes';
|
|
4
4
|
import { ContractOpener } from '../interfaces';
|
|
5
|
-
import { CurrencyType, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult } from './Struct';
|
|
5
|
+
import { CurrencyType, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, ToncenterV3IndexedTransaction, TransactionLinker } from './Struct';
|
|
6
6
|
export type ShardMessage = {
|
|
7
7
|
address: string;
|
|
8
8
|
value: bigint;
|
|
@@ -17,6 +17,14 @@ export type ShardTransaction = {
|
|
|
17
17
|
messages: ShardMessage[];
|
|
18
18
|
network: Network;
|
|
19
19
|
};
|
|
20
|
+
export type PreparedCrossChainTransaction = {
|
|
21
|
+
transaction: ShardTransaction;
|
|
22
|
+
transactionLinker: TransactionLinker;
|
|
23
|
+
};
|
|
24
|
+
export type PreparedBridgeTokensToTON = {
|
|
25
|
+
outMessagePayload: ethers.BytesLike;
|
|
26
|
+
totalValue: bigint;
|
|
27
|
+
};
|
|
20
28
|
export declare enum AssetOpType {
|
|
21
29
|
JETTON_BURN = "JETTON_BURN",
|
|
22
30
|
JETTON_TRANSFER = "JETTON_TRANSFER",
|
|
@@ -54,9 +62,11 @@ export type ResponseBase<T> = {
|
|
|
54
62
|
};
|
|
55
63
|
export type StringResponse = ResponseBase<string>;
|
|
56
64
|
export type OperationTypeResponse = ResponseBase<OperationType>;
|
|
65
|
+
export type OperationTypeV2Response = ResponseBase<OperationTypeV2Info>;
|
|
57
66
|
export type StatusesResponse = ResponseBase<StatusInfosByOperationId>;
|
|
58
67
|
export type OperationIdsByShardsKeyResponse = ResponseBase<OperationIdsByShardsKey>;
|
|
59
68
|
export type StageProfilingResponse = ResponseBase<ExecutionStagesByOperationId>;
|
|
69
|
+
export type StageProfilingV2Response = ResponseBase<ExecutionStagesV2ByOperationId>;
|
|
60
70
|
export type TACSimulationResponse = ResponseBase<TACSimulationResult>;
|
|
61
71
|
export type SuggestedTVMExecutorFeeResponse = ResponseBase<SuggestedTVMExecutorFee>;
|
|
62
72
|
export type ConvertCurrencyResponse = ResponseBase<ConvertedCurrencyRawResult>;
|
|
@@ -64,7 +74,7 @@ export type OperationIdWithLogIndex = {
|
|
|
64
74
|
operationId: string;
|
|
65
75
|
logIndex: number;
|
|
66
76
|
};
|
|
67
|
-
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex>;
|
|
77
|
+
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex[]>;
|
|
68
78
|
export interface SendResult {
|
|
69
79
|
success: boolean;
|
|
70
80
|
boc: string;
|
|
@@ -72,6 +82,29 @@ export interface SendResult {
|
|
|
72
82
|
error?: Error;
|
|
73
83
|
lastMessageIndex?: number;
|
|
74
84
|
}
|
|
85
|
+
export type SendGroupTransferResult = string | {
|
|
86
|
+
result: string;
|
|
87
|
+
};
|
|
88
|
+
export type SendBatchTransferResult = string | void | {
|
|
89
|
+
result: string | void;
|
|
90
|
+
};
|
|
91
|
+
export type RetryableOperationResult<T> = {
|
|
92
|
+
success: boolean;
|
|
93
|
+
data?: T;
|
|
94
|
+
lastError?: Error;
|
|
95
|
+
};
|
|
96
|
+
export type MetadataPersistenceType = 'none' | 'onchain' | 'offchain_private_domain' | 'offchain_ipfs' | 'semichain_private_domain' | 'semichain_ipfs';
|
|
97
|
+
export type OffchainMetadataResult<TMetadata = unknown> = {
|
|
98
|
+
metadata: TMetadata | null;
|
|
99
|
+
isIpfs: boolean;
|
|
100
|
+
contentUri: string;
|
|
101
|
+
};
|
|
102
|
+
export type ReadMetadataResult<TMetadata = unknown> = {
|
|
103
|
+
persistenceType: MetadataPersistenceType;
|
|
104
|
+
metadata: TMetadata | null;
|
|
105
|
+
contentUri?: string;
|
|
106
|
+
isJettonDeployerFaultyOnChainData?: boolean;
|
|
107
|
+
};
|
|
75
108
|
export type ToncenterTransaction = {
|
|
76
109
|
description: {
|
|
77
110
|
aborted: boolean;
|
|
@@ -104,6 +137,12 @@ export type TransactionDepth = {
|
|
|
104
137
|
export type AdjacentTransactionsResponse = {
|
|
105
138
|
transactions: ToncenterTransaction[];
|
|
106
139
|
};
|
|
140
|
+
export type TonAdjacentTransactionsResponse = {
|
|
141
|
+
transactions: ToncenterV3IndexedTransaction[];
|
|
142
|
+
};
|
|
143
|
+
export type ToncenterV3TransactionsResponse = {
|
|
144
|
+
transactions: ToncenterV3IndexedTransaction[];
|
|
145
|
+
};
|
|
107
146
|
export type TxFinalizerConfig = {
|
|
108
147
|
urlBuilder: (hash: string) => string;
|
|
109
148
|
authorization?: {
|
|
@@ -3,7 +3,7 @@ import { Cell, OpenedContract } from '@ton/ton';
|
|
|
3
3
|
import { AbstractProvider } from 'ethers';
|
|
4
4
|
import { JettonMinter, JettonMinterData } from '../../artifacts/tonTypes';
|
|
5
5
|
import type { FT, NFT } from '../assets';
|
|
6
|
-
import type { Asset, ContractOpener, ILogger } from '../interfaces';
|
|
6
|
+
import type { Asset, ContractOpener, ILogger, IToncenterV3Indexer } from '../interfaces';
|
|
7
7
|
import { SendResult } from './InternalStruct';
|
|
8
8
|
export type ContractState = {
|
|
9
9
|
balance: bigint;
|
|
@@ -37,6 +37,11 @@ export declare enum OperationType {
|
|
|
37
37
|
TAC_TON = "TAC-TON",
|
|
38
38
|
UNKNOWN = "UNKNOWN"
|
|
39
39
|
}
|
|
40
|
+
export type OperationTypeV2 = OperationType.TON_TAC_TON | OperationType.TON_TAC | OperationType.TAC_TON;
|
|
41
|
+
export declare enum OperationExecutionStatus {
|
|
42
|
+
SUCCESS = "success",
|
|
43
|
+
FAILED = "failed"
|
|
44
|
+
}
|
|
40
45
|
export type TACParams = {
|
|
41
46
|
/**
|
|
42
47
|
* Provider for TAC side. Use your own provider for tests or to increase ratelimit
|
|
@@ -56,6 +61,11 @@ export type TONParams = {
|
|
|
56
61
|
* Provider for TON side. Use your own provider for tests or to increase ratelimit
|
|
57
62
|
*/
|
|
58
63
|
contractOpener?: ContractOpener;
|
|
64
|
+
/**
|
|
65
|
+
* Indexed Toncenter v3 client used to resolve TON transaction context by hash.
|
|
66
|
+
* Use your own implementation for tests or custom indexed backends.
|
|
67
|
+
*/
|
|
68
|
+
tonIndexer?: IToncenterV3Indexer;
|
|
59
69
|
/**
|
|
60
70
|
* Address of TON settings contract. Use only for tests.
|
|
61
71
|
*/
|
|
@@ -120,6 +130,16 @@ export type TransactionLinker = {
|
|
|
120
130
|
export type TransactionLinkerWithOperationId = TransactionLinker & {
|
|
121
131
|
operationId?: string;
|
|
122
132
|
};
|
|
133
|
+
export type TACCrossChainTransactionResult = {
|
|
134
|
+
/**
|
|
135
|
+
* Hash of the TAC transaction
|
|
136
|
+
*/
|
|
137
|
+
txHash: string;
|
|
138
|
+
/**
|
|
139
|
+
* Crosschain operation id
|
|
140
|
+
*/
|
|
141
|
+
operationId?: string;
|
|
142
|
+
};
|
|
123
143
|
export type TONAsset = {
|
|
124
144
|
amount: string;
|
|
125
145
|
tokenAddress: string;
|
|
@@ -167,6 +187,54 @@ export type StageData = {
|
|
|
167
187
|
export type StatusInfo = StageData & {
|
|
168
188
|
stage: StageName;
|
|
169
189
|
};
|
|
190
|
+
/**
|
|
191
|
+
* Indexed transaction returned by Toncenter v3 `/transactions` and `/adjacentTransactions` endpoints.
|
|
192
|
+
*/
|
|
193
|
+
export type ToncenterV3IndexedTransaction = {
|
|
194
|
+
/** Account address that owns the transaction. */
|
|
195
|
+
account: string;
|
|
196
|
+
/** Indexed TON transaction hash. */
|
|
197
|
+
hash: string;
|
|
198
|
+
/** Optional trace identifier returned by Toncenter v3. */
|
|
199
|
+
traceId?: string;
|
|
200
|
+
/** Incoming message of the indexed transaction, when present in the response. */
|
|
201
|
+
inMsg?: {
|
|
202
|
+
/** Message source address. */
|
|
203
|
+
source?: string | null;
|
|
204
|
+
/** Message destination address. */
|
|
205
|
+
destination?: string | null;
|
|
206
|
+
/** Opcode reported by Toncenter v3 for the incoming message. */
|
|
207
|
+
opcode?: string | null;
|
|
208
|
+
/** Raw message content returned by Toncenter v3. */
|
|
209
|
+
messageContent?: {
|
|
210
|
+
/** BOC-encoded message body in base64 form. */
|
|
211
|
+
body?: string | null;
|
|
212
|
+
} | null;
|
|
213
|
+
} | null;
|
|
214
|
+
/** Outgoing messages of the indexed transaction. */
|
|
215
|
+
outMsgs: Array<{
|
|
216
|
+
/** Message destination address. `null` means external outbound log message. */
|
|
217
|
+
destination?: string | null;
|
|
218
|
+
/** Raw message content returned by Toncenter v3. */
|
|
219
|
+
messageContent?: {
|
|
220
|
+
/** BOC-encoded message body in base64 form. */
|
|
221
|
+
body?: string | null;
|
|
222
|
+
} | null;
|
|
223
|
+
}>;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Traversal settings for indexed search through a linked TON transaction chain in Toncenter v3.
|
|
227
|
+
*/
|
|
228
|
+
export type ToncenterV3TraversalParams = {
|
|
229
|
+
/**
|
|
230
|
+
* Maximum traversal depth from the starting transaction in the linked TON transaction chain.
|
|
231
|
+
*/
|
|
232
|
+
maxDepth?: number;
|
|
233
|
+
/**
|
|
234
|
+
* Maximum number of unique indexed transactions to inspect.
|
|
235
|
+
*/
|
|
236
|
+
maxScannedTransactions?: number;
|
|
237
|
+
};
|
|
170
238
|
export type ProfilingStageData = {
|
|
171
239
|
exists: boolean;
|
|
172
240
|
stageData: StageData | null;
|
|
@@ -225,7 +293,19 @@ export type ExecutionStages = {
|
|
|
225
293
|
operationType: OperationType;
|
|
226
294
|
metaInfo: MetaInfo;
|
|
227
295
|
} & Record<StageName, ProfilingStageData>;
|
|
296
|
+
export type OperationTypeV2Info = {
|
|
297
|
+
operationType: OperationTypeV2;
|
|
298
|
+
finalized: boolean;
|
|
299
|
+
};
|
|
300
|
+
export type ExecutionStagesV2 = {
|
|
301
|
+
operationType: OperationTypeV2;
|
|
302
|
+
metaInfo: MetaInfo;
|
|
303
|
+
finalized: boolean;
|
|
304
|
+
status: OperationExecutionStatus;
|
|
305
|
+
rollback: boolean;
|
|
306
|
+
} & Record<StageName, ProfilingStageData>;
|
|
228
307
|
export type ExecutionStagesByOperationId = Record<string, ExecutionStages>;
|
|
308
|
+
export type ExecutionStagesV2ByOperationId = Record<string, ExecutionStagesV2>;
|
|
229
309
|
export type StatusInfosByOperationId = Record<string, StatusInfo>;
|
|
230
310
|
export type OperationIds = {
|
|
231
311
|
operationIds: string[];
|
|
@@ -288,35 +368,153 @@ export type FeeParams = {
|
|
|
288
368
|
};
|
|
289
369
|
export type evmDataBuilder = (transactionLinker: TransactionLinker, evmProxyMsg: EvmProxyMsg, validExecutors: ValidExecutors) => Cell;
|
|
290
370
|
export type CrossChainTransactionOptions = {
|
|
371
|
+
/**
|
|
372
|
+
* Allows sending to continue even when TAC simulation returns an unsuccessful result.
|
|
373
|
+
* @default false
|
|
374
|
+
*/
|
|
291
375
|
allowSimulationError?: boolean;
|
|
292
376
|
/**
|
|
293
|
-
* If true,
|
|
377
|
+
* If true, validates the initial TON transaction tree right after sending the external message.
|
|
378
|
+
* This checks that the outbound TON transaction was actually executed before the SDK starts
|
|
379
|
+
* waiting for cross-chain tracking data.
|
|
294
380
|
* @default true
|
|
295
381
|
*/
|
|
296
382
|
ensureTxExecuted?: boolean;
|
|
297
383
|
/**
|
|
298
384
|
* If true, validates explicitly provided fee params against suggested values.
|
|
385
|
+
* Disable only when you intentionally want to send with custom fees.
|
|
299
386
|
* @default true
|
|
300
387
|
*/
|
|
301
388
|
shouldValidateFees?: boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Forces the SDK to treat the operation as round-trip TON -> TAC -> TON.
|
|
391
|
+
* When omitted, the SDK derives this automatically from simulation results and attached assets.
|
|
392
|
+
*/
|
|
302
393
|
isRoundTrip?: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Explicit override for the protocol fee included in the transaction.
|
|
396
|
+
* Normally this is taken from simulation or on-chain configuration.
|
|
397
|
+
*/
|
|
303
398
|
protocolFee?: bigint;
|
|
399
|
+
/**
|
|
400
|
+
* Optional whitelist of TAC-side executor addresses allowed to execute the TAC part of the operation.
|
|
401
|
+
* When omitted, trusted executors from SDK configuration are used.
|
|
402
|
+
*/
|
|
304
403
|
evmValidExecutors?: string[];
|
|
404
|
+
/**
|
|
405
|
+
* Explicit fee paid to the TAC-side executor.
|
|
406
|
+
* Normally this is filled from simulation unless you provide custom manual fee params.
|
|
407
|
+
*/
|
|
305
408
|
evmExecutorFee?: bigint;
|
|
409
|
+
/**
|
|
410
|
+
* Optional whitelist of TON-side executor addresses allowed to execute the TON part of the operation.
|
|
411
|
+
* When omitted, trusted executors from SDK configuration are used.
|
|
412
|
+
*/
|
|
306
413
|
tvmValidExecutors?: string[];
|
|
414
|
+
/**
|
|
415
|
+
* Explicit fee paid to the TON-side executor for round-trip operations.
|
|
416
|
+
* Required in manual mode when `withoutSimulation` is true and `isRoundTrip` is true.
|
|
417
|
+
*/
|
|
307
418
|
tvmExecutorFee?: bigint;
|
|
419
|
+
/**
|
|
420
|
+
* Controls whether rollback fee should be included in TAC simulation.
|
|
421
|
+
* Keep enabled unless you intentionally want estimation without rollback costs.
|
|
422
|
+
* @default true
|
|
423
|
+
*/
|
|
308
424
|
calculateRollbackFee?: boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Skips simulation entirely and uses only manually provided fee params.
|
|
427
|
+
* In this mode you must provide `protocolFee`, `evmExecutorFee`, and `evmProxyMsg.gasLimit`.
|
|
428
|
+
* If `isRoundTrip` is true, `tvmExecutorFee` is also required.
|
|
429
|
+
* @default false
|
|
430
|
+
*/
|
|
309
431
|
withoutSimulation?: boolean;
|
|
432
|
+
/**
|
|
433
|
+
* If true, validates that the sender currently owns or holds enough assets before building
|
|
434
|
+
* the cross-chain transaction payloads.
|
|
435
|
+
* Disable only if you already validated balances externally or need to skip this network call.
|
|
436
|
+
* @default true
|
|
437
|
+
*/
|
|
310
438
|
validateAssetsBalance?: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* If true, waits until the operation ID becomes available after sending the TON transaction.
|
|
441
|
+
* Disable when you only need the raw send result and do not want any tracker polling.
|
|
442
|
+
* @default true
|
|
443
|
+
*/
|
|
311
444
|
waitOperationId?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Retry policy used while resolving the operation ID.
|
|
447
|
+
* Use this to control timeout, attempts, delay, logger, callbacks, and success criteria.
|
|
448
|
+
*/
|
|
312
449
|
waitOptions?: WaitOptions<string>;
|
|
450
|
+
/**
|
|
451
|
+
* If true, waits for full cross-chain finalization after the operation ID is known:
|
|
452
|
+
* the SDK waits for a final operation type, fetches stage profiling, and validates
|
|
453
|
+
* TON transaction trees for `executedInTON` transactions when they exist.
|
|
454
|
+
* @default true
|
|
455
|
+
*/
|
|
456
|
+
waitFinalization?: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Wait options used to finalize the cross-chain operation after operationId resolution.
|
|
459
|
+
* Use this to configure retries, delay, logger, successCheck, and onSuccess callback
|
|
460
|
+
* for stage profiling retrieval and post-processing.
|
|
461
|
+
*/
|
|
462
|
+
finalizationWaitOptions?: WaitOptions<ExecutionStages>;
|
|
463
|
+
/**
|
|
464
|
+
* Custom builder for the EVM payload cell embedded into the TON message.
|
|
465
|
+
* Override only for advanced integrations that need non-standard TAC header encoding.
|
|
466
|
+
* By default the SDK uses `buildEvmDataCell`.
|
|
467
|
+
*/
|
|
313
468
|
evmDataBuilder?: evmDataBuilder;
|
|
314
469
|
};
|
|
315
|
-
export type BatchCrossChainTransactionOptions = Omit<CrossChainTransactionOptions, 'waitOperationId' | 'waitOptions' | 'ensureTxExecuted'>;
|
|
470
|
+
export type BatchCrossChainTransactionOptions = Omit<CrossChainTransactionOptions, 'waitOperationId' | 'waitOptions' | 'ensureTxExecuted' | 'waitFinalization' | 'finalizationWaitOptions'>;
|
|
316
471
|
export type CrossChainTransactionsOptions = {
|
|
317
472
|
waitOperationIds?: boolean;
|
|
318
473
|
waitOptions?: WaitOptions<OperationIdsByShardsKey>;
|
|
319
474
|
};
|
|
475
|
+
export type CrossChainTransactionToTONOptions = {
|
|
476
|
+
/**
|
|
477
|
+
* Optional explicit TON-side executor fee.
|
|
478
|
+
* When omitted, the SDK calls OperationTracker.getTVMExecutorFee().
|
|
479
|
+
*/
|
|
480
|
+
tvmExecutorFee?: bigint;
|
|
481
|
+
/**
|
|
482
|
+
* Optional whitelist of allowed TVM executors.
|
|
483
|
+
* Used both for fee estimation and for the out message itself.
|
|
484
|
+
*/
|
|
485
|
+
tvmValidExecutors?: string[];
|
|
486
|
+
/**
|
|
487
|
+
* If true, validates balances / ownership of non-native TAC assets before approvals and sending.
|
|
488
|
+
* Native TAC amount is still covered separately by the overall TAC balance sufficiency check.
|
|
489
|
+
* Disable only if you already validated balances externally or need to skip these RPC calls.
|
|
490
|
+
* @default true
|
|
491
|
+
*/
|
|
492
|
+
validateAssetsBalance?: boolean;
|
|
493
|
+
/**
|
|
494
|
+
* If true, waits until the operation ID becomes available after sending the TON transaction.
|
|
495
|
+
* Disable when you only need the raw send result and do not want any tracker polling.
|
|
496
|
+
* @default true
|
|
497
|
+
*/
|
|
498
|
+
waitOperationId?: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Retry policy used while resolving the operation ID.
|
|
501
|
+
* Use this to control timeout, attempts, delay, logger, callbacks, and success criteria.
|
|
502
|
+
*/
|
|
503
|
+
waitOptions?: WaitOptions<string>;
|
|
504
|
+
/**
|
|
505
|
+
* Wait options used to finalize the cross-chain operation after operationId resolution.
|
|
506
|
+
* Use this to configure retries, delay, logger, successCheck, and onSuccess callback
|
|
507
|
+
* for stage profiling retrieval and post-processing.
|
|
508
|
+
*/
|
|
509
|
+
waitFinalization?: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Wait options used to finalize the TAC->TON operation after operationId resolution.
|
|
512
|
+
* The SDK waits until the operation reaches a final operation type, fetches stage profiling,
|
|
513
|
+
* and, if profiling contains EXECUTED_IN_TON transactions, validates their TON transaction tree.
|
|
514
|
+
* This option is used only by sendCrossChainTransactionToTON and is ignored by bridgeTokensToTON.
|
|
515
|
+
*/
|
|
516
|
+
finalizationWaitOptions?: WaitOptions<ExecutionStages>;
|
|
517
|
+
};
|
|
320
518
|
export type ExecutionFeeEstimationResult = {
|
|
321
519
|
feeParams: FeeParams;
|
|
322
520
|
simulation?: TACSimulationResult;
|
|
@@ -461,6 +659,11 @@ export type TacGasPrice = {
|
|
|
461
659
|
fast: number;
|
|
462
660
|
slow: number;
|
|
463
661
|
};
|
|
662
|
+
export declare enum TransactionTreeDirection {
|
|
663
|
+
FORWARD = "forward",
|
|
664
|
+
BACKWARD = "backward",
|
|
665
|
+
BOTH = "both"
|
|
666
|
+
}
|
|
464
667
|
/**
|
|
465
668
|
* Parameters for tracking and validating transaction trees
|
|
466
669
|
*/
|
|
@@ -491,10 +694,10 @@ export type TrackTransactionTreeParams = {
|
|
|
491
694
|
* Direction to search the transaction tree:
|
|
492
695
|
* - 'forward': only search children (outgoing messages)
|
|
493
696
|
* - 'backward': only search parents (incoming messages)
|
|
494
|
-
* - 'both': search in both directions
|
|
495
|
-
* @default '
|
|
697
|
+
* - 'both': search in both directions
|
|
698
|
+
* @default 'forward'
|
|
496
699
|
*/
|
|
497
|
-
direction?:
|
|
700
|
+
direction?: TransactionTreeDirection;
|
|
498
701
|
/**
|
|
499
702
|
* Retry transaction lookup when `not_found` error occurs.
|
|
500
703
|
* Useful when transaction indexing has delays or when transactions appear gradually.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Origin = exports.defaultWaitOptions = exports.TokenSymbol = exports.StageName = exports.NFTAddressType = exports.AssetType = exports.OperationType = exports.CurrencyType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
|
|
3
|
+
exports.TransactionTreeDirection = exports.Origin = exports.defaultWaitOptions = exports.TokenSymbol = exports.StageName = exports.NFTAddressType = exports.AssetType = exports.OperationExecutionStatus = exports.OperationType = exports.CurrencyType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
|
|
4
4
|
const Consts_1 = require("../sdk/Consts");
|
|
5
5
|
var SimplifiedStatuses;
|
|
6
6
|
(function (SimplifiedStatuses) {
|
|
@@ -34,6 +34,11 @@ var OperationType;
|
|
|
34
34
|
OperationType["TAC_TON"] = "TAC-TON";
|
|
35
35
|
OperationType["UNKNOWN"] = "UNKNOWN";
|
|
36
36
|
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
37
|
+
var OperationExecutionStatus;
|
|
38
|
+
(function (OperationExecutionStatus) {
|
|
39
|
+
OperationExecutionStatus["SUCCESS"] = "success";
|
|
40
|
+
OperationExecutionStatus["FAILED"] = "failed";
|
|
41
|
+
})(OperationExecutionStatus || (exports.OperationExecutionStatus = OperationExecutionStatus = {}));
|
|
37
42
|
var AssetType;
|
|
38
43
|
(function (AssetType) {
|
|
39
44
|
AssetType["NFT"] = "NFT";
|
|
@@ -68,3 +73,9 @@ var Origin;
|
|
|
68
73
|
Origin["TON"] = "TON";
|
|
69
74
|
Origin["TAC"] = "TAC";
|
|
70
75
|
})(Origin || (exports.Origin = Origin = {}));
|
|
76
|
+
var TransactionTreeDirection;
|
|
77
|
+
(function (TransactionTreeDirection) {
|
|
78
|
+
TransactionTreeDirection["FORWARD"] = "forward";
|
|
79
|
+
TransactionTreeDirection["BACKWARD"] = "backward";
|
|
80
|
+
TransactionTreeDirection["BOTH"] = "both";
|
|
81
|
+
})(TransactionTreeDirection || (exports.TransactionTreeDirection = TransactionTreeDirection = {}));
|
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
import { Cell } from '@ton/ton';
|
|
2
|
+
import { MetadataPersistenceType } from '../structs/InternalStruct';
|
|
2
3
|
export declare const ONCHAIN_CONTENT_PREFIX = 0;
|
|
3
4
|
export declare const OFFCHAIN_CONTENT_PREFIX = 1;
|
|
4
|
-
export
|
|
5
|
+
export type JsonMetadataValue = string | number | boolean | null | JsonMetadataValue[] | {
|
|
6
|
+
[key: string]: JsonMetadataValue;
|
|
7
|
+
};
|
|
8
|
+
export type MetadataRecord<TKey extends string = string> = Partial<Record<TKey, JsonMetadataValue>> & {
|
|
9
|
+
[key: string]: JsonMetadataValue | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type CommonMetadataKeys = 'uri' | 'name' | 'description' | 'image' | 'image_data';
|
|
12
|
+
export type JettonMetaDataKeys = CommonMetadataKeys | 'symbol' | 'decimals' | 'amount_style' | 'render_type';
|
|
13
|
+
export type NFTMetadataKeys = CommonMetadataKeys;
|
|
14
|
+
export interface JettonMetadata extends MetadataRecord<JettonMetaDataKeys> {
|
|
5
15
|
uri?: string;
|
|
6
|
-
name
|
|
7
|
-
description
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
8
18
|
image?: string;
|
|
9
19
|
image_data?: string;
|
|
10
|
-
symbol
|
|
11
|
-
decimals?: string;
|
|
20
|
+
symbol?: string;
|
|
21
|
+
decimals?: string | number;
|
|
22
|
+
amount_style?: string;
|
|
23
|
+
render_type?: string;
|
|
12
24
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
export interface NFTMetadata extends MetadataRecord<NFTMetadataKeys> {
|
|
26
|
+
uri?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
image?: string;
|
|
30
|
+
image_data?: string;
|
|
31
|
+
}
|
|
32
|
+
type ExtendedMetadata<TKey extends string> = {
|
|
33
|
+
persistenceType: MetadataPersistenceType;
|
|
34
|
+
metadata: MetadataRecord<TKey> | null;
|
|
19
35
|
contentUri?: string;
|
|
20
36
|
};
|
|
37
|
+
export type JettonExtendedMetadata = ExtendedMetadata<JettonMetaDataKeys> & {
|
|
38
|
+
isJettonDeployerFaultyOnChainData?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type NFTExtendedMetadata = ExtendedMetadata<NFTMetadataKeys>;
|
|
21
41
|
export declare function buildJettonOffChainMetadata(contentUri: string): Cell;
|
|
22
|
-
export
|
|
42
|
+
export declare function buildNFTOffChainMetadata(contentUri: string): Cell;
|
|
23
43
|
export declare function buildJettonOnchainMetadata(data: JettonMetadata): Cell;
|
|
24
|
-
export
|
|
44
|
+
export declare function buildNFTOnchainMetadata(data: NFTMetadata): Cell;
|
|
45
|
+
export type persistenceType = MetadataPersistenceType;
|
|
25
46
|
export declare function readJettonMetadata(contentCell: Cell): Promise<JettonExtendedMetadata>;
|
|
47
|
+
export declare function readNFTMetadata(contentCell: Cell): Promise<NFTExtendedMetadata>;
|
|
48
|
+
export {};
|