@tonappchain/sdk 0.6.6-mainnet-alpha → 0.7.0-rc11

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 (97) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +191 -191
  3. package/dist/adapters/contractOpener.d.ts +2 -1
  4. package/dist/adapters/contractOpener.js +6 -6
  5. package/dist/adapters/retryableContractOpener.d.ts +6 -2
  6. package/dist/adapters/retryableContractOpener.js +2 -2
  7. package/dist/assets/AssetCache.d.ts +23 -0
  8. package/dist/assets/AssetCache.js +36 -0
  9. package/dist/assets/AssetFactory.d.ts +7 -0
  10. package/dist/assets/AssetFactory.js +46 -0
  11. package/dist/assets/FT.d.ts +58 -0
  12. package/dist/assets/FT.js +231 -0
  13. package/dist/assets/NFT.d.ts +65 -0
  14. package/dist/assets/NFT.js +210 -0
  15. package/dist/assets/TON.d.ts +38 -0
  16. package/dist/assets/TON.js +91 -0
  17. package/dist/assets/index.d.ts +4 -0
  18. package/dist/assets/index.js +11 -0
  19. package/dist/errors/errors.d.ts +6 -0
  20. package/dist/errors/errors.js +15 -1
  21. package/dist/errors/index.d.ts +2 -2
  22. package/dist/errors/index.js +26 -22
  23. package/dist/errors/instances.d.ts +4 -1
  24. package/dist/errors/instances.js +11 -2
  25. package/dist/index.d.ts +7 -0
  26. package/dist/index.js +14 -1
  27. package/dist/interfaces/Asset.d.ts +73 -0
  28. package/dist/interfaces/Asset.js +2 -0
  29. package/dist/interfaces/ContractOpener.d.ts +21 -0
  30. package/dist/interfaces/ContractOpener.js +2 -0
  31. package/dist/interfaces/IConfiguration.d.ts +35 -0
  32. package/dist/interfaces/IConfiguration.js +2 -0
  33. package/dist/interfaces/IHttpClient.d.ts +16 -0
  34. package/dist/interfaces/IHttpClient.js +2 -0
  35. package/dist/interfaces/ILiteSequencerClient.d.ts +30 -0
  36. package/dist/interfaces/ILiteSequencerClient.js +2 -0
  37. package/dist/interfaces/ILiteSequencerClientFactory.d.ts +9 -0
  38. package/dist/interfaces/ILiteSequencerClientFactory.js +2 -0
  39. package/dist/interfaces/ILogger.d.ts +10 -0
  40. package/dist/interfaces/ILogger.js +2 -0
  41. package/dist/interfaces/IOperationTracker.d.ts +66 -0
  42. package/dist/interfaces/IOperationTracker.js +2 -0
  43. package/dist/interfaces/ISimulator.d.ts +47 -0
  44. package/dist/interfaces/ISimulator.js +2 -0
  45. package/dist/interfaces/ITacSDK.d.ts +147 -0
  46. package/dist/interfaces/ITacSDK.js +2 -0
  47. package/dist/interfaces/ITransactionManager.d.ts +35 -0
  48. package/dist/interfaces/ITransactionManager.js +2 -0
  49. package/dist/interfaces/SenderAbstraction.d.ts +35 -0
  50. package/dist/interfaces/SenderAbstraction.js +2 -0
  51. package/dist/interfaces/WalletInstanse.d.ts +20 -0
  52. package/dist/interfaces/WalletInstanse.js +2 -0
  53. package/dist/interfaces/index.d.ts +13 -0
  54. package/dist/interfaces/index.js +29 -0
  55. package/dist/sdk/AxiosHttpClient.d.ts +12 -0
  56. package/dist/sdk/AxiosHttpClient.js +23 -0
  57. package/dist/sdk/Configuration.d.ts +21 -0
  58. package/dist/sdk/Configuration.js +90 -0
  59. package/dist/sdk/LiteSequencerClient.d.ts +6 -2
  60. package/dist/sdk/LiteSequencerClient.js +58 -14
  61. package/dist/sdk/Logger.d.ts +13 -0
  62. package/dist/sdk/Logger.js +25 -0
  63. package/dist/sdk/OperationTracker.d.ts +10 -5
  64. package/dist/sdk/OperationTracker.js +87 -45
  65. package/dist/sdk/Simulator.d.ts +17 -0
  66. package/dist/sdk/Simulator.js +163 -0
  67. package/dist/sdk/StartTracking.d.ts +6 -0
  68. package/dist/sdk/StartTracking.js +69 -32
  69. package/dist/sdk/TacSdk.d.ts +26 -43
  70. package/dist/sdk/TacSdk.js +121 -816
  71. package/dist/sdk/TransactionManager.d.ts +22 -0
  72. package/dist/sdk/TransactionManager.js +272 -0
  73. package/dist/sdk/TxFinalizer.d.ts +10 -0
  74. package/dist/sdk/TxFinalizer.js +104 -0
  75. package/dist/sdk/Utils.d.ts +7 -2
  76. package/dist/sdk/Utils.js +43 -24
  77. package/dist/sdk/Validator.d.ts +9 -0
  78. package/dist/sdk/Validator.js +43 -0
  79. package/dist/sender/BatchSender.d.ts +6 -4
  80. package/dist/sender/BatchSender.js +18 -6
  81. package/dist/sender/RawSender.d.ts +10 -5
  82. package/dist/sender/RawSender.js +46 -18
  83. package/dist/sender/SenderFactory.d.ts +1 -1
  84. package/dist/sender/SenderFactory.js +5 -4
  85. package/dist/sender/TonConnectSender.d.ts +6 -4
  86. package/dist/sender/TonConnectSender.js +14 -10
  87. package/dist/sender/index.d.ts +2 -2
  88. package/dist/sender/index.js +2 -2
  89. package/dist/structs/InternalStruct.d.ts +51 -32
  90. package/dist/structs/Struct.d.ts +88 -90
  91. package/dist/structs/Struct.js +11 -1
  92. package/dist/wrappers/HighloadQueryId.js +0 -1
  93. package/dist/wrappers/HighloadWalletV3.d.ts +4 -3
  94. package/dist/wrappers/HighloadWalletV3.js +5 -2
  95. package/package.json +67 -67
  96. package/dist/sender/SenderAbstraction.d.ts +0 -20
  97. package/dist/sender/SenderAbstraction.js +0 -5
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TON = void 0;
4
+ const ton_1 = require("@ton/ton");
5
+ const errors_1 = require("../errors");
6
+ const Consts_1 = require("../sdk/Consts");
7
+ const Utils_1 = require("../sdk/Utils");
8
+ const Struct_1 = require("../structs/Struct");
9
+ class TON {
10
+ constructor(config) {
11
+ this.type = Struct_1.AssetType.FT;
12
+ this.address = '';
13
+ this._config = config;
14
+ this._rawAmount = 0n;
15
+ }
16
+ static create(config) {
17
+ return new TON(config);
18
+ }
19
+ get rawAmount() {
20
+ return this._rawAmount;
21
+ }
22
+ get clone() {
23
+ const ton = new TON(this._config);
24
+ ton._rawAmount = this._rawAmount;
25
+ return ton;
26
+ }
27
+ async withAmount(amount) {
28
+ if (this._rawAmount > 0n) {
29
+ // clone token if withAmount set before to avoid changing the original token
30
+ const newToken = this.clone;
31
+ newToken._rawAmount = 'rawAmount' in amount ? amount.rawAmount : (0, Utils_1.calculateRawAmount)(amount.amount, 9);
32
+ return newToken;
33
+ }
34
+ if ('rawAmount' in amount) {
35
+ this._rawAmount = amount.rawAmount;
36
+ }
37
+ else {
38
+ this._rawAmount = (0, Utils_1.calculateRawAmount)(amount.amount, 9);
39
+ }
40
+ return this;
41
+ }
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);
48
+ }
49
+ return this;
50
+ }
51
+ async getEVMAddress() {
52
+ return this._config.TACParams.tokenUtils.computeAddress(this._config.nativeTONAddress);
53
+ }
54
+ async getTVMAddress() {
55
+ return '';
56
+ }
57
+ async generatePayload(params) {
58
+ const { excessReceiver, evmData, feeParams } = params;
59
+ const queryId = (0, Utils_1.generateRandomNumberByTimestamp)().randomNumber;
60
+ const feeData = (0, Utils_1.generateFeeData)(feeParams);
61
+ return (0, ton_1.beginCell)()
62
+ .storeUint(this._config.artifacts.ton.wrappers.CrossChainLayerOpCodes.anyone_tvmMsgToEVM, 32)
63
+ .storeUint(queryId, 64)
64
+ .storeUint(this._config.artifacts.ton.wrappers.OperationType.tonTransfer, 32)
65
+ .storeCoins(this._rawAmount)
66
+ .storeMaybeRef(feeData)
67
+ .storeAddress(ton_1.Address.parse(excessReceiver))
68
+ .storeMaybeRef(evmData)
69
+ .endCell();
70
+ }
71
+ async getUserBalance(userAddress) {
72
+ return (await this._config.TONParams.contractOpener.getContractState(ton_1.Address.parse(userAddress))).balance;
73
+ }
74
+ static async checkBalance(sender, config, transactions) {
75
+ const totalValue = transactions.reduce((acc, transaction) => acc + transaction.messages.reduce((acc, message) => acc + message.value, 0n), 0n);
76
+ const balance = await sender.getBalance(config.TONParams.contractOpener);
77
+ if (balance < totalValue) {
78
+ throw (0, errors_1.insufficientBalanceError)(Consts_1.TON_SYMBOL);
79
+ }
80
+ }
81
+ async checkCanBeTransferredBy(userAddress) {
82
+ const balance = await this.getUserBalance(userAddress);
83
+ if (balance < this._rawAmount) {
84
+ throw (0, errors_1.insufficientBalanceError)(Consts_1.TON_SYMBOL);
85
+ }
86
+ }
87
+ async getBalanceOf(userAddress) {
88
+ return this.getUserBalance(userAddress);
89
+ }
90
+ }
91
+ exports.TON = TON;
@@ -0,0 +1,4 @@
1
+ export { AssetFactory } from './AssetFactory';
2
+ export { FT } from './FT';
3
+ export { NFT } from './NFT';
4
+ export { TON } from './TON';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TON = exports.NFT = exports.FT = exports.AssetFactory = void 0;
4
+ var AssetFactory_1 = require("./AssetFactory");
5
+ Object.defineProperty(exports, "AssetFactory", { enumerable: true, get: function () { return AssetFactory_1.AssetFactory; } });
6
+ var FT_1 = require("./FT");
7
+ Object.defineProperty(exports, "FT", { enumerable: true, get: function () { return FT_1.FT; } });
8
+ var NFT_1 = require("./NFT");
9
+ Object.defineProperty(exports, "NFT", { enumerable: true, get: function () { return NFT_1.NFT; } });
10
+ var TON_1 = require("./TON");
11
+ Object.defineProperty(exports, "TON", { enumerable: true, get: function () { return TON_1.TON; } });
@@ -39,3 +39,9 @@ export declare class PrepareMessageGroupError extends ErrorWithStatusCode {
39
39
  export declare class NoValidGroupFoundError extends ErrorWithStatusCode {
40
40
  constructor(message: string, errorCode: number);
41
41
  }
42
+ export declare class InsufficientBalanceError extends ErrorWithStatusCode {
43
+ constructor(message: string, errorCode: number);
44
+ }
45
+ export declare class TokenError extends ErrorWithStatusCode {
46
+ constructor(message: string, errorCode: number);
47
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoValidGroupFoundError = exports.PrepareMessageGroupError = exports.EVMCallError = exports.SettingError = exports.MetadataError = exports.BitError = exports.FormatError = exports.KeyError = exports.WalletError = exports.AddressError = exports.FetchError = exports.ContractError = exports.ErrorWithStatusCode = void 0;
3
+ exports.TokenError = exports.InsufficientBalanceError = exports.NoValidGroupFoundError = exports.PrepareMessageGroupError = exports.EVMCallError = exports.SettingError = exports.MetadataError = exports.BitError = exports.FormatError = exports.KeyError = exports.WalletError = exports.AddressError = exports.FetchError = exports.ContractError = exports.ErrorWithStatusCode = void 0;
4
4
  class ErrorWithStatusCode extends Error {
5
5
  constructor(message, errorCode) {
6
6
  super(message);
@@ -93,3 +93,17 @@ class NoValidGroupFoundError extends ErrorWithStatusCode {
93
93
  }
94
94
  }
95
95
  exports.NoValidGroupFoundError = NoValidGroupFoundError;
96
+ class InsufficientBalanceError extends ErrorWithStatusCode {
97
+ constructor(message, errorCode) {
98
+ super(message, errorCode);
99
+ this.name = 'InsufficientBalanceError';
100
+ }
101
+ }
102
+ exports.InsufficientBalanceError = InsufficientBalanceError;
103
+ class TokenError extends ErrorWithStatusCode {
104
+ constructor(message, errorCode) {
105
+ super(message, errorCode);
106
+ this.name = 'TokenError';
107
+ }
108
+ }
109
+ exports.TokenError = TokenError;
@@ -1,2 +1,2 @@
1
- export { emptyContractError, operationFetchError, statusFetchError, tvmAddressError, evmAddressError, unknownWalletError, unsupportedKeyError, unsupportedFormatError, notMultiplyOf8Error, prefixError, emptySettingError, invalidMethodNameError, simulationError, emptyArrayError, profilingFetchError, allEndpointsFailedError, } from './instances';
2
- export { ContractError, FetchError, AddressError, WalletError, KeyError, FormatError, BitError, MetadataError, SettingError, EVMCallError, } from './errors';
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';
@@ -1,31 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVMCallError = exports.SettingError = exports.MetadataError = exports.BitError = exports.FormatError = exports.KeyError = exports.WalletError = exports.AddressError = exports.FetchError = exports.ContractError = exports.allEndpointsFailedError = exports.profilingFetchError = exports.emptyArrayError = 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.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;
4
+ var errors_1 = require("./errors");
5
+ Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return errors_1.AddressError; } });
6
+ Object.defineProperty(exports, "BitError", { enumerable: true, get: function () { return errors_1.BitError; } });
7
+ Object.defineProperty(exports, "ContractError", { enumerable: true, get: function () { return errors_1.ContractError; } });
8
+ Object.defineProperty(exports, "EVMCallError", { enumerable: true, get: function () { return errors_1.EVMCallError; } });
9
+ Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return errors_1.FetchError; } });
10
+ Object.defineProperty(exports, "FormatError", { enumerable: true, get: function () { return errors_1.FormatError; } });
11
+ Object.defineProperty(exports, "KeyError", { enumerable: true, get: function () { return errors_1.KeyError; } });
12
+ Object.defineProperty(exports, "MetadataError", { enumerable: true, get: function () { return errors_1.MetadataError; } });
13
+ Object.defineProperty(exports, "SettingError", { enumerable: true, get: function () { return errors_1.SettingError; } });
14
+ Object.defineProperty(exports, "TokenError", { enumerable: true, get: function () { return errors_1.TokenError; } });
15
+ Object.defineProperty(exports, "WalletError", { enumerable: true, get: function () { return errors_1.WalletError; } });
4
16
  var instances_1 = require("./instances");
