@tonappchain/sdk 0.7.2-payload-builder-0.2 → 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.
Files changed (49) 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/CrossChainLayer.compiled.json +1 -1
  16. package/dist/artifacts/testnet/ton/internal/build/Executor.compiled.json +1 -1
  17. package/dist/artifacts/testnet/ton/internal/build/JettonMinter.compiled.json +1 -1
  18. package/dist/artifacts/testnet/ton/internal/build/JettonProxy.compiled.json +1 -1
  19. package/dist/artifacts/testnet/ton/internal/build/JettonWallet.compiled.json +1 -1
  20. package/dist/artifacts/testnet/ton/internal/build/NFTItem.compiled.json +1 -1
  21. package/dist/artifacts/testnet/ton/internal/build/NFTProxy.compiled.json +1 -1
  22. package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.d.ts +13 -1
  23. package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.js +45 -7
  24. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +6 -2
  25. package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +9 -2
  26. package/dist/src/assets/AssetFactory.js +2 -8
  27. package/dist/src/assets/FT.d.ts +10 -0
  28. package/dist/src/assets/FT.js +47 -0
  29. package/dist/src/assets/TON.d.ts +1 -2
  30. package/dist/src/assets/TON.js +0 -1
  31. package/dist/src/interfaces/Asset.d.ts +1 -2
  32. package/dist/src/interfaces/ISimulator.d.ts +0 -7
  33. package/dist/src/interfaces/ITONTransactionManager.d.ts +1 -20
  34. package/dist/src/interfaces/ITacSDK.d.ts +1 -10
  35. package/dist/src/sdk/Consts.d.ts +0 -1
  36. package/dist/src/sdk/Consts.js +1 -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 +0 -1
  40. package/dist/src/sdk/StartTracking.js +33 -55
  41. package/dist/src/sdk/TONTransactionManager.d.ts +3 -4
  42. package/dist/src/sdk/TONTransactionManager.js +0 -23
  43. package/dist/src/sdk/TacSdk.d.ts +1 -2
  44. package/dist/src/sdk/TacSdk.js +0 -4
  45. package/dist/src/sdk/Utils.d.ts +5 -0
  46. package/dist/src/sdk/Utils.js +11 -0
  47. package/dist/src/structs/InternalStruct.d.ts +0 -3
  48. package/dist/src/structs/Struct.d.ts +1 -7
  49. package/package.json +2 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CrossChainLayer = exports.CrossChainLayerErrors = exports.CrossChainLayerOpCodes = exports.MsgType = void 0;
4
4
  exports.crossChainLayerConfigToCell = crossChainLayerConfigToCell;
5
5
  const core_1 = require("@ton/core");
6
+ const crypto_1 = require("@ton/crypto");
6
7
  const Constants_1 = require("./Constants");
7
8
  const GasUtils_1 = require("./utils/GasUtils");
8
9
  const MerkleRoots_1 = require("./utils/MerkleRoots");
@@ -33,7 +34,8 @@ exports.CrossChainLayerOpCodes = {
33
34
  admin_updateTacProtocolFee: 0x3531465c,
34
35
  newAdmin_confirmChangingAdminAddress: 0x6a4fbe34,
35
36
  sequencerMultisig_changeSequencerMultisigAddress: 0x5cec6be0,
36
- sequencerMultisig_updateMerkleRoot: 0x23b05641,
37
+ sequencerMultisig_updateMerkleRoot: 0x4b19e42a,
38
+ sequencerMultisig_updateGroupPublicKey: 0x74cd76b2,
37
39
  };
