@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,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAdjacentTransactionsHelper = getAdjacentTransactionsHelper;
|
|
4
3
|
exports.liteClientOpener = liteClientOpener;
|
|
5
4
|
exports.sandboxOpener = sandboxOpener;
|
|
6
5
|
exports.orbsOpener = orbsOpener;
|
|
7
6
|
exports.orbsOpener4 = orbsOpener4;
|
|
8
|
-
exports.tonClientOpener = tonClientOpener;
|
|
9
7
|
const ton_access_1 = require("@orbs-network/ton-access");
|
|
10
8
|
const ton_1 = require("@ton/ton");
|
|
11
9
|
const ton_lite_client_1 = require("@tonappchain/ton-lite-client");
|
|
@@ -44,74 +42,6 @@ async function getHttpV4EndpointWithRetry(network, maxRetries = 5, delay = 1000)
|
|
|
44
42
|
}
|
|
45
43
|
throw lastError || new Error('Failed to get HTTP V4 endpoint after retries');
|
|
46
44
|
}
|
|
47
|
-
async function findTransactionByHash(addr, targetHashB64, getTransactions, opts) {
|
|
48
|
-
const timeoutMs = opts?.timeoutMs ?? 60000; // 60 seconds default
|
|
49
|
-
const retryDelayMs = opts?.retryDelayMs ?? 2000; // 2 seconds between retries
|
|
50
|
-
const deadline = Date.now() + timeoutMs;
|
|
51
|
-
const limit = opts?.limit ?? 10;
|
|
52
|
-
while (Date.now() < deadline) {
|
|
53
|
-
const batch = await getTransactions(addr, {
|
|
54
|
-
limit,
|
|
55
|
-
archival: opts?.archival ?? true,
|
|
56
|
-
});
|
|
57
|
-
// Check each transaction in the current batch
|
|
58
|
-
for (const tx of batch) {
|
|
59
|
-
// 1. check tx itself
|
|
60
|
-
if (tx.hash().toString('base64') === targetHashB64) {
|
|
61
|
-
return tx;
|
|
62
|
-
}
|
|
63
|
-
// 2. check incoming message(external-in)
|
|
64
|
-
if (tx.inMessage && tx.inMessage.info.type === 'external-in') {
|
|
65
|
-
const hash = (0, Utils_1.getNormalizedExtMessageHash)(tx.inMessage);
|
|
66
|
-
if (hash === targetHashB64) {
|
|
67
|
-
return tx;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// 3. check incoming message(internal)
|
|
71
|
-
if (tx.inMessage && tx.inMessage.info.type === 'internal') {
|
|
72
|
-
const messageCell = (0, ton_1.beginCell)().store((0, ton_1.storeMessage)(tx.inMessage)).endCell();
|
|
73
|
-
const hash = messageCell.hash();
|
|
74
|
-
if (hash.toString('base64') === targetHashB64) {
|
|
75
|
-
return tx;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (Date.now() < deadline) {
|
|
80
|
-
await (0, Utils_1.sleep)(retryDelayMs);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
async function getAdjacentTransactionsHelper(addr, hashB64, getTransactions, opts) {
|
|
86
|
-
// 1. Find the root transaction
|
|
87
|
-
const rootTx = await findTransactionByHash(addr, hashB64, getTransactions, opts);
|
|
88
|
-
if (!rootTx)
|
|
89
|
-
return [];
|
|
90
|
-
const adjacent = [];
|
|
91
|
-
// 2. Follow every outgoing message
|
|
92
|
-
for (const msg of rootTx.outMessages.values()) {
|
|
93
|
-
const dst = msg.info.dest;
|
|
94
|
-
if (!dst || dst instanceof ton_1.ExternalAddress)
|
|
95
|
-
continue;
|
|
96
|
-
const msgHashB64 = (0, ton_1.beginCell)().store((0, ton_1.storeMessage)(msg)).endCell().hash().toString('base64');
|
|
97
|
-
const tx = await findTransactionByHash(dst, msgHashB64, getTransactions, opts);
|
|
98
|
-
if (tx)
|
|
99
|
-
adjacent.push(tx);
|
|
100
|
-
}
|
|
101
|
-
// 3. Optional: follow the incoming message (if it exists and is internal)
|
|
102
|
-
if (rootTx.inMessage?.info.type === 'internal') {
|
|
103
|
-
const src = rootTx.inMessage.info.src;
|
|
104
|
-
if (src instanceof ton_1.Address) {
|
|
105
|
-
// The incoming message belongs to the sender's out-message list,
|
|
106
|
-
// so we look for the same message hash on the sender side.
|
|
107
|
-
const msgHashB64 = (0, ton_1.beginCell)().store((0, ton_1.storeMessage)(rootTx.inMessage)).endCell().hash().toString('base64');
|
|
108
|
-
const tx = await findTransactionByHash(src, msgHashB64, getTransactions, opts);
|
|
109
|
-
if (tx)
|
|
110
|
-
adjacent.push(tx);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return adjacent;
|
|
114
|
-
}
|
|
115
45
|
function intToIP(int) {
|
|
116
46
|
const part1 = int & 255;
|
|
117
47
|
const part2 = (int >> 8) & 255;
|
|
@@ -142,14 +72,6 @@ async function liteClientOpener(options) {
|
|
|
142
72
|
const closeConnections = () => {
|
|
143
73
|
engine.close();
|
|
144
74
|
};
|
|
145
|
-
const getTransactions = async (address, opts) => {
|
|
146
|
-
const txsBuffered = await client
|
|
147
|
-
.getAccountTransactions(address, opts.lt ?? '', opts.hash ? Buffer.from(opts.hash, 'base64') : Buffer.alloc(0), opts.limit)
|
|
148
|
-
.then((r) => r.transactions);
|
|
149
|
-
const cell = ton_1.Cell.fromBoc(txsBuffered);
|
|
150
|
-
const transactions = cell.map((c) => (0, ton_1.loadTransaction)(c.beginParse()));
|
|
151
|
-
return transactions;
|
|
152
|
-
};
|
|
153
75
|
return {
|
|
154
76
|
getContractState: async (addr) => {
|
|
155
77
|
const block = await client.getMasterchainInfo();
|
|
@@ -164,21 +86,6 @@ async function liteClientOpener(options) {
|
|
|
164
86
|
},
|
|
165
87
|
open: (contract) => client.open(contract),
|
|
166
88
|
closeConnections,
|
|
167
|
-
getTransactionByHash: async (addr, hash, opts) => {
|
|
168
|
-
const tx = await findTransactionByHash(addr, hash, getTransactions, opts);
|
|
169
|
-
return tx;
|
|
170
|
-
},
|
|
171
|
-
getAdjacentTransactions: async (addr, hash, opts) => getAdjacentTransactionsHelper(addr, hash, getTransactions, opts),
|
|
172
|
-
getAddressInformation: async (addr) => {
|
|
173
|
-
const block = await client.getMasterchainInfo();
|
|
174
|
-
const state = await client.getAccountState(addr, block.last);
|
|
175
|
-
return {
|
|
176
|
-
lastTransaction: {
|
|
177
|
-
lt: state.lastTx?.lt.toString() ?? '',
|
|
178
|
-
hash: Buffer.from(state.lastTx?.hash.toString(16) ?? '', 'hex').toString('base64'),
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
89
|
};
|
|
183
90
|
}
|
|
184
91
|
function sandboxOpener(blockchain) {
|
|
@@ -192,47 +99,15 @@ function sandboxOpener(blockchain) {
|
|
|
192
99
|
state: state.state.type === 'uninit' ? 'uninitialized' : state.state.type,
|
|
193
100
|
};
|
|
194
101
|
},
|
|
195
|
-
getTransactionByHash: () => {
|
|
196
|
-
throw new Error('Not implemented.');
|
|
197
|
-
},
|
|
198
|
-
getAdjacentTransactions() {
|
|
199
|
-
throw new Error('Not implemented.');
|
|
200
|
-
},
|
|
201
|
-
getAddressInformation: async () => {
|
|
202
|
-
throw new Error('Not implemented.');
|
|
203
|
-
},
|
|
204
102
|
};
|
|
205
103
|
}
|
|
206
104
|
async function orbsOpener(network) {
|
|
207
105
|
const endpoint = await getHttpEndpointWithRetry(network);
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
open: client.open,
|
|
211
|
-
getContractState: client.getContractState,
|
|
212
|
-
getTransactionByHash: async (addr, hash, opts) => {
|
|
213
|
-
const tx = await findTransactionByHash(addr, hash, client.getTransactions, opts);
|
|
214
|
-
return tx;
|
|
215
|
-
},
|
|
216
|
-
getAdjacentTransactions: async (addr, hash, opts) => getAdjacentTransactionsHelper(addr, hash, client.getTransactions, opts),
|
|
217
|
-
getAddressInformation: async (addr) => {
|
|
218
|
-
const state = await client.getContractState(addr);
|
|
219
|
-
return {
|
|
220
|
-
lastTransaction: {
|
|
221
|
-
lt: state.lastTransaction?.lt ?? '',
|
|
222
|
-
hash: state.lastTransaction?.hash ?? '',
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
};
|
|
106
|
+
return new ton_1.TonClient({ endpoint });
|
|
227
107
|
}
|
|
228
108
|
async function orbsOpener4(network, timeout = 10000) {
|
|
229
109
|
const endpoint = await getHttpV4EndpointWithRetry(network);
|
|
230
110
|
const client4 = new ton_1.TonClient4({ endpoint, timeout });
|
|
231
|
-
const getTransactions = async (address, opts) => {
|
|
232
|
-
return client4
|
|
233
|
-
.getAccountTransactions(address, opts.lt ? BigInt(opts.lt) : 0n, opts.hash ? Buffer.from(opts.hash, 'base64') : Buffer.alloc(0))
|
|
234
|
-
.then((res) => res.map((t) => t.tx));
|
|
235
|
-
};
|
|
236
111
|
return {
|
|
237
112
|
open: (contract) => client4.open(contract),
|
|
238
113
|
getContractState: async (address) => {
|
|
@@ -247,44 +122,5 @@ async function orbsOpener4(network, timeout = 10000) {
|
|
|
247
122
|
state: state.account.state.type === 'uninit' ? 'uninitialized' : state.account.state.type,
|
|
248
123
|
};
|
|
249
124
|
},
|
|
250
|
-
getTransactionByHash: async (addr, hash, opts) => {
|
|
251
|
-
const tx = await findTransactionByHash(addr, hash, getTransactions, opts);
|
|
252
|
-
return tx;
|
|
253
|
-
},
|
|
254
|
-
getAdjacentTransactions: async (addr, hash, opts) => getAdjacentTransactionsHelper(addr, hash, getTransactions, opts),
|
|
255
|
-
getAddressInformation: async (addr) => {
|
|
256
|
-
const latestBlock = await client4.getLastBlock();
|
|
257
|
-
const latestBlockNumber = latestBlock.last.seqno;
|
|
258
|
-
const state = await client4.getAccount(latestBlockNumber, addr);
|
|
259
|
-
return {
|
|
260
|
-
lastTransaction: {
|
|
261
|
-
lt: state.account.last?.lt ?? '',
|
|
262
|
-
hash: state.account.last?.hash ?? '',
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function tonClientOpener(endpoint) {
|
|
269
|
-
const client = new ton_1.TonClient({
|
|
270
|
-
endpoint,
|
|
271
|
-
});
|
|
272
|
-
return {
|
|
273
|
-
open: client.open.bind(client),
|
|
274
|
-
getContractState: client.getContractState.bind(client),
|
|
275
|
-
getTransactionByHash: async (addr, hash, opts) => {
|
|
276
|
-
const tx = await findTransactionByHash(addr, hash, client.getTransactions.bind(client), opts);
|
|
277
|
-
return tx;
|
|
278
|
-
},
|
|
279
|
-
getAdjacentTransactions: async (addr, hash, opts) => getAdjacentTransactionsHelper(addr, hash, client.getTransactions.bind(client), opts),
|
|
280
|
-
getAddressInformation: async (addr) => {
|
|
281
|
-
const state = await client.getContractState(addr);
|
|
282
|
-
return {
|
|
283
|
-
lastTransaction: {
|
|
284
|
-
lt: state.lastTransaction?.lt ?? '',
|
|
285
|
-
hash: state.lastTransaction?.hash ?? '',
|
|
286
|
-
},
|
|
287
|
-
};
|
|
288
|
-
},
|
|
289
125
|
};
|
|
290
126
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
|
-
import { Address, Contract, OpenedContract
|
|
2
|
+
import { Address, Contract, OpenedContract } from '@ton/ton';
|
|
3
3
|
import { ContractOpener } from '../interfaces';
|
|
4
|
-
import { AddressInformation, GetTransactionsOptions } from '../structs/InternalStruct';
|
|
5
4
|
import { ContractState, Network } from '../structs/Struct';
|
|
6
5
|
export interface OpenerConfig {
|
|
7
6
|
/** Underlying opener implementation to use for this slot. */
|
|
@@ -14,11 +13,8 @@ export interface OpenerConfig {
|
|
|
14
13
|
export declare class RetryableContractOpener implements ContractOpener {
|
|
15
14
|
private readonly openerConfigs;
|
|
16
15
|
constructor(openerConfigs: OpenerConfig[]);
|
|
17
|
-
getTransactionByHash(address: Address, hash: string, opts: GetTransactionsOptions): Promise<Transaction | null>;
|
|
18
|
-
getAdjacentTransactions(address: Address, hash: string): Promise<Transaction[]>;
|
|
19
16
|
open<T extends Contract>(src: T): OpenedContract<T> | SandboxContract<T>;
|
|
20
17
|
getContractState(address: Address): Promise<ContractState>;
|
|
21
|
-
getAddressInformation(address: Address): Promise<AddressInformation>;
|
|
22
18
|
closeConnections(): void;
|
|
23
19
|
private executeWithFallback;
|
|
24
20
|
private tryWithRetries;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RetryableContractOpener = void 0;
|
|
4
4
|
exports.createDefaultRetryableOpener = createDefaultRetryableOpener;
|
|
5
|
+
const ton_1 = require("@ton/ton");
|
|
5
6
|
const instances_1 = require("../errors/instances");
|
|
6
7
|
const Struct_1 = require("../structs/Struct");
|
|
7
8
|
const contractOpener_1 = require("./contractOpener");
|
|
@@ -13,20 +14,6 @@ class RetryableContractOpener {
|
|
|
13
14
|
}
|
|
14
15
|
this.openerConfigs = openerConfigs;
|
|
15
16
|
}
|
|
16
|
-
async getTransactionByHash(address, hash, opts) {
|
|
17
|
-
const result = await this.executeWithFallback((config) => config.opener.getTransactionByHash(address, hash, opts));
|
|
18
|
-
if (result.success && result.data) {
|
|
19
|
-
return result.data;
|
|
20
|
-
}
|
|
21
|
-
throw result.lastError || (0, instances_1.allContractOpenerFailedError)('Failed to get transaction by hash');
|
|
22
|
-
}
|
|
23
|
-
async getAdjacentTransactions(address, hash) {
|
|
24
|
-
const result = await this.executeWithFallback((config) => config.opener.getAdjacentTransactions(address, hash));
|
|
25
|
-
if (result.success && result.data) {
|
|
26
|
-
return result.data;
|
|
27
|
-
}
|
|
28
|
-
throw result.lastError || (0, instances_1.allContractOpenerFailedError)('Failed to get account transactions');
|
|
29
|
-
}
|
|
30
17
|
open(src) {
|
|
31
18
|
const firstConfig = this.openerConfigs[0];
|
|
32
19
|
const contract = firstConfig.opener.open(src);
|
|
@@ -39,13 +26,6 @@ class RetryableContractOpener {
|
|
|
39
26
|
}
|
|
40
27
|
throw result.lastError || (0, instances_1.allContractOpenerFailedError)('Failed to get contract state');
|
|
41
28
|
}
|
|
42
|
-
async getAddressInformation(address) {
|
|
43
|
-
const result = await this.executeWithFallback((config) => config.opener.getAddressInformation(address));
|
|
44
|
-
if (result.success && result.data) {
|
|
45
|
-
return result.data;
|
|
46
|
-
}
|
|
47
|
-
throw result.lastError || (0, instances_1.allContractOpenerFailedError)('Failed to get address information');
|
|
48
|
-
}
|
|
49
29
|
closeConnections() {
|
|
50
30
|
for (const config of this.openerConfigs) {
|
|
51
31
|
config.opener.closeConnections?.();
|
|
@@ -107,7 +87,9 @@ class RetryableContractOpener {
|
|
|
107
87
|
exports.RetryableContractOpener = RetryableContractOpener;
|
|
108
88
|
async function createDefaultRetryableOpener(tonRpcEndpoint, networkType, maxRetries = 5, retryDelay = 1000) {
|
|
109
89
|
const openers = [];
|
|
110
|
-
const tonClient =
|
|
90
|
+
const tonClient = new ton_1.TonClient({
|
|
91
|
+
endpoint: new URL('api/v2/jsonRPC', tonRpcEndpoint).toString(),
|
|
92
|
+
});
|
|
111
93
|
openers.push({ opener: tonClient, retries: maxRetries, retryDelay });
|
|
112
94
|
if (networkType !== Struct_1.Network.DEV) {
|
|
113
95
|
try {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssetFactory = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
|
-
const Consts_1 = require("../sdk/Consts");
|
|
6
5
|
const Struct_1 = require("../structs/Struct");
|
|
7
6
|
const AssetCache_1 = require("./AssetCache");
|
|
8
7
|
const FT_1 = require("./FT");
|
|
@@ -10,9 +9,7 @@ const NFT_1 = require("./NFT");
|
|
|
10
9
|
const TON_1 = require("./TON");
|
|
11
10
|
class AssetFactory {
|
|
12
11
|
static async from(configuration, token) {
|
|
13
|
-
if (token.address === '' ||
|
|
14
|
-
token.address === configuration.nativeTONAddress ||
|
|
15
|
-
token.address === Consts_1.TON_BURN_ADDRESS) {
|
|
12
|
+
if (token.address === '' || token.address === configuration.nativeTONAddress) {
|
|
16
13
|
if (token.tokenType !== Struct_1.AssetType.FT)
|
|
17
14
|
throw (0, errors_1.unknownTokenTypeError)(token.address, 'detected TON, but token type is not FT');
|
|
18
15
|
return TON_1.TON.create(configuration);
|
|
@@ -29,10 +26,7 @@ class AssetFactory {
|
|
|
29
26
|
}
|
|
30
27
|
static async createFTAsset(configuration, address) {
|
|
31
28
|
const ton = TON_1.TON.create(configuration);
|
|
32
|
-
if (address === configuration.nativeTONAddress ||
|
|
33
|
-
address === '' ||
|
|
34
|
-
address === (await ton.getEVMAddress()) ||
|
|
35
|
-
address === Consts_1.TON_BURN_ADDRESS) {
|
|
29
|
+
if (address === configuration.nativeTONAddress || address === '' || address === (await ton.getEVMAddress())) {
|
|
36
30
|
return ton;
|
|
37
31
|
}
|
|
38
32
|
return FT_1.FT.fromAddress(configuration, address);
|
package/dist/src/assets/FT.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare class FT implements Asset {
|
|
|
14
14
|
private _decimals;
|
|
15
15
|
private _transferAmount;
|
|
16
16
|
private _evmAddress?;
|
|
17
|
+
private _displayMultiplierNumerator?;
|
|
18
|
+
private _displayMultiplierDenominator?;
|
|
17
19
|
get address(): string;
|
|
18
20
|
static getJettonData(configuration: IConfiguration, address: TVMAddress): Promise<JettonMinterData>;
|
|
19
21
|
getJettonData(): Promise<JettonMinterData>;
|
|
@@ -30,7 +32,15 @@ export declare class FT implements Asset {
|
|
|
30
32
|
withRawAmount(rawAmount: bigint): FT;
|
|
31
33
|
addAmount(amount: number): FT;
|
|
32
34
|
addRawAmount(rawAmount: bigint): FT;
|
|
35
|
+
withDisplayAmount(displayAmount: bigint): Promise<FT>;
|
|
36
|
+
addDisplayAmount(displayAmount: bigint): Promise<FT>;
|
|
33
37
|
getDecimals(): Promise<number>;
|
|
38
|
+
getDisplayMultiplier(): Promise<{
|
|
39
|
+
numerator: bigint;
|
|
40
|
+
denominator: bigint;
|
|
41
|
+
}>;
|
|
42
|
+
toDisplayAmount(onchainAmount: bigint): Promise<bigint>;
|
|
43
|
+
fromDisplayAmount(displayAmount: bigint): Promise<bigint>;
|
|
34
44
|
getEVMAddress(): Promise<string>;
|
|
35
45
|
getTVMAddress(): Promise<string>;
|
|
36
46
|
generatePayload(params: {
|
package/dist/src/assets/FT.js
CHANGED
|
@@ -146,6 +146,8 @@ class FT {
|
|
|
146
146
|
const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration, this._decimals);
|
|
147
147
|
ft._transferAmount = this._transferAmount;
|
|
148
148
|
ft._evmAddress = this._evmAddress;
|
|
149
|
+
ft._displayMultiplierNumerator = this._displayMultiplierNumerator;
|
|
150
|
+
ft._displayMultiplierDenominator = this._displayMultiplierDenominator;
|
|
149
151
|
return ft;
|
|
150
152
|
}
|
|
151
153
|
withAmount(amount) {
|
|
@@ -174,9 +176,54 @@ class FT {
|
|
|
174
176
|
this._transferAmount = this._transferAmount + rawAmount;
|
|
175
177
|
return this;
|
|
176
178
|
}
|
|
179
|
+
async withDisplayAmount(displayAmount) {
|
|
180
|
+
const onchainAmount = await this.fromDisplayAmount(displayAmount);
|
|
181
|
+
if (this._transferAmount > 0n) {
|
|
182
|
+
const newToken = this.clone;
|
|
183
|
+
newToken._transferAmount = onchainAmount;
|
|
184
|
+
return newToken;
|
|
185
|
+
}
|
|
186
|
+
this._transferAmount = onchainAmount;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
async addDisplayAmount(displayAmount) {
|
|
190
|
+
const onchainAmount = await this.fromDisplayAmount(displayAmount);
|
|
191
|
+
this._transferAmount = this._transferAmount + onchainAmount;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
177
194
|
async getDecimals() {
|
|
178
195
|
return this._decimals;
|
|
179
196
|
}
|
|
197
|
+
async getDisplayMultiplier() {
|
|
198
|
+
// Return cached values if available
|
|
199
|
+
if (this._displayMultiplierNumerator !== undefined && this._displayMultiplierDenominator !== undefined) {
|
|
200
|
+
return {
|
|
201
|
+
numerator: this._displayMultiplierNumerator,
|
|
202
|
+
denominator: this._displayMultiplierDenominator,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// Fetch and cache the multiplier
|
|
206
|
+
try {
|
|
207
|
+
const multiplier = await this._jettonMinter.getDisplayMultiplier();
|
|
208
|
+
this._displayMultiplierNumerator = multiplier.numerator;
|
|
209
|
+
this._displayMultiplierDenominator = multiplier.denominator;
|
|
210
|
+
return multiplier;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
// If the method doesn't exist or fails, assume no scaling (1:1)
|
|
214
|
+
this._displayMultiplierNumerator = 1n;
|
|
215
|
+
this._displayMultiplierDenominator = 1n;
|
|
216
|
+
return { numerator: 1n, denominator: 1n };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async toDisplayAmount(onchainAmount) {
|
|
220
|
+
const { numerator, denominator } = await this.getDisplayMultiplier();
|
|
221
|
+
return (0, Utils_1.muldivr)(onchainAmount, numerator, denominator);
|
|
222
|
+
}
|
|
223
|
+
async fromDisplayAmount(displayAmount) {
|
|
224
|
+
const { numerator, denominator } = await this.getDisplayMultiplier();
|
|
225
|
+
return (0, Utils_1.muldivr)(displayAmount, denominator, numerator);
|
|
226
|
+
}
|
|
180
227
|
async getEVMAddress() {
|
|
181
228
|
if (this._evmAddress) {
|
|
182
229
|
return this._evmAddress;
|
package/dist/src/assets/TON.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ import { Cell } from '@ton/ton';
|
|
|
2
2
|
import { Asset, IConfiguration } from '../interfaces';
|
|
3
3
|
import type { SenderAbstraction } from '../sender';
|
|
4
4
|
import type { ShardTransaction } from '../structs/InternalStruct';
|
|
5
|
-
import { AssetType, FeeParams
|
|
5
|
+
import { AssetType, FeeParams } from '../structs/Struct';
|
|
6
6
|
export declare class TON implements Asset {
|
|
7
7
|
readonly address: string;
|
|
8
8
|
readonly type: AssetType;
|
|
9
9
|
private evmAddress;
|
|
10
10
|
private _rawAmount;
|
|
11
11
|
private _config;
|
|
12
|
-
readonly origin: Origin;
|
|
13
12
|
constructor(config: IConfiguration);
|
|
14
13
|
static create(config: IConfiguration): TON;
|
|
15
14
|
get rawAmount(): bigint;
|
package/dist/src/assets/TON.js
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { LiteSequencerClient } from './sdk/LiteSequencerClient';
|
|
|
10
10
|
export { ConsoleLogger, NoopLogger } from './sdk/Logger';
|
|
11
11
|
export { OperationTracker } from './sdk/OperationTracker';
|
|
12
12
|
export { Simulator } from './sdk/Simulator';
|
|
13
|
+
export { startTracking, startTrackingMultiple } from './sdk/StartTracking';
|
|
13
14
|
export { TacSdk } from './sdk/TacSdk';
|
|
14
15
|
export { TACTransactionManager } from './sdk/TACTransactionManager';
|
|
15
16
|
export { TONTransactionManager } from './sdk/TONTransactionManager';
|
package/dist/src/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TONTransactionManager = exports.TACTransactionManager = exports.TacSdk = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.AgnosticStructs = exports.AgnosticProxySDK = void 0;
|
|
39
|
+
exports.TONTransactionManager = exports.TACTransactionManager = exports.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.AgnosticStructs = exports.AgnosticProxySDK = void 0;
|
|
40
40
|
__exportStar(require("./adapters"), exports);
|
|
41
41
|
var AgnosticSdk_1 = require("./agnosticSdk/AgnosticSdk");
|
|
42
42
|
Object.defineProperty(exports, "AgnosticProxySDK", { enumerable: true, get: function () { return AgnosticSdk_1.AgnosticProxySDK; } });
|
|
@@ -57,6 +57,9 @@ var OperationTracker_1 = require("./sdk/OperationTracker");
|
|
|
57
57
|
Object.defineProperty(exports, "OperationTracker", { enumerable: true, get: function () { return OperationTracker_1.OperationTracker; } });
|
|
58
58
|
var Simulator_1 = require("./sdk/Simulator");
|
|
59
59
|
Object.defineProperty(exports, "Simulator", { enumerable: true, get: function () { return Simulator_1.Simulator; } });
|
|
60
|
+
var StartTracking_1 = require("./sdk/StartTracking");
|
|
61
|
+
Object.defineProperty(exports, "startTracking", { enumerable: true, get: function () { return StartTracking_1.startTracking; } });
|
|
62
|
+
Object.defineProperty(exports, "startTrackingMultiple", { enumerable: true, get: function () { return StartTracking_1.startTrackingMultiple; } });
|
|
60
63
|
var TacSdk_1 = require("./sdk/TacSdk");
|
|
61
64
|
Object.defineProperty(exports, "TacSdk", { enumerable: true, get: function () { return TacSdk_1.TacSdk; } });
|
|
62
65
|
var TACTransactionManager_1 = require("./sdk/TACTransactionManager");
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Cell } from '@ton/ton';
|
|
2
|
-
import { AssetType, FeeParams
|
|
2
|
+
import { AssetType, FeeParams } from '../structs/Struct';
|
|
3
3
|
export interface Asset {
|
|
4
4
|
address: string;
|
|
5
5
|
type: AssetType;
|
|
6
6
|
rawAmount: bigint;
|
|
7
7
|
clone: Asset;
|
|
8
|
-
origin: Origin;
|
|
9
8
|
/**
|
|
10
9
|
* Returns a new asset instance with the specified transfer amount in human-readable units.
|
|
11
10
|
* Does not mutate the current asset instance.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
|
-
import type { Address, Contract, OpenedContract
|
|
3
|
-
import { AddressInformation, GetTransactionsOptions } from '../structs/InternalStruct';
|
|
2
|
+
import type { Address, Contract, OpenedContract } from '@ton/ton';
|
|
4
3
|
import { ContractState } from '../structs/Struct';
|
|
5
4
|
export interface ContractOpener {
|
|
6
5
|
/**
|
|
@@ -19,7 +18,4 @@ export interface ContractOpener {
|
|
|
19
18
|
* Closes any underlying connections if supported by the implementation.
|
|
20
19
|
*/
|
|
21
20
|
closeConnections?: () => unknown;
|
|
22
|
-
getTransactionByHash(address: Address, hash: string, opts?: GetTransactionsOptions): Promise<Transaction | null>;
|
|
23
|
-
getAdjacentTransactions(address: Address, hash: string, opts?: GetTransactionsOptions): Promise<Transaction[]>;
|
|
24
|
-
getAddressInformation(address: Address): Promise<AddressInformation>;
|
|
25
21
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { SenderAbstraction } from '../sender';
|
|
2
2
|
import { CrosschainTx, ExecutionFeeEstimationResult } from '../structs/Struct';
|
|
3
|
-
import { Asset } from './Asset';
|
|
4
3
|
export interface ISimulator {
|
|
5
4
|
/**
|
|
6
5
|
* Simulates a list of cross-chain transactions for a given sender.
|
|
@@ -16,10 +15,4 @@ export interface ISimulator {
|
|
|
16
15
|
* @returns Promise with fee estimation and execution info.
|
|
17
16
|
*/
|
|
18
17
|
getSimulationInfo(sender: SenderAbstraction, tx: CrosschainTx): Promise<ExecutionFeeEstimationResult>;
|
|
19
|
-
/**
|
|
20
|
-
* Estimates the total TON network fees required for a cross-chain transaction.
|
|
21
|
-
* @param assets Assets to be included in the transaction.
|
|
22
|
-
* @returns The total estimated fee in nanotons (1 TON = 10^9 nanotons) for processing all provided assets.
|
|
23
|
-
*/
|
|
24
|
-
estimateTONFees(assets: Asset[]): number;
|
|
25
18
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { SenderAbstraction } from '../sender';
|
|
2
|
-
import { BatchCrossChainTx,
|
|
3
|
-
import { Asset } from './Asset';
|
|
2
|
+
import { BatchCrossChainTx, CrossChainTransactionsOptions, CrosschainTx, EvmProxyMsg, TransactionLinkerWithOperationId } from '../structs/Struct';
|
|
4
3
|
export interface ITONTransactionManager {
|
|
5
4
|
/**
|
|
6
5
|
* Sends a single cross-chain transaction.
|
|
@@ -18,22 +17,4 @@ export interface ITONTransactionManager {
|
|
|
18
17
|
* @returns Array of transaction linkers, one per submitted transaction.
|
|
19
18
|
*/
|
|
20
19
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTx[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Builds the fee parameters for a cross-chain transaction.
|
|
23
|
-
* @param options Transaction configuration options.
|
|
24
|
-
* @param evmProxyMsg Encoded EVM proxy message.
|
|
25
|
-
* @param sender Sender abstraction for TVM message sending.
|
|
26
|
-
* @param tx Cross-chain transaction to bridge.
|
|
27
|
-
* @returns Promise with the fee parameters.
|
|
28
|
-
*/
|
|
29
|
-
buildFeeParams(options: CrossChainTransactionOptions, evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<FeeParams>;
|
|
30
|
-
/**
|
|
31
|
-
* Prepares the transaction payloads required for a cross-chain operation without sending them.
|
|
32
|
-
* @param evmProxyMsg Encoded EVM proxy message.
|
|
33
|
-
* @param senderAddress TVM address of the transaction sender (wallet address).
|
|
34
|
-
* @param assets Assets to be included in the transaction.
|
|
35
|
-
* @param options Optional transaction configuration including error handling and executor settings.
|
|
36
|
-
* @returns Promise with the prepared transaction payloads.
|
|
37
|
-
*/
|
|
38
|
-
prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets: Asset[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
|
|
39
20
|
}
|
|
@@ -2,7 +2,7 @@ import { Wallet } from 'ethers';
|
|
|
2
2
|
import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
3
3
|
import { FT, NFT } from '../assets';
|
|
4
4
|
import type { SenderAbstraction } from '../sender';
|
|
5
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike,
|
|
5
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, BatchCrossChainTxWithAssetLike, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
|
|
6
6
|
import { Asset } from './Asset';
|
|
7
7
|
import { IConfiguration } from './IConfiguration';
|
|
8
8
|
import { IOperationTracker } from './IOperationTracker';
|
|
@@ -182,13 +182,4 @@ export interface ITacSDK {
|
|
|
182
182
|
* Returns the operation tracker instance used for querying operation statuses and utilities.
|
|
183
183
|
*/
|
|
184
184
|
getOperationTracker(): IOperationTracker;
|
|
185
|
-
/**
|
|
186
|
-
* Prepares the transaction payloads required for a cross-chain operation without sending them.
|
|
187
|
-
* @param evmProxyMsg Encoded EVM proxy message.
|
|
188
|
-
* @param senderAddress TVM address of the transaction sender (wallet address).
|
|
189
|
-
* @param assets Assets to be included in the transaction.
|
|
190
|
-
* @param options Optional transaction configuration including error handling and executor settings.
|
|
191
|
-
* @returns Promise with the prepared transaction payloads.
|
|
192
|
-
*/
|
|
193
|
-
prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
|
|
194
185
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Contract, ContractProvider, MessageRelaxed, SendMode } from '@ton/ton';
|
|
2
2
|
export interface WalletInstanse extends Contract {
|
|
3
3
|
/**
|
|
4
4
|
* Returns current wallet seqno, used for nonce/ordering.
|
|
5
5
|
* @param provider Contract provider to query the wallet.
|
|
6
6
|
*/
|
|
7
7
|
getSeqno(provider: ContractProvider): Promise<number>;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Sends a transfer with specified messages and send mode.
|
|
10
|
+
* @param provider Contract provider used to send the transfer.
|
|
11
|
+
* @param args Transfer arguments including seqno, secretKey, messages and sendMode.
|
|
12
|
+
*/
|
|
13
|
+
sendTransfer(provider: ContractProvider, args: {
|
|
10
14
|
seqno: number;
|
|
11
15
|
secretKey: Buffer;
|
|
12
16
|
messages: MessageRelaxed[];
|
|
13
17
|
sendMode: SendMode;
|
|
14
18
|
timeout?: number;
|
|
15
|
-
}):
|
|
19
|
+
}): Promise<void>;
|
|
16
20
|
}
|
package/dist/src/sdk/Consts.d.ts
CHANGED
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.
|
|
3
|
+
exports.TAC_DECIMALS = exports.TON_DECIMALS = 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 = exports.TRANSACTION_TON_AMOUNT = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
5
|
exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.55);
|
|
6
6
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
@@ -17,4 +17,3 @@ exports.TAC_SYMBOL = 'TAC';
|
|
|
17
17
|
exports.FIFTEEN_MINUTES = 15 * 60 * 1000;
|
|
18
18
|
exports.TON_DECIMALS = 9;
|
|
19
19
|
exports.TAC_DECIMALS = 18;
|
|
20
|
-
exports.TON_BURN_ADDRESS = 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IConfiguration, ILogger, IOperationTracker, ISimulator } from '../interfaces';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
3
|
import { CrosschainTx, ExecutionFeeEstimationResult } from '../structs/Struct';
|
|
4
4
|
export declare class Simulator implements ISimulator {
|
|
@@ -8,23 +8,4 @@ export declare class Simulator implements ISimulator {
|
|
|
8
8
|
constructor(config: IConfiguration, operationTracker: IOperationTracker, logger?: ILogger);
|
|
9
9
|
getSimulationsInfo(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
|
|
10
10
|
getSimulationInfo(sender: SenderAbstraction, tx: CrosschainTx): Promise<ExecutionFeeEstimationResult>;
|
|
11
|
-
calculateTONFees({ accountBits, accountCells, timeDelta, msgBits, msgCells, gasUsed, bitPricePs, cellPricePs, lumpPrice, gasPrice, firstFrac, ihrPriceFactor, }: {
|
|
12
|
-
accountBits: number;
|
|
13
|
-
accountCells: number;
|
|
14
|
-
timeDelta: number;
|
|
15
|
-
msgBits: number;
|
|
16
|
-
msgCells: number;
|
|
17
|
-
gasUsed: number;
|
|
18
|
-
bitPricePs?: number;
|
|
19
|
-
cellPricePs?: number;
|
|
20
|
-
lumpPrice?: number;
|
|
21
|
-
gasPrice?: number;
|
|
22
|
-
firstFrac?: number;
|
|
23
|
-
ihrPriceFactor?: number;
|
|
24
|
-
}): number;
|
|
25
|
-
private readonly TON_FEE_CONSTANTS;
|
|
26
|
-
private readonly TRANSACTION_STEPS;
|
|
27
|
-
private calculateStepFee;
|
|
28
|
-
private calculateTransactionPipeline;
|
|
29
|
-
estimateTONFees(assets: Asset[]): number;
|
|
30
11
|
}
|