@tonappchain/sdk 0.6.4 → 0.7.0-rc6
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/adapters/contractOpener.d.ts +1 -1
- package/dist/adapters/contractOpener.js +7 -8
- package/dist/adapters/retryableContractOpener.d.ts +21 -0
- package/dist/adapters/retryableContractOpener.js +101 -0
- package/dist/assets/AssetFactory.d.ts +13 -0
- package/dist/assets/AssetFactory.js +73 -0
- package/dist/assets/FT.d.ts +58 -0
- package/dist/assets/FT.js +199 -0
- package/dist/assets/NFT.d.ts +60 -0
- package/dist/assets/NFT.js +170 -0
- package/dist/assets/TON.d.ts +38 -0
- package/dist/assets/TON.js +91 -0
- package/dist/assets/index.d.ts +4 -0
- package/dist/assets/index.js +11 -0
- package/dist/errors/errors.d.ts +6 -0
- package/dist/errors/errors.js +15 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.js +26 -21
- package/dist/errors/instances.d.ts +9 -4
- package/dist/errors/instances.js +19 -5
- package/dist/index.d.ts +12 -6
- package/dist/index.js +24 -13
- package/dist/sdk/Configuration.d.ts +21 -0
- package/dist/sdk/Configuration.js +90 -0
- package/dist/sdk/Consts.js +2 -2
- package/dist/sdk/LiteSequencerClient.d.ts +1 -1
- package/dist/sdk/LiteSequencerClient.js +5 -11
- package/dist/sdk/Logger.d.ts +13 -0
- package/dist/sdk/Logger.js +25 -0
- package/dist/sdk/OperationTracker.d.ts +21 -6
- package/dist/sdk/OperationTracker.js +155 -75
- package/dist/sdk/Simulator.d.ts +23 -0
- package/dist/sdk/Simulator.js +169 -0
- package/dist/sdk/StartTracking.d.ts +6 -0
- package/dist/sdk/StartTracking.js +66 -29
- package/dist/sdk/TacSdk.d.ts +12 -41
- package/dist/sdk/TacSdk.js +69 -717
- package/dist/sdk/TransactionManager.d.ts +22 -0
- package/dist/sdk/TransactionManager.js +257 -0
- package/dist/sdk/TxFinalizer.d.ts +10 -0
- package/dist/sdk/TxFinalizer.js +104 -0
- package/dist/sdk/Utils.d.ts +12 -4
- package/dist/sdk/Utils.js +80 -16
- package/dist/sdk/Validator.d.ts +9 -0
- package/dist/sdk/Validator.js +43 -0
- package/dist/sender/BatchSender.d.ts +7 -4
- package/dist/sender/BatchSender.js +18 -6
- package/dist/sender/RawSender.d.ts +9 -4
- package/dist/sender/RawSender.js +46 -18
- package/dist/sender/SenderAbstraction.d.ts +5 -3
- package/dist/sender/SenderFactory.d.ts +1 -1
- package/dist/sender/SenderFactory.js +5 -4
- package/dist/sender/TonConnectSender.d.ts +5 -3
- package/dist/sender/TonConnectSender.js +12 -8
- package/dist/sender/index.d.ts +1 -1
- package/dist/sender/index.js +1 -1
- package/dist/structs/InternalStruct.d.ts +36 -33
- package/dist/structs/Services.d.ts +40 -0
- package/dist/structs/Services.js +2 -0
- package/dist/structs/Struct.d.ts +98 -79
- package/dist/structs/Struct.js +11 -1
- package/dist/wrappers/HighloadQueryId.js +0 -1
- package/dist/wrappers/HighloadWalletV3.d.ts +3 -2
- package/dist/wrappers/HighloadWalletV3.js +5 -2
- package/dist/wrappers/JettonWallet.d.ts +11 -2
- package/dist/wrappers/JettonWallet.js +34 -17
- package/package.json +3 -3
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BatchSender = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
|
-
const SenderAbstraction_1 = require("./SenderAbstraction");
|
|
6
|
-
const Consts_1 = require("../sdk/Consts");
|
|
7
5
|
const instances_1 = require("../errors/instances");
|
|
6
|
+
const Consts_1 = require("../sdk/Consts");
|
|
7
|
+
const HighloadWalletV3_1 = require("../wrappers/HighloadWalletV3");
|
|
8
8
|
class BatchSender {
|
|
9
9
|
constructor(wallet, secretKey) {
|
|
10
10
|
this.wallet = wallet;
|
|
11
11
|
this.secretKey = secretKey;
|
|
12
|
+
this.lastCreatedAt = 0;
|
|
13
|
+
}
|
|
14
|
+
async getBalanceOf(asset) {
|
|
15
|
+
return asset.getBalanceOf(this.getSenderAddress());
|
|
12
16
|
}
|
|
13
|
-
async
|
|
17
|
+
async getBalance(contractOpener) {
|
|
18
|
+
const { balance } = await contractOpener.getContractState(this.wallet.address);
|
|
19
|
+
return balance;
|
|
20
|
+
}
|
|
21
|
+
async sendShardTransactions(shardTransactions, _chain, contractOpener) {
|
|
14
22
|
const allMessages = [];
|
|
15
23
|
let minValidUntil = Number.MAX_SAFE_INTEGER;
|
|
16
24
|
for (const transaction of shardTransactions) {
|
|
@@ -28,7 +36,6 @@ class BatchSender {
|
|
|
28
36
|
const results = [];
|
|
29
37
|
let currentMessageIndex = 0;
|
|
30
38
|
for (const group of groups) {
|
|
31
|
-
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
32
39
|
try {
|
|
33
40
|
const result = await this.sendGroup(group, contractOpener);
|
|
34
41
|
results.push({
|
|
@@ -85,16 +92,22 @@ class BatchSender {
|
|
|
85
92
|
}
|
|
86
93
|
async sendGroup(messages, contractOpener) {
|
|
87
94
|
const walletContract = contractOpener.open(this.wallet);
|
|
95
|
+
let createdAt = HighloadWalletV3_1.HighloadWalletV3.generateCreatedAt();
|
|
96
|
+
if (createdAt <= this.lastCreatedAt) {
|
|
97
|
+
createdAt = this.lastCreatedAt + 1; // to prevent error::already_executed on highload wallet
|
|
98
|
+
}
|
|
99
|
+
this.lastCreatedAt = createdAt;
|
|
88
100
|
return walletContract.sendTransfer({
|
|
89
101
|
secretKey: this.secretKey,
|
|
90
102
|
messages,
|
|
91
103
|
sendMode: ton_1.SendMode.PAY_GAS_SEPARATELY,
|
|
104
|
+
createdAt,
|
|
92
105
|
});
|
|
93
106
|
}
|
|
94
107
|
getSenderAddress() {
|
|
95
108
|
return this.wallet.address.toString();
|
|
96
109
|
}
|
|
97
|
-
async sendShardTransaction(shardTransaction,
|
|
110
|
+
async sendShardTransaction(shardTransaction, _chain, contractOpener) {
|
|
98
111
|
const messages = [];
|
|
99
112
|
for (const message of shardTransaction.messages) {
|
|
100
113
|
messages.push((0, ton_1.internal)({
|
|
@@ -104,7 +117,6 @@ class BatchSender {
|
|
|
104
117
|
body: message.payload,
|
|
105
118
|
}));
|
|
106
119
|
}
|
|
107
|
-
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
108
120
|
const result = await this.sendGroup(messages, contractOpener);
|
|
109
121
|
return {
|
|
110
122
|
success: true,
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import type { ContractOpener } from '../structs/Struct';
|
|
2
1
|
import type { SendResult, ShardTransaction } from '../structs/InternalStruct';
|
|
2
|
+
import type { Asset, ContractOpener } from '../structs/Struct';
|
|
3
3
|
import { Network } from '../structs/Struct';
|
|
4
4
|
import { SenderAbstraction, WalletInstance } from './SenderAbstraction';
|
|
5
5
|
export declare class RawSender implements SenderAbstraction {
|
|
6
6
|
private wallet;
|
|
7
7
|
private secretKey;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private maxBatchSize;
|
|
9
|
+
constructor(wallet: WalletInstance, secretKey: Buffer, maxBatchSize?: number);
|
|
10
|
+
getBalanceOf(asset: Asset): Promise<bigint>;
|
|
11
|
+
getBalance(contractOpener: ContractOpener): Promise<bigint>;
|
|
12
|
+
sendShardTransactions(shardTransactions: ShardTransaction[], _chain: Network, contractOpener: ContractOpener): Promise<SendResult[]>;
|
|
13
|
+
private prepareBatches;
|
|
14
|
+
private sendBatch;
|
|
10
15
|
getSenderAddress(): string;
|
|
11
|
-
sendShardTransaction(shardTransaction: ShardTransaction,
|
|
16
|
+
sendShardTransaction(shardTransaction: ShardTransaction, _chain: Network, contractOpener: ContractOpener): Promise<SendResult>;
|
|
12
17
|
}
|
package/dist/sender/RawSender.js
CHANGED
|
@@ -3,24 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RawSender = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
const ton_2 = require("@ton/ton");
|
|
6
|
-
const SenderAbstraction_1 = require("./SenderAbstraction");
|
|
7
6
|
class RawSender {
|
|
8
|
-
constructor(wallet, secretKey) {
|
|
7
|
+
constructor(wallet, secretKey, maxBatchSize = 4) {
|
|
9
8
|
this.wallet = wallet;
|
|
10
9
|
this.secretKey = secretKey;
|
|
10
|
+
this.maxBatchSize = maxBatchSize;
|
|
11
11
|
}
|
|
12
|
-
async
|
|
12
|
+
async getBalanceOf(asset) {
|
|
13
|
+
return asset.getBalanceOf(this.getSenderAddress());
|
|
14
|
+
}
|
|
15
|
+
async getBalance(contractOpener) {
|
|
16
|
+
const { balance } = await contractOpener.getContractState(this.wallet.address);
|
|
17
|
+
return balance;
|
|
18
|
+
}
|
|
19
|
+
async sendShardTransactions(shardTransactions, _chain, contractOpener) {
|
|
20
|
+
const allMessages = [];
|
|
21
|
+
for (const transaction of shardTransactions) {
|
|
22
|
+
for (const message of transaction.messages) {
|
|
23
|
+
allMessages.push((0, ton_1.internal)({
|
|
24
|
+
to: message.address,
|
|
25
|
+
value: (0, ton_1.fromNano)(message.value),
|
|
26
|
+
bounce: true,
|
|
27
|
+
body: message.payload,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const batches = this.prepareBatches(allMessages);
|
|
13
32
|
const results = [];
|
|
14
33
|
let currentMessageIndex = 0;
|
|
15
|
-
for (const
|
|
34
|
+
for (const batch of batches) {
|
|
16
35
|
try {
|
|
17
|
-
const result = await this.
|
|
36
|
+
const result = await this.sendBatch(batch, contractOpener);
|
|
18
37
|
results.push({
|
|
19
38
|
success: true,
|
|
20
39
|
result,
|
|
21
|
-
lastMessageIndex: currentMessageIndex +
|
|
40
|
+
lastMessageIndex: currentMessageIndex + batch.length - 1,
|
|
22
41
|
});
|
|
23
|
-
currentMessageIndex += shardTx.messages.length;
|
|
24
42
|
}
|
|
25
43
|
catch (error) {
|
|
26
44
|
results.push({
|
|
@@ -30,16 +48,32 @@ class RawSender {
|
|
|
30
48
|
});
|
|
31
49
|
break; // Stop sending after first error
|
|
32
50
|
}
|
|
51
|
+
currentMessageIndex += batch.length;
|
|
33
52
|
}
|
|
34
53
|
return results;
|
|
35
54
|
}
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
prepareBatches(messages) {
|
|
56
|
+
const batches = [];
|
|
57
|
+
for (let i = 0; i < messages.length; i += this.maxBatchSize) {
|
|
58
|
+
const batch = messages.slice(i, i + this.maxBatchSize);
|
|
59
|
+
batches.push(batch);
|
|
60
|
+
}
|
|
61
|
+
return batches;
|
|
38
62
|
}
|
|
39
|
-
async
|
|
63
|
+
async sendBatch(messages, contractOpener) {
|
|
40
64
|
const walletContract = contractOpener.open(this.wallet);
|
|
41
|
-
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
42
65
|
const seqno = await walletContract.getSeqno();
|
|
66
|
+
return walletContract.sendTransfer({
|
|
67
|
+
seqno,
|
|
68
|
+
secretKey: this.secretKey,
|
|
69
|
+
messages,
|
|
70
|
+
sendMode: ton_2.SendMode.PAY_GAS_SEPARATELY,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getSenderAddress() {
|
|
74
|
+
return this.wallet.address.toString();
|
|
75
|
+
}
|
|
76
|
+
async sendShardTransaction(shardTransaction, _chain, contractOpener) {
|
|
43
77
|
const messages = [];
|
|
44
78
|
for (const message of shardTransaction.messages) {
|
|
45
79
|
messages.push((0, ton_1.internal)({
|
|
@@ -49,13 +83,7 @@ class RawSender {
|
|
|
49
83
|
body: message.payload,
|
|
50
84
|
}));
|
|
51
85
|
}
|
|
52
|
-
await (
|
|
53
|
-
const result = await walletContract.sendTransfer({
|
|
54
|
-
seqno,
|
|
55
|
-
secretKey: this.secretKey,
|
|
56
|
-
messages,
|
|
57
|
-
sendMode: ton_2.SendMode.PAY_GAS_SEPARATELY,
|
|
58
|
-
});
|
|
86
|
+
const result = await this.sendBatch(messages, contractOpener);
|
|
59
87
|
return {
|
|
60
88
|
success: true,
|
|
61
89
|
result,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Contract, ContractProvider, MessageRelaxed, SendMode } from '@ton/ton';
|
|
2
|
-
import type { ContractOpener } from '../structs/Struct';
|
|
3
2
|
import type { SendResult, ShardTransaction } from '../structs/InternalStruct';
|
|
3
|
+
import type { Asset, ContractOpener } from '../structs/Struct';
|
|
4
4
|
import { Network } from '../structs/Struct';
|
|
5
5
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
6
6
|
export interface WalletInstance extends Contract {
|
|
@@ -14,7 +14,9 @@ export interface WalletInstance extends Contract {
|
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
}
|
|
16
16
|
export interface SenderAbstraction {
|
|
17
|
-
sendShardTransaction(shardTransaction: ShardTransaction,
|
|
18
|
-
sendShardTransactions(shardTransactions: ShardTransaction[],
|
|
17
|
+
sendShardTransaction(shardTransaction: ShardTransaction, chain?: Network, contractOpener?: ContractOpener): Promise<SendResult>;
|
|
18
|
+
sendShardTransactions(shardTransactions: ShardTransaction[], chain?: Network, contractOpener?: ContractOpener): Promise<SendResult[]>;
|
|
19
19
|
getSenderAddress(): string;
|
|
20
|
+
getBalance(contractOpener: ContractOpener): Promise<bigint>;
|
|
21
|
+
getBalanceOf(asset: Asset): Promise<bigint>;
|
|
20
22
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WalletContractV2R1, WalletContractV2R2, WalletContractV3R1, WalletContractV3R2, WalletContractV4, WalletContractV5R1 } from '@ton/ton';
|
|
2
2
|
import { TonConnectUI } from '@tonconnect/ui';
|
|
3
|
-
import { SenderAbstraction } from './SenderAbstraction';
|
|
4
3
|
import { Network } from '../structs/Struct';
|
|
5
4
|
import { HighloadWalletV3 } from '../wrappers/HighloadWalletV3';
|
|
5
|
+
import { SenderAbstraction } from './SenderAbstraction';
|
|
6
6
|
export type WalletVersion = 'V2R1' | 'V2R2' | 'V3R1' | 'V3R2' | 'V4' | 'V5R1' | 'HIGHLOAD_V3';
|
|
7
7
|
export declare const wallets: {
|
|
8
8
|
V2R1: typeof WalletContractV2R1;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SenderFactory = exports.wallets = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
const ton_crypto_1 = require("ton-crypto");
|
|
6
|
-
const RawSender_1 = require("./RawSender");
|
|
7
|
-
const TonConnectSender_1 = require("./TonConnectSender");
|
|
8
|
-
const BatchSender_1 = require("./BatchSender");
|
|
9
6
|
const errors_1 = require("../errors");
|
|
10
7
|
const Struct_1 = require("../structs/Struct");
|
|
11
8
|
const HighloadWalletV3_1 = require("../wrappers/HighloadWalletV3");
|
|
9
|
+
const BatchSender_1 = require("./BatchSender");
|
|
10
|
+
const RawSender_1 = require("./RawSender");
|
|
11
|
+
const TonConnectSender_1 = require("./TonConnectSender");
|
|
12
12
|
exports.wallets = {
|
|
13
13
|
V2R1: ton_1.WalletContractV2R1,
|
|
14
14
|
V2R2: ton_1.WalletContractV2R2,
|
|
@@ -27,6 +27,7 @@ class SenderFactory {
|
|
|
27
27
|
throw (0, errors_1.unknownWalletError)(params.version);
|
|
28
28
|
}
|
|
29
29
|
const keypair = await (0, ton_crypto_1.mnemonicToWalletKey)(params.mnemonic.split(' '));
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
31
|
const config = {
|
|
31
32
|
workchain: 0,
|
|
32
33
|
publicKey: keypair.publicKey,
|
|
@@ -53,7 +54,7 @@ class SenderFactory {
|
|
|
53
54
|
if (params.version === 'HIGHLOAD_V3') {
|
|
54
55
|
return new BatchSender_1.BatchSender(wallet, keypair.secretKey);
|
|
55
56
|
}
|
|
56
|
-
return new RawSender_1.RawSender(wallet, keypair.secretKey);
|
|
57
|
+
return new RawSender_1.RawSender(wallet, keypair.secretKey, params.version === 'V5R1' ? 254 : 4);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
exports.SenderFactory = SenderFactory;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { TonConnectUI } from '@tonconnect/ui';
|
|
2
2
|
import type { SendResult, ShardTransaction } from '../structs/InternalStruct';
|
|
3
|
-
import { ContractOpener, Network } from '../structs/Struct';
|
|
3
|
+
import { Asset, ContractOpener, Network } from '../structs/Struct';
|
|
4
4
|
import { SenderAbstraction } from './SenderAbstraction';
|
|
5
5
|
export declare class TonConnectSender implements SenderAbstraction {
|
|
6
6
|
readonly tonConnect: TonConnectUI;
|
|
7
7
|
constructor(tonConnect: TonConnectUI);
|
|
8
|
+
getBalanceOf(asset: Asset): Promise<bigint>;
|
|
9
|
+
getBalance(contractOpener: ContractOpener): Promise<bigint>;
|
|
8
10
|
private sendChunkedMessages;
|
|
9
|
-
sendShardTransactions(shardTransactions: ShardTransaction[],
|
|
11
|
+
sendShardTransactions(shardTransactions: ShardTransaction[], chain: Network): Promise<SendResult[]>;
|
|
10
12
|
getSenderAddress(): string;
|
|
11
|
-
sendShardTransaction(shardTransaction: ShardTransaction,
|
|
13
|
+
sendShardTransaction(shardTransaction: ShardTransaction, chain: Network): Promise<SendResult>;
|
|
12
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TonConnectSender = void 0;
|
|
4
|
+
const ton_1 = require("@ton/ton");
|
|
4
5
|
const protocol_1 = require("@tonconnect/protocol");
|
|
5
6
|
const ui_1 = require("@tonconnect/ui");
|
|
6
7
|
const Struct_1 = require("../structs/Struct");
|
|
@@ -10,13 +11,18 @@ class TonConnectSender {
|
|
|
10
11
|
constructor(tonConnect) {
|
|
11
12
|
this.tonConnect = tonConnect;
|
|
12
13
|
}
|
|
14
|
+
async getBalanceOf(asset) {
|
|
15
|
+
return asset.getBalanceOf(this.getSenderAddress());
|
|
16
|
+
}
|
|
17
|
+
async getBalance(contractOpener) {
|
|
18
|
+
return this.tonConnect.account
|
|
19
|
+
? (await contractOpener.getContractState((0, ton_1.address)(this.tonConnect.account?.address))).balance
|
|
20
|
+
: 0n;
|
|
21
|
+
}
|
|
13
22
|
async sendChunkedMessages(messages, validUntil, chain) {
|
|
14
23
|
const responses = [];
|
|
15
24
|
let currentMessageIndex = 0;
|
|
16
|
-
const chunkSize =
|
|
17
|
-
//@ts-ignore // 'find' checks that maxMessages is a property of the feature
|
|
18
|
-
this.tonConnect.wallet?.device.features.find((feat) => feat.hasOwnProperty('maxMessages'))?.maxMessages ||
|
|
19
|
-
CHUNK_SIZE;
|
|
25
|
+
const chunkSize = this.tonConnect.wallet?.device.features.find((feat) => Object.prototype.hasOwnProperty.call(feat, 'maxMessages'))?.maxMessages || CHUNK_SIZE;
|
|
20
26
|
for (let i = 0; i < messages.length; i += chunkSize) {
|
|
21
27
|
const chunk = messages.slice(i, i + chunkSize);
|
|
22
28
|
const transaction = {
|
|
@@ -47,7 +53,7 @@ class TonConnectSender {
|
|
|
47
53
|
}
|
|
48
54
|
return responses;
|
|
49
55
|
}
|
|
50
|
-
async sendShardTransactions(shardTransactions,
|
|
56
|
+
async sendShardTransactions(shardTransactions, chain) {
|
|
51
57
|
const allMessages = [];
|
|
52
58
|
let minValidUntil = Number.MAX_SAFE_INTEGER;
|
|
53
59
|
for (const transaction of shardTransactions) {
|
|
@@ -60,13 +66,12 @@ class TonConnectSender {
|
|
|
60
66
|
}
|
|
61
67
|
minValidUntil = Math.min(minValidUntil, transaction.validUntil);
|
|
62
68
|
}
|
|
63
|
-
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
64
69
|
return this.sendChunkedMessages(allMessages, minValidUntil, chain);
|
|
65
70
|
}
|
|
66
71
|
getSenderAddress() {
|
|
67
72
|
return this.tonConnect.account?.address?.toString() || '';
|
|
68
73
|
}
|
|
69
|
-
async sendShardTransaction(shardTransaction,
|
|
74
|
+
async sendShardTransaction(shardTransaction, chain) {
|
|
70
75
|
const messages = [];
|
|
71
76
|
for (const message of shardTransaction.messages) {
|
|
72
77
|
messages.push({
|
|
@@ -75,7 +80,6 @@ class TonConnectSender {
|
|
|
75
80
|
payload: protocol_1.Base64.encode(message.payload.toBoc()).toString(),
|
|
76
81
|
});
|
|
77
82
|
}
|
|
78
|
-
await (0, SenderAbstraction_1.sleep)(delay * 1000);
|
|
79
83
|
const responses = await this.sendChunkedMessages(messages, shardTransaction.validUntil, chain);
|
|
80
84
|
return responses[0];
|
|
81
85
|
}
|
package/dist/sender/index.d.ts
CHANGED
package/dist/sender/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BatchSender"), exports);
|
|
17
18
|
__exportStar(require("./SenderAbstraction"), exports);
|
|
18
19
|
__exportStar(require("./SenderFactory"), exports);
|
|
19
|
-
__exportStar(require("./BatchSender"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cell } from '@ton/ton';
|
|
2
|
-
import { ContractOpener, TACSimulationResult, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, RawAssetBridgingData, StatusInfosByOperationId, OperationType, AssetType, SuggestedTONExecutorFee } from './Struct';
|
|
3
|
-
import { AbstractProvider, ethers, Interface, InterfaceAbi } from 'ethers';
|
|
4
2
|
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
3
|
+
import { AbstractProvider, ethers } from 'ethers';
|
|
4
|
+
import { ContractOpener, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, SuggestedTONExecutorFee, TACSimulationResult } from './Struct';
|
|
5
5
|
export type ShardMessage = {
|
|
6
6
|
address: string;
|
|
7
7
|
value: bigint;
|
|
@@ -22,31 +22,6 @@ export type RandomNumberByTimestamp = {
|
|
|
22
22
|
timestamp: number;
|
|
23
23
|
randomNumber: number;
|
|
24
24
|
};
|
|
25
|
-
export type JettonBridgingData = RawAssetBridgingData & {
|
|
26
|
-
type: AssetType.FT;
|
|
27
|
-
address: string;
|
|
28
|
-
};
|
|
29
|
-
export type JettonTransferData = JettonBridgingData;
|
|
30
|
-
export type JettonBurnData = JettonBridgingData & {
|
|
31
|
-
notificationReceiverAddress: string;
|
|
32
|
-
};
|
|
33
|
-
export type NFTBridgingData = RawAssetBridgingData & {
|
|
34
|
-
type: AssetType.NFT;
|
|
35
|
-
address: string;
|
|
36
|
-
};
|
|
37
|
-
export type NFTTransferData = NFTBridgingData & {
|
|
38
|
-
to: string;
|
|
39
|
-
responseAddress: string;
|
|
40
|
-
evmData: Cell;
|
|
41
|
-
crossChainTonAmount?: bigint;
|
|
42
|
-
feeData?: Cell;
|
|
43
|
-
};
|
|
44
|
-
export type NFTBurnData = NFTBridgingData & {
|
|
45
|
-
notificationReceiverAddress: string;
|
|
46
|
-
evmData: Cell;
|
|
47
|
-
crossChainTonAmount?: bigint;
|
|
48
|
-
feeData?: Cell;
|
|
49
|
-
};
|
|
50
25
|
export type InternalTONParams = {
|
|
51
26
|
contractOpener: ContractOpener;
|
|
52
27
|
jettonProxyAddress: string;
|
|
@@ -60,16 +35,11 @@ export type InternalTONParams = {
|
|
|
60
35
|
export type InternalTACParams = {
|
|
61
36
|
provider: AbstractProvider;
|
|
62
37
|
crossChainLayer: testnet.tac.wrappers.CrossChainLayerTAC | mainnet.tac.wrappers.CrossChainLayerTAC;
|
|
63
|
-
settings: testnet.tac.wrappers.SettingsTAC |
|
|
38
|
+
settings: testnet.tac.wrappers.SettingsTAC | mainnet.tac.wrappers.SettingsTAC;
|
|
64
39
|
tokenUtils: testnet.tac.wrappers.TokenUtilsTAC | mainnet.tac.wrappers.TokenUtilsTAC;
|
|
65
40
|
trustedTACExecutors: string[];
|
|
66
41
|
trustedTONExecutors: string[];
|
|
67
42
|
abiCoder: ethers.AbiCoder;
|
|
68
|
-
crossChainLayerABI: Interface | InterfaceAbi;
|
|
69
|
-
crossChainLayerTokenABI: Interface | InterfaceAbi;
|
|
70
|
-
crossChainLayerTokenBytecode: string;
|
|
71
|
-
crossChainLayerNFTABI: Interface | InterfaceAbi;
|
|
72
|
-
crossChainLayerNFTBytecode: string;
|
|
73
43
|
};
|
|
74
44
|
export type ResponseBase<T> = {
|
|
75
45
|
response: T;
|
|
@@ -87,3 +57,36 @@ export interface SendResult {
|
|
|
87
57
|
error?: Error;
|
|
88
58
|
lastMessageIndex?: number;
|
|
89
59
|
}
|
|
60
|
+
export type ToncenterTransaction = {
|
|
61
|
+
description: {
|
|
62
|
+
aborted: boolean;
|
|
63
|
+
action: {
|
|
64
|
+
resultCode: number;
|
|
65
|
+
success: boolean;
|
|
66
|
+
};
|
|
67
|
+
computePh: {
|
|
68
|
+
exitCode: number;
|
|
69
|
+
success: boolean;
|
|
70
|
+
};
|
|
71
|
+
destroyed: boolean;
|
|
72
|
+
};
|
|
73
|
+
hash: string;
|
|
74
|
+
inMsg: {
|
|
75
|
+
hash: string;
|
|
76
|
+
opcode: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type TransactionDepth = {
|
|
80
|
+
hash: string;
|
|
81
|
+
depth: number;
|
|
82
|
+
};
|
|
83
|
+
export type AdjacentTransactionsResponse = {
|
|
84
|
+
transactions: ToncenterTransaction[];
|
|
85
|
+
};
|
|
86
|
+
export type TxFinalizerConfig = {
|
|
87
|
+
urlBuilder: (hash: string) => string;
|
|
88
|
+
authorization: {
|
|
89
|
+
header: string;
|
|
90
|
+
value: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mainnet, testnet } from '@tonappchain/artifacts';
|
|
2
|
+
import type { SenderAbstraction } from '../sender';
|
|
3
|
+
import { InternalTACParams, InternalTONParams } from './InternalStruct';
|
|
4
|
+
import { Asset, CrosschainTx, EvmProxyMsg, ExecutionFeeEstimationResult, ExecutionStages, ExecutionStagesByOperationId, Network, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTONExecutorFee, TACSimulationRequest, TACSimulationResult, TransactionLinker, WaitOptions } from './Struct';
|
|
5
|
+
export interface IConfiguration {
|
|
6
|
+
readonly network: Network;
|
|
7
|
+
readonly artifacts: typeof testnet | typeof mainnet;
|
|
8
|
+
readonly TONParams: InternalTONParams;
|
|
9
|
+
readonly TACParams: InternalTACParams;
|
|
10
|
+
readonly liteSequencerEndpoints: string[];
|
|
11
|
+
readonly nativeTONAddress: string;
|
|
12
|
+
nativeTACAddress(): Promise<string>;
|
|
13
|
+
readonly getTrustedTACExecutors: string[];
|
|
14
|
+
readonly getTrustedTONExecutors: string[];
|
|
15
|
+
closeConnections(): unknown;
|
|
16
|
+
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export interface ILogger {
|
|
19
|
+
debug(...arg: unknown[]): void;
|
|
20
|
+
info(...arg: unknown[]): void;
|
|
21
|
+
warn(...arg: unknown[]): void;
|
|
22
|
+
error(...arg: unknown[]): void;
|
|
23
|
+
}
|
|
24
|
+
export interface ISimulator {
|
|
25
|
+
simulateTACMessage(req: TACSimulationRequest): Promise<TACSimulationResult>;
|
|
26
|
+
simulateTransactions(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<TACSimulationResult[]>;
|
|
27
|
+
getTVMExecutorFeeInfo(assets: Asset[], feeSymbol: string): Promise<SuggestedTONExecutorFee>;
|
|
28
|
+
getTransactionSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: Asset[]): Promise<ExecutionFeeEstimationResult>;
|
|
29
|
+
getSimulationInfoForTransaction(evmProxyMsg: EvmProxyMsg, transactionLinker: TransactionLinker, assets: Asset[], allowSimulationError?: boolean, isRoundTrip?: boolean, evmValidExecutors?: string[], tvmValidExecutors?: string[]): Promise<ExecutionFeeEstimationResult>;
|
|
30
|
+
}
|
|
31
|
+
export interface IOperationTracker {
|
|
32
|
+
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType>): Promise<OperationType>;
|
|
33
|
+
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string>): Promise<string>;
|
|
34
|
+
getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, waitOptions?: WaitOptions<OperationIdsByShardsKey>, chunkSize?: number): Promise<OperationIdsByShardsKey>;
|
|
35
|
+
getStageProfiling(operationId: string, waitOptions?: WaitOptions<ExecutionStages>): Promise<ExecutionStages>;
|
|
36
|
+
getStageProfilings(operationIds: string[], waitOptions?: WaitOptions<ExecutionStagesByOperationId>, chunkSize?: number): Promise<ExecutionStagesByOperationId>;
|
|
37
|
+
getOperationStatuses(operationIds: string[], waitOptions?: WaitOptions<StatusInfosByOperationId>, chunkSize?: number): Promise<StatusInfosByOperationId>;
|
|
38
|
+
getOperationStatus(operationId: string, waitOptions?: WaitOptions<StatusInfo>): Promise<StatusInfo>;
|
|
39
|
+
getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
|
|
40
|
+
}
|