@tonappchain/sdk 0.7.0-rc14 → 0.7.0-rc16

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 (56) hide show
  1. package/README.md +7 -7
  2. package/dist/adapters/retryableContractOpener.js +1 -1
  3. package/dist/assets/AssetFactory.js +1 -1
  4. package/dist/assets/FT.d.ts +8 -12
  5. package/dist/assets/FT.js +69 -36
  6. package/dist/assets/NFT.d.ts +4 -2
  7. package/dist/assets/NFT.js +14 -2
  8. package/dist/assets/TON.d.ts +4 -10
  9. package/dist/assets/TON.js +17 -15
  10. package/dist/errors/index.d.ts +1 -1
  11. package/dist/errors/index.js +7 -2
  12. package/dist/errors/instances.d.ts +8 -1
  13. package/dist/errors/instances.js +22 -16
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.js +5 -3
  16. package/dist/interfaces/Asset.d.ts +22 -17
  17. package/dist/interfaces/ILiteSequencerClient.d.ts +14 -1
  18. package/dist/interfaces/IOperationTracker.d.ts +16 -1
  19. package/dist/interfaces/ISimulator.d.ts +7 -36
  20. package/dist/interfaces/ITACTransactionManager.d.ts +15 -0
  21. package/dist/interfaces/ITONTransactionManager.d.ts +21 -0
  22. package/dist/interfaces/ITONTransactionManager.js +2 -0
  23. package/dist/interfaces/ITacSDK.d.ts +51 -13
  24. package/dist/interfaces/index.d.ts +2 -1
  25. package/dist/interfaces/index.js +2 -1
  26. package/dist/sdk/Configuration.d.ts +1 -0
  27. package/dist/sdk/Configuration.js +52 -4
  28. package/dist/sdk/Consts.d.ts +1 -0
  29. package/dist/sdk/Consts.js +5 -4
  30. package/dist/sdk/LiteSequencerClient.d.ts +5 -3
  31. package/dist/sdk/LiteSequencerClient.js +27 -4
  32. package/dist/sdk/OperationTracker.d.ts +3 -1
  33. package/dist/sdk/OperationTracker.js +51 -11
  34. package/dist/sdk/Simulator.d.ts +6 -12
  35. package/dist/sdk/Simulator.js +30 -124
  36. package/dist/sdk/TACTransactionManager.d.ts +10 -0
  37. package/dist/sdk/TACTransactionManager.js +92 -0
  38. package/dist/sdk/TONTransactionManager.d.ts +17 -0
  39. package/dist/sdk/TONTransactionManager.js +209 -0
  40. package/dist/sdk/TacSdk.d.ts +16 -10
  41. package/dist/sdk/TacSdk.js +52 -19
  42. package/dist/sdk/TxFinalizer.d.ts +3 -2
  43. package/dist/sdk/TxFinalizer.js +8 -8
  44. package/dist/sdk/Utils.d.ts +8 -4
  45. package/dist/sdk/Utils.js +80 -12
  46. package/dist/sdk/Validator.d.ts +2 -2
  47. package/dist/sdk/Validator.js +1 -1
  48. package/dist/structs/InternalStruct.d.ts +6 -2
  49. package/dist/structs/Struct.d.ts +70 -16
  50. package/dist/wrappers/JettonMaster.d.ts +1 -1
  51. package/dist/wrappers/JettonMaster.js +1 -1
  52. package/package.json +4 -3
  53. package/dist/interfaces/ITransactionManager.d.ts +0 -35
  54. package/dist/sdk/TransactionManager.d.ts +0 -22
  55. package/dist/sdk/TransactionManager.js +0 -272
  56. /package/dist/interfaces/{ITransactionManager.js → ITACTransactionManager.js} +0 -0
package/README.md CHANGED
@@ -40,16 +40,16 @@ The TAC SDK enables you to create frontends that:
40
40
  ### SDK Components
41
41
 
42
42
  - **[`TacSdk`](./docs/sdks/tac_sdk.md)**: The main class for interacting with the TAC protocol.