17
+ Object.defineProperty(exports, "allEndpointsFailedError", { enumerable: true, get: function () { return instances_1.allEndpointsFailedError; } });
18
+ Object.defineProperty(exports, "emptyArrayError", { enumerable: true, get: function () { return instances_1.emptyArrayError; } });
5
19
  Object.defineProperty(exports, "emptyContractError", { enumerable: true, get: function () { return instances_1.emptyContractError; } });
20
+ Object.defineProperty(exports, "emptySettingError", { enumerable: true, get: function () { return instances_1.emptySettingError; } });
21
+ Object.defineProperty(exports, "evmAddressError", { enumerable: true, get: function () { return instances_1.evmAddressError; } });
22
+ Object.defineProperty(exports, "indexRequiredError", { enumerable: true, get: function () { return instances_1.indexRequiredError; } });
23
+ Object.defineProperty(exports, "insufficientBalanceError", { enumerable: true, get: function () { return instances_1.insufficientBalanceError; } });
24
+ Object.defineProperty(exports, "invalidMethodNameError", { enumerable: true, get: function () { return instances_1.invalidMethodNameError; } });
25
+ Object.defineProperty(exports, "notMultiplyOf8Error", { enumerable: true, get: function () { return instances_1.notMultiplyOf8Error; } });
6
26
  Object.defineProperty(exports, "operationFetchError", { enumerable: true, get: function () { return instances_1.operationFetchError; } });
