@tonappchain/sdk 0.8.1-rc1 → 0.9.0-rc1

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 (33) hide show
  1. package/README.md +2 -0
  2. package/dist/artifacts/dev/tac/utils.d.ts +3 -1
  3. package/dist/artifacts/dev/tac/utils.js +11 -3
  4. package/dist/artifacts/mainnet/tac/utils.d.ts +3 -1
  5. package/dist/artifacts/mainnet/tac/utils.js +11 -3
  6. package/dist/artifacts/testnet/tac/utils.d.ts +3 -1
  7. package/dist/artifacts/testnet/tac/utils.js +11 -3
  8. package/dist/esm/artifacts/index.d.mts +1 -0
  9. package/dist/esm/artifacts/index.mjs +10 -0
  10. package/dist/esm/artifacts/tacTypes.d.mts +1 -0
  11. package/dist/esm/artifacts/tacTypes.mjs +0 -0
  12. package/dist/esm/artifacts/tonTypes.d.mts +1 -0
  13. package/dist/esm/artifacts/tonTypes.mjs +0 -0
  14. package/dist/esm/chunk-6AEFUAMZ.mjs +13895 -0
  15. package/dist/esm/src/index.d.mts +1 -0
  16. package/dist/esm/src/index.mjs +7720 -0
  17. package/dist/src/agnosticSdk/DebugHelpers.js +5 -5
  18. package/dist/src/agnosticSdk/HooksHandler.js +6 -6
  19. package/dist/src/agnosticSdk/ReplacementHelper.js +2 -2
  20. package/dist/src/assets/FT.js +3 -3
  21. package/dist/src/assets/NFT.js +2 -2
  22. package/dist/src/assets/TON.js +1 -1
  23. package/dist/src/sdk/Configuration.js +11 -11
  24. package/dist/src/sdk/TACTransactionManager.js +4 -4
  25. package/dist/src/sdk/Utils.js +4 -4
  26. package/dist/src/structs/InternalStruct.d.ts +3 -3
  27. package/package.json +51 -21
  28. package/dist/artifacts/dev/tac/internal/scripts/utils/encoding.d.ts +0 -4
  29. package/dist/artifacts/dev/tac/internal/scripts/utils/encoding.js +0 -18
  30. package/dist/artifacts/mainnet/tac/internal/scripts/utils/encoding.d.ts +0 -4
  31. package/dist/artifacts/mainnet/tac/internal/scripts/utils/encoding.js +0 -18
  32. package/dist/artifacts/testnet/tac/internal/scripts/utils/encoding.d.ts +0 -4
  33. package/dist/artifacts/testnet/tac/internal/scripts/utils/encoding.js +0 -18