43
- - [`create`](./docs/sdks/tac_sdk.md#create-static): Initializes the SDK instance.
43
+ - [`create`](./docs/sdks/tac_sdk.md#creating-an-instance-of-tacsdk): Initializes the SDK instance.
44
44
  - [`sendCrossChainTransaction`](./docs/sdks/tac_sdk.md#sendcrosschaintransaction): Sends a cross-chain transaction from TON to TAC.
45
45
  - [`getEVMTokenAddress`](./docs/sdks/tac_sdk.md#getevmtokenaddress): Gets the TAC address for a TON token.
46
46
  - [`getTVMTokenAddress`](./docs/sdks/tac_sdk.md#gettvmtokenaddress): Gets the TON address for a TAC token.
47
- - [`getTransactionSimulationInfo`](./docs/sdks/tac_sdk.md#gettransactionsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
47
+ - [`getSimulationInfo`](./docs/sdks/tac_sdk.md#getsimulationinfo): Performs a complete simulation of a crosschain transaction to estimate fees and gather execution-related metadata.
48
48
  - [`getUserJettonBalance`](./docs/sdks/tac_sdk.md#getuserjettonbalance): Gets a user's Jetton balance (raw).
49
49
  - [`getUserJettonBalanceExtended`](./docs/sdks/tac_sdk.md#getuserjettonbalanceextended): Gets extended Jetton balance info (including decimals).
50
50
  - [`getUserJettonWalletAddress`](./docs/sdks/tac_sdk.md#getuserjettonwalletaddress): Calculates a user's Jetton wallet address.
51
- - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress-getter): Placeholder address for native TON.
52
- - [`nativeTACAddress (getter)`](./docs/sdks/tac_sdk.md#nativetacaddress-getter): Gets the native asset address on the TAC chain.
51
+ - [`nativeTONAddress (getter)`](./docs/sdks/tac_sdk.md#nativetonaddress): Placeholder address for native TON.
52
+ - [`nativeTACAddress (getter)`](./docs/sdks/tac_sdk.md#nativetacaddress): Gets the native asset address on the TAC chain.
53
53
  - *(See file for more...)*
54
54
 
55
55
  - **[`OperationTracker`](./docs/sdks/operation_tracker.md)**: Tools for monitoring cross-chain operation status.
@@ -75,9 +75,9 @@ The TAC SDK enables you to create frontends that:
75
75
  - [`StageName`](./docs/models/enums.md#stagename): Identifiers for tracking stages (`COLLECTED_IN_TAC`, `EXECUTED_IN_TAC`, etc.).
76
76
 
77
77
  - **[`Structs`](./docs/models/structs.md)**: Core data structures.
78
- - [`AssetBridgingData`](./docs/models/structs.md#assetbridgingdata): Specifies assets to bridge (TON or Jettons).
79
- - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg): Defines the target EVM call details.
80
- - [`TransactionLinker`](./docs/models/structs.md#transactionlinker): Identifies a cross-chain operation.
78
+ - [`AssetLike`](./docs/models/structs.md#assetlike): Flexible asset specification for cross-chain operations.
79
+ - [`EvmProxyMsg`](./docs/models/structs.md#evmproxymsg-type): Defines the target EVM call details.
80
+ - [`TransactionLinker`](./docs/models/structs.md#transactionlinker-type): Identifies a cross-chain operation.
81
81
  - *(See file for more...)*
82
82
 
83
83
  Navigate through the linked files for full details on parameters, return types, examples, and more.
@@ -86,7 +86,7 @@ class RetryableContractOpener {
86
86
  }
87
87
  }
88
88
  exports.RetryableContractOpener = RetryableContractOpener;
89
- async function createDefaultRetryableOpener(artifacts, maxRetries = 3, retryDelay = 1000) {
89
+ async function createDefaultRetryableOpener(artifacts, maxRetries = 5, retryDelay = 1000) {
90
90
  const tonClient = new ton_1.TonClient({
91
91
  endpoint: new URL('api/v2/jsonRPC', artifacts.TON_RPC_ENDPOINT_BY_TAC).toString(),
92
92
  });
@@ -16,7 +16,7 @@ class AssetFactory {
16
16
  }
17
17
  const cachedAsset = AssetCache_1.AssetCache.get(token);
18
18
  if (cachedAsset) {
19
- return cachedAsset.clone.withAmount({ rawAmount: 0n });
19
+ return cachedAsset.clone.withRawAmount(0n);
20
20
  }
21
21
  const asset = token.tokenType === Struct_1.AssetType.FT
22
22
  ? await this.createFTAsset(configuration, token.address)
@@ -2,7 +2,7 @@ import { SandboxContract } from '@ton/sandbox';
2
2
  import { Cell, OpenedContract } from '@ton/ton';
3
3
  import { Asset, ContractOpener, IConfiguration } from '../interfaces';
4
4
  import { AssetOpType } from '../structs/InternalStruct';
5
- import { AssetType, EVMAddress, FeeParams, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
5
+ import { AssetType, EVMAddress, FeeParams, FTOriginAndData, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
6
6
  import { Origin } from '../structs/Struct';
7
7
  import { JettonMasterData } from '../wrappers/JettonMaster';
8
8
  import { JettonWallet } from '../wrappers/JettonWallet';
@@ -12,29 +12,25 @@ export declare class FT implements Asset {
12
12
  readonly origin: Origin;
13
13
  private _configuration;
14
14
  private _jettonMinter;
15
- private _decimals?;
15
+ private _decimals;
16
16
  private _transferAmount;
17
17
  private _evmAddress?;
18
18
  get address(): string;
19
19
  static getJettonData(contractOpener: ContractOpener, address: TVMAddress): Promise<JettonMasterData>;
20
20
  getJettonData(): Promise<JettonMasterData>;
21
21
  static getOrigin(configuration: IConfiguration, address: TVMAddress): Promise<Origin>;
22
+ static getOriginAndData(configuration: IConfiguration, address: TVMAddress): Promise<FTOriginAndData>;
22
23
  static getTVMAddress(configuration: IConfiguration, address: EVMAddress): Promise<string>;
23
24
  static getEVMAddress(configuration: IConfiguration, address: TVMAddress): Promise<string>;
24
25
  private constructor();
26
+ private static getTACDecimals;
25
27
  static fromAddress(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<FT>;
26
28
  get rawAmount(): bigint;
27
29
  get clone(): FT;
28
- withAmount(amount: {
29
- rawAmount: bigint;
30
- } | {
31
- amount: number;
32
- }): Promise<FT>;
33
- addAmount(amount: {
34
- rawAmount: bigint;
35
- } | {
36
- amount: number;
37
- }): Promise<FT>;
30
+ withAmount(amount: number): FT;
31
+ withRawAmount(rawAmount: bigint): FT;
32
+ addAmount(amount: number): FT;
33
+ addRawAmount(rawAmount: bigint): FT;
38
34
  getDecimals(): Promise<number>;
39
35
  getEVMAddress(): Promise<string>;
40
36
  getTVMAddress(): Promise<string>;
package/dist/assets/FT.js CHANGED
@@ -25,16 +25,21 @@ class FT {
25
25
  return FT.getJettonData(this._configuration.TONParams.contractOpener, this._tvmAddress.toString());
26
26
  }
27
27
  static async getOrigin(configuration, address) {
28
+ const result = await this.getOriginAndData(configuration, address);
29
+ return result.origin;
30
+ }
31
+ static async getOriginAndData(configuration, address) {
28
32
  const { jettonMinterCode, crossChainLayerAddress, jettonWalletCode } = configuration.TONParams;
29
33
  const { code: thisCodeBOC } = await configuration.TONParams.contractOpener.getContractState(ton_1.Address.parse(address));
30
34
  if (!thisCodeBOC) {
31
35
  throw errors_1.emptyContractError;
32
36
  }
33
37
  const thisCode = ton_1.Cell.fromBoc(thisCodeBOC)[0];
38
+ const jettonMinter = configuration.TONParams.contractOpener.open(JettonMaster_1.JettonMaster.createFromAddress(ton_1.Address.parse(address)));
34
39
  if (!jettonMinterCode.equals(thisCode)) {
35
- return Struct_2.Origin.TON;
40
+ const jettonData = await jettonMinter.getJettonData();
41
+ return { origin: Struct_2.Origin.TON, jettonMinter, jettonData };
36
42
  }
37
- const jettonMinter = configuration.TONParams.contractOpener.open(JettonMaster_1.JettonMaster.createFromAddress(ton_1.Address.parse(address)));
38
43
  const evmAddress = await jettonMinter.getEVMAddress();
39
44
  const expectedMinterAddress = await (0, Utils_1.calculateContractAddress)(jettonMinterCode, (0, ton_1.beginCell)()
40
45
  .storeCoins(0)
@@ -45,20 +50,19 @@ class FT {
45
50
  .storeStringTail(evmAddress)
46
51
  .endCell());
47
52
  if (!expectedMinterAddress.equals(ton_1.Address.parse(address))) {
48
- return Struct_2.Origin.TON;
53
+ const jettonData = await jettonMinter.getJettonData();
54
+ return { origin: Struct_2.Origin.TON, jettonMinter, jettonData };
49
55
  }
50
- return Struct_2.Origin.TAC;
56
+ return { origin: Struct_2.Origin.TAC, jettonMinter, evmAddress };
51
57
  }
52
58
  static async getTVMAddress(configuration, address) {
53
59
  Validator_1.Validator.validateEVMAddress(address);
54
- // If token is TON native
55
60
  const fromTVM = await configuration.TACParams.tokenUtils['exists(address)'](address);
56
61
  if (fromTVM) {
57
62
  const erc20Token = configuration.artifacts.tac.wrappers.CrossChainLayerERC20FactoryTAC.connect(address, configuration.TACParams.provider);
58
63
  const info = await erc20Token.getInfo();
59
64
  return info.tvmAddress;
60
65
  }
61
- // If token is TAC native
62
66
  const jettonMaster = JettonMaster_1.JettonMaster.createFromConfig({
63
67
  evmTokenAddress: address,
64
68
  crossChainLayerAddress: ton_1.Address.parse(configuration.TONParams.crossChainLayerAddress),
@@ -78,25 +82,57 @@ class FT {
78
82
  return givenMinter.getEVMAddress();
79
83
  }
80
84
  }
81
- constructor(address, origin, configuration) {
85
+ constructor(address, origin, configuration, decimals) {
82
86
  this.type = Struct_1.AssetType.FT;
83
87
  this._tvmAddress = ton_1.Address.parse(address);
84
88
  this._configuration = configuration;
85
89
  this._jettonMinter = this._configuration.TONParams.contractOpener.open(new JettonMaster_1.JettonMaster(this._tvmAddress));
86
90
  this.origin = origin;
87
91
  this._transferAmount = 0n;
92
+ this._decimals = decimals;
93
+ }
94
+ static async getTACDecimals(configuration, evmAddress) {
95
+ const nativeTACAddress = await configuration.nativeTACAddress();
96
+ if (evmAddress === nativeTACAddress) {
97
+ return 18; // Native TAC always has 18 decimals
98
+ }
99
+ // For ERC20 contracts, get decimals from contract
100
+ const erc20Token = configuration.artifacts.tac.wrappers.ERC20FactoryTAC.connect(evmAddress, configuration.TACParams.provider);
101
+ return Number(await erc20Token.decimals());
88
102
  }
89
103
  static async fromAddress(configuration, address) {
90
104
  const tvmAddress = (0, ethers_1.isAddress)(address) ? await this.getTVMAddress(configuration, address) : address;
91
- const origin = await FT.getOrigin(configuration, tvmAddress).catch((e) => {
105
+ const { origin, jettonMinter, evmAddress: cachedEvmAddress, jettonData, } = await this.getOriginAndData(configuration, tvmAddress).catch((e) => {
92
106
  if (e instanceof errors_1.ContractError) {
93
- return Struct_2.Origin.TAC;
107
+ const jettonMinter = configuration.TONParams.contractOpener.open(JettonMaster_1.JettonMaster.createFromAddress(ton_1.Address.parse(tvmAddress)));
108
+ return { origin: Struct_2.Origin.TAC, jettonMinter, evmAddress: undefined, jettonData: undefined };
94
109
  }
95
110
  throw e;
96
111
  });
97
- const token = new FT(tvmAddress, origin, configuration);
98
- if ((0, ethers_1.isAddress)(address)) {
99
- token._evmAddress = address;
112
+ let decimals;
113
+ let finalEvmAddress;
114
+ if (origin === Struct_2.Origin.TON) {
115
+ if (!jettonData) {
116
+ throw errors_1.missingJettonDataError;
117
+ }
118
+ const decimalsRaw = jettonData.content.metadata.decimals;
119
+ if (decimalsRaw === undefined) {
120
+ throw errors_1.missingDecimals;
121
+ }
122
+ decimals = Number(decimalsRaw);
123
+ }
124
+ else {
125
+ if ((0, ethers_1.isAddress)(address)) {
126
+ finalEvmAddress = address;
127
+ }
128
+ else {
129
+ finalEvmAddress = cachedEvmAddress || (await jettonMinter.getEVMAddress());
130
+ }
131
+ decimals = await this.getTACDecimals(configuration, finalEvmAddress);
132
+ }
133
+ const token = new FT(tvmAddress, origin, configuration, decimals);
134
+ if (finalEvmAddress || (0, ethers_1.isAddress)(address)) {
135
+ token._evmAddress = finalEvmAddress || address;
100
136
  }
101
137
  return token;
102
138
  }
@@ -104,44 +140,41 @@ class FT {
104
140
  return this._transferAmount;
105
141
  }
106
142
  get clone() {
107
- const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration);
143
+ const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration, this._decimals);
108
144
  ft._transferAmount = this._transferAmount;
109
145
  ft._evmAddress = this._evmAddress;
110
- ft._decimals = this._decimals;
111
146
  return ft;
112
147
  }
113
- async withAmount(amount) {
148
+ withAmount(amount) {
114
149
  if (this._transferAmount > 0n) {
115
- // clone token if withAmount set before to avoid changing the original token
116
150
  const newToken = this.clone;
117
- newToken._transferAmount =
118
- 'rawAmount' in amount ? amount.rawAmount : (0, Utils_1.calculateRawAmount)(amount.amount, await this.getDecimals());
151
+ const decimals = this._decimals;
152
+ newToken._transferAmount = (0, Utils_1.calculateRawAmount)(amount, decimals);
119
153
  return newToken;
120
154
  }
121
- if ('rawAmount' in amount) {
122
- this._transferAmount = amount.rawAmount;
123
- }
124
- else {
125
- const decimals = await this.getDecimals();
126
- this._transferAmount = (0, Utils_1.calculateRawAmount)(amount.amount, decimals);
127
- }
155
+ const decimals = this._decimals;
156
+ this._transferAmount = (0, Utils_1.calculateRawAmount)(amount, decimals);
128
157
  return this;
129
158
  }
130
- async addAmount(amount) {
131
- if ('rawAmount' in amount) {
132
- this._transferAmount = this._transferAmount + amount.rawAmount;
133
- }
134
- else {
135
- const decimals = await this.getDecimals();
136
- this._transferAmount = this._transferAmount + (0, Utils_1.calculateRawAmount)(amount.amount, decimals);
159
+ withRawAmount(rawAmount) {
160
+ if (this._transferAmount > 0n) {
161
+ const newToken = this.clone;
162
+ newToken._transferAmount = rawAmount;
163
+ return newToken;
137
164
  }
165
+ this._transferAmount = rawAmount;
166
+ return this;
167
+ }
168
+ addAmount(amount) {
169
+ const decimals = this._decimals;
170
+ this._transferAmount = this._transferAmount + (0, Utils_1.calculateRawAmount)(amount, decimals);
171
+ return this;
172
+ }
173
+ addRawAmount(rawAmount) {
174
+ this._transferAmount = this._transferAmount + rawAmount;
138
175
  return this;
139
176
  }
140
177
  async getDecimals() {
141
- if (!this._decimals) {
142
- const decimalsRaw = (await this._jettonMinter.getJettonData()).content.metadata.decimals;
143
- this._decimals = decimalsRaw ? Number(decimalsRaw) : 9;
144
- }
145
178
  return this._decimals;
146
179
  }
147
180
  async getEVMAddress() {
@@ -46,8 +46,10 @@ export declare class NFT implements Asset {
46
46
  get address(): string;
47
47
  get rawAmount(): bigint;
48
48
  get clone(): NFT;
49
- withAmount(): Promise<NFT>;
50
- addAmount(): Promise<NFT>;
49
+ withAmount(_amount?: number): NFT;
50
+ withRawAmount(_rawAmount?: bigint): NFT;
51
+ addAmount(_amount?: number): NFT;
52
+ addRawAmount(_rawAmount?: bigint): NFT;
51
53
  getEVMAddress(): Promise<string>;
52
54
  getTVMAddress(): Promise<string>;
53
55
  generatePayload(params: {
@@ -139,10 +139,22 @@ class NFT {
139
139
  get clone() {
140
140
  return new NFT(this._addresses, this.origin, this._configuration);
141
141
  }
142
- async withAmount() {
142
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
143
+ withAmount(_amount) {
144
+ // NFTs are non-fungible; amount is always 1. Keep API consistent.
143
145
  return this;
144
146
  }
145
- async addAmount() {
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
+ withRawAmount(_rawAmount) {
149
+ // NFTs are non-fungible; raw amount concept is not applicable. Keep API consistent.
150
+ return this;
151
+ }
152
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
+ addAmount(_amount) {
154
+ return this;
155
+ }
156
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
+ addRawAmount(_rawAmount) {
146
158
  return this;
147
159
  }
148
160
  async getEVMAddress() {
@@ -12,16 +12,10 @@ export declare class TON implements Asset {
12
12
  static create(config: IConfiguration): TON;
13
13
  get rawAmount(): bigint;
14
14
  get clone(): TON;
15
- withAmount(amount: {
16
- rawAmount: bigint;
17
- } | {
18
- amount: number;
19
- }): Promise<TON>;
20
- addAmount(amount: {
21
- rawAmount: bigint;
22
- } | {
23
- amount: number;
24
- }): Promise<TON>;
15
+ withAmount(amount: number): TON;
16
+ withRawAmount(rawAmount: bigint): TON;
17
+ addAmount(amount: number): TON;
18
+ addRawAmount(rawAmount: bigint): TON;
25
19
  getEVMAddress(): Promise<string>;
26
20
  getTVMAddress(): Promise<string>;
27
21
  generatePayload(params: {
@@ -24,28 +24,30 @@ class TON {
24
24
  ton._rawAmount = this._rawAmount;
25
25
  return ton;
26
26
  }
27
- async withAmount(amount) {
27
+ withAmount(amount) {
28
28
  if (this._rawAmount > 0n) {
29
- // clone token if withAmount set before to avoid changing the original token
30
29
  const newToken = this.clone;
31
- newToken._rawAmount = 'rawAmount' in amount ? amount.rawAmount : (0, Utils_1.calculateRawAmount)(amount.amount, 9);
30
+ newToken._rawAmount = (0, Utils_1.calculateRawAmount)(amount, 9);
32
31
  return newToken;
33
32
  }
34
- if ('rawAmount' in amount) {
35
- this._rawAmount = amount.rawAmount;
36
- }
37
- else {
38
- this._rawAmount = (0, Utils_1.calculateRawAmount)(amount.amount, 9);
39
- }
33
+ this._rawAmount = (0, Utils_1.calculateRawAmount)(amount, 9);
40
34
  return this;
41
35
  }
42
- async addAmount(amount) {
43
- if ('rawAmount' in amount) {
44
- this._rawAmount = this._rawAmount + amount.rawAmount;
45
- }
46
- else {
47
- this._rawAmount = this._rawAmount + (0, Utils_1.calculateRawAmount)(amount.amount, 9);
36
+ withRawAmount(rawAmount) {
37
+ if (this._rawAmount > 0n) {
38
+ const newToken = this.clone;
39
+ newToken._rawAmount = rawAmount;
40
+ return newToken;
48
41
  }
42
+ this._rawAmount = rawAmount;
43
+ return this;
44
+ }
45
+ addAmount(amount) {
46
+ this._rawAmount = this._rawAmount + (0, Utils_1.calculateRawAmount)(amount, 9);
47
+ return this;
48
+ }
49
+ addRawAmount(rawAmount) {
50
+ this._rawAmount = this._rawAmount + rawAmount;
49
51
  return this;
50
52
  }
51
53
  async getEVMAddress() {
@@ -1,2 +1,2 @@
1
1
  export { AddressError, BitError, ContractError, EVMCallError, FetchError, FormatError, KeyError, MetadataError, SettingError, TokenError, WalletError, } from './errors';
2
- export { allEndpointsFailedError, emptyArrayError, emptyContractError, emptySettingError, evmAddressError, indexRequiredError, insufficientBalanceError, invalidMethodNameError, notMultiplyOf8Error, operationFetchError, prefixError, profilingFetchError, simulationError, statusFetchError, tvmAddressError, unknownTokenTypeError, unknownWalletError, unsupportedFormatError, unsupportedKeyError, } from './instances';
2
+ export { allEndpointsFailedError, emptyArrayError, emptyContractError, emptySettingError, evmAddressError, indexRequiredError, insufficientBalanceError, invalidMethodNameError, missingDecimals, missingFeeParamsError, missingGasLimitError, missingJettonDataError, missingTvmExecutorFeeError, notMultiplyOf8Error, operationFetchError, prefixError, profilingFetchError, simulationFetchError, statusFetchError, tvmAddressError, unknownTokenTypeError, unknownWalletError, unsupportedFormatError, unsupportedKeyError } from './instances';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.tvmAddressError = exports.statusFetchError = exports.simulationError = exports.profilingFetchError = exports.prefixError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.invalidMethodNameError = exports.insufficientBalanceError = exports.indexRequiredError = exports.evmAddressError = exports.emptySettingError = exports.emptyContractError = exports.emptyArrayError = exports.allEndpointsFailedError = exports.WalletError = exports.TokenError = exports.SettingError = exports.MetadataError = exports.KeyError = exports.FormatError = exports.FetchError = exports.EVMCallError = exports.ContractError = exports.BitError = exports.AddressError = void 0;
3
+ exports.unsupportedKeyError = exports.unsupportedFormatError = exports.unknownWalletError = exports.unknownTokenTypeError = exports.tvmAddressError = exports.statusFetchError = exports.simulationFetchError = exports.profilingFetchError = exports.prefixError = exports.operationFetchError = exports.notMultiplyOf8Error = exports.missingTvmExecutorFeeError = exports.missingJettonDataError = exports.missingGasLimitError = exports.missingFeeParamsError = exports.missingDecimals = exports.invalidMethodNameError = exports.insufficientBalanceError = exports.indexRequiredError = exports.evmAddressError = exports.emptySettingError = exports.emptyContractError = exports.emptyArrayError = exports.allEndpointsFailedError = exports.WalletError = exports.TokenError = exports.SettingError = exports.MetadataError = exports.KeyError = exports.FormatError = exports.FetchError = exports.EVMCallError = exports.ContractError = exports.BitError = exports.AddressError = void 0;
4
4
  var errors_1 = require("./errors");
5
5
  Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return errors_1.AddressError; } });
6
6
  Object.defineProperty(exports, "BitError", { enumerable: true, get: function () { return errors_1.BitError; } });
@@ -22,11 +22,16 @@ Object.defineProperty(exports, "evmAddressError", { enumerable: true, get: funct
22
22
  Object.defineProperty(exports, "indexRequiredError", { enumerable: true, get: function () { return instances_1.indexRequiredError; } });
23
23
  Object.defineProperty(exports, "insufficientBalanceError", { enumerable: true, get: function () { return instances_1.insufficientBalanceError; } });
24
24
  Object.defineProperty(exports, "invalidMethodNameError", { enumerable: true, get: function () { return instances_1.invalidMethodNameError; } });
25
+ Object.defineProperty(exports, "missingDecimals", { enumerable: true, get: function () { return instances_1.missingDecimals; } });
26
+ Object.defineProperty(exports, "missingFeeParamsError", { enumerable: true, get: function () { return instances_1.missingFeeParamsError; } });
27
+ Object.defineProperty(exports, "missingGasLimitError", { enumerable: true, get: function () { return instances_1.missingGasLimitError; } });
28
+ Object.defineProperty(exports, "missingJettonDataError", { enumerable: true, get: function () { return instances_1.missingJettonDataError; } });
29
+ Object.defineProperty(exports, "missingTvmExecutorFeeError", { enumerable: true, get: function () { return instances_1.missingTvmExecutorFeeError; } });
25
30
  Object.defineProperty(exports, "notMultiplyOf8Error", { enumerable: true, get: function () { return instances_1.notMultiplyOf8Error; } });
26
31
  Object.defineProperty(exports, "operationFetchError", { enumerable: true, get: function () { return instances_1.operationFetchError; } });
27
32
  Object.defineProperty(exports, "prefixError", { enumerable: true, get: function () { return instances_1.prefixError; } });
28
33
  Object.defineProperty(exports, "profilingFetchError", { enumerable: true, get: function () { return instances_1.profilingFetchError; } });
29
- Object.defineProperty(exports, "simulationError", { enumerable: true, get: function () { return instances_1.simulationError; } });
34
+ Object.defineProperty(exports, "simulationFetchError", { enumerable: true, get: function () { return instances_1.simulationFetchError; } });
30
35
  Object.defineProperty(exports, "statusFetchError", { enumerable: true, get: function () { return instances_1.statusFetchError; } });
31
36
  Object.defineProperty(exports, "tvmAddressError", { enumerable: true, get: function () { return instances_1.tvmAddressError; } });
32
37
  Object.defineProperty(exports, "unknownTokenTypeError", { enumerable: true, get: function () { return instances_1.unknownTokenTypeError; } });
@@ -11,7 +11,6 @@ export declare const notMultiplyOf8Error: BitError;
11
11
  export declare const prefixError: MetadataError;
12
12
  export declare const emptySettingError: (setting: string) => SettingError;
13
13
  export declare const invalidMethodNameError: (methodName: string) => EVMCallError;
14
- export declare const simulationError: (inner: unknown) => FetchError;
15
14
  export declare const profilingFetchError: (msg: string, inner?: unknown) => FetchError;
16
15
  export declare const emptyArrayError: (msg: string) => FetchError;
17
16
  export declare const invalidAssetType: FormatError;
@@ -22,3 +21,11 @@ export declare const allContractOpenerFailedError: (inner: unknown) => FetchErro
22
21
  export declare const insufficientBalanceError: (token: string) => InsufficientBalanceError;
23
22
  export declare const unknownTokenTypeError: (token: string, reason?: string) => TokenError;
24
23
  export declare const indexRequiredError: (token: string) => TokenError;
24
+ export declare const convertCurrencyFetchError: (msg: string, inner?: unknown) => FetchError;
25
+ export declare const simulationFetchError: (msg: string, inner?: unknown) => FetchError;
26
+ export declare const getTONFeeInfoFetchError: (msg: string, inner?: unknown) => FetchError;
27
+ export declare const missingFeeParamsError: FormatError;
28
+ export declare const missingTvmExecutorFeeError: FormatError;
29
+ export declare const missingGasLimitError: FormatError;
30
+ export declare const missingDecimals: MetadataError;
31
+ export declare const missingJettonDataError: MetadataError;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.simulationError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
3
+ exports.missingJettonDataError = exports.missingDecimals = exports.missingGasLimitError = exports.missingTvmExecutorFeeError = exports.missingFeeParamsError = exports.getTONFeeInfoFetchError = exports.simulationFetchError = exports.convertCurrencyFetchError = exports.indexRequiredError = exports.unknownTokenTypeError = exports.insufficientBalanceError = exports.allContractOpenerFailedError = exports.allEndpointsFailedError = exports.noValidGroupFoundError = exports.prepareMessageGroupError = exports.invalidAssetType = exports.emptyArrayError = exports.profilingFetchError = exports.invalidMethodNameError = exports.emptySettingError = exports.prefixError = exports.notMultiplyOf8Error = exports.unsupportedFormatError = exports.unsupportedKeyError = exports.unknownWalletError = exports.evmAddressError = exports.tvmAddressError = exports.statusFetchError = exports.operationFetchError = exports.emptyContractError = void 0;
4
4
  const errors_1 = require("./errors");
5
5
  exports.emptyContractError = new errors_1.ContractError('unexpected empty contract code of given jetton.', 100);
6
6
  const operationFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch OperationId: ${msg}`, 101, inner);
@@ -22,26 +22,32 @@ const emptySettingError = (setting) => new errors_1.SettingError(`unexpected emp
22
22
  exports.emptySettingError = emptySettingError;
23
23
  const invalidMethodNameError = (methodName) => new errors_1.EVMCallError(`Invalid Solidity method name: "${methodName}". Method must be either a valid identifier or have parameters (bytes,bytes).`, 111);
24
24
  exports.invalidMethodNameError = invalidMethodNameError;
25
- const simulationError = (inner) =>
26
- // try to get meaningful error message from axios error
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- new errors_1.FetchError(`Failed to simulate EVM call: ${inner?.response?.data?.error}`, 112, inner);
29
- exports.simulationError = simulationError;
30
- const profilingFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch stage profiling: ${msg}`, 113, inner);
25
+ const profilingFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch stage profiling: ${msg}`, 112, inner);
31
26
  exports.profilingFetchError = profilingFetchError;
32
- const emptyArrayError = (msg) => new errors_1.FetchError(`empty array: ${msg}`, 114);
27
+ const emptyArrayError = (msg) => new errors_1.FetchError(`empty array: ${msg}`, 113);
33
28
  exports.emptyArrayError = emptyArrayError;
34
- exports.invalidAssetType = new errors_1.FormatError('Invalid asset type', 115);
35
- const prepareMessageGroupError = (isBocSizeValid, isDepthValid) => new errors_1.PrepareMessageGroupError(`Failed to prepare message group: BOC size valid: ${isBocSizeValid}, depth valid: ${isDepthValid}`, 116);
29
+ exports.invalidAssetType = new errors_1.FormatError('Invalid asset type', 114);
30
+ const prepareMessageGroupError = (isBocSizeValid, isDepthValid) => new errors_1.PrepareMessageGroupError(`Failed to prepare message group: BOC size valid: ${isBocSizeValid}, depth valid: ${isDepthValid}`, 115);
36
31
  exports.prepareMessageGroupError = prepareMessageGroupError;
37
- exports.noValidGroupFoundError = new errors_1.NoValidGroupFoundError('Failed to prepare valid message group', 117);
38
- const allEndpointsFailedError = (inner) => new errors_1.FetchError('All endpoints failed', 118, inner);
32
+ exports.noValidGroupFoundError = new errors_1.NoValidGroupFoundError('Failed to prepare valid message group', 116);
33
+ const allEndpointsFailedError = (inner) => new errors_1.FetchError('All endpoints failed', 117, inner);
39
34
  exports.allEndpointsFailedError = allEndpointsFailedError;
40
- const allContractOpenerFailedError = (inner) => new errors_1.FetchError('All contract opener failed', 119, inner);
35
+ const allContractOpenerFailedError = (inner) => new errors_1.FetchError('All contract opener failed', 118, inner);
41
36
  exports.allContractOpenerFailedError = allContractOpenerFailedError;
42
- const insufficientBalanceError = (token) => new errors_1.InsufficientBalanceError(`Insufficient balance of ${token}`, 120);
37
+ const insufficientBalanceError = (token) => new errors_1.InsufficientBalanceError(`Insufficient balance of ${token}`, 119);
43
38
  exports.insufficientBalanceError = insufficientBalanceError;
44
- const unknownTokenTypeError = (token, reason) => new errors_1.TokenError(`Unknown token type of ${token}: ${reason}`, 121);
39
+ const unknownTokenTypeError = (token, reason) => new errors_1.TokenError(`Unknown token type of ${token}: ${reason}`, 120);
45
40
  exports.unknownTokenTypeError = unknownTokenTypeError;
46
- const indexRequiredError = (token) => new errors_1.TokenError(`Index is required for collection ${token}`, 122);
41
+ const indexRequiredError = (token) => new errors_1.TokenError(`Index is required for collection ${token}`, 121);
47
42
  exports.indexRequiredError = indexRequiredError;
43
+ const convertCurrencyFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch convert currency: ${msg}`, 122, inner);
44
+ exports.convertCurrencyFetchError = convertCurrencyFetchError;
45
+ const simulationFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch simulate tac msg: ${msg}`, 123, inner);
46
+ exports.simulationFetchError = simulationFetchError;
47
+ const getTONFeeInfoFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch simulate tac msg: ${msg}`, 124, inner);
48
+ exports.getTONFeeInfoFetchError = getTONFeeInfoFetchError;
49
+ exports.missingFeeParamsError = new errors_1.FormatError('When withoutSimulation is true, protocolFee and evmExecutorFee must be provided in options', 125);
50
+ exports.missingTvmExecutorFeeError = new errors_1.FormatError('When withoutSimulation is true and isRoundTrip is true, tvmExecutorFee must be provided in options', 126);
51
+ exports.missingGasLimitError = new errors_1.FormatError('When withoutSimulation is true, gasLimit must be provided in evmProxyMsg', 127);
52
+ exports.missingDecimals = new errors_1.MetadataError('Missing decimals in jetton metadata', 128);
53
+ exports.missingJettonDataError = new errors_1.MetadataError('Jetton data should be available for TON origin', 129);
package/dist/index.d.ts CHANGED
@@ -10,7 +10,8 @@ export { OperationTracker } from './sdk/OperationTracker';
10
10
  export { Simulator } from './sdk/Simulator';
11
11
  export { startTracking, startTrackingMultiple } from './sdk/StartTracking';
12
12
  export { TacSdk } from './sdk/TacSdk';
13
- export { TransactionManager } from './sdk/TransactionManager';
13
+ export { TONTransactionManager } from './sdk/TONTransactionManager';
14
+ export { TACTransactionManager } from './sdk/TACTransactionManager';
14
15
  export * from './sender';
15
16
  export * from './structs/Struct';
16
17
  export { Network, SimplifiedStatuses } from './structs/Struct';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.JettonWalletOpCodes = exports.JettonWallet = exports.HighloadWalletV3 = exports.readJettonMetadata = exports.SimplifiedStatuses = exports.Network = exports.TransactionManager = exports.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.orbsOpener = exports.liteClientOpener = void 0;
17
+ exports.JettonWalletOpCodes = exports.JettonWallet = exports.HighloadWalletV3 = exports.readJettonMetadata = exports.SimplifiedStatuses = exports.Network = exports.TACTransactionManager = exports.TONTransactionManager = exports.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = exports.AxiosHttpClient = exports.orbsOpener = exports.liteClientOpener = void 0;
18
18
  var contractOpener_1 = require("./adapters/contractOpener");
19
19
  Object.defineProperty(exports, "liteClientOpener", { enumerable: true, get: function () { return contractOpener_1.liteClientOpener; } });
20
20
  Object.defineProperty(exports, "orbsOpener", { enumerable: true, get: function () { return contractOpener_1.orbsOpener; } });
@@ -39,8 +39,10 @@ Object.defineProperty(exports, "startTracking", { enumerable: true, get: functio
39
39
  Object.defineProperty(exports, "startTrackingMultiple", { enumerable: true, get: function () { return StartTracking_1.startTrackingMultiple; } });
40
40
  var TacSdk_1 = require("./sdk/TacSdk");
41
41
  Object.defineProperty(exports, "TacSdk", { enumerable: true, get: function () { return TacSdk_1.TacSdk; } });
42
- var TransactionManager_1 = require("./sdk/TransactionManager");
43
- Object.defineProperty(exports, "TransactionManager", { enumerable: true, get: function () { return TransactionManager_1.TransactionManager; } });
42
+ var TONTransactionManager_1 = require("./sdk/TONTransactionManager");
43
+ Object.defineProperty(exports, "TONTransactionManager", { enumerable: true, get: function () { return TONTransactionManager_1.TONTransactionManager; } });
44
+ var TACTransactionManager_1 = require("./sdk/TACTransactionManager");
45
+ Object.defineProperty(exports, "TACTransactionManager", { enumerable: true, get: function () { return TACTransactionManager_1.TACTransactionManager; } });
44
46
  __exportStar(require("./sender"), exports);
45
47
  __exportStar(require("./structs/Struct"), exports);
46
48
  var Struct_1 = require("./structs/Struct");
@@ -6,28 +6,33 @@ export interface Asset {
6
6
  rawAmount: bigint;
7
7
  clone: Asset;
8
8
  /**
9
- * Returns a new asset instance with the specified transfer amount.
10
- * Use { rawAmount } for base units (e.g., nano units), or { amount } for human-readable units if supported by the implementation.
9
+ * Returns a new asset instance with the specified transfer amount in human-readable units.
11
10
  * Does not mutate the current asset instance.
12
- * @param amount Object specifying either rawAmount (bigint base units) or amount (number in human units).
13
- * @returns Promise that resolves to a new Asset reflecting the requested amount.
11
+ * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
12
+ * @returns A new Asset reflecting the requested amount.
14
13
  */
15
- withAmount(amount: {
16
- rawAmount: bigint;
17
- } | {
18
- amount: number;
19
- }): Promise<Asset>;
14
+ withAmount(amount: number): Asset;
20
15
  /**
21
- * Increases the transfer amount by the specified value and returns a new asset instance.
16
+ * Returns a new asset instance with the specified transfer amount in raw base units.
22
17
  * Does not mutate the current asset instance.
23
- * @param amount Object specifying either rawAmount (bigint base units) or amount (number in human units).
24
- * @returns Promise that resolves to a new Asset with the increased amount.
18
+ * @param rawAmount Amount in raw base units (bigint).
19
+ * @returns A new Asset reflecting the requested raw amount.
25
20
  */
26
- addAmount(amount: {
27
- rawAmount: bigint;
28
- } | {
29
- amount: number;
30
- }): Promise<Asset>;
21
+ withRawAmount(rawAmount: bigint): Asset;
22
+ /**
23
+ * Increases the transfer amount by the specified value (human-readable units) and returns a new asset instance.
24
+ * Does not mutate the current asset instance.
25
+ * @param amount Amount in human units (e.g., 1.5 TON). Decimals are resolved during asset creation.
26
+ * @returns A new Asset with the increased amount.
27
+ */
28
+ addAmount(amount: number): Asset;
29
+ /**
30
+ * Increases the transfer amount by the specified raw base units and returns a new asset instance.
31
+ * Does not mutate the current asset instance.
32
+ * @param rawAmount Amount in raw base units (bigint).
33
+ * @returns A new Asset with the increased amount in raw units.
34
+ */
35
+ addRawAmount(rawAmount: bigint): Asset;
31
36
  /**
32
37
  * Resolves the corresponding EVM token address for this asset.
33
38
  * Useful when bridging or interacting with EVM-compatible networks.
@@ -1,4 +1,4 @@
1
- import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, TransactionLinker } from '../structs/Struct';
1
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
2
2
  export interface ILiteSequencerClient {
3
3
  /** Retrieves the operation type by id. */
4
4
  getOperationType(operationId: string): Promise<OperationType>;
@@ -27,4 +27,17 @@ export interface ILiteSequencerClient {
27
27
  getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
28
28
  /** Converts currency amount using the sequencer-provided rate source. */
29
29
  convertCurrency(params: ConvertCurrencyParams): Promise<ConvertedCurrencyResult>;
30
+ /**
31
+ * Gets TVM executor fee information for cross-chain operations.
32
+ * @param params Parameters for fee calculation including assets and fee symbol.
33
+ * @returns Promise resolving to suggested TVM executor fee information.
34
+ */
35
+ getTVMExecutorFee(params: GetTVMExecutorFeeParams): Promise<SuggestedTVMExecutorFee>;
36
+ /**
37
+ * Simulates TAC message execution without broadcasting it on-chain.
38
+ * Useful for estimating fees and validating transaction inputs.
39
+ * @param params Simulation request with encoded message and context.
40
+ * @returns Promise resolving to detailed simulation result.
41
+ */
42
+ simulateTACMessage(params: TACSimulationParams): Promise<TACSimulationResult>;
30
43
  }