27
+ Object.defineProperty(exports, "prefixError", { enumerable: true, get: function () { return instances_1.prefixError; } });
28
+ 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; } });
7
30
  Object.defineProperty(exports, "statusFetchError", { enumerable: true, get: function () { return instances_1.statusFetchError; } });
8
31
  Object.defineProperty(exports, "tvmAddressError", { enumerable: true, get: function () { return instances_1.tvmAddressError; } });
9
- Object.defineProperty(exports, "evmAddressError", { enumerable: true, get: function () { return instances_1.evmAddressError; } });
32
+ Object.defineProperty(exports, "unknownTokenTypeError", { enumerable: true, get: function () { return instances_1.unknownTokenTypeError; } });
10
33
  Object.defineProperty(exports, "unknownWalletError", { enumerable: true, get: function () { return instances_1.unknownWalletError; } });
11
- Object.defineProperty(exports, "unsupportedKeyError", { enumerable: true, get: function () { return instances_1.unsupportedKeyError; } });
12
34
  Object.defineProperty(exports, "unsupportedFormatError", { enumerable: true, get: function () { return instances_1.unsupportedFormatError; } });
13
- Object.defineProperty(exports, "notMultiplyOf8Error", { enumerable: true, get: function () { return instances_1.notMultiplyOf8Error; } });
14
- Object.defineProperty(exports, "prefixError", { enumerable: true, get: function () { return instances_1.prefixError; } });
15
- Object.defineProperty(exports, "emptySettingError", { enumerable: true, get: function () { return instances_1.emptySettingError; } });
16
- Object.defineProperty(exports, "invalidMethodNameError", { enumerable: true, get: function () { return instances_1.invalidMethodNameError; } });
17
- Object.defineProperty(exports, "simulationError", { enumerable: true, get: function () { return instances_1.simulationError; } });
18
- Object.defineProperty(exports, "emptyArrayError", { enumerable: true, get: function () { return instances_1.emptyArrayError; } });
19
- Object.defineProperty(exports, "profilingFetchError", { enumerable: true, get: function () { return instances_1.profilingFetchError; } });
20
- Object.defineProperty(exports, "allEndpointsFailedError", { enumerable: true, get: function () { return instances_1.allEndpointsFailedError; } });
21
- var errors_1 = require("./errors");
22
- Object.defineProperty(exports, "ContractError", { enumerable: true, get: function () { return errors_1.ContractError; } });
23
- Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return errors_1.FetchError; } });
24
- Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return errors_1.AddressError; } });
25
- Object.defineProperty(exports, "WalletError", { enumerable: true, get: function () { return errors_1.WalletError; } });
26
- Object.defineProperty(exports, "KeyError", { enumerable: true, get: function () { return errors_1.KeyError; } });
27
- Object.defineProperty(exports, "FormatError", { enumerable: true, get: function () { return errors_1.FormatError; } });
28
- Object.defineProperty(exports, "BitError", { enumerable: true, get: function () { return errors_1.BitError; } });
29
- Object.defineProperty(exports, "MetadataError", { enumerable: true, get: function () { return errors_1.MetadataError; } });
30
- Object.defineProperty(exports, "SettingError", { enumerable: true, get: function () { return errors_1.SettingError; } });
31
- Object.defineProperty(exports, "EVMCallError", { enumerable: true, get: function () { return errors_1.EVMCallError; } });
35
+ Object.defineProperty(exports, "unsupportedKeyError", { enumerable: true, get: function () { return instances_1.unsupportedKeyError; } });
@@ -1,4 +1,4 @@
1
- import { ContractError, FetchError, AddressError, WalletError, KeyError, FormatError, BitError, MetadataError, SettingError, EVMCallError, NoValidGroupFoundError, PrepareMessageGroupError } from './errors';
1
+ import { AddressError, BitError, ContractError, EVMCallError, FetchError, FormatError, InsufficientBalanceError, KeyError, MetadataError, NoValidGroupFoundError, PrepareMessageGroupError, SettingError, TokenError, WalletError } from './errors';
2
2
  export declare const emptyContractError: ContractError;
