@tonappchain/sdk 0.7.3-rc1 → 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/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/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/FT.js +1 -1
- package/dist/src/errors/index.d.ts +1 -1
- package/dist/src/errors/index.js +3 -1
- package/dist/src/errors/instances.d.ts +2 -0
- package/dist/src/errors/instances.js +5 -1
- package/dist/src/interfaces/ContractOpener.d.ts +1 -1
- package/dist/src/interfaces/ILiteSequencerClient.d.ts +5 -1
- package/dist/src/interfaces/IOperationTracker.d.ts +6 -0
- package/dist/src/interfaces/ITACTransactionManager.d.ts +4 -3
- package/dist/src/interfaces/ITacSDK.d.ts +26 -5
- 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 +2 -0
- package/dist/src/sdk/Consts.js +3 -1
- package/dist/src/sdk/LiteSequencerClient.d.ts +2 -1
- package/dist/src/sdk/LiteSequencerClient.js +22 -1
- package/dist/src/sdk/OperationTracker.d.ts +1 -0
- package/dist/src/sdk/OperationTracker.js +18 -0
- package/dist/src/sdk/TACTransactionManager.d.ts +3 -2
- package/dist/src/sdk/TACTransactionManager.js +45 -35
- package/dist/src/sdk/TacSdk.d.ts +6 -2
- package/dist/src/sdk/TacSdk.js +36 -2
- package/dist/src/sdk/Utils.js +2 -2
- package/dist/src/structs/InternalStruct.d.ts +8 -3
- package/dist/src/structs/Struct.d.ts +55 -2
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { Wallet } from 'ethers';
|
|
|
2
2
|
import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
3
3
|
import { FT, NFT, TAC, TON } from '../assets';
|
|
4
4
|
import type { SenderAbstraction } from '../sender';
|
|
5
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike,
|
|
5
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
|
|
6
6
|
import { Asset } from './Asset';
|
|
7
7
|
import { ContractOpener } from './ContractOpener';
|
|
8
8
|
import { IConfiguration } from './IConfiguration';
|
|
@@ -29,8 +29,8 @@ export interface ITacSDK {
|
|
|
29
29
|
*/
|
|
30
30
|
get getTrustedTONExecutors(): string[];
|
|
31
31
|
/**
|
|
32
|
-
* Closes
|
|
33
|
-
*
|
|
32
|
+
* Closes TON liteclient connections.
|
|
33
|
+
* Use only with LiteClientOpener.
|
|
34
34
|
*/
|
|
35
35
|
closeConnections(): unknown;
|
|
36
36
|
/**
|
|
@@ -106,14 +106,15 @@ export interface ITacSDK {
|
|
|
106
106
|
* the bridged native TAC amount. The SDK requires EIP-1559 fee data from the TAC provider, can
|
|
107
107
|
* validate balances / ownership of non-native TAC assets, uses provider gas estimates as-is,
|
|
108
108
|
* validates those estimates against the latest TAC block gas limit,
|
|
109
|
-
*
|
|
109
|
+
* first estimates approval gas and checks TAC balance for approvals, submits approvals,
|
|
110
|
+
* then estimates the bridge message and checks the remaining TAC balance before sending it.
|
|
110
111
|
* @param signer Ethers Wallet used to sign EVM transaction on TAC side.
|
|
111
112
|
* @param tonTarget Recipient TVM address on TON.
|
|
112
113
|
* @param assets Optional list of TAC assets to include in the bridge transaction.
|
|
113
114
|
* @param options Optional TAC -> TON bridge configuration.
|
|
114
115
|
* @returns Promise with TAC transaction hash and optional operationId.
|
|
115
116
|
*/
|
|
116
|
-
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: AssetLike[], options?:
|
|
117
|
+
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: AssetLike[], options?: CrossChainTransactionToTONOptions): Promise<TACCrossChainTransactionResult>;
|
|
117
118
|
/**
|
|
118
119
|
* Sends multiple cross-chain transactions in one batch and optionally waits for tracking info.
|
|
119
120
|
* @param sender Sender abstraction for signing/sending TVM messages.
|
|
@@ -122,6 +123,26 @@ export interface ITacSDK {
|
|
|
122
123
|
* @returns Promise with an array of TransactionLinkerWithOperationId for each submitted transaction.
|
|
123
124
|
*/
|
|
124
125
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Resolves operation id by any TON hash from a linked chain of TON transactions.
|
|
128
|
+
* The SDK first resolves indexed TON transaction context, traverses adjacent TON transactions
|
|
129
|
+
* until it finds the crossChainLayer transaction that the sequencer would collect as a TVM event,
|
|
130
|
+
* and only then queries the sequencer with that exact transaction hash.
|
|
131
|
+
* @param transactionHash Any TON transaction hash from the relevant linked chain of TON transactions.
|
|
132
|
+
* @param waitOptions Optional waiting settings for the final sequencer lookup. Pass `null` to disable retries.
|
|
133
|
+
* @returns Promise resolving to operation id, or empty string when the sequencer-collected crossChainLayer event transaction is not found.
|
|
134
|
+
*/
|
|
135
|
+
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Resolves operation id by the BOC of an external TON message that was sent to the blockchain.
|
|
138
|
+
* The SDK derives the normalized external-in message hash from the BOC, finds the root TON transaction
|
|
139
|
+
* that processed that external message through the configured contract opener, and then reuses the same
|
|
140
|
+
* linked chain of TON transactions lookup as `getOperationIdByTonTransactionHash(...)`.
|
|
141
|
+
* @param boc BOC of the external TON message that was sent to the blockchain.
|
|
142
|
+
* @param waitOptions Optional waiting settings for the final sequencer lookup. Pass `null` to disable retries.
|
|
143
|
+
* @returns Promise resolving to operation id, or empty string when the sequencer-collected crossChainLayer event transaction is not found.
|
|
144
|
+
*/
|
|
145
|
+
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
125
146
|
/**
|
|
126
147
|
* Bridges tokens/value from EVM to TON chain via the executor.
|
|
127
148
|
* This is a low-level send-only method. It prepares the TAC -> TON message, performs approvals,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ToncenterV3IndexedTransaction, ToncenterV3TraversalParams } from '../structs/Struct';
|
|
2
|
+
/**
|
|
3
|
+
* Contract for indexed TON transaction lookup by hash.
|
|
4
|
+
* Used when the SDK must resolve any TON transaction hash from a linked chain of TON transactions
|
|
5
|
+
* into indexed transaction context and then find the sequencer-collected event transaction on crossChainLayer.
|
|
6
|
+
*/
|
|
7
|
+
export interface IToncenterV3Indexer {
|
|
8
|
+
/** Indexed Toncenter v3 endpoint used by this client. */
|
|
9
|
+
readonly endpoint: string;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves TON transaction context by hash using an indexed backend.
|
|
12
|
+
* Accepts any TON transaction hash format supported by the indexer, including hashes from
|
|
13
|
+
* any point in the same linked chain of TON transactions.
|
|
14
|
+
* @param transactionHash TON transaction hash to resolve in the indexed backend.
|
|
15
|
+
* @returns Indexed transaction with owning account context, or null if not found.
|
|
16
|
+
*/
|
|
17
|
+
getTransactionByHash(transactionHash: string): Promise<ToncenterV3IndexedTransaction | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves adjacent indexed transactions for the provided hash from the same linked chain of TON transactions.
|
|
20
|
+
* The result may contain both parent and child transactions.
|
|
21
|
+
* @param transactionHash TON transaction hash to resolve around.
|
|
22
|
+
* @returns Adjacent indexed transactions, or an empty array when none were found.
|
|
23
|
+
*/
|
|
24
|
+
getAdjacentTransactions(transactionHash: string): Promise<ToncenterV3IndexedTransaction[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Traverses the linked chain of TON transactions in both directions starting from any TON transaction hash
|
|
27
|
+
* from that linked transaction chain, and returns the transaction on crossChainLayer that the sequencer would collect
|
|
28
|
+
* as a TVM event.
|
|
29
|
+
* @param transactionHash Any TON transaction hash from the target linked chain of TON transactions.
|
|
30
|
+
* @param crossChainLayerAddress crossChainLayer address whose sequencer-collected event transaction should be found in that linked chain of TON transactions.
|
|
31
|
+
* @param params Optional traversal settings. Defaults are applied when omitted.
|
|
32
|
+
* @returns Indexed crossChainLayer transaction that matches the sequencer event collector rules, or null if it was not found.
|
|
33
|
+
*/
|
|
34
|
+
findCollectibleCrossChainLayerTransaction(transactionHash: string, crossChainLayerAddress: string, params?: ToncenterV3TraversalParams): Promise<ToncenterV3IndexedTransaction | null>;
|
|
35
|
+
}
|
|
@@ -10,6 +10,7 @@ export * from './ISimulator';
|
|
|
10
10
|
export * from './ITacExplorerClient';
|
|
11
11
|
export * from './ITacSDK';
|
|
12
12
|
export * from './ITACTransactionManager';
|
|
13
|
+
export * from './IToncenterV3Indexer';
|
|
13
14
|
export * from './ITONTransactionManager';
|
|
14
15
|
export * from './SenderAbstraction';
|
|
15
16
|
export * from './WalletInstanse';
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./ISimulator"), exports);
|
|
|
26
26
|
__exportStar(require("./ITacExplorerClient"), exports);
|
|
27
27
|
__exportStar(require("./ITacSDK"), exports);
|
|
28
28
|
__exportStar(require("./ITACTransactionManager"), exports);
|
|
29
|
+
__exportStar(require("./IToncenterV3Indexer"), exports);
|
|
29
30
|
__exportStar(require("./ITONTransactionManager"), exports);
|
|
30
31
|
__exportStar(require("./SenderAbstraction"), exports);
|
|
31
32
|
__exportStar(require("./WalletInstanse"), exports);
|
package/dist/src/sdk/Consts.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export declare const TON_BURN_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
|
19
19
|
export declare const DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 30000;
|
|
20
20
|
export declare const DEFAULT_RETRY_MAX_COUNT = 5;
|
|
21
21
|
export declare const DEFAULT_RETRY_DELAY_MS = 1000;
|
|
22
|
+
export declare const DEFAULT_RETRY_MAX_DELAY_MS = 30000;
|
|
23
|
+
export declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 3;
|
|
22
24
|
export declare const DEFAULT_WAIT_TIMEOUT_MS = 300000;
|
|
23
25
|
export declare const DEFAULT_WAIT_MAX_ATTEMPTS = 30;
|
|
24
26
|
export declare const DEFAULT_WAIT_DELAY_MS = 10000;
|
package/dist/src/sdk/Consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IGNORE_OPCODE = exports.SHARDS_KEY_RANDOM_RANGE = exports.DEFAULT_EIP1559_PRIORITY_FEE = exports.NFT_BRIDGE_AMOUNT = exports.CROSS_CHAIN_MESSAGE_VERSION_V1 = exports.IGNORE_MSG_VALUE_1_NANO = exports.DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = exports.DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = exports.DEFAULT_RETRY_ON_NOT_FOUND = exports.DEFAULT_FIND_TX_MAX_DEPTH = exports.DEFAULT_FIND_TX_ARCHIVAL = exports.DEFAULT_MAX_SCANNED_TRANSACTIONS = exports.DEFAULT_FIND_TX_LIMIT = exports.DEFAULT_WAIT_DELAY_MS = exports.DEFAULT_WAIT_MAX_ATTEMPTS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.DEFAULT_RETRY_DELAY_MS = exports.DEFAULT_RETRY_MAX_COUNT = exports.DEFAULT_HTTP_CLIENT_TIMEOUT_MS = exports.TON_BURN_ADDRESS = exports.MINUTE = exports.FIVE_MINUTES = exports.TAC_DECIMALS = exports.TON_DECIMALS = exports.ONE_YEAR_SECONDS = exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = void 0;
|
|
3
|
+
exports.IGNORE_OPCODE = exports.SHARDS_KEY_RANDOM_RANGE = exports.DEFAULT_EIP1559_PRIORITY_FEE = exports.NFT_BRIDGE_AMOUNT = exports.CROSS_CHAIN_MESSAGE_VERSION_V1 = exports.IGNORE_MSG_VALUE_1_NANO = exports.DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = exports.DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = exports.DEFAULT_RETRY_ON_NOT_FOUND = exports.DEFAULT_FIND_TX_MAX_DEPTH = exports.DEFAULT_FIND_TX_ARCHIVAL = exports.DEFAULT_MAX_SCANNED_TRANSACTIONS = exports.DEFAULT_FIND_TX_LIMIT = exports.DEFAULT_WAIT_DELAY_MS = exports.DEFAULT_WAIT_MAX_ATTEMPTS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.DEFAULT_RETRY_BACKOFF_MULTIPLIER = exports.DEFAULT_RETRY_MAX_DELAY_MS = exports.DEFAULT_RETRY_DELAY_MS = exports.DEFAULT_RETRY_MAX_COUNT = exports.DEFAULT_HTTP_CLIENT_TIMEOUT_MS = exports.TON_BURN_ADDRESS = exports.MINUTE = exports.FIVE_MINUTES = exports.TAC_DECIMALS = exports.TON_DECIMALS = exports.ONE_YEAR_SECONDS = exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
6
6
|
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
|
|
@@ -23,6 +23,8 @@ exports.TON_BURN_ADDRESS = 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c';
|
|
|
23
23
|
exports.DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 30000;
|
|
24
24
|
exports.DEFAULT_RETRY_MAX_COUNT = 5;
|
|
25
25
|
exports.DEFAULT_RETRY_DELAY_MS = 1000;
|
|
26
|
+
exports.DEFAULT_RETRY_MAX_DELAY_MS = 30000;
|
|
27
|
+
exports.DEFAULT_RETRY_BACKOFF_MULTIPLIER = 3;
|
|
26
28
|
exports.DEFAULT_WAIT_TIMEOUT_MS = 300000; // 5 minutes
|
|
27
29
|
exports.DEFAULT_WAIT_MAX_ATTEMPTS = 30;
|
|
28
30
|
exports.DEFAULT_WAIT_DELAY_MS = 10000; // 10 seconds
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { IHttpClient, ILiteSequencerClient } from '../interfaces';
|
|
2
2
|
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
|
|
3
3
|
export declare class LiteSequencerClient implements ILiteSequencerClient {
|
|
4
|
-
|
|
4
|
+
readonly endpoint: string;
|
|
5
5
|
private readonly maxChunkSize;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
constructor(endpoint: string, maxChunkSize?: number, httpClient?: IHttpClient);
|
|
8
8
|
private getRequestLabel;
|
|
9
9
|
getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
|
|
10
|
+
getOperationIdByTonTransactionHash(transactionHash: string): Promise<string>;
|
|
10
11
|
getOperationType(operationId: string): Promise<OperationType>;
|
|
11
12
|
getOperationTypeV2(operationId: string): Promise<OperationTypeV2Info>;
|
|
12
13
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
@@ -23,7 +23,11 @@ class LiteSequencerClient {
|
|
|
23
23
|
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
24
24
|
params: { transactionHash },
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
const operationResponse = response.data.response;
|
|
27
|
+
if (operationResponse.length > 0) {
|
|
28
|
+
return operationResponse[0].operationId;
|
|
29
|
+
}
|
|
30
|
+
return '';
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
33
|
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
@@ -40,6 +44,23 @@ class LiteSequencerClient {
|
|
|
40
44
|
throw (0, errors_1.operationFetchError)(`request ${requestLabel} failed to complete request`, error);
|
|
41
45
|
}
|
|
42
46
|
}
|
|
47
|
+
async getOperationIdByTonTransactionHash(transactionHash) {
|
|
48
|
+
const path = 'ton/operation-id';
|
|
49
|
+
const requestLabel = this.getRequestLabel('GET', path);
|
|
50
|
+
try {
|
|
51
|
+
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
52
|
+
params: { transactionHash },
|
|
53
|
+
});
|
|
54
|
+
return response.data.response || '';
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
if (error?.response?.status === 404) {
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
throw (0, errors_1.operationFetchError)(`request ${requestLabel} failed to complete request`, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
43
64
|
async getOperationType(operationId) {
|
|
44
65
|
const path = 'operation-type';
|
|
45
66
|
const requestLabel = this.getRequestLabel('GET', path);
|
|
@@ -8,6 +8,7 @@ export declare class OperationTracker implements IOperationTracker {
|
|
|
8
8
|
private readonly logger;
|
|
9
9
|
constructor(network: Network, customLiteSequencerEndpoints?: string[], logger?: ILogger, clientFactory?: ILiteSequencerClientFactory);
|
|
10
10
|
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
11
|
+
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
11
12
|
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType> | null): Promise<OperationType>;
|
|
12
13
|
getOperationTypeV2(operationId: string, waitOptions?: WaitOptions<OperationTypeV2Info> | null): Promise<OperationTypeV2Info>;
|
|
13
14
|
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
@@ -52,6 +52,24 @@ class OperationTracker {
|
|
|
52
52
|
? await requestFn()
|
|
53
53
|
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, `OperationTracker: Getting operation ID by transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
54
54
|
}
|
|
55
|
+
async getOperationIdByTonTransactionHash(transactionHash, waitOptions) {
|
|
56
|
+
const requestFn = async () => {
|
|
57
|
+
let lastError;
|
|
58
|
+
for (const client of this.clients) {
|
|
59
|
+
try {
|
|
60
|
+
const id = await client.getOperationIdByTonTransactionHash(transactionHash);
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
lastError = error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError, waitOptions?.includeErrorTrace ?? false);
|
|
68
|
+
};
|
|
69
|
+
return waitOptions === null
|
|
70
|
+
? await requestFn()
|
|
71
|
+
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, `OperationTracker: Getting operation ID by TON transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
72
|
+
}
|
|
55
73
|
async getOperationType(operationId, waitOptions) {
|
|
56
74
|
const requestFn = async () => {
|
|
57
75
|
let lastError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import { Asset, IConfiguration, ILogger, IOperationTracker, ITACTransactionManager } from '../interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { CrossChainTransactionToTONOptions, TACCrossChainTransactionResult } from '../structs/Struct';
|
|
4
4
|
export declare class TACTransactionManager implements ITACTransactionManager {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly operationTracker;
|
|
@@ -8,6 +8,7 @@ export declare class TACTransactionManager implements ITACTransactionManager {
|
|
|
8
8
|
constructor(config: IConfiguration, operationTracker: IOperationTracker, logger?: ILogger);
|
|
9
9
|
private prepareBridgeTokensToTON;
|
|
10
10
|
private approveAsset;
|
|
11
|
-
|
|
11
|
+
private estimateApprovalGas;
|
|
12
|
+
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: Asset[], options?: CrossChainTransactionToTONOptions): Promise<TACCrossChainTransactionResult>;
|
|
12
13
|
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: Asset[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
|
|
13
14
|
}
|
|
@@ -36,7 +36,6 @@ class TACTransactionManager {
|
|
|
36
36
|
this.logger.debug(`Suggested TON executor fee: ${(0, Utils_1.formatObjectForLogging)(suggestedFee)}`);
|
|
37
37
|
tvmExecutorFee = BigInt(suggestedFee.inTAC);
|
|
38
38
|
}
|
|
39
|
-
const crossChainLayerAddress = await this.config.TACParams.crossChainLayer.getAddress();
|
|
40
39
|
const protocolFee = await this.config.TACParams.crossChainLayer.getProtocolFee();
|
|
41
40
|
const shardsKey = BigInt(Math.round(Math.random() * Consts_1.SHARDS_KEY_RANDOM_RANGE));
|
|
42
41
|
this.logger.debug(`Shards key: ${shardsKey}, Protocol fee: ${protocolFee}`);
|
|
@@ -66,29 +65,44 @@ class TACTransactionManager {
|
|
|
66
65
|
toBridgeNFT,
|
|
67
66
|
};
|
|
68
67
|
return {
|
|
69
|
-
crossChainLayerAddress,
|
|
70
68
|
outMessagePayload: this.config.artifacts.tac.utils.encodeOutMessageV1(outMessage),
|
|
71
69
|
totalValue: value + BigInt(outMessage.tvmProtocolFee) + BigInt(outMessage.tvmExecutorFee),
|
|
72
70
|
};
|
|
73
71
|
}
|
|
74
72
|
async approveAsset(asset, signer, spenderAddress, transactionParams = {}) {
|
|
75
73
|
const evmAddress = await asset.getEVMAddress();
|
|
74
|
+
const hasTransactionParams = Object.keys(transactionParams).length > 0;
|
|
76
75
|
if (asset.type === Struct_1.AssetType.FT) {
|
|
77
76
|
this.logger.debug(`Approving FT ${evmAddress} for ${spenderAddress}`);
|
|
78
77
|
const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
|
|
79
|
-
const tx =
|
|
78
|
+
const tx = hasTransactionParams
|
|
79
|
+
? await contract.connect(signer).approve(spenderAddress, asset.rawAmount, transactionParams)
|
|
80
|
+
: await contract.connect(signer).approve(spenderAddress, asset.rawAmount);
|
|
80
81
|
await tx.wait();
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
84
|
this.logger.debug(`Approving NFT ${evmAddress} for ${spenderAddress}`);
|
|
84
85
|
const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
|
|
85
|
-
const tx =
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const tx = hasTransactionParams
|
|
87
|
+
? await contract
|
|
88
|
+
.connect(signer)
|
|
89
|
+
.approve(spenderAddress, asset.addresses.index, transactionParams)
|
|
90
|
+
: await contract.connect(signer).approve(spenderAddress, asset.addresses.index);
|
|
88
91
|
await tx.wait();
|
|
89
92
|
}
|
|
90
93
|
this.logger.debug(`Approved ${evmAddress} for ${spenderAddress}`);
|
|
91
94
|
}
|
|
95
|
+
async estimateApprovalGas(asset, signer, spenderAddress, transactionParams = {}) {
|
|
96
|
+
const evmAddress = await asset.getEVMAddress();
|
|
97
|
+
if (asset.type === Struct_1.AssetType.FT) {
|
|
98
|
+
const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
|
|
99
|
+
return contract.connect(signer).approve.estimateGas(spenderAddress, asset.rawAmount, transactionParams);
|
|
100
|
+
}
|
|
101
|
+
const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
|
|
102
|
+
return contract
|
|
103
|
+
.connect(signer)
|
|
104
|
+
.approve.estimateGas(spenderAddress, asset.addresses.index, transactionParams);
|
|
105
|
+
}
|
|
92
106
|
async sendCrossChainTransactionToTON(signer, tonTarget, assets = [], options) {
|
|
93
107
|
const signerAddress = signer.address;
|
|
94
108
|
const nativeTACAsset = await assets_1.AssetFactory.from(this.config, {
|
|
@@ -98,21 +112,22 @@ class TACTransactionManager {
|
|
|
98
112
|
let value = 0n;
|
|
99
113
|
const bridgeAssets = [];
|
|
100
114
|
for (const asset of assets) {
|
|
101
|
-
if (asset.origin === Struct_1.Origin.TAC &&
|
|
115
|
+
if (asset.origin === Struct_1.Origin.TAC &&
|
|
116
|
+
asset.type === Struct_1.AssetType.FT &&
|
|
117
|
+
asset.address === nativeTACAsset.address) {
|
|
102
118
|
value += asset.rawAmount;
|
|
103
119
|
continue;
|
|
104
120
|
}
|
|
105
121
|
bridgeAssets.push(asset);
|
|
106
122
|
}
|
|
123
|
+
const crossChainLayerAddress = await this.config.TACParams.crossChainLayer.getAddress();
|
|
107
124
|
const preparedBridge = await this.prepareBridgeTokensToTON(value, tonTarget, bridgeAssets, options?.tvmExecutorFee, options?.tvmValidExecutors);
|
|
108
125
|
const feeData = await this.config.TACParams.provider.getFeeData();
|
|
109
126
|
const maxFeePerGas = feeData.maxFeePerGas;
|
|
110
127
|
if (maxFeePerGas === null) {
|
|
111
128
|
throw (0, errors_1.gasPriceFetchError)('TAC provider did not return maxFeePerGas');
|
|
112
129
|
}
|
|
113
|
-
const latestBlock = await this.config.TACParams.provider
|
|
114
|
-
.getBlock('latest')
|
|
115
|
-
.catch((error) => {
|
|
130
|
+
const latestBlock = await this.config.TACParams.provider.getBlock('latest').catch((error) => {
|
|
116
131
|
throw (0, errors_1.blockGasLimitFetchError)('provider failed to return latest block', error);
|
|
117
132
|
});
|
|
118
133
|
const blockGasLimit = latestBlock?.gasLimit;
|
|
@@ -127,28 +142,26 @@ class TACTransactionManager {
|
|
|
127
142
|
if (shouldValidateAssetsBalance) {
|
|
128
143
|
await Promise.all(bridgeAssets.map((asset) => asset.checkCanBeTransferredBy(signerAddress, Struct_1.BlockchainType.TAC)));
|
|
129
144
|
}
|
|
130
|
-
let
|
|
145
|
+
let requiredApprovalBalance = 0n;
|
|
131
146
|
const approvalPlans = [];
|
|
132
147
|
for (const asset of bridgeAssets) {
|
|
133
|
-
|
|
134
|
-
if (asset.type === Struct_1.AssetType.FT) {
|
|
135
|
-
const contract = new ethers_1.ethers.Contract(await asset.getEVMAddress(), this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
|
|
136
|
-
estimatedGas = await contract
|
|
137
|
-
.connect(signer)
|
|
138
|
-
.approve.estimateGas(preparedBridge.crossChainLayerAddress, asset.rawAmount, transactionParams);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
const contract = new ethers_1.ethers.Contract(await asset.getEVMAddress(), this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
|
|
142
|
-
estimatedGas = await contract
|
|
143
|
-
.connect(signer)
|
|
144
|
-
.approve.estimateGas(preparedBridge.crossChainLayerAddress, asset.addresses.index, transactionParams);
|
|
145
|
-
}
|
|
148
|
+
const estimatedGas = await this.estimateApprovalGas(asset, signer, crossChainLayerAddress, transactionParams);
|
|
146
149
|
if (estimatedGas > blockGasLimit) {
|
|
147
150
|
throw (0, errors_1.estimatedGasExceedsBlockGasLimitError)('approve', estimatedGas, blockGasLimit);
|
|
148
151
|
}
|
|
149
|
-
|
|
152
|
+
requiredApprovalBalance += estimatedGas * maxFeePerGas;
|
|
150
153
|
approvalPlans.push({ asset, gasLimit: estimatedGas });
|
|
151
154
|
}
|
|
155
|
+
const approvalBalance = await this.config.TACParams.provider.getBalance(signer.address);
|
|
156
|
+
if (approvalBalance < requiredApprovalBalance) {
|
|
157
|
+
throw (0, errors_1.insufficientBalanceError)(Consts_1.TAC_SYMBOL);
|
|
158
|
+
}
|
|
159
|
+
for (const approval of approvalPlans) {
|
|
160
|
+
await this.approveAsset(approval.asset, signer, crossChainLayerAddress, {
|
|
161
|
+
...transactionParams,
|
|
162
|
+
gasLimit: approval.gasLimit,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
152
165
|
const sendMessageGas = await this.config.TACParams.crossChainLayer
|
|
153
166
|
.connect(signer)
|
|
154
167
|
.sendMessage.estimateGas(Consts_1.CROSS_CHAIN_MESSAGE_VERSION_V1, preparedBridge.outMessagePayload, {
|
|
@@ -158,17 +171,11 @@ class TACTransactionManager {
|
|
|
158
171
|
if (sendMessageGas > blockGasLimit) {
|
|
159
172
|
throw (0, errors_1.estimatedGasExceedsBlockGasLimitError)('sendMessage', sendMessageGas, blockGasLimit);
|
|
160
173
|
}
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
174
|
+
const requiredSendMessageBalance = preparedBridge.totalValue + sendMessageGas * maxFeePerGas;
|
|
175
|
+
const sendMessageBalance = await this.config.TACParams.provider.getBalance(signer.address);
|
|
176
|
+
if (sendMessageBalance < requiredSendMessageBalance) {
|
|
164
177
|
throw (0, errors_1.insufficientBalanceError)(Consts_1.TAC_SYMBOL);
|
|
165
178
|
}
|
|
166
|
-
for (const approval of approvalPlans) {
|
|
167
|
-
await this.approveAsset(approval.asset, signer, preparedBridge.crossChainLayerAddress, {
|
|
168
|
-
...transactionParams,
|
|
169
|
-
gasLimit: approval.gasLimit,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
179
|
const tx = await this.config.TACParams.crossChainLayer
|
|
173
180
|
.connect(signer)
|
|
174
181
|
.sendMessage(Consts_1.CROSS_CHAIN_MESSAGE_VERSION_V1, preparedBridge.outMessagePayload, {
|
|
@@ -219,7 +226,10 @@ class TACTransactionManager {
|
|
|
219
226
|
}
|
|
220
227
|
async bridgeTokensToTON(signer, value, tonTarget, assets = [], tvmExecutorFee, tvmValidExecutors) {
|
|
221
228
|
this.logger.debug('Bridging tokens to TON');
|
|
222
|
-
|
|
229
|
+
Validator_1.Validator.validateTVMAddress(tonTarget);
|
|
230
|
+
Validator_1.Validator.validateTVMAddresses(tvmValidExecutors);
|
|
231
|
+
const crossChainLayerAddress = await this.config.TACParams.crossChainLayer.getAddress();
|
|
232
|
+
const { outMessagePayload, totalValue } = await this.prepareBridgeTokensToTON(value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors);
|
|
223
233
|
this.logger.debug(`Total value: ${totalValue}`);
|
|
224
234
|
for (const asset of assets) {
|
|
225
235
|
await this.approveAsset(asset, signer, crossChainLayerAddress);
|
package/dist/src/sdk/TacSdk.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
|
3
3
|
import { FT, NFT, TAC, TON } from '../assets';
|
|
4
4
|
import { ContractOpener, IConfiguration, ILogger, IOperationTracker, ITacExplorerClient, ITacSDK } from '../interfaces';
|
|
5
5
|
import type { SenderAbstraction } from '../sender';
|
|
6
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike,
|
|
6
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrossChainTransactionToTONOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SDKParams, SuggestedTVMExecutorFee, TACCrossChainTransactionResult, TacGasPrice, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
|
|
7
7
|
export declare class TacSdk implements ITacSDK {
|
|
8
8
|
readonly config: IConfiguration;
|
|
9
9
|
readonly contactOpener: ContractOpener;
|
|
@@ -12,6 +12,7 @@ export declare class TacSdk implements ITacSDK {
|
|
|
12
12
|
private readonly simulator;
|
|
13
13
|
private readonly tonTransactionManager;
|
|
14
14
|
private readonly tacTransactionManager;
|
|
15
|
+
private readonly tonIndexer;
|
|
15
16
|
private constructor();
|
|
16
17
|
static create(sdkParams: SDKParams, logger?: ILogger): Promise<TacSdk>;
|
|
17
18
|
closeConnections(): unknown;
|
|
@@ -23,8 +24,10 @@ export declare class TacSdk implements ITacSDK {
|
|
|
23
24
|
getSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<ExecutionFeeEstimationResult>;
|
|
24
25
|
getTVMExecutorFeeInfo(assets: AssetLike[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTVMExecutorFee>;
|
|
25
26
|
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<TransactionLinkerWithOperationId>;
|
|
26
|
-
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: AssetLike[], options?:
|
|
27
|
+
sendCrossChainTransactionToTON(signer: Wallet, tonTarget: string, assets?: AssetLike[], options?: CrossChainTransactionToTONOptions): Promise<TACCrossChainTransactionResult>;
|
|
27
28
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTxWithAssetLike[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
29
|
+
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
30
|
+
getOperationIdByTonTransactionBoc(boc: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
28
31
|
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: AssetLike[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
|
|
29
32
|
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
30
33
|
simulateTACMessage(req: TACSimulationParams): Promise<TACSimulationResult>;
|
|
@@ -48,4 +51,5 @@ export declare class TacSdk implements ITacSDK {
|
|
|
48
51
|
prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
|
|
49
52
|
getTACGasPrice(): Promise<TacGasPrice>;
|
|
50
53
|
getTonContractOpener(): ContractOpener;
|
|
54
|
+
private toSequencerTonTransactionHash;
|
|
51
55
|
}
|
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();
|
|
@@ -99,6 +104,32 @@ class TacSdk {
|
|
|
99
104
|
})));
|
|
100
105
|
return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, options);
|
|
101
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
|
+
}
|
|
102
133
|
async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors) {
|
|
103
134
|
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
104
135
|
return this.tacTransactionManager.bridgeTokensToTON(signer, value, tonTarget, normalizedAssets, tvmExecutorFee, tvmValidExecutors);
|
|
@@ -204,5 +235,8 @@ class TacSdk {
|
|
|
204
235
|
getTonContractOpener() {
|
|
205
236
|
return this.contactOpener;
|
|
206
237
|
}
|
|
238
|
+
toSequencerTonTransactionHash(transaction) {
|
|
239
|
+
return `0x${(0, Utils_1.normalizeHashToHex)(transaction.hash)}`;
|
|
240
|
+
}
|
|
207
241
|
}
|
|
208
242
|
exports.TacSdk = TacSdk;
|
package/dist/src/sdk/Utils.js
CHANGED
|
@@ -416,7 +416,7 @@ function decodeBase64Like(input) {
|
|
|
416
416
|
}
|
|
417
417
|
function getNormalizedExtMessageHash(message) {
|
|
418
418
|
if (message.info.type !== 'external-in') {
|
|
419
|
-
throw
|
|
419
|
+
throw (0, errors_1.externalInMessageRequiredError)(message.info.type);
|
|
420
420
|
}
|
|
421
421
|
const info = {
|
|
422
422
|
...message.info,
|
|
@@ -460,5 +460,5 @@ function recurisivelyCollectCellStats(cell) {
|
|
|
460
460
|
return { bits, cells };
|
|
461
461
|
}
|
|
462
462
|
function isFinalProfiling(profilingData) {
|
|
463
|
-
return profilingData.operationType !== Struct_1.OperationType.PENDING && profilingData.operationType !== Struct_1.OperationType.UNKNOWN;
|
|
463
|
+
return (profilingData.operationType !== Struct_1.OperationType.PENDING && profilingData.operationType !== Struct_1.OperationType.UNKNOWN);
|
|
464
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, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, TransactionLinker } 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;
|
|
@@ -22,7 +22,6 @@ export type PreparedCrossChainTransaction = {
|
|
|
22
22
|
transactionLinker: TransactionLinker;
|
|
23
23
|
};
|
|
24
24
|
export type PreparedBridgeTokensToTON = {
|
|
25
|
-
crossChainLayerAddress: string;
|
|
26
25
|
outMessagePayload: ethers.BytesLike;
|
|
27
26
|
totalValue: bigint;
|
|
28
27
|
};
|
|
@@ -75,7 +74,7 @@ export type OperationIdWithLogIndex = {
|
|
|
75
74
|
operationId: string;
|
|
76
75
|
logIndex: number;
|
|
77
76
|
};
|
|
78
|
-
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex>;
|
|
77
|
+
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex[]>;
|
|
79
78
|
export interface SendResult {
|
|
80
79
|
success: boolean;
|
|
81
80
|
boc: string;
|
|
@@ -138,6 +137,12 @@ export type TransactionDepth = {
|
|
|
138
137
|
export type AdjacentTransactionsResponse = {
|
|
139
138
|
transactions: ToncenterTransaction[];
|
|
140
139
|
};
|
|
140
|
+
export type TonAdjacentTransactionsResponse = {
|
|
141
|
+
transactions: ToncenterV3IndexedTransaction[];
|
|
142
|
+
};
|
|
143
|
+
export type ToncenterV3TransactionsResponse = {
|
|
144
|
+
transactions: ToncenterV3IndexedTransaction[];
|
|
145
|
+
};
|
|
141
146
|
export type TxFinalizerConfig = {
|
|
142
147
|
urlBuilder: (hash: string) => string;
|
|
143
148
|
authorization?: {
|