38
40
  exports.CrossChainLayerErrors = {
39
41
  noErrors: 0,
@@ -50,6 +52,9 @@ exports.CrossChainLayerErrors = {
50
52
  votingNotActive: 202,
51
53
  messageCollectEndTimeLow: 203,
52
54
  notEnoughProtocolFee: 204,
55
+ messageCollectEndTimeHigh: 205,
56
+ invalidSenderSignature: 32,
57
+ unknownOp: 0xfffff,
53
58
  };
54
59
  function crossChainLayerConfigToCell(config) {
55
60
  return (0, core_1.beginCell)()
@@ -57,6 +62,9 @@ function crossChainLayerConfigToCell(config) {
57
62
  .storeAddress(config.newAdminAddress ? core_1.Address.parse(config.newAdminAddress) : null)
58
63
  .storeAddress(core_1.Address.parse(config.sequencerMultisigAddress))
59
64
  .storeRef((0, core_1.beginCell)()
65
+ .storeUint(config.groupPublicKey ? config.groupPublicKey : 0n, Constants_1.Params.bitsize.hash)
66
+ .endCell())
67
+ .storeRef((0, core_1.beginCell)()
60
68
  .storeCoins(config.tacProtocolFee ? (0, core_1.toNano)(config.tacProtocolFee.toFixed(9)) : 0)
61
69
  .storeCoins(config.tonProtocolFee ? (0, core_1.toNano)(config.tonProtocolFee.toFixed(9)) : 0)
62
70
  .storeCoins(config.protocolFeeSupply ? (0, core_1.toNano)(config.protocolFeeSupply.toFixed(9)) : 0)
@@ -134,18 +142,34 @@ class CrossChainLayer {
134
142
  .endCell(),
135
143
  });
136
144
  }
137
- async sendUpdateMerkleRoot(provider, via, value, opts) {
145
+ async sendUpdateGroupPublicKey(provider, via, value, opts) {
138
146
  await provider.internal(via, {
139
147
  value,
140
148
  sendMode: core_1.SendMode.PAY_GAS_SEPARATELY,
141
149
  body: (0, core_1.beginCell)()
142
- .storeUint(exports.CrossChainLayerOpCodes.sequencerMultisig_updateMerkleRoot, Constants_1.Params.bitsize.op)
150
+ .storeUint(exports.CrossChainLayerOpCodes.sequencerMultisig_updateGroupPublicKey, Constants_1.Params.bitsize.op)
143
151
  .storeUint(opts.queryId || 0, Constants_1.Params.bitsize.queryId)
144
- .storeUint(opts.merkleRoot, Constants_1.Params.bitsize.hash)
145
- .storeUint(opts.messageCollectEndTime, Constants_1.Params.bitsize.time)
152
+ .storeUint(opts.groupPublicKey, Constants_1.Params.bitsize.hash)
146
153
  .endCell(),
147
154
  });
148
155
  }
156
+ buildSignedUpdateMerkleRoot(secretKey, merkleRoot, messageCollectEndTime) {
157
+ let msg = (0, core_1.beginCell)()
158
+ .storeUint(merkleRoot, Constants_1.Params.bitsize.hash)
159
+ .storeUint(messageCollectEndTime, Constants_1.Params.bitsize.time)
160
+ .endCell();
161
+ let signature = (0, crypto_1.sign)(msg.hash(), secretKey);
162
+ msg = (0, core_1.beginCell)()
163
+ .storeUint(exports.CrossChainLayerOpCodes.sequencerMultisig_updateMerkleRoot, 32)
164
+ .storeBuffer(signature)
165
+ .storeSlice(msg.asSlice())
166
+ .endCell();
167
+ return msg;
168
+ }
169
+ async sendUpdateMerkleRoot(provider, secretKey, opts) {
170
+ const msg = this.buildSignedUpdateMerkleRoot(secretKey, opts.merkleRoot, opts.messageCollectEndTime);
171
+ await provider.external(msg);
172
+ }
149
173
  async sendAddProtocolFee(provider, via, value, opts) {
150
174
  await provider.internal(via, {
151
175
  value,
@@ -280,10 +304,12 @@ class CrossChainLayer {
280
304
  const tonProtocolFee = Number((0, core_1.fromNano)(result.stack.readNumber()));
281
305
  const protocolFeeSupply = Number((0, core_1.fromNano)(result.stack.readNumber()));
282
306
  const executorCode = result.stack.readCell();
307
+ const groupPublicKey = result.stack.readBigNumber();
283
308
  return {
284
309
  adminAddress,
285
310
  newAdminAddress,
286
311
  sequencerMultisigAddress,
312
+ groupPublicKey,
287
313
  maxRootsSize,
288
314
  merkleRoots: (0, MerkleRoots_1.cellToArray)(merkleRoots),
289
315
  prevEpoch,
@@ -306,6 +332,7 @@ class CrossChainLayer {
306
332
  const nextVotingTime = result.stack.readNumber();
307
333
  const epochDelay = result.stack.readNumber();
308
334
  const maxRootsSize = result.stack.readNumber();
335
+ const groupPublicKey = result.stack.readBigNumber();
309
336
  return {
310
337
  lastMerkleRoot,
311
338
  prevEpoch,
@@ -314,6 +341,7 @@ class CrossChainLayer {
314
341
  nextVotingTime,
315
342
  epochDelay,
316
343
  maxRootsSize,
344
+ groupPublicKey,
317
345
  };
318
346
  }
319
347
  async getExecutorAddress(provider, payload) {
@@ -329,8 +357,18 @@ class CrossChainLayer {
329
357
  stateInit,
330
358
  };
331
359
  }
360
+ async getEvmMsgToTvmFees(provider, payload, proofBits, proofCells, executorFeeAmount, executorFeeToken) {
361
+ const result = await provider.get('calculate_evm_msg_to_tvm_fees', [
362
+ { type: 'cell', cell: payload },
363
+ { type: 'int', value: proofBits },
364
+ { type: 'int', value: proofCells },
365
+ { type: 'int', value: executorFeeAmount },
366
+ { type: 'slice', cell: (0, core_1.beginCell)().storeAddress(executorFeeToken).endCell() },
367
+ ]);
368
+ return result.stack.readBigNumber();
369
+ }
332
370
  }
333
371
  exports.CrossChainLayer = CrossChainLayer;
334
372
  CrossChainLayer.minStorageDuration = 365 * 24 * 3600; //1 year
335
- CrossChainLayer.storageStats = new GasUtils_1.StorageStats(34518n, 87n);
336
- CrossChainLayer.addFeeGasConsumption = 6460n;
373
+ CrossChainLayer.storageStats = new GasUtils_1.StorageStats(36550n, 90n);
374
+ CrossChainLayer.addFeeGasConsumption = 7525n;
@@ -19,7 +19,7 @@ export declare const JettonMinterErrors: {
19
19
  };
20
20
  export type JettonMinterConfig = {
21
21
  totalSupply: bigint;
22
- adminAddress: Address;
22
+ adminAddress?: Address;
23
23
  newAdminAddress?: Address;
24
24
  content: Cell;
25
25
  jettonWalletCode: Cell;
@@ -28,7 +28,7 @@ export type JettonMinterConfig = {
28
28
  export type JettonMinterData = {
29
29
  totalSupply: bigint;
30
30
  mintable: boolean;
31
- adminAddress: Address;
31
+ adminAddress?: Address;
32
32
  content: Cell;
33
33
  walletCode: Cell;
34
34
  };
@@ -91,4 +91,8 @@ export declare class JettonMinter implements Contract {
91
91
  getJettonData(provider: ContractProvider): Promise<JettonMinterData>;
92
92
  getEVMTokenAddress(provider: ContractProvider): Promise<string>;
93
93
  getFullData(provider: ContractProvider): Promise<JettonMinterConfig>;
94
+ getDisplayMultiplier(provider: ContractProvider): Promise<{
95
+ numerator: bigint;
96
+ denominator: bigint;
97
+ }>;
94
98
  }
@@ -166,7 +166,7 @@ class JettonMinter {
166
166
  const res = await provider.get('get_jetton_data', []);
167
167
  const totalSupply = res.stack.readBigNumber();
168
168
  const mintable = res.stack.readBoolean();
169
- const adminAddress = res.stack.readAddress();
169
+ const adminAddress = res.stack.readAddressOpt() ?? undefined;
170
170
  const content = res.stack.readCell();
171
171
  const walletCode = res.stack.readCell();
172
172
  return {
@@ -184,7 +184,7 @@ class JettonMinter {
184
184
  async getFullData(provider) {
185
185
  const res = await provider.get('get_full_data', []);
186
186
  const totalSupply = res.stack.readBigNumber();
187
- const adminAddress = res.stack.readAddress();
187
+ const adminAddress = res.stack.readAddressOpt() ?? undefined;
188
188
  const newAdminAddress = res.stack.readAddressOpt() ?? undefined;
189
189
  const content = res.stack.readCell();
190
190
  const jettonWalletCode = res.stack.readCell();
@@ -198,5 +198,12 @@ class JettonMinter {
198
198
  evmTokenAddress,
199
199
  };
200
200
  }
201
+ async getDisplayMultiplier(provider) {
202
+ const res = await provider.get('get_display_multiplier', []);
203
+ return {
204
+ numerator: res.stack.readBigNumber(),
205
+ denominator: res.stack.readBigNumber(),
206
+ };
207
+ }
201
208
  }
202
209
  exports.JettonMinter = JettonMinter;
@@ -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,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: {
@@ -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;
@@ -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;
@@ -1,11 +1,10 @@
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.
@@ -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
  }
@@ -13,4 +13,3 @@ export declare const TAC_SYMBOL = "TAC";
13
13
  export declare const FIFTEEN_MINUTES: number;
14
14
  export declare const TON_DECIMALS = 9;
15
15
  export declare const TAC_DECIMALS = 18;
16
- export declare const TON_BURN_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TON_BURN_ADDRESS = 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;
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 { Asset, IConfiguration, ILogger, IOperationTracker, ISimulator } from '../interfaces';
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
  }
@@ -2,71 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Simulator = void 0;
4
4
  const ton_1 = require("@ton/ton");
5
- const assets_1 = require("../assets");
6
- const errors_1 = require("../errors");
7
- const Struct_1 = require("../structs/Struct");
8
5
  const Logger_1 = require("./Logger");
9
6
  const Utils_1 = require("./Utils");
10
7
  const Validator_1 = require("./Validator");
11
8
  class Simulator {
12
9
  constructor(config, operationTracker, logger = new Logger_1.NoopLogger()) {
13
- this.TON_FEE_CONSTANTS = {
14
- messageSizes: {
15
- jetton: { bits: 1500, cells: 4 },
16
- nft: { bits: 1300, cells: 4 },
17
- ton: { bits: 500, cells: 1 },
18
- },
19
- walletSendTokenPrice: 0.006 * 10 ** 9, // 0.006 TON in nanotons
20
- storageTimeDelta: 1 * 24 * 3600, // 1 day in seconds
21
- messageOverhead: { bits: 847, cells: 3 },
22
- };
23
- this.TRANSACTION_STEPS = {
24
- crossChainLayer: {
25
- accountBits: 34534,
26
- accountCells: 85,
27
- gasUsed: 13636,
28
- },
29
- jettonWallet: {
30
- accountBits: 949,
31
- accountCells: 3,
32
- gasUsed: 11000,
33
- },
34
- jettonWalletTransfer: {
35
- accountBits: 949,
36
- accountCells: 3,
37
- gasUsed: 12000,
38
- },
39
- jettonWalletBurn: {
40
- accountBits: 949,
41
- accountCells: 3,
42
- gasUsed: 8653,
43
- },
44
- jettonProxy: {
45
- accountBits: 7760,
46
- accountCells: 16,
47
- gasUsed: 8515,
48
- },
49
- jettonMinter: {
50
- accountBits: 10208,
51
- accountCells: 28,
52
- gasUsed: 10357,
53
- },
54
- nftItem: {
55
- accountBits: 1422,
56
- accountCells: 5,
57
- gasUsed: 11722,
58
- },
59
- nftItemBurn: {
60
- accountBits: 1422,
61
- accountCells: 5,
62
- gasUsed: 11552,
63
- },
64
- nftProxy: {
65
- accountBits: 7512,
66
- accountCells: 15,
67
- gasUsed: 7688,
68
- },
69
- };
70
10
  this.config = config;
71
11
  this.operationTracker = operationTracker;
72
12
  this.logger = logger;
@@ -126,105 +66,5 @@ class Simulator {
126
66
  }
127
67
  return { feeParams, simulation };
128
68
  }
129
- calculateTONFees({
130
- // Contract usage
131
- accountBits, accountCells, timeDelta,
132
- // Message size
133
- msgBits, msgCells,
134
- // Gas and computation
135
- gasUsed,
136
- // Config values (defaults for BaseChain)
137
- bitPricePs = 1, cellPricePs = 500, lumpPrice = 400000, gasPrice = 400, firstFrac = 21845, ihrPriceFactor = 0, }) {
138
- // Storage Fee (nanotons)
139
- const storageFee = Math.ceil(((accountBits * bitPricePs + accountCells * cellPricePs) * timeDelta) / 2 ** 16);
140
- // Computation Fee (nanotons)
141
- const computeFee = gasUsed * gasPrice;
142
- // Forwarding Fee (nanotons)
143
- const msgFwdFees = lumpPrice + Math.ceil((bitPricePs * msgBits + cellPricePs * msgCells) / 2 ** 16);
144
- const ihrFwdFees = Math.ceil((msgFwdFees * ihrPriceFactor) / 2 ** 16);
145
- const totalFwdFees = msgFwdFees + ihrFwdFees;
146
- // Action Fee (nanotons)
147
- const actionFee = Math.floor((msgFwdFees * firstFrac) / 2 ** 16);
148
- // Combine all fees
149
- const totalFees = storageFee + computeFee + actionFee + totalFwdFees;
150
- return totalFees;
151
- }
152
- calculateStepFee(step, messageSize) {
153
- return this.calculateTONFees({
154
- ...step,
155
- timeDelta: this.TON_FEE_CONSTANTS.storageTimeDelta,
156
- msgBits: messageSize.bits,
157
- msgCells: messageSize.cells,
158
- });
159
- }
160
- calculateTransactionPipeline(steps) {
161
- return steps.reduce((total, { step, messageSize }) => total + this.calculateStepFee(step, messageSize), this.TON_FEE_CONSTANTS.walletSendTokenPrice);
162
- }
163
- estimateTONFees(assets) {
164
- const { messageSizes, messageOverhead } = this.TON_FEE_CONSTANTS;
165
- return assets.reduce((totalFees, asset) => {
166
- const assetFee = (() => {
167
- switch (asset.type) {
168
- case Struct_1.AssetType.FT:
169
- if (asset instanceof assets_1.TON) {
170
- // Pipeline: wallet -> ccl -> log
171
- return this.calculateTransactionPipeline([
172
- { step: this.TRANSACTION_STEPS.crossChainLayer, messageSize: messageSizes.ton },
173
- ]);
174
- }
175
- if (asset.origin === Struct_1.Origin.TON) {
176
- // Pipeline: wallet -> jetton wallet -> jetton wallet -> jetton proxy -> ccl -> log
177
- return this.calculateTransactionPipeline([
178
- {
179
- step: this.TRANSACTION_STEPS.jettonWallet,
180
- messageSize: {
181
- bits: messageSizes.jetton.bits + messageOverhead.bits,
182
- cells: messageSizes.jetton.cells + messageOverhead.cells,
183
- },
184
- },
185
- { step: this.TRANSACTION_STEPS.jettonWalletTransfer, messageSize: messageSizes.jetton },
186
- { step: this.TRANSACTION_STEPS.jettonProxy, messageSize: messageSizes.jetton },
187
- { step: this.TRANSACTION_STEPS.crossChainLayer, messageSize: messageSizes.jetton },
188
- ]);
189
- }
190
- if (asset.origin === Struct_1.Origin.TAC) {
191
- // Pipeline: wallet -> jetton wallet -> jetton minter -> ccl -> log
192
- return this.calculateTransactionPipeline([
193
- {
194
- step: this.TRANSACTION_STEPS.jettonWalletBurn,
195
- messageSize: {
196
- bits: messageSizes.jetton.bits + messageOverhead.bits,
197
- cells: messageSizes.jetton.cells + messageOverhead.cells,
198
- },
199
- },
200
- { step: this.TRANSACTION_STEPS.jettonMinter, messageSize: messageSizes.jetton },
201
- { step: this.TRANSACTION_STEPS.crossChainLayer, messageSize: messageSizes.jetton },
202
- ]);
203
- }
204
- return 0;
205
- case Struct_1.AssetType.NFT:
206
- if (asset.origin === Struct_1.Origin.TON) {
207
- // Pipeline: wallet -> nft item -> nft proxy -> ccl -> log
208
- return this.calculateTransactionPipeline([
209
- { step: this.TRANSACTION_STEPS.nftItem, messageSize: messageSizes.nft },
210
- { step: this.TRANSACTION_STEPS.nftProxy, messageSize: messageSizes.nft },
211
- { step: this.TRANSACTION_STEPS.crossChainLayer, messageSize: messageSizes.nft },
212
- ]);
213
- }
214
- if (asset.origin === Struct_1.Origin.TAC) {
215
- // Pipeline: wallet -> nft item -> ccl -> log
216
- return this.calculateTransactionPipeline([
217
- { step: this.TRANSACTION_STEPS.nftItemBurn, messageSize: messageSizes.nft },
218
- { step: this.TRANSACTION_STEPS.crossChainLayer, messageSize: messageSizes.nft },
219
- ]);
220
- }
221
- return 0;
222
- default:
223
- throw (0, errors_1.unknownTokenTypeError)(asset.type);
224
- }
225
- })();
226
- return totalFees + assetFee;
227
- }, 0);
228
- }
229
69
  }
230
70
  exports.Simulator = Simulator;
@@ -19,4 +19,3 @@ export declare function startTrackingMultiple(transactionLinkers: TransactionLin
19
19
  txFinalizerConfig?: TxFinalizerConfig;
20
20
  logger?: ILogger;
21
21
  }): Promise<void | ExecutionStages[]>;
22
- export declare function printExecutionStagesTable(stages: ExecutionStages, logger: ILogger): void;