3
3
  export declare const operationFetchError: (msg: string, inner?: unknown) => FetchError;
4
4
  export declare const statusFetchError: (msg: string, inner?: unknown) => FetchError;
@@ -19,3 +19,6 @@ export declare const prepareMessageGroupError: (isBocSizeValid: boolean, isDepth
19
19
  export declare const noValidGroupFoundError: NoValidGroupFoundError;
20
20
  export declare const allEndpointsFailedError: (inner: unknown) => FetchError;
21
21
  export declare const allContractOpenerFailedError: (inner: unknown) => FetchError;
22
+ export declare const insufficientBalanceError: (token: string) => InsufficientBalanceError;
23
+ export declare const unknownTokenTypeError: (token: string, reason?: string) => TokenError;
24
+ export declare const indexRequiredError: (token: string) => TokenError;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.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;
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,7 +22,10 @@ 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) => new errors_1.FetchError(`Failed to simulate EVM call: ${inner}`, 112, inner);
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);
26
29
  exports.simulationError = simulationError;
27
30
  const profilingFetchError = (msg, inner) => new errors_1.FetchError(`failed to fetch stage profiling: ${msg}`, 113, inner);
28
31
  exports.profilingFetchError = profilingFetchError;
@@ -36,3 +39,9 @@ const allEndpointsFailedError = (inner) => new errors_1.FetchError('All endpoint
36
39
  exports.allEndpointsFailedError = allEndpointsFailedError;
37
40
  const allContractOpenerFailedError = (inner) => new errors_1.FetchError('All contract opener failed', 119, inner);
38
41
  exports.allContractOpenerFailedError = allContractOpenerFailedError;
42
+ const insufficientBalanceError = (token) => new errors_1.InsufficientBalanceError(`Insufficient balance of ${token}`, 120);
43
+ exports.insufficientBalanceError = insufficientBalanceError;
44
+ const unknownTokenTypeError = (token, reason) => new errors_1.TokenError(`Unknown token type of ${token}: ${reason}`, 121);
45
+ exports.unknownTokenTypeError = unknownTokenTypeError;
46
+ const indexRequiredError = (token) => new errors_1.TokenError(`Index is required for collection ${token}`, 122);
47
+ exports.indexRequiredError = indexRequiredError;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  export { liteClientOpener, orbsOpener } from './adapters/contractOpener';
2
2
  export * from './errors';
3
+ export { Configuration } from './sdk/Configuration';
3
4
  export { LiteSequencerClient } from './sdk/LiteSequencerClient';
5
+ export { ConsoleLogger, NoopLogger } from './sdk/Logger';
4
6
  export { OperationTracker } from './sdk/OperationTracker';
7
+ export { Simulator } from './sdk/Simulator';
5
8
  export { startTracking, startTrackingMultiple } from './sdk/StartTracking';
6
9
  export { TacSdk } from './sdk/TacSdk';
10
+ export { AxiosHttpClient } from './sdk/AxiosHttpClient';
11
+ export { TransactionManager } from './sdk/TransactionManager';
7
12
  export * from './sender';
13
+ export * from './interfaces';
8
14
  export * from './structs/Struct';
9
15
  export { Network, SimplifiedStatuses } from './structs/Struct';
16
+ export * from './assets';
10
17
  export { readJettonMetadata } from './wrappers/ContentUtils';
11
18
  export { HighloadWalletV3 } from './wrappers/HighloadWalletV3';
12
19
  export type { JettonWalletData } from './wrappers/JettonWallet';
package/dist/index.js CHANGED
@@ -14,25 +14,38 @@ 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.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.OperationTracker = exports.LiteSequencerClient = exports.orbsOpener = exports.liteClientOpener = void 0;
17
+ exports.JettonWalletOpCodes = exports.JettonWallet = exports.HighloadWalletV3 = exports.readJettonMetadata = exports.SimplifiedStatuses = exports.Network = exports.TransactionManager = exports.AxiosHttpClient = exports.TacSdk = exports.startTrackingMultiple = exports.startTracking = exports.Simulator = exports.OperationTracker = exports.NoopLogger = exports.ConsoleLogger = exports.LiteSequencerClient = exports.Configuration = 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; } });
21
21
  __exportStar(require("./errors"), exports);
