@tonappchain/sdk 0.7.2-payload-builder-0.3 → 0.7.2-scaled-ui-support-2

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.
Files changed (59) hide show
  1. package/dist/artifacts/dev/ton/internal/build/Executor.compiled.json +1 -1
  2. package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.d.ts +4 -0
  3. package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.js +7 -0
  4. package/dist/artifacts/mainnet/ton/internal/build/CrossChainLayer.compiled.json +1 -1
  5. package/dist/artifacts/mainnet/ton/internal/build/Executor.compiled.json +1 -1
  6. package/dist/artifacts/mainnet/ton/internal/build/JettonMinter.compiled.json +1 -1
  7. package/dist/artifacts/mainnet/ton/internal/build/JettonProxy.compiled.json +1 -1
  8. package/dist/artifacts/mainnet/ton/internal/build/JettonWallet.compiled.json +1 -1
  9. package/dist/artifacts/mainnet/ton/internal/build/NFTItem.compiled.json +1 -1
  10. package/dist/artifacts/mainnet/ton/internal/build/NFTProxy.compiled.json +1 -1
  11. package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.d.ts +13 -1
  12. package/dist/artifacts/mainnet/ton/internal/wrappers/CrossChainLayer.js +45 -7
  13. package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.d.ts +6 -2
  14. package/dist/artifacts/mainnet/ton/internal/wrappers/JettonMinter.js +9 -2
  15. package/dist/artifacts/testnet/ton/internal/build/Executor.compiled.json +1 -1
  16. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +4 -0
  17. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +7 -0
  18. package/dist/src/adapters/contractOpener.d.ts +0 -4
  19. package/dist/src/adapters/contractOpener.js +1 -165
  20. package/dist/src/adapters/retryableContractOpener.d.ts +1 -5
  21. package/dist/src/adapters/retryableContractOpener.js +4 -22
  22. package/dist/src/assets/AssetFactory.js +2 -8
  23. package/dist/src/assets/FT.d.ts +10 -0
  24. package/dist/src/assets/FT.js +51 -4
  25. package/dist/src/assets/TON.d.ts +1 -2
  26. package/dist/src/assets/TON.js +0 -1
  27. package/dist/src/index.d.ts +1 -0
  28. package/dist/src/index.js +4 -1
  29. package/dist/src/interfaces/Asset.d.ts +5 -2
  30. package/dist/src/interfaces/ContractOpener.d.ts +1 -5
  31. package/dist/src/interfaces/ISimulator.d.ts +0 -7
  32. package/dist/src/interfaces/ITONTransactionManager.d.ts +1 -20
  33. package/dist/src/interfaces/ITacSDK.d.ts +1 -10
  34. package/dist/src/interfaces/WalletInstanse.d.ts +8 -4
  35. package/dist/src/sdk/Consts.d.ts +1 -1
  36. package/dist/src/sdk/Consts.js +2 -2
  37. package/dist/src/sdk/Simulator.d.ts +1 -20
  38. package/dist/src/sdk/Simulator.js +0 -160
  39. package/dist/src/sdk/StartTracking.d.ts +3 -5
  40. package/dist/src/sdk/StartTracking.js +40 -60
  41. package/dist/src/sdk/TONTransactionManager.d.ts +4 -7
  42. package/dist/src/sdk/TONTransactionManager.js +2 -38
  43. package/dist/src/sdk/TacSdk.d.ts +1 -2
  44. package/dist/src/sdk/TacSdk.js +1 -7
  45. package/dist/src/sdk/TxFinalizer.d.ts +4 -15
  46. package/dist/src/sdk/TxFinalizer.js +23 -102
  47. package/dist/src/sdk/Utils.d.ts +6 -6
  48. package/dist/src/sdk/Utils.js +9 -35
  49. package/dist/src/sender/BatchSender.js +0 -19
  50. package/dist/src/sender/RawSender.js +1 -34
  51. package/dist/src/sender/SenderFactory.js +1 -1
  52. package/dist/src/sender/TonConnectSender.js +0 -2
  53. package/dist/src/structs/InternalStruct.d.ts +1 -22
  54. package/dist/src/structs/Struct.d.ts +2 -20
  55. package/dist/src/wrappers/HighloadWalletV3.d.ts +3 -5
  56. package/dist/src/wrappers/HighloadWalletV3.js +3 -14
  57. package/package.json +3 -2
  58. package/dist/src/interfaces/ITxFinalizer.d.ts +0 -5
  59. 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
