@tonappchain/sdk 0.7.2-payload-builder-0.3 → 0.7.2-scaled-ui-support-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifacts/dev/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.d.ts +4 -0
- package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.js +7 -0
- package/dist/artifacts/mainnet/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonMinter.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonProxy.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/JettonWallet.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/NFTItem.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/build/NFTProxy.compiled.json +1 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.d.ts +13 -1
- package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.js +45 -7
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.d.ts +6 -2
- package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.js +9 -2
- package/dist/artifacts/testnet/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +4 -0
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +7 -0
- package/dist/src/adapters/contractOpener.d.ts +0 -4
- package/dist/src/adapters/contractOpener.js +1 -165
- package/dist/src/adapters/retryableContractOpener.d.ts +1 -5
- package/dist/src/adapters/retryableContractOpener.js +4 -22
- package/dist/src/assets/AssetFactory.js +2 -8
- package/dist/src/assets/FT.d.ts +10 -0
- package/dist/src/assets/FT.js +47 -0
- package/dist/src/assets/TON.d.ts +1 -2
- package/dist/src/assets/TON.js +0 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +4 -1
- package/dist/src/interfaces/Asset.d.ts +1 -2
- package/dist/src/interfaces/ContractOpener.d.ts +1 -5
- package/dist/src/interfaces/ISimulator.d.ts +0 -7
- package/dist/src/interfaces/ITONTransactionManager.d.ts +1 -20
- package/dist/src/interfaces/ITacSDK.d.ts +1 -10
- package/dist/src/interfaces/WalletInstanse.d.ts +8 -4
- package/dist/src/sdk/Consts.d.ts +0 -1
- package/dist/src/sdk/Consts.js +1 -2
- package/dist/src/sdk/Simulator.d.ts +1 -20
- package/dist/src/sdk/Simulator.js +0 -160
- package/dist/src/sdk/StartTracking.d.ts +3 -5
- package/dist/src/sdk/StartTracking.js +40 -60
- package/dist/src/sdk/TONTransactionManager.d.ts +4 -7
- package/dist/src/sdk/TONTransactionManager.js +2 -38
- package/dist/src/sdk/TacSdk.d.ts +1 -2
- package/dist/src/sdk/TacSdk.js +1 -7
- package/dist/src/sdk/TxFinalizer.d.ts +4 -15
- package/dist/src/sdk/TxFinalizer.js +23 -102
- package/dist/src/sdk/Utils.d.ts +6 -6
- package/dist/src/sdk/Utils.js +9 -35
- package/dist/src/sender/BatchSender.js +0 -19
- package/dist/src/sender/RawSender.js +1 -34
- package/dist/src/sender/SenderFactory.js +1 -1
- package/dist/src/sender/TonConnectSender.js +0 -2
- package/dist/src/structs/InternalStruct.d.ts +1 -22
- package/dist/src/structs/Struct.d.ts +2 -20
- package/dist/src/wrappers/HighloadWalletV3.d.ts +3 -5
- package/dist/src/wrappers/HighloadWalletV3.js +3 -14
- package/package.json +3 -2
- package/dist/src/interfaces/ITxFinalizer.d.ts +0 -5
- package/dist/src/interfaces/ITxFinalizer.js +0 -2
|
@@ -1,112 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const ton_1 = require("@ton/ton");
|
|
3
|
+
exports.TonTxFinalizer = void 0;
|
|
5
4
|
const AxiosHttpClient_1 = require("./AxiosHttpClient");
|
|
6
5
|
const Logger_1 = require("./Logger");
|
|
7
6
|
const Utils_1 = require("./Utils");
|
|
8
7
|
const IGNORE_OPCODE = [
|
|
9
|
-
0xd53276db, // Excess
|
|
10
|
-
0x7362d09c, // Jetton Notify
|
|
8
|
+
'0xd53276db', // Excess
|
|
9
|
+
'0x7362d09c', // Jetton Notify
|
|
11
10
|
];
|
|
12
11
|
class TonTxFinalizer {
|
|
13
|
-
constructor(contractOpener, logger = new Logger_1.NoopLogger()) {
|
|
14
|
-
this.contractOpener = contractOpener;
|
|
15
|
-
this.logger = logger;
|
|
16
|
-
}
|
|
17
|
-
// Fetches adjacent transactions from toncenter
|
|
18
|
-
async fetchAdjacentTransactions(address, hash, retries = 5, delay = 1000, opts) {
|
|
19
|
-
for (let i = retries; i >= 0; i--) {
|
|
20
|
-
try {
|
|
21
|
-
const txs = await this.contractOpener.getAdjacentTransactions(address, hash, opts);
|
|
22
|
-
return txs;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
const errorMessage = error.message;
|
|
26
|
-
// Rate limit error (429) - retry
|
|
27
|
-
if (errorMessage.includes('429')) {
|
|
28
|
-
if (i > 0) {
|
|
29
|
-
await (0, Utils_1.sleep)(delay);
|
|
30
|
-
}
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
// Log all errors except 404 Not Found
|
|
34
|
-
if (!errorMessage.includes('404')) {
|
|
35
|
-
const logMessage = error instanceof Error ? error.message : error;
|
|
36
|
-
this.logger.warn(`Failed to fetch adjacent transactions for ${hash}:`, logMessage);
|
|
37
|
-
}
|
|
38
|
-
if (i > 0) {
|
|
39
|
-
await (0, Utils_1.sleep)(delay);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
// Checks if all transactions in the tree are successful
|
|
46
|
-
async trackTransactionTree(address, hash, params) {
|
|
47
|
-
const { maxDepth = 10 } = params;
|
|
48
|
-
const parsedAddress = ton_1.Address.parse(address);
|
|
49
|
-
const visitedHashes = new Set();
|
|
50
|
-
const queue = [{ address: parsedAddress, hash, depth: 0 }];
|
|
51
|
-
while (queue.length > 0) {
|
|
52
|
-
const { hash: currentHash, depth: currentDepth, address: currentAddress } = queue.shift();
|
|
53
|
-
if (visitedHashes.has(currentHash)) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
visitedHashes.add(currentHash);
|
|
57
|
-
this.logger.debug(`Checking hash (depth ${currentDepth}): ${currentHash}`);
|
|
58
|
-
const transactions = await this.fetchAdjacentTransactions(currentAddress, currentHash, 5, 1000, {
|
|
59
|
-
limit: 10,
|
|
60
|
-
archival: true,
|
|
61
|
-
});
|
|
62
|
-
console.log(`Found ${transactions.length} adjacent transactions for ${currentHash}`);
|
|
63
|
-
if (transactions.length === 0)
|
|
64
|
-
continue;
|
|
65
|
-
for (const tx of transactions) {
|
|
66
|
-
if (tx.description.type !== 'generic' || !tx.inMessage)
|
|
67
|
-
continue;
|
|
68
|
-
const bodySlice = tx.inMessage.body.beginParse();
|
|
69
|
-
if (bodySlice.remainingBits < 32)
|
|
70
|
-
continue;
|
|
71
|
-
const opcode = bodySlice.loadUint(32);
|
|
72
|
-
if (!IGNORE_OPCODE.includes(opcode)) {
|
|
73
|
-
const { aborted, computePhase, actionPhase } = tx.description;
|
|
74
|
-
if (aborted ||
|
|
75
|
-
computePhase.type == 'skipped' ||
|
|
76
|
-
!computePhase.success ||
|
|
77
|
-
computePhase.exitCode !== 0 ||
|
|
78
|
-
(actionPhase && (!actionPhase.success || actionPhase.resultCode !== 0))) {
|
|
79
|
-
throw new Error(`Transaction failed:\n` +
|
|
80
|
-
`hash = ${currentHash}, ` +
|
|
81
|
-
`aborted = ${aborted}, ` +
|
|
82
|
-
`compute phase: ${computePhase.type === 'skipped' ? 'skipped' : `success = ${computePhase.success}, exit code = ${computePhase.exitCode}`}, ` +
|
|
83
|
-
`action phase: ${!actionPhase ? 'skipped' : `success = ${actionPhase.success}, result code = ${actionPhase.resultCode}`} `);
|
|
84
|
-
}
|
|
85
|
-
if (currentDepth + 1 < maxDepth) {
|
|
86
|
-
if (tx.outMessages.size > 0) {
|
|
87
|
-
queue.push({
|
|
88
|
-
hash: tx.hash().toString('base64'),
|
|
89
|
-
address: tx.inMessage.info.dest,
|
|
90
|
-
depth: currentDepth + 1,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this.logger.debug(`Skipping hash (depth ${currentDepth}): ${tx.hash().toString('base64')}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
this.logger.debug(`Finished checking hash (depth ${currentDepth}): ${currentHash}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.TonTxFinalizer = TonTxFinalizer;
|
|
104
|
-
class TonTxFinalizerV3 {
|
|
105
12
|
constructor(apiConfig, logger = new Logger_1.NoopLogger(), httpClient = new AxiosHttpClient_1.AxiosHttpClient()) {
|
|
106
13
|
this.apiConfig = apiConfig;
|
|
107
14
|
this.logger = logger;
|
|
108
15
|
this.httpClient = httpClient;
|
|
109
16
|
}
|
|
17
|
+
logHashFormats(hash) {
|
|
18
|
+
let hex, base64;
|
|
19
|
+
if (hash.startsWith('0x')) {
|
|
20
|
+
hex = hash;
|
|
21
|
+
const cleanHex = hex.slice(2);
|
|
22
|
+
const buffer = Buffer.from(cleanHex, 'hex');
|
|
23
|
+
base64 = buffer.toString('base64');
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
base64 = hash;
|
|
27
|
+
const buffer = Buffer.from(base64, 'base64');
|
|
28
|
+
hex = '0x' + buffer.toString('hex');
|
|
29
|
+
}
|
|
30
|
+
return { hex: hex, base64: base64 };
|
|
31
|
+
}
|
|
110
32
|
// Fetches adjacent transactions from toncenter
|
|
111
33
|
async fetchAdjacentTransactions(hash, retries = 5, delay = 1000) {
|
|
112
34
|
for (let i = retries; i >= 0; i--) {
|
|
@@ -142,8 +64,7 @@ class TonTxFinalizerV3 {
|
|
|
142
64
|
return [];
|
|
143
65
|
}
|
|
144
66
|
// Checks if all transactions in the tree are successful
|
|
145
|
-
async trackTransactionTree(
|
|
146
|
-
const { maxDepth = 10 } = params;
|
|
67
|
+
async trackTransactionTree(hash, maxDepth = 10) {
|
|
147
68
|
const visitedHashes = new Set();
|
|
148
69
|
const queue = [{ hash, depth: 0 }];
|
|
149
70
|
while (queue.length > 0) {
|
|
@@ -152,12 +73,12 @@ class TonTxFinalizerV3 {
|
|
|
152
73
|
continue;
|
|
153
74
|
}
|
|
154
75
|
visitedHashes.add(currentHash);
|
|
155
|
-
this.logger.debug(`Checking hash (depth ${currentDepth}): ${currentHash}`);
|
|
76
|
+
this.logger.debug(`Checking hash (depth ${currentDepth}):\nhex: ${this.logHashFormats(currentHash).hex}\nbase64: ${this.logHashFormats(currentHash).base64}`);
|
|
156
77
|
const transactions = await this.fetchAdjacentTransactions(currentHash);
|
|
157
78
|
if (transactions.length === 0)
|
|
158
79
|
continue;
|
|
159
80
|
for (const tx of transactions) {
|
|
160
|
-
if (!IGNORE_OPCODE.includes(
|
|
81
|
+
if (!IGNORE_OPCODE.includes(tx.inMsg.opcode) && tx.inMsg.opcode !== null) {
|
|
161
82
|
const { aborted, computePh: compute_ph, action } = tx.description;
|
|
162
83
|
if (aborted ||
|
|
163
84
|
!compute_ph.success ||
|
|
@@ -179,10 +100,10 @@ class TonTxFinalizerV3 {
|
|
|
179
100
|
}
|
|
180
101
|
}
|
|
181
102
|
else {
|
|
182
|
-
this.logger.debug(`Skipping hash (depth ${currentDepth}): ${tx.hash}`);
|
|
103
|
+
this.logger.debug(`Skipping hash (depth ${currentDepth}):\nhex: ${this.logHashFormats(tx.hash).hex}\nbase64: ${this.logHashFormats(tx.hash).base64}`);
|
|
183
104
|
}
|
|
184
105
|
}
|
|
185
106
|
}
|
|
186
107
|
}
|
|
187
108
|
}
|
|
188
|
-
exports.
|
|
109
|
+
exports.TonTxFinalizer = TonTxFinalizer;
|
package/dist/src/sdk/Utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, Cell
|
|
1
|
+
import { Address, Cell } from '@ton/ton';
|
|
2
2
|
import { AbiCoder } from 'ethers';
|
|
3
3
|
import type { FT, NFT, TON } from '../assets';
|
|
4
4
|
import { Asset, IConfiguration } from '../interfaces';
|
|
@@ -32,8 +32,8 @@ export declare function normalizeAssets(config: IConfiguration, assets?: AssetLi
|
|
|
32
32
|
export declare function getAddressString(cell?: Cell): string;
|
|
33
33
|
export declare function getNumber(len: number, cell?: Cell): number;
|
|
34
34
|
export declare function getString(cell?: Cell): string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Multiply-divide with rounding (muldivr)
|
|
37
|
+
* Calculates (a * b + c / 2) / c with proper rounding
|
|
38
|
+
*/
|
|
39
|
+
export declare function muldivr(a: bigint, b: bigint, c: bigint): bigint;
|
package/dist/src/sdk/Utils.js
CHANGED
|
@@ -19,8 +19,7 @@ exports.normalizeAssets = normalizeAssets;
|
|
|
19
19
|
exports.getAddressString = getAddressString;
|
|
20
20
|
exports.getNumber = getNumber;
|
|
21
21
|
exports.getString = getString;
|
|
22
|
-
exports.
|
|
23
|
-
exports.retry = retry;
|
|
22
|
+
exports.muldivr = muldivr;
|
|
24
23
|
const ton_1 = require("@ton/ton");
|
|
25
24
|
const ethers_1 = require("ethers");
|
|
26
25
|
const ton_crypto_1 = require("ton-crypto");
|
|
@@ -301,38 +300,13 @@ function getNumber(len, cell) {
|
|
|
301
300
|
function getString(cell) {
|
|
302
301
|
return cell?.beginParse().loadStringTail() ?? '';
|
|
303
302
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Multiply-divide with rounding (muldivr)
|
|
305
|
+
* Calculates (a * b + c / 2) / c with proper rounding
|
|
306
|
+
*/
|
|
307
|
+
function muldivr(a, b, c) {
|
|
308
|
+
if (c === 0n) {
|
|
309
|
+
throw new Error('Division by zero in muldivr');
|
|
307
310
|
}
|
|
308
|
-
|
|
309
|
-
...message.info,
|
|
310
|
-
src: undefined,
|
|
311
|
-
importFee: 0n,
|
|
312
|
-
};
|
|
313
|
-
const normalizedMessage = {
|
|
314
|
-
...message,
|
|
315
|
-
init: null,
|
|
316
|
-
info: info,
|
|
317
|
-
};
|
|
318
|
-
return (0, ton_1.beginCell)()
|
|
319
|
-
.store((0, ton_1.storeMessage)(normalizedMessage, { forceRef: true }))
|
|
320
|
-
.endCell()
|
|
321
|
-
.hash()
|
|
322
|
-
.toString('base64');
|
|
323
|
-
}
|
|
324
|
-
async function retry(fn, options) {
|
|
325
|
-
let lastError;
|
|
326
|
-
for (let i = 0; i < options.retries; i++) {
|
|
327
|
-
try {
|
|
328
|
-
return await fn();
|
|
329
|
-
}
|
|
330
|
-
catch (e) {
|
|
331
|
-
if (e instanceof Error) {
|
|
332
|
-
lastError = e;
|
|
333
|
-
}
|
|
334
|
-
await new Promise((resolve) => setTimeout(resolve, options.delay));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
throw lastError;
|
|
311
|
+
return (a * b + c / 2n) / c;
|
|
338
312
|
}
|
|
@@ -38,16 +38,7 @@ class BatchSender {
|
|
|
38
38
|
for (const group of groups) {
|
|
39
39
|
try {
|
|
40
40
|
const result = await this.sendGroup(group, contractOpener);
|
|
41
|
-
// Extract BoC if it's a string, or from sandbox result
|
|
42
|
-
let externalMsgBoc = '';
|
|
43
|
-
if (typeof result === 'string') {
|
|
44
|
-
externalMsgBoc = result;
|
|
45
|
-
}
|
|
46
|
-
else if (result?.result) {
|
|
47
|
-
externalMsgBoc = result.result;
|
|
48
|
-
}
|
|
49
41
|
results.push({
|
|
50
|
-
boc: externalMsgBoc,
|
|
51
42
|
success: true,
|
|
52
43
|
result,
|
|
53
44
|
lastMessageIndex: currentMessageIndex + group.length - 1,
|
|
@@ -55,7 +46,6 @@ class BatchSender {
|
|
|
55
46
|
}
|
|
56
47
|
catch (error) {
|
|
57
48
|
results.push({
|
|
58
|
-
boc: '',
|
|
59
49
|
success: false,
|
|
60
50
|
error: error,
|
|
61
51
|
lastMessageIndex: currentMessageIndex - 1,
|
|
@@ -128,16 +118,7 @@ class BatchSender {
|
|
|
128
118
|
}));
|
|
129
119
|
}
|
|
130
120
|
const result = await this.sendGroup(messages, contractOpener);
|
|
131
|
-
// Extract BoC if it's a string, or from sandbox result
|
|
132
|
-
let externalMsgBoc = '';
|
|
133
|
-
if (typeof result === 'string') {
|
|
134
|
-
externalMsgBoc = result;
|
|
135
|
-
}
|
|
136
|
-
else if (result?.result) {
|
|
137
|
-
externalMsgBoc = result.result;
|
|
138
|
-
}
|
|
139
121
|
return {
|
|
140
|
-
boc: externalMsgBoc,
|
|
141
122
|
success: true,
|
|
142
123
|
result,
|
|
143
124
|
lastMessageIndex: shardTransaction.messages.length - 1,
|
|
@@ -34,16 +34,7 @@ class RawSender {
|
|
|
34
34
|
for (const batch of batches) {
|
|
35
35
|
try {
|
|
36
36
|
const result = await this.sendBatch(batch, contractOpener);
|
|
37
|
-
// Extract BoC if it's a string, or from sandbox result
|
|
38
|
-
let externalMsgBoc = '';
|
|
39
|
-
if (typeof result === 'string') {
|
|
40
|
-
externalMsgBoc = result;
|
|
41
|
-
}
|
|
42
|
-
else if (result?.result) {
|
|
43
|
-
externalMsgBoc = result.result;
|
|
44
|
-
}
|
|
45
37
|
results.push({
|
|
46
|
-
boc: externalMsgBoc,
|
|
47
38
|
success: true,
|
|
48
39
|
result,
|
|
49
40
|
lastMessageIndex: currentMessageIndex + batch.length - 1,
|
|
@@ -51,7 +42,6 @@ class RawSender {
|
|
|
51
42
|
}
|
|
52
43
|
catch (error) {
|
|
53
44
|
results.push({
|
|
54
|
-
boc: '',
|
|
55
45
|
success: false,
|
|
56
46
|
error: error,
|
|
57
47
|
lastMessageIndex: currentMessageIndex - 1,
|
|
@@ -73,26 +63,12 @@ class RawSender {
|
|
|
73
63
|
async sendBatch(messages, contractOpener) {
|
|
74
64
|
const walletContract = contractOpener.open(this.wallet);
|
|
75
65
|
const seqno = await walletContract.getSeqno();
|
|
76
|
-
|
|
77
|
-
const msg = this.wallet.createTransfer({
|
|
66
|
+
return walletContract.sendTransfer({
|
|
78
67
|
seqno,
|
|
79
68
|
secretKey: this.secretKey,
|
|
80
69
|
messages,
|
|
81
70
|
sendMode: ton_2.SendMode.PAY_GAS_SEPARATELY,
|
|
82
71
|
});
|
|
83
|
-
let neededInit = null;
|
|
84
|
-
if (this.wallet.init && (await contractOpener.getContractState(this.wallet.address)).state !== 'active') {
|
|
85
|
-
neededInit = this.wallet.init;
|
|
86
|
-
}
|
|
87
|
-
const ext = (0, ton_1.external)({
|
|
88
|
-
to: this.wallet.address,
|
|
89
|
-
init: neededInit,
|
|
90
|
-
body: msg,
|
|
91
|
-
});
|
|
92
|
-
const boc = (0, ton_1.beginCell)().store((0, ton_1.storeMessage)(ext)).endCell().toBoc().toString('base64');
|
|
93
|
-
// Send the transaction
|
|
94
|
-
const result = await walletContract.send(msg);
|
|
95
|
-
return boc || result;
|
|
96
72
|
}
|
|
97
73
|
getSenderAddress() {
|
|
98
74
|
return this.wallet.address.toString();
|
|
@@ -108,16 +84,7 @@ class RawSender {
|
|
|
108
84
|
}));
|
|
109
85
|
}
|
|
110
86
|
const result = await this.sendBatch(messages, contractOpener);
|
|
111
|
-
// Extract BoC if it's a string, or from sandbox result
|
|
112
|
-
let externalMsgBoc = '';
|
|
113
|
-
if (typeof result === 'string') {
|
|
114
|
-
externalMsgBoc = result;
|
|
115
|
-
}
|
|
116
|
-
else if (result?.result) {
|
|
117
|
-
externalMsgBoc = result.result;
|
|
118
|
-
}
|
|
119
87
|
return {
|
|
120
|
-
boc: externalMsgBoc,
|
|
121
88
|
success: true,
|
|
122
89
|
result,
|
|
123
90
|
lastMessageIndex: shardTransaction.messages.length - 1,
|
|
@@ -51,7 +51,7 @@ class SenderFactory {
|
|
|
51
51
|
config.timeout = params.options?.highloadV3?.timeout ?? HighloadWalletV3_1.DEFAULT_TIMEOUT;
|
|
52
52
|
}
|
|
53
53
|
const wallet = exports.wallets[params.version].create(config);
|
|
54
|
-
if (
|
|
54
|
+
if (params.version === 'HIGHLOAD_V3') {
|
|
55
55
|
return new BatchSender_1.BatchSender(wallet, keypair.secretKey);
|
|
56
56
|
}
|
|
57
57
|
return new RawSender_1.RawSender(wallet, keypair.secretKey, params.version === 'V5R1' ? 254 : 4);
|
|
@@ -35,7 +35,6 @@ class TonConnectSender {
|
|
|
35
35
|
responses.push({
|
|
36
36
|
success: true,
|
|
37
37
|
result: response,
|
|
38
|
-
boc: response.boc,
|
|
39
38
|
lastMessageIndex: currentMessageIndex + chunk.length - 1,
|
|
40
39
|
});
|
|
41
40
|
currentMessageIndex += chunk.length;
|
|
@@ -43,7 +42,6 @@ class TonConnectSender {
|
|
|
43
42
|
catch (error) {
|
|
44
43
|
responses.push({
|
|
45
44
|
success: false,
|
|
46
|
-
boc: '',
|
|
47
45
|
error: error,
|
|
48
46
|
lastMessageIndex: currentMessageIndex - 1,
|
|
49
47
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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';
|
|
@@ -7,9 +7,6 @@ export type ShardMessage = {
|
|
|
7
7
|
address: string;
|
|
8
8
|
value: bigint;
|
|
9
9
|
payload: Cell;
|
|
10
|
-
extra: {
|
|
11
|
-
networkFeeIncluded: bigint;
|
|
12
|
-
};
|
|
13
10
|
};
|
|
14
11
|
export type ShardTransaction = {
|
|
15
12
|
validUntil: number;
|
|
@@ -64,7 +61,6 @@ export type OperationIdWithLogIndex = {
|
|
|
64
61
|
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex>;
|
|
65
62
|
export interface SendResult {
|
|
66
63
|
success: boolean;
|
|
67
|
-
boc: string;
|
|
68
64
|
result?: unknown;
|
|
69
65
|
error?: Error;
|
|
70
66
|
lastMessageIndex?: number;
|
|
@@ -92,7 +88,6 @@ export type ToncenterTransaction = {
|
|
|
92
88
|
}[];
|
|
93
89
|
};
|
|
94
90
|
export type TransactionDepth = {
|
|
95
|
-
address?: Address;
|
|
96
91
|
hash: string;
|
|
97
92
|
depth: number;
|
|
98
93
|
};
|
|
@@ -119,19 +114,3 @@ export type ConvertedCurrencyRawResult = {
|
|
|
119
114
|
tacPrice: USDPriceInfoRaw;
|
|
120
115
|
tonPrice: USDPriceInfoRaw;
|
|
121
116
|
};
|
|
122
|
-
export type GetTransactionsOptions = {
|
|
123
|
-
limit: number;
|
|
124
|
-
lt?: string;
|
|
125
|
-
hash?: string;
|
|
126
|
-
to_lt?: string;
|
|
127
|
-
inclusive?: boolean;
|
|
128
|
-
archival?: boolean;
|
|
129
|
-
timeoutMs?: number;
|
|
130
|
-
retryDelayMs?: number;
|
|
131
|
-
};
|
|
132
|
-
export type AddressInformation = {
|
|
133
|
-
lastTransaction: {
|
|
134
|
-
lt: string;
|
|
135
|
-
hash: string;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
|
-
import {
|
|
2
|
+
import { 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
6
|
import type { Asset, ContractOpener, ILogger } from '../interfaces';
|
|
7
|
-
import { ITxFinalizer } from '../interfaces/ITxFinalizer';
|
|
8
|
-
import { SendResult } from './InternalStruct';
|
|
9
7
|
export type ContractState = {
|
|
10
8
|
balance: bigint;
|
|
11
9
|
state: 'active' | 'uninitialized' | 'frozen';
|
|
@@ -61,10 +59,6 @@ export type TONParams = {
|
|
|
61
59
|
* Address of TON settings contract. Use only for tests.
|
|
62
60
|
*/
|
|
63
61
|
settingsAddress?: string;
|
|
64
|
-
/**
|
|
65
|
-
* TxFinalizer for tracking transaction tree
|
|
66
|
-
*/
|
|
67
|
-
txFinalizer?: ITxFinalizer;
|
|
68
62
|
};
|
|
69
63
|
export type SDKParams = {
|
|
70
64
|
/**
|
|
@@ -116,7 +110,7 @@ export type TransactionLinker = {
|
|
|
116
110
|
shardCount: number;
|
|
117
111
|
shardsKey: string;
|
|
118
112
|
timestamp: number;
|
|
119
|
-
sendTransactionResult?:
|
|
113
|
+
sendTransactionResult?: unknown;
|
|
120
114
|
};
|
|
121
115
|
export type TransactionLinkerWithOperationId = TransactionLinker & {
|
|
122
116
|
operationId?: string;
|
|
@@ -373,11 +367,6 @@ export interface WaitOptions<T = unknown, TContext = unknown> {
|
|
|
373
367
|
* Receives both the result and optional context with additional parameters
|
|
374
368
|
*/
|
|
375
369
|
onSuccess?: (result: T, context?: TContext) => Promise<void> | void;
|
|
376
|
-
/**
|
|
377
|
-
* Ensure that TON transaction is succesful
|
|
378
|
-
* @default true
|
|
379
|
-
*/
|
|
380
|
-
ensureTxExecuted?: boolean;
|
|
381
370
|
}
|
|
382
371
|
export declare const defaultWaitOptions: WaitOptions;
|
|
383
372
|
export declare enum Origin {
|
|
@@ -429,10 +418,3 @@ export type FTOriginAndData = {
|
|
|
429
418
|
evmAddress?: string;
|
|
430
419
|
jettonData?: JettonMinterData;
|
|
431
420
|
};
|
|
432
|
-
export type CrossChainPayloadResult = {
|
|
433
|
-
body: Cell;
|
|
434
|
-
destinationAddress: string;
|
|
435
|
-
tonAmount: bigint;
|
|
436
|
-
networkFee: bigint;
|
|
437
|
-
transactionLinker: TransactionLinker;
|
|
438
|
-
};
|
|
@@ -25,8 +25,6 @@ export declare class HighloadWalletV3 implements WalletInstanse {
|
|
|
25
25
|
data: Cell;
|
|
26
26
|
} | undefined);
|
|
27
27
|
getSeqno(): Promise<number>;
|
|
28
|
-
send(provider: ContractProvider, msg: Cell): Promise<void>;
|
|
29
|
-
createTransfer(): Cell;
|
|
30
28
|
sendTransfer(provider: ContractProvider, args: {
|
|
31
29
|
seqno?: number;
|
|
32
30
|
secretKey: Buffer;
|
|
@@ -35,7 +33,7 @@ export declare class HighloadWalletV3 implements WalletInstanse {
|
|
|
35
33
|
timeout?: number;
|
|
36
34
|
subwalletId?: number;
|
|
37
35
|
createdAt?: number;
|
|
38
|
-
}): Promise<
|
|
36
|
+
}): Promise<void>;
|
|
39
37
|
static create(config: HighloadWalletV3Config, code?: Cell, workchain?: number): HighloadWalletV3;
|
|
40
38
|
static generateCreatedAt(): number;
|
|
41
39
|
sendExternalMessage(provider: ContractProvider, secretKey: Buffer, opts: {
|
|
@@ -45,8 +43,8 @@ export declare class HighloadWalletV3 implements WalletInstanse {
|
|
|
45
43
|
createdAt: number;
|
|
46
44
|
subwalletId: number;
|
|
47
45
|
timeout: number;
|
|
48
|
-
}): Promise<
|
|
49
|
-
sendBatch(provider: ContractProvider, secretKey: Buffer, messages: OutActionSendMsg[], subwallet: number, timeout: number, createdAt?: number, value?: bigint): Promise<
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
sendBatch(provider: ContractProvider, secretKey: Buffer, messages: OutActionSendMsg[], subwallet: number, timeout: number, createdAt?: number, value?: bigint): Promise<void>;
|
|
50
48
|
getQueryIdFromCreatedAt(createdAt: number): HighloadQueryId;
|
|
51
49
|
getExternalMessage(messages: MessageRelaxed[], sendMode: SendMode, value: bigint, queryId: HighloadQueryId): MessageRelaxed;
|
|
52
50
|
static createInternalTransferBody(opts: {
|
|
@@ -30,15 +30,9 @@ class HighloadWalletV3 {
|
|
|
30
30
|
async getSeqno() {
|
|
31
31
|
return 0; // will not be used
|
|
32
32
|
}
|
|
33
|
-
async send(provider, msg) {
|
|
34
|
-
await provider.external(msg);
|
|
35
|
-
}
|
|
36
|
-
createTransfer() {
|
|
37
|
-
throw new Error('Not implemented. Use sendTransfer instead - it returns the BOC as a string');
|
|
38
|
-
}
|
|
39
33
|
async sendTransfer(provider, args) {
|
|
40
34
|
if (!args.messages.length) {
|
|
41
|
-
return
|
|
35
|
+
return;
|
|
42
36
|
}
|
|
43
37
|
const state = await provider.getState();
|
|
44
38
|
const isActive = state.state.type === 'active';
|
|
@@ -49,7 +43,7 @@ class HighloadWalletV3 {
|
|
|
49
43
|
mode: args.sendMode,
|
|
50
44
|
outMsg: msg,
|
|
51
45
|
}));
|
|
52
|
-
|
|
46
|
+
await this.sendBatch(provider, args.secretKey, actions, subwalletId, timeout, args.createdAt);
|
|
53
47
|
}
|
|
54
48
|
static create(config, code = HIGHLOAD_V3_CODE, workchain = 0) {
|
|
55
49
|
const data = highloadWalletV3ConfigToCell(config);
|
|
@@ -78,12 +72,7 @@ class HighloadWalletV3 {
|
|
|
78
72
|
.storeUint(opts.createdAt, exports.TIMESTAMP_SIZE)
|
|
79
73
|
.storeUint(opts.timeout, exports.TIMEOUT_SIZE)
|
|
80
74
|
.endCell();
|
|
81
|
-
|
|
82
|
-
.storeBuffer((0, ton_crypto_1.sign)(messageInner.hash(), secretKey))
|
|
83
|
-
.storeRef(messageInner)
|
|
84
|
-
.endCell();
|
|
85
|
-
await provider.external(externalMessage);
|
|
86
|
-
return externalMessage.toBoc().toString('base64');
|
|
75
|
+
await provider.external((0, ton_1.beginCell)().storeBuffer((0, ton_crypto_1.sign)(messageInner.hash(), secretKey)).storeRef(messageInner).endCell());
|
|
87
76
|
}
|
|
88
77
|
async sendBatch(provider, secretKey, messages, subwallet, timeout, createdAt, value = 0n) {
|
|
89
78
|
if (createdAt == undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonappchain/sdk",
|
|
3
|
-
"version": "0.7.2-
|
|
3
|
+
"version": "0.7.2-scaled-ui-support-1",
|
|
4
4
|
"repository": "https://github.com/TacBuild/tac-sdk.git",
|
|
5
5
|
"author": "TAC. <developers@tac>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,10 +69,11 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@aws-crypto/sha256-js": "^5.2.0",
|
|
71
71
|
"@orbs-network/ton-access": "^2.3.3",
|
|
72
|
-
"@ton/ton": "
|
|
72
|
+
"@ton/ton": "15.1.0",
|
|
73
73
|
"@tonappchain/ton-lite-client": "3.0.6",
|
|
74
74
|
"@tonconnect/ui": "^2.0.11",
|
|
75
75
|
"bn.js": "^5.2.1",
|
|
76
|
+
"cli-table3": "^0.6.5",
|
|
76
77
|
"dotenv": "^16.4.7",
|
|
77
78
|
"ethers": "^6.13.5",
|
|
78
79
|
"ton-crypto": "^3.2.0"
|