22
+ var Configuration_1 = require("./sdk/Configuration");
23
+ Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return Configuration_1.Configuration; } });
22
24
  var LiteSequencerClient_1 = require("./sdk/LiteSequencerClient");
23
25
  Object.defineProperty(exports, "LiteSequencerClient", { enumerable: true, get: function () { return LiteSequencerClient_1.LiteSequencerClient; } });
26
+ var Logger_1 = require("./sdk/Logger");
27
+ Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return Logger_1.ConsoleLogger; } });
28
+ Object.defineProperty(exports, "NoopLogger", { enumerable: true, get: function () { return Logger_1.NoopLogger; } });
24
29
  var OperationTracker_1 = require("./sdk/OperationTracker");
25
30
  Object.defineProperty(exports, "OperationTracker", { enumerable: true, get: function () { return OperationTracker_1.OperationTracker; } });
31
+ var Simulator_1 = require("./sdk/Simulator");
32
+ Object.defineProperty(exports, "Simulator", { enumerable: true, get: function () { return Simulator_1.Simulator; } });
26
33
  var StartTracking_1 = require("./sdk/StartTracking");
27
34
  Object.defineProperty(exports, "startTracking", { enumerable: true, get: function () { return StartTracking_1.startTracking; } });
28
35
  Object.defineProperty(exports, "startTrackingMultiple", { enumerable: true, get: function () { return StartTracking_1.startTrackingMultiple; } });