- const client = new ton_1.TonClient({ endpoint });
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, Transaction } from '@ton/ton';
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 = (0, contractOpener_1.tonClientOpener)(new URL('api/v2/jsonRPC', tonRpcEndpoint).toString());
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);
@@ -14,6 +14,10 @@ export declare class FT implements Asset {
14
14
  private _decimals;
15
15
  private _transferAmount;
16
16
  private _evmAddress?;
17
+ private _displayMultiplierNumerator;
18
+ private _displayMultiplierDenominator;
19
+ private _displayMultiplierFetchedAt;
20
+ private _displayMultiplierCacheDuration;
17
21
  get address(): string;
18
22
  static getJettonData(configuration: IConfiguration, address: TVMAddress): Promise<JettonMinterData>;
19
23
  getJettonData(): Promise<JettonMinterData>;
@@ -31,6 +35,12 @@ export declare class FT implements Asset {
31
35
  addAmount(amount: number): FT;
32
36
  addRawAmount(rawAmount: bigint): FT;
33
37
  getDecimals(): Promise<number>;
38
+ private refreshDisplayMultiplierInternal;
39
+ private ensureFreshDisplayMultiplier;
40
+ refreshDisplayMultiplier(): Promise<void>;
41
+ setDisplayMultiplierCacheDuration(durationMs: number): void;
42
+ toDisplayAmount(onchainAmount: bigint): bigint;
43
+ fromDisplayAmount(displayAmount: bigint): bigint;
34
44
  getEVMAddress(): Promise<string>;
35
45
  getTVMAddress(): Promise<string>;
36
46
  generatePayload(params: {
@@ -85,6 +85,10 @@ class FT {
85
85
  }
86
86
  constructor(address, origin, configuration, decimals) {
87
87
  this.type = Struct_1.AssetType.FT;
88
+ this._displayMultiplierNumerator = 1n;
89
+ this._displayMultiplierDenominator = 1n;
90
+ this._displayMultiplierFetchedAt = 0;
91
+ this._displayMultiplierCacheDuration = Consts_1.FIVE_MINUTES;
88
92
  this._tvmAddress = ton_1.Address.parse(address);
89
93
  this._configuration = configuration;
90
94
  this._jettonMinter = this._configuration.TONParams.contractOpener.open(configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(this._tvmAddress));
@@ -137,6 +141,8 @@ class FT {
137
141
  if (finalEvmAddress || (0, ethers_1.isAddress)(address)) {
138
142
  token._evmAddress = finalEvmAddress || address;
139
143
  }
144
+ // Fetch and cache display multiplier for TEP-526 support
145
+ await token.refreshDisplayMultiplierInternal();
140
146
  return token;
141
147
  }
142
148
  get rawAmount() {
@@ -146,15 +152,21 @@ class FT {
146
152
  const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration, this._decimals);
147
153
  ft._transferAmount = this._transferAmount;
148
154
  ft._evmAddress = this._evmAddress;
155
+ ft._displayMultiplierNumerator = this._displayMultiplierNumerator;
156
+ ft._displayMultiplierDenominator = this._displayMultiplierDenominator;
157
+ ft._displayMultiplierFetchedAt = this._displayMultiplierFetchedAt;
158
+ ft._displayMultiplierCacheDuration = this._displayMultiplierCacheDuration;
149
159
  return ft;
150
160
  }
151
161
  withAmount(amount) {
162
+ const rawAmount = (0, Utils_1.calculateRawAmount)(amount, this._decimals);
163
+ const onchainAmount = this.fromDisplayAmount(rawAmount);
152
164
  if (this._transferAmount > 0n) {
153
165
  const newToken = this.clone;
154
- newToken._transferAmount = (0, Utils_1.calculateRawAmount)(amount, this._decimals);
166
+ newToken._transferAmount = onchainAmount;
155
167
  return newToken;
156
168
  }
157
- this._transferAmount = (0, Utils_1.calculateRawAmount)(amount, this._decimals);
169
+ this._transferAmount = onchainAmount;
158
170
  return this;
159
171
  }
160
172
  withRawAmount(rawAmount) {
@@ -167,7 +179,9 @@ class FT {
167
179
  return this;
168
180
  }
169
181
  addAmount(amount) {
170
- this._transferAmount = this._transferAmount + (0, Utils_1.calculateRawAmount)(amount, this._decimals);
182
+ const rawAmount = (0, Utils_1.calculateRawAmount)(amount, this._decimals);
183
+ const onchainAmount = this.fromDisplayAmount(rawAmount);
184
+ this._transferAmount = this._transferAmount + onchainAmount;
171
185
  return this;
172
186
  }
173
187
  addRawAmount(rawAmount) {
@@ -177,6 +191,37 @@ class FT {
177
191
  async getDecimals() {
178
192
  return this._decimals;
179
193
  }
194
+ async refreshDisplayMultiplierInternal() {
195
+ try {
196
+ const multiplier = await this._jettonMinter.getDisplayMultiplier();
197
+ this._displayMultiplierNumerator = multiplier.numerator;
198
+ this._displayMultiplierDenominator = multiplier.denominator;
199
+ this._displayMultiplierFetchedAt = Date.now();
200
+ }
201
+ catch {
202
+ this._displayMultiplierNumerator = 1n;
203
+ this._displayMultiplierDenominator = 1n;
204
+ this._displayMultiplierFetchedAt = Date.now();
205
+ }
206
+ }
207
+ async ensureFreshDisplayMultiplier() {
208
+ const age = Date.now() - this._displayMultiplierFetchedAt;
209
+ if (age > this._displayMultiplierCacheDuration) {
210
+ await this.refreshDisplayMultiplierInternal();
211
+ }
212
+ }
213
+ async refreshDisplayMultiplier() {
214
+ await this.refreshDisplayMultiplierInternal();
215
+ }
216
+ setDisplayMultiplierCacheDuration(durationMs) {
217
+ this._displayMultiplierCacheDuration = durationMs;
218
+ }
219
+ toDisplayAmount(onchainAmount) {
220
+ return (0, Utils_1.muldivr)(onchainAmount, this._displayMultiplierNumerator, this._displayMultiplierDenominator);
221
+ }
222
+ fromDisplayAmount(displayAmount) {
223
+ return (0, Utils_1.muldivr)(displayAmount, this._displayMultiplierDenominator, this._displayMultiplierNumerator);
224
+ }
180
225
  async getEVMAddress() {
181
226
  if (this._evmAddress) {
182
227
  return this._evmAddress;
@@ -222,10 +267,12 @@ class FT {
222
267
  return (await this._jettonMinter.getWalletAddress(ton_1.Address.parse(userAddress))).toString({ bounceable: true });
223
268
  }
224
269
  async getUserBalance(userAddress) {
270
+ await this.ensureFreshDisplayMultiplier();
225
271
  const wallet = await this.getWallet(userAddress);
226
272
  return BigInt(await wallet.getJettonBalance());
227
273
  }
228
274
  async getUserBalanceExtended(userAddress) {
275
+ await this.ensureFreshDisplayMultiplier();
229
276
  const masterState = await this._configuration.TONParams.contractOpener.getContractState(this._tvmAddress);
230
277
  if (masterState.state !== 'active') {
231
278
  return { exists: false };
@@ -236,7 +283,7 @@ class FT {
236
283
  return {
237
284
  rawAmount,
238
285
  decimals,
239
- amount: (0, Utils_1.calculateAmount)(rawAmount, decimals),
286
+ amount: (0, Utils_1.calculateAmount)(this.toDisplayAmount(rawAmount), decimals),
240
287
  exists: true,
241
288
  };
242
289
  }
@@ -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, Origin } from '../structs/Struct';
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;
@@ -9,7 +9,6 @@ const Struct_1 = require("../structs/Struct");
9
9
  class TON {
10
10
  constructor(config) {
11
11
  this.type = Struct_1.AssetType.FT;
12
- this.origin = Struct_1.Origin.TON;
13
12
  this.address = '';
14
13
  this._config = config;
15
14
  this._rawAmount = 0n;
@@ -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,14 +1,14 @@
1
1
  import type { Cell } from '@ton/ton';
2
- import { AssetType, FeeParams, Origin } from '../structs/Struct';
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.
11
+ * For FT assets, this applies TEP-526 scaling automatically if supported by the token.
12
12
  * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
13
13
  * @returns A new Asset reflecting the requested amount.
14
14
  */
@@ -16,6 +16,7 @@ export interface Asset {
16
16
  /**
17
17
  * Returns a new asset instance with the specified transfer amount in raw base units.
18
18
  * Does not mutate the current asset instance.
19
+ * No TEP-526 scaling is applied - sets the raw onchain amount directly.
19
20
  * @param rawAmount Amount in raw base units (bigint).
20
21
  * @returns A new Asset reflecting the requested raw amount.
21
22
  */
@@ -23,6 +24,7 @@ export interface Asset {
23
24
  /**
24
25
  * Increases the transfer amount by the specified value (human-readable units) and returns a new asset instance.
25
26
  * Does not mutate the current asset instance.
27
+ * For FT assets, this applies TEP-526 scaling automatically if supported by the token.
26
28
  * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
27
29
  * @returns A new Asset with the increased amount.
28
30
  */
@@ -30,6 +32,7 @@ export interface Asset {
30
32
  /**
31
33
  * Increases the transfer amount by the specified raw base units and returns a new asset instance.
32
34
  * Does not mutate the current asset instance.
35
+ * No TEP-526 scaling is applied - adds to the raw onchain amount directly.
33
36
  * @param rawAmount Amount in raw base units (bigint).
34
37
  * @returns A new Asset with the increased amount in raw units.
35
38
  */
@@ -1,6 +1,5 @@
1
1
  import { SandboxContract } from '@ton/sandbox';
2
- import type { Address, Contract, OpenedContract, Transaction } from '@ton/ton';
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, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EvmProxyMsg, FeeParams, TransactionLinkerWithOperationId } from '../structs/Struct';
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, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
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
  }