@@ -30,11 +30,11 @@ class DebugHelpers {
30
30
  try {
31
31
  switch (hook.hookType) {
32
32
  case AgnosticStructs_1.HookType.Custom:
33
- return ethers_1.ethers.AbiCoder.defaultAbiCoder().decode(['tuple(bool,address,uint256,bytes,bytes)'], hook.hookData)[0];
33
+ return ethers_1.AbiCoder.defaultAbiCoder().decode(['tuple(bool,address,uint256,bytes,bytes)'], hook.hookData)[0];
34
34
  case AgnosticStructs_1.HookType.FullBalanceApprove:
35
- return ethers_1.ethers.AbiCoder.defaultAbiCoder().decode(['tuple(address,address,bool)'], hook.hookData)[0];
35
+ return ethers_1.AbiCoder.defaultAbiCoder().decode(['tuple(address,address,bool)'], hook.hookData)[0];
36
36
  case AgnosticStructs_1.HookType.FullBalanceTransfer:
37
- return ethers_1.ethers.AbiCoder.defaultAbiCoder().decode(['tuple(address,address,bool)'], hook.hookData)[0];
37
+ return ethers_1.AbiCoder.defaultAbiCoder().decode(['tuple(address,address,bool)'], hook.hookData)[0];
38
38
  default:
39
39
  throw new Error(`Unknown hook type: ${hook.hookType}`);
40
40
  }
@@ -168,7 +168,7 @@ class DebugHelpers {
168
168
  hasReplacements = true;
169
169
  }
170
170
  const perspective = isFromSA ? 'Smart Account' : 'Proxy Contract';
171
- const valueStr = value > 0n ? ` (sending ${ethers_1.ethers.formatEther(value)} ETH)` : '';
171
+ const valueStr = value > 0n ? ` (sending ${(0, ethers_1.formatEther)(value)} ETH)` : '';
172
172
  const replacementStr = hasReplacements ? ' 🔄 [with dynamic value replacement]' : '';
173
173
  return `📞 Custom call to ${this._formatAddress(contractAddress)} from ${perspective}${valueStr}
174
174
  Function: ${functionDescription}${replacementStr}`;
@@ -254,7 +254,7 @@ class DebugHelpers {
254
254
  * @returns The encoded zap call that can be used as calldata in tac sdk
255
255
  */
256
256
  encodeZapCall(zapCall) {
257
- return ethers_1.ethers.AbiCoder.defaultAbiCoder().encode([
257
+ return ethers_1.AbiCoder.defaultAbiCoder().encode([
258
258
  'tuple(' +
259
259
  'tuple(uint8,bytes)[],' + // hooks: only hookType and hookData
260
260
  'tuple(address[],tuple(address,uint256,uint256)[],bool)' + // bridgeData
@@ -24,19 +24,19 @@ class HooksHandler {
24
24
  if (dynamicReplacements && dynamicReplacements.length > 0) {
25
25
  // For now, support single replacement (can be extended)
26
26
  const replacement = dynamicReplacements[0];
27
- const replacementData = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['tuple(uint16,uint16,address,address)'], [[replacement.position, replacement.len, replacement.token, replacement.balanceAddress]]);
27
+ const replacementData = ethers_1.AbiCoder.defaultAbiCoder().encode(['tuple(uint16,uint16,address,address)'], [[replacement.position, replacement.len, replacement.token, replacement.balanceAddress]]);
28
28
  // Encode as ReplacementType.Amount with the replacement data
29
- improvedMissionInfo = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['uint8', 'bytes'], [AgnosticStructs_1.ReplacementType.Amount, replacementData]);
29
+ improvedMissionInfo = ethers_1.AbiCoder.defaultAbiCoder().encode(['uint8', 'bytes'], [AgnosticStructs_1.ReplacementType.Amount, replacementData]);
30
30
  }
31
31
  const customHookData = {
32
32
  isFromSAPerspective,
33
- contractAddress: ethers_1.ethers.getAddress(contractAddress.toLowerCase()), // Normalize address to checksum format
33
+ contractAddress: (0, ethers_1.getAddress)(contractAddress.toLowerCase()), // Normalize address to checksum format
34
34
  value,
35
35
  data,
36
36
  improvedMissionInfo,
37
37
  };
38
38
  // Encode only the CustomHookData
39
- const encodedHookData = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['tuple(bool,address,uint256,bytes,bytes)'], [
39
+ const encodedHookData = ethers_1.AbiCoder.defaultAbiCoder().encode(['tuple(bool,address,uint256,bytes,bytes)'], [
40
40
  [
41
41
  customHookData.isFromSAPerspective,
42
42
  customHookData.contractAddress,
@@ -64,7 +64,7 @@ class HooksHandler {
64
64
  isFromSAPerspective,
65
65
  };
66
66
  // Encode only the ApproveHookData
67
- const encodedHookData = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['tuple(address,address,bool)'], [[approveHookData.token, approveHookData.to, approveHookData.isFromSAPerspective]]);
67
+ const encodedHookData = ethers_1.AbiCoder.defaultAbiCoder().encode(['tuple(address,address,bool)'], [[approveHookData.token, approveHookData.to, approveHookData.isFromSAPerspective]]);
68
68
  return {
69
69
  hookType: AgnosticStructs_1.HookType.FullBalanceApprove,
70
70
  hookData: encodedHookData,
@@ -84,7 +84,7 @@ class HooksHandler {
84
84
  isFromSAPerspective,
85
85
  };
86
86
  // Encode only the TransferHookData
87
- const encodedHookData = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(['tuple(address,address,bool)'], [[transferHookData.token, transferHookData.to, transferHookData.isFromSAPerspective]]);
87
+ const encodedHookData = ethers_1.AbiCoder.defaultAbiCoder().encode(['tuple(address,address,bool)'], [[transferHookData.token, transferHookData.to, transferHookData.isFromSAPerspective]]);
88
88
  return {
89
89
  hookType: AgnosticStructs_1.HookType.FullBalanceTransfer,
90
90
  hookData: encodedHookData,
@@ -156,11 +156,11 @@ class ReplacementHelper {
156
156
  validation.warnings.push(`⚠️ Parameter '${param.name}' might not be intended for amount replacement`);
157
157
  }
158
158
  // Check token address
159
- if (!ethers_1.ethers.isAddress(token)) {
159
+ if (!(0, ethers_1.isAddress)(token)) {
160
160
  validation.isValid = false;
161
161
  validation.warnings.push(`Invalid token address: ${token}`);
162
162
  }
163
- if (!ethers_1.ethers.isAddress(balanceAddress)) {
163
+ if (!(0, ethers_1.isAddress)(balanceAddress)) {
164
164
  validation.isValid = false;
165
165
  validation.warnings.push(`Invalid balance address: ${balanceAddress}`);
166
166
  }
@@ -58,7 +58,7 @@ class FT {
58
58
  const fromTVM = await configuration.TACParams.tokenUtils['exists(address)'](address);
59
59
  if (fromTVM) {
60
60
  const cclErc20Abi = configuration.artifacts.tac.compilationArtifacts.ICrossChainLayerERC20.abi;
61
- const erc20Token = new ethers_1.ethers.Contract(address, cclErc20Abi, configuration.TACParams.provider);
61
+ const erc20Token = new ethers_1.Contract(address, cclErc20Abi, configuration.TACParams.provider);
62
62
  const info = await erc20Token.getInfo();
63
63
  return info.tvmAddress;
64
64
  }
@@ -118,7 +118,7 @@ class FT {
118
118
  }
119
119
  // For ERC20 contracts, get decimals from contract
120
120
  const erc20TokenAbi = configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi;
121
- const erc20Token = new ethers_1.ethers.Contract(evmAddress, erc20TokenAbi, configuration.TACParams.provider);
121
+ const erc20Token = new ethers_1.Contract(evmAddress, erc20TokenAbi, configuration.TACParams.provider);
122
122
  return Number(await erc20Token.decimals());
123
123
  }
124
124
  static async fromAddress(configuration, address) {
@@ -322,7 +322,7 @@ class FT {
322
322
  if (evmAddress === nativeTACAddress) {
323
323
  return this._configuration.TACParams.provider.getBalance(userAddress);
324
324
  }
325
- const erc20Token = new ethers_1.ethers.Contract(evmAddress, this._configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this._configuration.TACParams.provider);
325
+ const erc20Token = new ethers_1.Contract(evmAddress, this._configuration.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this._configuration.TACParams.provider);
326
326
  return erc20Token.balanceOf(userAddress);
327
327
  }
328
328
  getTransferPayload(rawAmount, notificationReceiverAddress, responseAddress, evmData, crossChainTonAmount, forwardFeeAmount, feeData) {
@@ -100,7 +100,7 @@ class NFT {
100
100
  const exists = await configuration.TACParams.tokenUtils['exists(address)'](collectionAddress);
101
101
  if (exists) {
102
102
  const cclErc721TokenAbi = configuration.artifacts.tac.compilationArtifacts.ICrossChainLayerERC721.abi;
103
- const cclErc721Token = new ethers_1.ethers.Contract(collectionAddress, cclErc721TokenAbi, configuration.TACParams.provider);
103
+ const cclErc721Token = new ethers_1.Contract(collectionAddress, cclErc721TokenAbi, configuration.TACParams.provider);
104
104
  const info = await cclErc721Token.getInfo();
105
105
  const NFTCollectionC = configuration.artifacts.ton.wrappers.NFTCollection;
106
106
  const nftCollection = configuration.TONParams.contractOpener.open(NFTCollectionC.createFromAddress((0, ton_1.address)(info.tvmAddress)));
@@ -222,7 +222,7 @@ class NFT {
222
222
  return (await this.isOwnedBy(userAddress)) ? 1n : 0n;
223
223
  }
224
224
  Validator_1.Validator.validateEVMAddress(userAddress);
225
- const nft = new ethers_1.ethers.Contract(await this.getEVMAddress(), this._configuration.artifacts.tac.compilationArtifacts.IERC721.abi, this._configuration.TACParams.provider);
225
+ const nft = new ethers_1.Contract(await this.getEVMAddress(), this._configuration.artifacts.tac.compilationArtifacts.IERC721.abi, this._configuration.TACParams.provider);
226
226
  return (await nft.ownerOf(this._addresses.index)).toLowerCase() === userAddress.toLowerCase() ? 1n : 0n;
227
227
  }
228
228
  getBurnPayload(crossChainLayerAddress, evmData, crossChainTonAmount, feeData) {
@@ -99,7 +99,7 @@ class TON {
99
99
  return this.getUserBalance(userAddress);
100
100
  }
101
101
  Validator_1.Validator.validateEVMAddress(userAddress);
102
- const token = new ethers_1.ethers.Contract(await this.getEVMAddress(), this._config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this._config.TACParams.provider);
102
+ const token = new ethers_1.Contract(await this.getEVMAddress(), this._config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this._config.TACParams.provider);
103
103
  return token.balanceOf(userAddress);
104
104
  }
105
105
  }
@@ -117,13 +117,13 @@ class Configuration {
117
117
  saFactoryAddress = TACParams.saFactoryAddress;
118
118
  }
119
119
  else {
120
- provider = TACParams?.provider ?? ethers_1.ethers.getDefaultProvider(artifacts.TAC_RPC_ENDPOINT);
120
+ provider = TACParams?.provider ?? (0, ethers_1.getDefaultProvider)(artifacts.TAC_RPC_ENDPOINT);
121
121
  settingsAddress = TACParams?.settingsAddress ?? artifacts.TAC_SETTINGS_ADDRESS;
122
122
  saFactoryAddress = TACParams?.saFactoryAddress ?? artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS;
123
123
  }
124
124
  Validator_1.Validator.validateEVMAddress(settingsAddress);
125
125
  const settingsAbi = artifacts.tac.compilationArtifacts.ISettings.abi;
126
- const settings = new ethers_1.ethers.Contract(settingsAddress, settingsAbi, provider);
126
+ const settings = new ethers_1.Contract(settingsAddress, settingsAbi, provider);
127
127
  const loaded = await this.loadTACSettingsViaMulticall(network, provider, settingsAddress);
128
128
  let crossChainLayerAddress;
129
129
  let tokenUtilsAddress;
@@ -142,11 +142,11 @@ class Configuration {
142
142
  trustedTONExecutors = await settings.getTrustedTVMExecutors();
143
143
  }
144
144
  const crossChainLayerAbi = artifacts.tac.compilationArtifacts.ICrossChainLayer.abi;
145
- const crossChainLayer = new ethers_1.ethers.Contract(crossChainLayerAddress, crossChainLayerAbi, provider);
145
+ const crossChainLayer = new ethers_1.Contract(crossChainLayerAddress, crossChainLayerAbi, provider);
146
146
  const tokenUtilsAbi = artifacts.tac.compilationArtifacts.ITokenUtils.abi;
147
- const tokenUtils = new ethers_1.ethers.Contract(tokenUtilsAddress, tokenUtilsAbi, provider);
147
+ const tokenUtils = new ethers_1.Contract(tokenUtilsAddress, tokenUtilsAbi, provider);
148
148
  const TacSAFactoryAbi = artifacts.tac.compilationArtifacts.ISAFactory.abi;
149
- const smartAccountFactory = new ethers_1.ethers.Contract(saFactoryAddress, TacSAFactoryAbi, provider);
149
+ const smartAccountFactory = new ethers_1.Contract(saFactoryAddress, TacSAFactoryAbi, provider);
150
150
  return {
151
151
  provider,
152
152
  settings,
@@ -155,7 +155,7 @@ class Configuration {
155
155
  crossChainLayer,
156
156
  trustedTACExecutors,
157
157
  trustedTONExecutors,
158
- abiCoder: new ethers_1.ethers.AbiCoder(),
158
+ abiCoder: new ethers_1.AbiCoder(),
159
159
  };
160
160
  }
161
161
  static async loadTACSettingsViaMulticall(network, provider, settingsAddress) {
@@ -168,11 +168,11 @@ class Configuration {
168
168
  const multicallAbi = artifacts.tac.multicall.MULTICALL_ABI_ETHERS;
169
169
  try {
170
170
  Validator_1.Validator.validateEVMAddress(multicallAddress);
171
- const multicall = new ethers_1.ethers.Contract(multicallAddress, multicallAbi, provider);
172
- const abiCoder = new ethers_1.ethers.AbiCoder();
173
- const selectorGetAddressSetting = ethers_1.ethers.id('getAddressSetting(bytes32)').slice(0, 10);
174
- const selectorGetTrustedEVMExecutors = ethers_1.ethers.id('getTrustedEVMExecutors()').slice(0, 10);
175
- const selectorGetTrustedTVMExecutors = ethers_1.ethers.id('getTrustedTVMExecutors()').slice(0, 10);
171
+ const multicall = new ethers_1.Contract(multicallAddress, multicallAbi, provider);
172
+ const abiCoder = new ethers_1.AbiCoder();
173
+ const selectorGetAddressSetting = (0, ethers_1.id)('getAddressSetting(bytes32)').slice(0, 10);
174
+ const selectorGetTrustedEVMExecutors = (0, ethers_1.id)('getTrustedEVMExecutors()').slice(0, 10);
175
+ const selectorGetTrustedTVMExecutors = (0, ethers_1.id)('getTrustedTVMExecutors()').slice(0, 10);
176
176
  const crossChainLayerKey = (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('CrossChainLayerAddress'));
177
177
  const tokenUtilsKey = (0, ethers_1.keccak256)((0, ethers_1.toUtf8Bytes)('TokenUtilsAddress'));
178
178
  const encodeGetAddressSetting = (key) => selectorGetAddressSetting + abiCoder.encode(['bytes32'], [key]).slice(2);
@@ -74,7 +74,7 @@ class TACTransactionManager {
74
74
  const hasTransactionParams = Object.keys(transactionParams).length > 0;
75
75
  if (asset.type === Struct_1.AssetType.FT) {
76
76
  this.logger.debug(`Approving FT ${evmAddress} for ${spenderAddress}`);
77
- const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
77
+ const contract = new ethers_1.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
78
78
  const tx = hasTransactionParams
79
79
  ? await contract.connect(signer).approve(spenderAddress, asset.rawAmount, transactionParams)
80
80
  : await contract.connect(signer).approve(spenderAddress, asset.rawAmount);
@@ -82,7 +82,7 @@ class TACTransactionManager {
82
82
  }
83
83
  else {
84
84
  this.logger.debug(`Approving NFT ${evmAddress} for ${spenderAddress}`);
85
- const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
85
+ const contract = new ethers_1.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
86
86
  const tx = hasTransactionParams
87
87
  ? await contract
88
88
  .connect(signer)
@@ -95,10 +95,10 @@ class TACTransactionManager {
95
95
  async estimateApprovalGas(asset, signer, spenderAddress, transactionParams = {}) {
96
96
  const evmAddress = await asset.getEVMAddress();
97
97
  if (asset.type === Struct_1.AssetType.FT) {
98
- const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
98
+ const contract = new ethers_1.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC20WithDecimals.abi, this.config.TACParams.provider);
99
99
  return contract.connect(signer).approve.estimateGas(spenderAddress, asset.rawAmount, transactionParams);
100
100
  }
101
- const contract = new ethers_1.ethers.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
101
+ const contract = new ethers_1.Contract(evmAddress, this.config.artifacts.tac.compilationArtifacts.IERC721.abi, this.config.TACParams.provider);
102
102
  return contract
103
103
  .connect(signer)
104
104
  .approve.estimateGas(spenderAddress, asset.addresses.index, transactionParams);
@@ -88,10 +88,10 @@ function generateTransactionLinker(caller, shardCount) {
88
88
  };
89
89
  }
90
90
  function calculateEVMTokenAddress(abiCoder, tokenUtilsAddress, crossChainLayerTokenBytecode, crossChainLayerAddress, tvmAddress) {
91
- const salt = ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['string'], [tvmAddress]));
92
- const initCode = ethers_1.ethers.solidityPacked(['bytes', 'bytes'], [crossChainLayerTokenBytecode, abiCoder.encode(['address'], [crossChainLayerAddress])]);
93
- const initCodeHash = ethers_1.ethers.keccak256(initCode);
94
- return ethers_1.ethers.getCreate2Address(tokenUtilsAddress, salt, initCodeHash);
91
+ const salt = (0, ethers_1.keccak256)((0, ethers_1.solidityPacked)(['string'], [tvmAddress]));
92
+ const initCode = (0, ethers_1.solidityPacked)(['bytes', 'bytes'], [crossChainLayerTokenBytecode, abiCoder.encode(['address'], [crossChainLayerAddress])]);
93
+ const initCodeHash = (0, ethers_1.keccak256)(initCode);
94
+ return (0, ethers_1.getCreate2Address)(tokenUtilsAddress, salt, initCodeHash);
95
95
  }
96
96
  const snakeToCamel = (str) => str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
97
97
  const convertKeysToCamelCase = (data) => {
@@ -1,5 +1,5 @@
1
1
  import type { Address, Cell, Message } from '@ton/ton';
2
- import { AbstractProvider, ethers } from 'ethers';
2
+ import { AbiCoder, AbstractProvider, BytesLike } from 'ethers';
3
3
  import { ICrossChainLayer, ISAFactory, ISettings, ITokenUtils } from '../../artifacts/tacTypes';
4
4
  import { ContractOpener, IToncenterV3Indexer } from '../interfaces';
5
5
  import { CurrencyType, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, ToncenterV3IndexedTransaction, TransactionLinker } from './Struct';
@@ -22,7 +22,7 @@ export type PreparedCrossChainTransaction = {
22
22
  transactionLinker: TransactionLinker;
23
23
  };
24
24
  export type PreparedBridgeTokensToTON = {
25
- outMessagePayload: ethers.BytesLike;
25
+ outMessagePayload: BytesLike;
26
26
  totalValue: bigint;
27
27
  };
28
28
  export declare enum AssetOpType {
@@ -56,7 +56,7 @@ export type InternalTACParams = {
56
56
  smartAccountFactory: ISAFactory;
57
57
  trustedTACExecutors: string[];
58
58
  trustedTONExecutors: string[];
59
- abiCoder: ethers.AbiCoder;
59
+ abiCoder: AbiCoder;
60
60
  };
61
61
  export type ResponseBase<T> = {
62
62
  response: T;
package/package.json CHANGED
@@ -1,26 +1,38 @@
1
1
  {
2
2
  "name": "@tonappchain/sdk",
3
- "version": "0.8.1-rc1",
3
+ "version": "0.9.0-rc1",
4
4
  "repository": "https://github.com/TacBuild/tac-sdk.git",
5
5
  "author": "TAC. <developers@tac>",
6
6
  "license": "MIT",
7
7
  "main": "dist/src/index.js",
8
+ "module": "dist/esm/src/index.mjs",
8
9
  "types": "dist/src/index.d.ts",
9
10
  "exports": {
10
11
  ".": {
11
12
  "node": {
12
- "types": "./dist/src/index.d.ts",
13
- "require": "./dist/src/index.js",
14
- "import": "./dist/src/index.js"
13
+ "import": {
14
+ "types": "./dist/esm/src/index.d.mts",
15
+ "default": "./dist/esm/src/index.mjs"
16
+ },
17
+ "require": {
18
+ "types": "./dist/src/index.d.ts",
19
+ "default": "./dist/src/index.js"
20
+ }
15
21
  },
16
22
  "browser": {
17
- "types": "./dist/src/index.d.ts",
18
- "import": "./dist/src/index.js"
23
+ "import": {
24
+ "types": "./dist/esm/src/index.d.mts",
25
+ "default": "./dist/esm/src/index.mjs"
26
+ }
27
+ },
28
+ "import": {
29
+ "types": "./dist/esm/src/index.d.mts",
30
+ "default": "./dist/esm/src/index.mjs"
19
31
  },
20
- "types": "./dist/src/index.d.ts",
21
- "require": "./dist/src/index.js",
22
- "import": "./dist/src/index.js",
23
- "default": "./dist/src/index.js"
32
+ "require": {
33
+ "types": "./dist/src/index.d.ts",
34
+ "default": "./dist/src/index.js"
35
+ }
24
36
  },
25
37
  "./package.json": "./package.json",
26
38
  "./dist": null,
@@ -28,19 +40,34 @@
28
40
  "./src": null,
29
41
  "./src/*": null,
30
42
  "./artifacts": {
31
- "types": "./dist/artifacts/index.d.ts",
32
- "import": "./dist/artifacts/index.js",
33
- "require": "./dist/artifacts/index.js"
43
+ "import": {
44
+ "types": "./dist/esm/artifacts/index.d.mts",
45
+ "default": "./dist/esm/artifacts/index.mjs"
46
+ },
47
+ "require": {
48
+ "types": "./dist/artifacts/index.d.ts",
49
+ "default": "./dist/artifacts/index.js"
50
+ }
34
51
  },
35
52
  "./artifacts/types/ton": {
36
- "types": "./dist/artifacts/tonTypes.d.ts",
37
- "import": "./dist/artifacts/tonTypes.js",
38
- "require": "./dist/artifacts/tonTypes.js"
53
+ "import": {
54
+ "types": "./dist/esm/artifacts/tonTypes.d.mts",
55
+ "default": "./dist/esm/artifacts/tonTypes.mjs"
56
+ },
57
+ "require": {
58
+ "types": "./dist/artifacts/tonTypes.d.ts",
59
+ "default": "./dist/artifacts/tonTypes.js"
60
+ }
39
61
  },
40
62
  "./artifacts/types/tac": {
41
- "types": "./dist/artifacts/tacTypes.d.ts",
42
- "import": "./dist/artifacts/tacTypes.js",
43
- "require": "./dist/artifacts/tacTypes.js"
63
+ "import": {
64
+ "types": "./dist/esm/artifacts/tacTypes.d.mts",
65
+ "default": "./dist/esm/artifacts/tacTypes.mjs"
66
+ },
67
+ "require": {
68
+ "types": "./dist/artifacts/tacTypes.d.ts",
69
+ "default": "./dist/artifacts/tacTypes.js"
70
+ }
44
71
  },
45
72
  "./artifacts/*": null,
46
73
  "./*": null
@@ -49,8 +76,9 @@
49
76
  "dist"
50
77
  ],
51
78
  "scripts": {
52
- "litebuild": "rm -rf dist && tsc --declaration",
79
+ "litebuild": "rm -rf dist && tsc --declaration && npm run build:esm",
53
80
  "build": "bash build.sh",
81
+ "build:esm": "esbuild src/index.ts artifacts/index.ts artifacts/tonTypes.ts artifacts/tacTypes.ts --bundle --format=esm --platform=neutral --target=es2020 --packages=external --outdir=dist/esm --outbase=. --out-extension:.js=.mjs --splitting && cp -R esm-types/. dist/esm",
54
82
  "build:artifacts:tac:dev": "cd artifacts/dev/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
55
83
  "build:artifacts:ton:dev": "cd artifacts/dev/l1_tvm_ton && npm i && npm run compile:ts && npm run build:all && rsync -avh --delete ./build ./wrappers ../ton/internal/",
56
84
  "build:artifacts:tac:testnet": "cd artifacts/testnet/l2-evm && npm i && npx hardhat compile && rsync -avh --delete ./artifacts ./scripts ./typechain-types ../tac/internal/",
@@ -60,7 +88,8 @@
60
88
  "build:artifacts:ton:all": "npm run build:artifacts:ton:dev && npm run build:artifacts:ton:testnet && npm run build:artifacts:ton:mainnet",
61
89
  "build:artifacts:tac:all": "npm run build:artifacts:tac:dev && npm run build:artifacts:tac:testnet && npm run build:artifacts:tac:mainnet",
62
90
  "build:artifacts": "npm run build:artifacts:ton:all && npm run build:artifacts:tac:all",
63
- "test": "jest --verbose --runInBand",
91
+ "test": "npm run test:package && jest --verbose --runInBand",
92
+ "test:package": "npm run litebuild && node --test tests/package/modules.test.mjs && tsc -p tests/package/tsconfig.json && tsc -p tests/package/tsconfig.bundler.json",
64
93
  "test:ton-providers": "RUN_TON_PROVIDER_TESTS=1 jest --verbose --runInBand tests/ton_providers",
65
94
  "test:toncenter-v2-tree": "RUN_TON_PROVIDER_TESTS=1 jest --verbose --runInBand tests/ton_providers/contractOpeners/toncenterV2HistoricalTree.spec.ts",
66
95
  "release": "npm run build && npx release-it",
@@ -99,6 +128,7 @@
99
128
  "@tonconnect/ui": "^3.0.0",
100
129
  "@types/bn.js": "^5.1.6",
101
130
  "@types/jest": "^29.5.14",
131
+ "esbuild": "^0.28.1",
102
132
  "eslint": "^9.26.0",
103
133
  "eslint-config-prettier": "^10.0.2",
104
134
  "eslint-plugin-simple-import-sort": "^12.1.1",
@@ -1,4 +0,0 @@
1
- import { BytesLike } from "ethers";
2
- import { InMessageV1Struct, OutMessageV1Struct } from "../../typechain-types/contracts/core/Structs.sol/IStructsInterface";
3
- export declare function encodeInMessageV1(inMessage: InMessageV1Struct): BytesLike;
4
- export declare function encodeOutMessageV1(outMessage: OutMessageV1Struct): BytesLike;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeInMessageV1 = encodeInMessageV1;
7
- exports.encodeOutMessageV1 = encodeOutMessageV1;
8
- const ethers_1 = require("ethers");
9
- const IStructsInterface_json_1 = __importDefault(require("../../artifacts/contracts/core/Structs.sol/IStructsInterface.json"));
10
- const structsInterface = new ethers_1.ethers.Interface(IStructsInterface_json_1.default.abi);
11
- function encodeInMessageV1(inMessage) {
12
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__InMessageV1", [inMessage]));
13
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
14
- }
15
- function encodeOutMessageV1(outMessage) {
16
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__OutMessageV1", [outMessage]));
17
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
18
- }
@@ -1,4 +0,0 @@
1
- import { BytesLike } from "ethers";
2
- import { InMessageV1Struct, OutMessageV1Struct } from "../../typechain-types/contracts/core/Structs.sol/IStructsInterface";
3
- export declare function encodeInMessageV1(inMessage: InMessageV1Struct): BytesLike;
4
- export declare function encodeOutMessageV1(outMessage: OutMessageV1Struct): BytesLike;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeInMessageV1 = encodeInMessageV1;
7
- exports.encodeOutMessageV1 = encodeOutMessageV1;
8
- const ethers_1 = require("ethers");
9
- const IStructsInterface_json_1 = __importDefault(require("../../artifacts/contracts/core/Structs.sol/IStructsInterface.json"));
10
- const structsInterface = new ethers_1.ethers.Interface(IStructsInterface_json_1.default.abi);
11
- function encodeInMessageV1(inMessage) {
12
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__InMessageV1", [inMessage]));
13
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
14
- }
15
- function encodeOutMessageV1(outMessage) {
16
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__OutMessageV1", [outMessage]));
17
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
18
- }
@@ -1,4 +0,0 @@
1
- import { BytesLike } from "ethers";
2
- import { InMessageV1Struct, OutMessageV1Struct } from "../../typechain-types/contracts/core/Structs.sol/IStructsInterface";
3
- export declare function encodeInMessageV1(inMessage: InMessageV1Struct): BytesLike;
4
- export declare function encodeOutMessageV1(outMessage: OutMessageV1Struct): BytesLike;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeInMessageV1 = encodeInMessageV1;
7
- exports.encodeOutMessageV1 = encodeOutMessageV1;
8
- const ethers_1 = require("ethers");
9
- const IStructsInterface_json_1 = __importDefault(require("../../artifacts/contracts/core/Structs.sol/IStructsInterface.json"));
10
- const structsInterface = new ethers_1.ethers.Interface(IStructsInterface_json_1.default.abi);
11
- function encodeInMessageV1(inMessage) {
12
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__InMessageV1", [inMessage]));
13
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
14
- }
15
- function encodeOutMessageV1(outMessage) {
16
- const encodedCall = ethers_1.ethers.getBytes(structsInterface.encodeFunctionData("__OutMessageV1", [outMessage]));
17
- return ethers_1.ethers.hexlify(encodedCall.slice(4));
18
- }