29
36
  var TacSdk_1 = require("./sdk/TacSdk");
30
37
  Object.defineProperty(exports, "TacSdk", { enumerable: true, get: function () { return TacSdk_1.TacSdk; } });
38
+ var AxiosHttpClient_1 = require("./sdk/AxiosHttpClient");
39
+ Object.defineProperty(exports, "AxiosHttpClient", { enumerable: true, get: function () { return AxiosHttpClient_1.AxiosHttpClient; } });
40
+ var TransactionManager_1 = require("./sdk/TransactionManager");
41
+ Object.defineProperty(exports, "TransactionManager", { enumerable: true, get: function () { return TransactionManager_1.TransactionManager; } });
31
42
  __exportStar(require("./sender"), exports);
43
+ __exportStar(require("./interfaces"), exports);
32
44
  __exportStar(require("./structs/Struct"), exports);
33
45
  var Struct_1 = require("./structs/Struct");
34
46
  Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return Struct_1.Network; } });
35
47
  Object.defineProperty(exports, "SimplifiedStatuses", { enumerable: true, get: function () { return Struct_1.SimplifiedStatuses; } });
48
+ __exportStar(require("./assets"), exports);
36
49
  var ContentUtils_1 = require("./wrappers/ContentUtils");
37
50
  Object.defineProperty(exports, "readJettonMetadata", { enumerable: true, get: function () { return ContentUtils_1.readJettonMetadata; } });
38
51
  var HighloadWalletV3_1 = require("./wrappers/HighloadWalletV3");
@@ -0,0 +1,73 @@
1
+ import type { Cell } from '@ton/ton';
2
+ import { AssetType, FeeParams } from '../structs/Struct';
3
+ export interface Asset {
4
+ address: string;
5
+ type: AssetType;
6
+ rawAmount: bigint;
7
+ clone: Asset;
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.
11
+ * 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 IAsset reflecting the requested amount.
14
+ */
15
+ withAmount(amount: {
16
+ rawAmount: bigint;
17
+ } | {
18
+ amount: number;
19
+ }): Promise<Asset>;
20
+ /**
21
+ * Increases the transfer amount by the specified value and returns a new asset instance.
22
+ * 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 IAsset with the increased amount.
25
+ */
26
+ addAmount(amount: {
27
+ rawAmount: bigint;
28
+ } | {
29
+ amount: number;
30
+ }): Promise<Asset>;
31
+ /**
32
+ * Resolves the corresponding EVM token address for this asset.
33
+ * Useful when bridging or interacting with EVM-compatible networks.
34
+ * @returns Promise that resolves to the EVM address as a checksum string.
35
+ */
36
+ getEVMAddress(): Promise<string>;
37
+ /**
38
+ * Returns the TVM (TON Virtual Machine) address for this asset.
39
+ * @returns Promise that resolves to the TVM address as a friendly or raw string depending on implementation.
40
+ */
41
+ getTVMAddress(): Promise<string>;
42
+ /**
43
+ * Generates a TVM payload for transferring or interacting with this asset across chains.
44
+ * Implementations may include cross-chain metadata, fees, and forwarding info.
45
+ * @param params Parameters that describe the payload composition.
46
+ * @param params.excessReceiver Address that will receive the excess TON after execution.
47
+ * @param params.evmData Serialized EVM-side call data to be forwarded via the bridge.
48
+ * @param params.crossChainTonAmount Optional TON amount to transfer cross-chain with the message.
49
+ * @param params.forwardFeeTonAmount Optional TON amount used to cover forwarding fees on TON.
50
+ * @param params.feeParams Optional fee parameters to fine-tune execution costs.
51
+ * @returns Promise that resolves to a Cell containing the encoded payload.
52
+ */
53
+ generatePayload(params: {
54
+ excessReceiver: string;
55
+ evmData: Cell;
56
+ crossChainTonAmount?: bigint;
57
+ forwardFeeTonAmount?: bigint;
58
+ feeParams?: FeeParams;
59
+ }): Promise<Cell>;
60
+ /**
61
+ * Validates whether the specified user is allowed to transfer this asset.
62
+ * Implementations should throw if the transfer is not permitted (e.g., frozen asset, missing wallet, insufficient permissions).
63
+ * @param userAddress TVM address of the user attempting to transfer the asset.
64
+ * @returns Promise that resolves if transfer is allowed; rejects with an error otherwise.
65
+ */
66
+ checkCanBeTransferredBy(userAddress: string): Promise<void>;
67
+ /**
68
+ * Retrieves the current balance of this asset for the given user address.
69
+ * @param userAddress TVM address of the user.
70
+ * @returns Promise that resolves to the balance in raw base units (bigint).
71
+ */
72
+ getBalanceOf(userAddress: string): Promise<bigint>;
73
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import type { Address, Contract, OpenedContract } from '@ton/ton';
2
+ import { SandboxContract } from '@ton/sandbox';
3
+ import { ContractState } from '../structs/Struct';
4
+ export interface ContractOpener {
5
+ /**
6
+ * Opens a contract for interaction using the underlying client (lite client, sandbox, etc.).
7
+ * @param src Contract source instance to open.
8
+ * @returns Opened contract ready for method calls and sending messages.
9
+ */
10
+ open<T extends Contract>(src: T): OpenedContract<T> | SandboxContract<T>;
11
+ /**
12
+ * Fetches on-chain contract state for a given address.
13
+ * @param address TVM address of the contract.
14
+ * @returns Promise with the contract state (code/data/existence).
15
+ */
16
+ getContractState(address: Address): Promise<ContractState>;
17
+ /**
18
+ * Closes any underlying connections if supported by the implementation.
19
+ */
20
+ closeConnections?: () => unknown;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ import { mainnet, testnet } from '@tonappchain/artifacts';
2
+ import { InternalTACParams, InternalTONParams } from '../structs/InternalStruct';
3
+ import { Network } from '../structs/Struct';
4
+ export interface IConfiguration {
5
+ /** Current network the SDK is configured for (e.g., MAINNET/TESTNET). */
6
+ readonly network: Network;
7
+ /** Resolved artifacts bundle for the selected network (contract ABIs/addresses). */
8
+ readonly artifacts: typeof testnet | typeof mainnet;
9
+ /** Low-level TON client parameters and dependencies. */
10
+ readonly TONParams: InternalTONParams;
11
+ /** Low-level TAC (EVM-side) client parameters and dependencies. */
12
+ readonly TACParams: InternalTACParams;
13
+ /** List of Lite Sequencer API endpoints used for tracking and utilities. */
14
+ readonly liteSequencerEndpoints: string[];
15
+ /** Native TON coin master address for the configured network. */
16
+ readonly nativeTONAddress: string;
17
+ /**
18
+ * Returns the native TAC token (Jetton master) address for the configured network.
19
+ */
20
+ nativeTACAddress(): Promise<string>;
21
+ /** Whitelisted EVM (TAC) executor addresses considered trusted. */
22
+ readonly getTrustedTACExecutors: string[];
23
+ /** Whitelisted TVM (TON) executor addresses considered trusted. */
24
+ readonly getTrustedTONExecutors: string[];
25
+ /**
26
+ * Closes any underlying connections/resources held by configuration-level clients.
27
+ * Implementations should be idempotent.
28
+ */
29
+ closeConnections(): unknown;
30
+ /**
31
+ * Checks if a given TVM address is a deployed contract on the current network.
32
+ * @param address TVM address to verify.
33
+ */
34
+ isContractDeployedOnTVM(address: string): Promise<boolean>;
35
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ export interface IHttpClient {
3
+ /**
4
+ * Sends an HTTP GET request and returns a typed Axios response.
5
+ * @param url Target URL.
6
+ * @param config Optional Axios request configuration.
7
+ */
8
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
9
+ /**
10
+ * Sends an HTTP POST request and returns a typed Axios response.
11
+ * @param url Target URL.
12
+ * @param data Request body payload.
13
+ * @param config Optional Axios request configuration.
14
+ */
15
+ post<T>(url: string, data: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,30 @@
1
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, StatusInfosByOperationId, TransactionLinker } from '../structs/Struct';
2
+ export interface ILiteSequencerClient {
3
+ /** Retrieves the operation type by id. */
4
+ getOperationType(operationId: string): Promise<OperationType>;
5
+ /** Resolves operation id by a transaction linker. */
6
+ getOperationId(transactionLinker: TransactionLinker): Promise<string>;
7
+ /** Resolves operation id by the originating transaction hash. */
8
+ getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
9
+ /**
10
+ * Resolves operation ids for multiple shard keys.
11
+ * @param shardsKeys Shard keys to query.
12
+ * @param caller Human-readable identifier of the caller (for rate limiting/observability).
13
+ * @param chunkSize Optional chunk size for batching requests.
14
+ */
15
+ getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, chunkSize?: number): Promise<OperationIdsByShardsKey>;
16
+ /**
17
+ * Fetches stage profiling data for a set of operation ids.
18
+ * @param operationIds Operation ids to get profiling for.
19
+ * @param chunkSize Optional batching size.
20
+ */
21
+ getStageProfilings(operationIds: string[], chunkSize?: number): Promise<ExecutionStagesByOperationId>;
22
+ /**
23
+ * Fetches statuses for a set of operation ids.
24
+ * @param operationIds Operation ids to get statuses for.
25
+ * @param chunkSize Optional batching size.
26
+ */
27
+ getOperationStatuses(operationIds: string[], chunkSize?: number): Promise<StatusInfosByOperationId>;
28
+ /** Converts currency amount using the sequencer-provided rate source. */
29
+ convertCurrency(params: ConvertCurrencyParams): Promise<ConvertedCurrencyResult>;
30
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { ILiteSequencerClient } from './ILiteSequencerClient';
2
+ export interface ILiteSequencerClientFactory {
3
+ /**
4
+ * Creates Lite Sequencer clients for the provided HTTP endpoints.
5
+ * @param endpoints List of base URLs.
6
+ * @returns Array of ILiteSequencerClient instances, one per endpoint.
7
+ */
8
+ createClients(endpoints: string[]): ILiteSequencerClient[];
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export interface ILogger {
2
+ /** Logs verbose diagnostic information useful during development. */
3
+ debug(...arg: unknown[]): void;
4
+ /** Logs general informational messages about normal operation. */
5
+ info(...arg: unknown[]): void;
6
+ /** Logs warnings about unexpected but non-fatal conditions. */
7
+ warn(...arg: unknown[]): void;
8
+ /** Logs errors for failures and exceptional conditions. */
9
+ error(...arg: unknown[]): void;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,66 @@
1
+ import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, OperationIdsByShardsKey, OperationType, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, TransactionLinker, WaitOptions } from '../structs/Struct';
2
+ export interface IOperationTracker {
3
+ /**
4
+ * Returns the operation type for the given id, optionally waiting according to the provided policy.
5
+ * @param operationId Operation identifier.
6
+ * @param waitOptions Optional waiting and polling settings.
7
+ */
8
+ getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType>): Promise<OperationType>;
9
+ /**
10
+ * Resolves an operation id for the given transaction linker, optionally waiting until available.
11
+ * @param transactionLinker Reference to originating transaction across chains.
12
+ * @param waitOptions Optional waiting settings.
13
+ */
14
+ getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string>): Promise<string>;
15
+ /**
16
+ * Resolves an operation id by a transaction hash, optionally waiting until available.
17
+ * @param transactionHash Hash of the originating transaction.
18
+ * @param waitOptions Optional waiting settings.
19
+ */
20
+ getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string>): Promise<string>;
21
+ /**
22
+ * Resolves operation ids by shard keys for a particular caller, with optional batching and waiting.
23
+ * @param shardsKeys List of shard keys.
24
+ * @param caller Human-readable identifier of the caller (for tracing/limits).
25
+ * @param waitOptions Optional waiting settings.
26
+ * @param chunkSize Optional batching size for network requests.
27
+ */
28
+ getOperationIdsByShardsKeys(shardsKeys: string[], caller: string, waitOptions?: WaitOptions<OperationIdsByShardsKey>, chunkSize?: number): Promise<OperationIdsByShardsKey>;
29
+ /**
30
+ * Gets detailed stage profiling for a single operation, optionally waiting until available.
31
+ * @param operationId Operation identifier.
32
+ * @param waitOptions Optional waiting settings.
33
+ */
34
+ getStageProfiling(operationId: string, waitOptions?: WaitOptions<ExecutionStages>): Promise<ExecutionStages>;
35
+ /**
36
+ * Gets stage profiling for multiple operations in bulk.
37
+ * @param operationIds Operation identifiers.
38
+ * @param waitOptions Optional waiting settings.
39
+ * @param chunkSize Optional batching size for requests.
40
+ */
41
+ getStageProfilings(operationIds: string[], waitOptions?: WaitOptions<ExecutionStagesByOperationId>, chunkSize?: number): Promise<ExecutionStagesByOperationId>;
42
+ /**
43
+ * Gets statuses for multiple operations.
44
+ * @param operationIds Operation identifiers.
45
+ * @param waitOptions Optional waiting settings.
46
+ * @param chunkSize Optional batching size for requests.
47
+ */
48
+ getOperationStatuses(operationIds: string[], waitOptions?: WaitOptions<StatusInfosByOperationId>, chunkSize?: number): Promise<StatusInfosByOperationId>;
49
+ /**
50
+ * Gets a single operation status, optionally waiting according to policy.
51
+ * @param operationId Operation identifier.
52
+ * @param waitOptions Optional waiting settings.
53
+ */
54
+ getOperationStatus(operationId: string, waitOptions?: WaitOptions<StatusInfo>): Promise<StatusInfo>;
55
+ /**
56
+ * Returns a simplified status for the provided transaction linker.
57
+ * @param transactionLinker Reference to originating transaction across chains.
58
+ */
59
+ getSimplifiedOperationStatus(transactionLinker: TransactionLinker): Promise<SimplifiedStatuses>;
60
+ /**
61
+ * Converts currency using the tracker service, optionally waiting for completion.
62
+ * @param params Conversion parameters.
63
+ * @param waitOptions Optional waiting settings.
64
+ */
65
+ convertCurrency(params: ConvertCurrencyParams, waitOptions?: WaitOptions<ConvertedCurrencyResult>): Promise<ConvertedCurrencyResult>;
66
+ }