@layerzerolabs/ton-sdk-tools 3.0.12-ton.0 → 3.0.18-ton.0

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.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import * as fs2 from 'fs';
2
- import fs2__default from 'fs';
3
- import * as path2 from 'path';
4
- import path2__default from 'path';
1
+ import * as fs from 'fs';
2
+ import fs__default from 'fs';
3
+ import * as path from 'path';
4
+ import path__default from 'path';
5
5
  import { Cell, beginCell, Address, SendMode, contractAddress, Dictionary, toNano } from '@ton/core';
6
6
  import { toBigIntBE, toBufferBE } from 'bigint-buffer';
7
7
  import * as crc32 from 'crc-32';
@@ -9,66 +9,8 @@ import { extractEvents as extractEvents$1 } from '@ton/sandbox/dist/event/Event'
9
9
  import { randomAddress, compareTransaction, flattenTransaction } from '@ton/test-utils';
10
10
  import { Sha256 } from '@aws-crypto/sha256-js';
11
11
 
12
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
13
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
14
- }) : x)(function(x) {
15
- if (typeof require !== "undefined")
16
- return require.apply(this, arguments);
17
- throw Error('Dynamic require of "' + x + '" is not supported');
18
- });
19
- function thisPkgRoot(startDir = __dirname) {
20
- let currentDir = startDir;
21
- while (currentDir !== path2__default.parse(currentDir).root) {
22
- const packageJsonPath = path2__default.join(currentDir, "package.json");
23
- if (fs2__default.existsSync(packageJsonPath)) {
24
- return currentDir;
25
- }
26
- currentDir = path2__default.dirname(currentDir);
27
- }
28
- return "";
29
- }
30
- function assertActiveCell(state) {
31
- if (state.type !== "active") {
32
- throw new Error("Contract is not active");
33
- }
34
- if (!state.data) {
35
- throw new Error("Contract data is empty");
36
- }
37
- return Cell.fromBoc(state.data)[0];
38
- }
39
- function getContractsPath(overrideInputPath) {
40
- return overrideInputPath ?? process.env.CONTRACTS_FOLDER ?? path2__default.dirname(__require.resolve("@layerzerolabs/layerzero-v2-ton/package.json"));
41
- }
42
- function getSdkPath() {
43
- return process.env.SDK_FOLDER ?? thisPkgRoot();
44
- }
45
- function getContractsCodePath() {
46
- return path2__default.resolve(getContractsPath(), "src");
47
- }
48
- function getSdkCodePath() {
49
- return path2__default.resolve(getSdkPath(), "src");
50
- }
51
- function getContractBuildPath(name, overrideInputPath) {
52
- const contractsRoot = getContractsPath(overrideInputPath);
53
- const f = path2__default.join(contractsRoot, "build", `${name}.compiled.json`);
54
- if (!fs2__default.existsSync(f)) {
55
- const altPath = path2__default.dirname(__require.resolve("@layerzerolabs/layerzero-v2-ton/package.json"));
56
- const altF = path2__default.join(altPath, "build", `${name}.compiled.json`);
57
- if (fs2__default.existsSync(altF)) {
58
- return altF;
59
- } else {
60
- throw new Error(
61
- `Contract build file not found: ${f}, did you forget to run 'yarn compile' in ton/contracts?`
62
- );
63
- }
64
- }
65
- return f;
66
- }
67
- function getCompiledCode(name, overrideInputPath) {
68
- const compiledJson = fs2__default.readFileSync(getContractBuildPath(name, overrideInputPath), "utf-8");
69
- const { hex: code } = JSON.parse(compiledJson);
70
- return Cell.fromBoc(Buffer.from(code, "hex"))[0];
71
- }
12
+ // src/sdk-tools.ts
13
+ var cellFromArtifact = ({ hex }) => Cell.fromHex(hex);
72
14
  function getOpcodeCRC(input) {
73
15
  return BigInt(crc32.str(input) >>> 0);
74
16
  }
@@ -120,6 +62,18 @@ function isValidHex(str2) {
120
62
  const hexRegex = /^(0x)?[0-9A-Fa-f]+$/;
121
63
  return hexRegex.test(str2);
122
64
  }
65
+ function findDeepestCell(cell) {
66
+ const refs = Array.from({ length: cell.refs.length }, (_, i) => cell.refs.at(i));
67
+ if (refs.length === 0) {
68
+ return { subTreeCells: 1 };
69
+ }
70
+ let size = 0;
71
+ for (const ref of refs) {
72
+ if (!ref) continue;
73
+ size += findDeepestCell(ref).subTreeCells;
74
+ }
75
+ return { subTreeCells: size };
76
+ }
123
77
 
124
78
  // src/sdk-tools.ts
125
79
  var file_signature_header = `////// Generated by sdk/sdk-generator.ts`;
@@ -208,6 +162,7 @@ function tsTypeToTSGetterName(tsType, wrapperName = "platonic") {
208
162
  return `${wrapperName}.getClCell`;
209
163
  case "Tuple":
210
164
  return `${wrapperName}.getClObj`;
165
+ // TODO: this will definitely bite me in the future
211
166
  case "LzDict":
212
167
  return "getLzDict";
213
168
  default:
@@ -309,15 +264,15 @@ function mergeInputArgs(result, added) {
309
264
  }
310
265
  function parseDirectory(directoryPath) {
311
266
  let result = {};
312
- const items = fs2.readdirSync(directoryPath);
267
+ const items = fs.readdirSync(directoryPath);
313
268
  items.forEach((item) => {
314
- const itemPath = path2.join(directoryPath, item);
315
- const stats = fs2.statSync(itemPath);
269
+ const itemPath = path.join(directoryPath, item);
270
+ const stats = fs.statSync(itemPath);
316
271
  if (itemPath.includes("base_storage")) ;
317
272
  if (stats.isDirectory()) {
318
273
  result = mergeConstructorDicts(result, parseDirectory(itemPath));
319
- } else if (stats.isFile() && path2.extname(item) === ".fc" && !itemPath.includes("@ston-fi")) {
320
- const content = fs2.readFileSync(itemPath, "utf8");
274
+ } else if (stats.isFile() && path.extname(item) === ".fc" && !itemPath.includes("@ston-fi")) {
275
+ const content = fs.readFileSync(itemPath, "utf8");
321
276
  result = mergeConstructorDicts(result, parseClasses(content));
322
277
  }
323
278
  });
@@ -514,15 +469,24 @@ export class TonContractWrapper extends BaseWrapper {
514
469
  return ret.stack.readCell()
515
470
  }
516
471
 
517
- async getDictItem(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<Cell> {
472
+ async getDictCellItem(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<Cell> {
518
473
  const args: TupleItem[] = [
519
474
  { type: 'cell', cell: dict_cell },
520
475
  { type: 'int', value: key },
521
476
  ]
522
- const ret = await provider.get('cl::dict256::get', args)
477
+ const ret = await provider.get('cl::dict256::get<cellRef>', args)
523
478
  return ret.stack.readCell()
524
479
  }
525
480
 
481
+ async getDictUint256Item(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<bigint> {
482
+ const args: TupleItem[] = [
483
+ { type: 'cell', cell: dict_cell },
484
+ { type: 'int', value: key },
485
+ ]
486
+ const ret = await provider.get('cl::dict256::get<uint256>', args)
487
+ return ret.stack.readBigNumber()
488
+ }
489
+
526
490
  async getSetDictItem(provider: ContractProvider, dict_cell: Cell, key: bigint, value: Cell): Promise<Cell> {
527
491
  const args: TupleItem[] = [
528
492
  { type: 'cell', cell: dict_cell },
@@ -563,7 +527,7 @@ export class TonContractWrapper extends BaseWrapper {
563
527
  ${generatedMethods}
564
528
  }
565
529
  `;
566
- fs2.writeFileSync(path2.join(directory, "TonContractWrapper.ts"), savedCode);
530
+ fs.writeFileSync(path.join(directory, "TonContractWrapper.ts"), savedCode);
567
531
  }
568
532
  function saveAllTypes(tonObjects, directory) {
569
533
  const generatedTypes = Object.entries(tonObjects).filter(([_, tonObject]) => tonObject.attributes.length > 0).map(([_, tonObject]) => "export " + (tonObject.tsTypeCode ?? "")).join("");
@@ -601,8 +565,12 @@ export class LzDict {
601
565
  return new LzDict(beginCell().endCell())
602
566
  }
603
567
 
604
- async get(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<Cell> {
605
- return wrapper.getDictItem(this._cell, key)
568
+ async getCell(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<Cell> {
569
+ return wrapper.getDictCellItem(this._cell, key)
570
+ }
571
+
572
+ async getBigInt(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<bigint> {
573
+ return wrapper.getDictUint256Item(this._cell, key)
606
574
  }
607
575
 
608
576
  async set(key: bigint, value: Cell, wrapper: ExtendedContract<TonContractWrapper>): Promise<void> {
@@ -620,7 +588,7 @@ ${generatedTypes}
620
588
 
621
589
  ${generatedNameMap}
622
590
  `;
623
- fs2.writeFileSync(path2.join(directory, "allTypes.ts"), savedCode);
591
+ fs.writeFileSync(path.join(directory, "allTypes.ts"), savedCode);
624
592
  }
625
593
  function saveTonObjectUnwrapper(tonObjects, directory) {
626
594
  const allTypes = [
@@ -868,58 +836,42 @@ export class TonObjectUnwrapper {
868
836
  ${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructorCode ?? "").join("\n")}
869
837
  }
870
838
  `;
871
- fs2.writeFileSync(path2.join(directory, "TonObjectUnwrapper.ts"), savedCode);
839
+ fs.writeFileSync(path.join(directory, "TonObjectUnwrapper.ts"), savedCode);
872
840
  }
873
841
  function findClass(tonClasses, name) {
874
- if (name in tonClasses)
875
- return tonClasses[name];
842
+ if (name in tonClasses) return tonClasses[name];
876
843
  const lzName = "lz::" + name;
877
- if (lzName in tonClasses)
878
- return tonClasses[lzName];
844
+ if (lzName in tonClasses) return tonClasses[lzName];
879
845
  const mdName = "md::" + name;
880
- if (mdName in tonClasses)
881
- return tonClasses[mdName];
846
+ if (mdName in tonClasses) return tonClasses[mdName];
882
847
  const clName = "cl::" + name;
883
- if (clName in tonClasses)
884
- return tonClasses[clName];
848
+ if (clName in tonClasses) return tonClasses[clName];
885
849
  const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
886
- if (packetV1Key in tonClasses)
887
- return tonClasses[packetV1Key];
850
+ if (packetV1Key in tonClasses) return tonClasses[packetV1Key];
888
851
  const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
889
- if (packetV1UnderscoreKey in tonClasses)
890
- return tonClasses[packetV1UnderscoreKey];
852
+ if (packetV1UnderscoreKey in tonClasses) return tonClasses[packetV1UnderscoreKey];
891
853
  const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
892
- if (packetV2Key in tonClasses)
893
- return tonClasses[packetV2Key];
854
+ if (packetV2Key in tonClasses) return tonClasses[packetV2Key];
894
855
  const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
895
- if (packetV2UnderscoreKey in tonClasses)
896
- return tonClasses[packetV2UnderscoreKey];
856
+ if (packetV2UnderscoreKey in tonClasses) return tonClasses[packetV2UnderscoreKey];
897
857
  return void 0;
898
858
  }
899
859
  function findClassKey(tonClasses, name) {
900
- if (name in tonClasses)
901
- return name;
860
+ if (name in tonClasses) return name;
902
861
  const lzName = "lz::" + name;
903
- if (lzName in tonClasses)
904
- return lzName;
862
+ if (lzName in tonClasses) return lzName;
905
863
  const mdName = "md::" + name;
906
- if (mdName in tonClasses)
907
- return mdName;
864
+ if (mdName in tonClasses) return mdName;
908
865
  const clName = "cl::" + name;
909
- if (clName in tonClasses)
910
- return clName;
866
+ if (clName in tonClasses) return clName;
911
867
  const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
912
- if (packetV1Key in tonClasses)
913
- return packetV1Key;
868
+ if (packetV1Key in tonClasses) return packetV1Key;
914
869
  const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
915
- if (packetV1UnderscoreKey in tonClasses)
916
- return packetV1UnderscoreKey;
870
+ if (packetV1UnderscoreKey in tonClasses) return packetV1UnderscoreKey;
917
871
  const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
918
- if (packetV2Key in tonClasses)
919
- return packetV2Key;
872
+ if (packetV2Key in tonClasses) return packetV2Key;
920
873
  const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
921
- if (packetV2UnderscoreKey in tonClasses)
922
- return packetV2UnderscoreKey;
874
+ if (packetV2UnderscoreKey in tonClasses) return packetV2UnderscoreKey;
923
875
  return void 0;
924
876
  }
925
877
  function generateConstructorCodes(className, tonClasses) {
@@ -930,6 +882,10 @@ function generateConstructorCodes(className, tonClasses) {
930
882
  const { constructorInputArgs: inputArgs } = tonClass;
931
883
  const fnName = snakeToCamelCase(`getNew_${className}`);
932
884
  const scratchFnName = snakeToCamelCase(`getNew_${className}FromScratch`);
885
+ let methodIdName = `${className}::New`;
886
+ if (className.includes("::New")) {
887
+ methodIdName = className;
888
+ }
933
889
  tonClass.constructorName = fnName;
934
890
  tonClass.fromScratchConstructorName = scratchFnName;
935
891
  tonClass.nonClassConstructorArgs = {};
@@ -937,7 +893,7 @@ function generateConstructorCodes(className, tonClasses) {
937
893
  async ${fnName}(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
938
894
  ${Object.entries(inputArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
939
895
  }` : ""}): Promise<Cell> {
940
- const getResult = await provider.get('${className}::New', [
896
+ const getResult = await provider.get('${methodIdName}', [
941
897
  ${Object.entries(inputArgs).map(
942
898
  ([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
943
899
  ).join(",\n ")}
@@ -952,7 +908,7 @@ function generateConstructorCodes(className, tonClasses) {
952
908
  async ${fnName}Cell(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
953
909
  ${Object.entries(cellArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType, "Slice", true)}`).join(",\n ")}
954
910
  }` : ""}): Promise<Cell> {
955
- const getResult = await provider.get('${className}::New', [
911
+ const getResult = await provider.get('${methodIdName}', [
956
912
  ${Object.entries(cellArgs).map(
957
913
  ([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
958
914
  ).join(",\n ")}
@@ -1192,12 +1148,12 @@ function recursiveGenDeconstructorCode(classConstructors, key = "") {
1192
1148
  function getSpecificFiles(dirPath, includeName) {
1193
1149
  const files = [];
1194
1150
  function traverseDir(currentPath) {
1195
- const entries = fs2.readdirSync(currentPath, { withFileTypes: true });
1151
+ const entries = fs.readdirSync(currentPath, { withFileTypes: true });
1196
1152
  for (const entry of entries) {
1197
- const fullPath = path2.join(currentPath, entry.name);
1153
+ const fullPath = path.join(currentPath, entry.name);
1198
1154
  if (entry.isDirectory()) {
1199
1155
  traverseDir(fullPath);
1200
- } else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (path2.extname(entry.name) === ".fc" || path2.extname(entry.name) === ".func")) {
1156
+ } else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (path.extname(entry.name) === ".fc" || path.extname(entry.name) === ".func")) {
1201
1157
  files.push(fullPath);
1202
1158
  }
1203
1159
  }
@@ -1233,7 +1189,7 @@ export const tonObjects = {
1233
1189
  }
1234
1190
  tsCode += `} as const
1235
1191
  `;
1236
- fs2.writeFileSync(path2.resolve(filePath, fileName), tsCode, "utf8");
1192
+ fs.writeFileSync(path.resolve(filePath, fileName), tsCode, "utf8");
1237
1193
  }
1238
1194
  function tonConstNameToTSName(name) {
1239
1195
  return name.replace(/::/g, "_");
@@ -1253,7 +1209,7 @@ function extractConstants(fileNames, constType) {
1253
1209
  }
1254
1210
  const result = /* @__PURE__ */ new Map();
1255
1211
  for (const fileName of fileNames) {
1256
- const fileContent = fs2.readFileSync(fileName, "utf-8");
1212
+ const fileContent = fs.readFileSync(fileName, "utf-8");
1257
1213
  const lines = fileContent.split("\n");
1258
1214
  for (const line of lines) {
1259
1215
  const trimmedLine = line.trim();
@@ -1302,7 +1258,7 @@ function extractEvents(fileNames) {
1302
1258
  const eventRegex = /^const\s+(?:int\s+)?([\w:]+::[eE][vV][eE][nN][tT]::[\w:]+)\s*=\s*"([\w:]+)"[uc];$/;
1303
1259
  const result = /* @__PURE__ */ new Map();
1304
1260
  for (const fileName of fileNames) {
1305
- const fileContent = fs2.readFileSync(fileName, "utf-8");
1261
+ const fileContent = fs.readFileSync(fileName, "utf-8");
1306
1262
  const lines = fileContent.split("\n");
1307
1263
  for (const line of lines) {
1308
1264
  const trimmedLine = line.trim();
@@ -1323,7 +1279,7 @@ export const ${variableName} = {
1323
1279
  ${Array.from(events.entries()).map(([key, [rawValue, intValue]]) => ` ${key}: {stringValue: "${rawValue}", intValue: ${intValue}n},`).join("\n")}
1324
1280
  } as const
1325
1281
  `;
1326
- fs2.writeFileSync(path2.join(directory, filename), savedCode);
1282
+ fs.writeFileSync(path.join(directory, filename), savedCode);
1327
1283
  }
1328
1284
  function saveConstantsFile(constants, directory, variableName, filename) {
1329
1285
  const savedCode = `${file_signature_header}
@@ -1331,30 +1287,30 @@ export const ${variableName} = {
1331
1287
  ${Array.from(constants.entries()).map(([key, value]) => ` ${key}: ${value}n,`).join("\n")}
1332
1288
  } as const
1333
1289
  `;
1334
- fs2.writeFileSync(path2.join(directory, filename), savedCode);
1290
+ fs.writeFileSync(path.join(directory, filename), savedCode);
1335
1291
  }
1336
1292
  function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
1337
1293
  const contractDirs = [];
1338
1294
  const viewFunctions = {};
1339
1295
  function findContractDirs(dir) {
1340
- const entries = fs2.readdirSync(dir, { withFileTypes: true });
1296
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
1341
1297
  const isAContractFolder = entries.some((entry) => !entry.isDirectory() && nameWhitelist.includes(entry.name));
1342
1298
  if (isAContractFolder && !blacklist.some((word) => dir.includes(word))) {
1343
1299
  contractDirs.push(dir);
1344
1300
  }
1345
1301
  entries.forEach((entry) => {
1346
1302
  if (entry.isDirectory()) {
1347
- findContractDirs(path2.join(dir, entry.name));
1303
+ findContractDirs(path.join(dir, entry.name));
1348
1304
  }
1349
1305
  });
1350
1306
  }
1351
1307
  findContractDirs(rootDir);
1352
1308
  contractDirs.forEach((dir) => {
1353
- const files = fs2.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
1309
+ const files = fs.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
1354
1310
  files.forEach((file) => {
1355
- const filePath = path2.join(dir, file);
1356
- const contractName = snakeToCamelCase(path2.basename(path2.dirname(dir)) + "_" + path2.basename(dir));
1357
- const content = fs2.readFileSync(filePath, "utf-8");
1311
+ const filePath = path.join(dir, file);
1312
+ const contractName = snakeToCamelCase(path.basename(path.dirname(dir)) + "_" + path.basename(dir));
1313
+ const content = fs.readFileSync(filePath, "utf-8");
1358
1314
  const functionRegex = /(\((?:[^()]+,\s*)*[^()]+\)|[\w:]+)\s+(\w+(?:::\w+)*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{([^}]*)\}/g;
1359
1315
  let match;
1360
1316
  while ((match = functionRegex.exec(content)) !== null) {
@@ -1418,7 +1374,7 @@ import { ExtendedContract, TonContractWrapper } from '../wrappers'
1418
1374
 
1419
1375
  ${generatedFunctions}
1420
1376
  `;
1421
- fs2.writeFileSync(path2.join(directory, filename), savedCode);
1377
+ fs.writeFileSync(path.join(directory, filename), savedCode);
1422
1378
  }
1423
1379
  var BaseWrapper = class {
1424
1380
  constructor(address, init) {
@@ -1471,6 +1427,16 @@ import {
1471
1427
  } from '@ton/sandbox'
1472
1428
  import { FlatTransactionComparable } from '@ton/test-utils'
1473
1429
 
1430
+ import ChannelArtifact from '@layerzerolabs/layerzero-v2-ton/build/Channel.compiled.json'
1431
+ import ControllerArtifact from '@layerzerolabs/layerzero-v2-ton/build/Controller.compiled.json'
1432
+ import EndpointArtifact from '@layerzerolabs/layerzero-v2-ton/build/Endpoint.compiled.json'
1433
+ import MultiSigArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSig.compiled.json'
1434
+ import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSigOrder.compiled.json'
1435
+ import SmlConnectionArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlConnection.compiled.json'
1436
+ import SmlManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlManager.compiled.json'
1437
+ import ZroMinterArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroMinter.compiled.json'
1438
+ import ZroWalletArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroWallet.compiled.json'
1439
+
1474
1440
  import {
1475
1441
  JettonMinter,
1476
1442
  JettonWallet,
@@ -1480,7 +1446,7 @@ import {
1480
1446
  Profile,
1481
1447
  TransferRequest,
1482
1448
  buildOnchainMetadata,
1483
- getCompiledCode,
1449
+ cellFromArtifact,
1484
1450
  getRandomInt,
1485
1451
  printTransactionTrace,
1486
1452
  } from '@layerzerolabs/ton-sdk-tools'
@@ -1768,6 +1734,10 @@ export async function buildNonceMd(nonce: bigint, allStorages: SandboxContract<T
1768
1734
  return allStorages.getObject('md::Nonce::New', [{ type: 'int', value: nonce }])
1769
1735
  }
1770
1736
 
1737
+ export async function buildLzReceivePrepareMd(nonce: bigint, nanotons: bigint, allStorages: SandboxContract<TonContractWrapper>): Promise<Cell> {
1738
+ return allStorages.getObject('md::LzReceivePrepare::New', [{ type: 'int', value: nonce }, { type: 'int', value: nanotons }])
1739
+ }
1740
+
1771
1741
  export function buildMessageBody(donationNanos: number, origin: Address, opcode: number, md: Cell): Cell {
1772
1742
  return beginMessage(opcode)
1773
1743
  .storeUint(donationNanos, 64)
@@ -2396,9 +2366,9 @@ export async function getZroWallet(
2396
2366
  {
2397
2367
  admin: ownerAddress,
2398
2368
  content: buildOnchainMetadata(zroOnchainMetaData),
2399
- wallet_code: getCompiledCode('ZroWallet'),
2369
+ wallet_code: cellFromArtifact(ZroWalletArtifact),
2400
2370
  },
2401
- getCompiledCode('ZroMinter')
2371
+ cellFromArtifact(ZroMinterArtifact)
2402
2372
  )
2403
2373
  )
2404
2374
 
@@ -2425,12 +2395,12 @@ export async function openAndDeployControllerViaMultiSig(
2425
2395
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2426
2396
  const controller: SandboxContract<TonContractWrapper> = blockchain.openContract(
2427
2397
  TonContractWrapper.create(
2428
- getCompiledCode('Controller'),
2398
+ cellFromArtifact(ControllerArtifact),
2429
2399
  await allStorages.getNewControllerCell({
2430
2400
  owner: addressToBigInt(multiSigContract.address),
2431
2401
  eid,
2432
- endpointCode: getCompiledCode('Endpoint'),
2433
- channelCode: getCompiledCode('Channel'),
2402
+ endpointCode: cellFromArtifact(EndpointArtifact),
2403
+ channelCode: cellFromArtifact(ChannelArtifact),
2434
2404
  })
2435
2405
  )
2436
2406
  )
@@ -2508,7 +2478,7 @@ export async function openAndDeployEndpoint(
2508
2478
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2509
2479
  const endpoint: SandboxContract<TonContractWrapper> = blockchain.openContract(
2510
2480
  TonContractWrapper.create(
2511
- getCompiledCode('Endpoint'),
2481
+ cellFromArtifact(EndpointArtifact),
2512
2482
  await controller.getNewEndpointCell({
2513
2483
  eid: srcEid,
2514
2484
  dstEid: dstEid,
@@ -2561,7 +2531,7 @@ export async function openAndDeployChannel(
2561
2531
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2562
2532
  const channel: SandboxContract<TonContractWrapper> = blockchain.openContract(
2563
2533
  TonContractWrapper.create(
2564
- getCompiledCode('Channel'),
2534
+ cellFromArtifact(ChannelArtifact),
2565
2535
  await srcFixture.controller.getNewChannelCell({
2566
2536
  owner: addressToBigInt(srcFixture.controller.address),
2567
2537
  path: srcFixture.path,
@@ -2614,15 +2584,15 @@ export async function openAndDeploySmlManager(
2614
2584
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2615
2585
  const smlManager: SandboxContract<TonContractWrapper> = blockchain.openContract(
2616
2586
  TonContractWrapper.create(
2617
- getCompiledCode('SmlManager'),
2587
+ cellFromArtifact(SmlManagerArtifact),
2618
2588
  await allStorages.getNewSmlManagerCell({
2619
2589
  owner: addressToBigInt(fixture.owner.address),
2620
2590
  eid: fixture.eid,
2621
2591
  version,
2622
2592
  controllerAddress: addressToBigInt(fixture.controller.address),
2623
- endpointCode: getCompiledCode('Endpoint'),
2624
- channelCode: getCompiledCode('Channel'),
2625
- smlConnectionCode: getCompiledCode('SmlConnection'),
2593
+ endpointCode: cellFromArtifact(EndpointArtifact),
2594
+ channelCode: cellFromArtifact(ChannelArtifact),
2595
+ smlConnectionCode: cellFromArtifact(SmlConnectionArtifact),
2626
2596
  })
2627
2597
  )
2628
2598
  )
@@ -2655,7 +2625,7 @@ export async function openAndDeploySmlConnection(
2655
2625
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2656
2626
  const smlConnection: SandboxContract<TonContractWrapper> = blockchain.openContract(
2657
2627
  TonContractWrapper.create(
2658
- getCompiledCode('SmlConnection'),
2628
+ cellFromArtifact(SmlConnectionArtifact),
2659
2629
  await allStorages.getNewSmlConnectionCell({
2660
2630
  owner: addressToBigInt(smlManager.address),
2661
2631
  path: srcFixture.path,
@@ -2686,7 +2656,7 @@ export async function openAndDeploySmlConnection(
2686
2656
  {
2687
2657
  from: srcFixture.oApp.address,
2688
2658
  to: smlManager.address,
2689
- op: Number(OPCODES.SmlManager_OP_DEPLOY_CONNECTION),
2659
+ op: Number(OPCODES.MsglibManager_OP_DEPLOY_CONNECTION),
2690
2660
  success: true,
2691
2661
  },
2692
2662
  {
@@ -2825,7 +2795,7 @@ export async function setupFixture(
2825
2795
 
2826
2796
  // =============================set up 3/3 multi-sig as the controller owner================================
2827
2797
 
2828
- addLibToBlockchain(blockchain, getCompiledCode('MultiSigOrder'))
2798
+ addLibToBlockchain(blockchain, cellFromArtifact(MultiSigOrderArtifact))
2829
2799
 
2830
2800
  const multiSigners = [multiSigOwner1, multiSigOwner2, multiSigOwner3]
2831
2801
  const proposers = await blockchain.createWallets(getRandomInt(10, 20))
@@ -2838,7 +2808,7 @@ export async function setupFixture(
2838
2808
  }
2839
2809
 
2840
2810
  const multiSigContract = blockchain.openContract(
2841
- Multisig.createFromConfig(multiSigConfig, getCompiledCode('MultiSig'))
2811
+ Multisig.createFromConfig(multiSigConfig, cellFromArtifact(MultiSigArtifact))
2842
2812
  )
2843
2813
 
2844
2814
  // deploy the multisig contract
@@ -2884,9 +2854,9 @@ export async function setupFixture(
2884
2854
  {
2885
2855
  admin: multiSigOwner1.address,
2886
2856
  content: buildOnchainMetadata(zroOnchainMetaData),
2887
- wallet_code: getCompiledCode('ZroWallet'),
2857
+ wallet_code: cellFromArtifact(ZroWalletArtifact),
2888
2858
  },
2889
- getCompiledCode('ZroMinter')
2859
+ cellFromArtifact(ZroMinterArtifact)
2890
2860
  )
2891
2861
  )
2892
2862
 
@@ -3155,7 +3125,7 @@ export async function wireFixturesTogetherWithSML(
3155
3125
  )
3156
3126
  }
3157
3127
  `;
3158
- fs2__default.writeFileSync(path2__default.join(directory, filename), savedCode);
3128
+ fs__default.writeFileSync(path__default.join(directory, filename), savedCode);
3159
3129
  }
3160
3130
 
3161
3131
  // src/externalWrappers/Multisig-Constants.ts
@@ -3459,15 +3429,12 @@ var getMsgPrices = (configRaw, workchain) => {
3459
3429
  };
3460
3430
  };
3461
3431
  var storageCollected = (trans) => {
3462
- if (trans.description.type !== "generic")
3463
- throw new Error("Expected generic transaction");
3432
+ if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
3464
3433
  return trans.description.storagePhase ? trans.description.storagePhase.storageFeesCollected : 0n;
3465
3434
  };
3466
3435
  var computedGeneric = (trans) => {
3467
- if (trans.description.type !== "generic")
3468
- throw new Error("Expected generic transaction");
3469
- if (trans.description.computePhase.type !== "vm")
3470
- throw new Error("Compute phase expected");
3436
+ if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
3437
+ if (trans.description.computePhase.type !== "vm") throw new Error("Compute phase expected");
3471
3438
  return trans.description.computePhase;
3472
3439
  };
3473
3440
  var Txiterator = class {
@@ -3484,8 +3451,7 @@ var Txiterator = class {
3484
3451
  throw new Error("MsgQueued is undefined");
3485
3452
  }
3486
3453
  const inMsg = curMsg.msg;
3487
- if (inMsg.info.type !== "internal")
3488
- throw new Error("Internal only");
3454
+ if (inMsg.info.type !== "internal") throw new Error("Internal only");
3489
3455
  const smc = await this.blockchain.getContract(inMsg.info.dest);
3490
3456
  const res = await smc.receiveMessage(inMsg, { now: this.blockchain.now });
3491
3457
  const bcRes = {
@@ -3824,20 +3790,20 @@ var decimalCount = 9;
3824
3790
  var decimal = pow10(decimalCount);
3825
3791
  var defaultPath = "gasInfo";
3826
3792
  function createDirectoryIfNotExist(directoryPath) {
3827
- if (!fs2.existsSync(directoryPath)) {
3828
- fs2.mkdirSync(directoryPath, { recursive: true });
3793
+ if (!fs.existsSync(directoryPath)) {
3794
+ fs.mkdirSync(directoryPath, { recursive: true });
3829
3795
  }
3830
3796
  }
3831
3797
  function sortAndSave(filePath, gasInfo) {
3832
3798
  const entries = Object.entries(gasInfo);
3833
3799
  const sortedEntries = entries.sort(([, valueA], [, valueB]) => parseFloat(valueA) - parseFloat(valueB));
3834
3800
  const jsonData = JSON.stringify(Object.fromEntries(sortedEntries), null, 2);
3835
- fs2.writeFileSync(filePath, `${jsonData}
3801
+ fs.writeFileSync(filePath, `${jsonData}
3836
3802
  `, "utf8");
3837
3803
  }
3838
3804
  function readOrCreateJsonFile(filePath) {
3839
- if (fs2.existsSync(filePath)) {
3840
- const fileContent = fs2.readFileSync(filePath, "utf8");
3805
+ if (fs.existsSync(filePath)) {
3806
+ const fileContent = fs.readFileSync(filePath, "utf8");
3841
3807
  return JSON.parse(fileContent);
3842
3808
  } else {
3843
3809
  return {};
@@ -3865,8 +3831,7 @@ function formatCoinsPure(value, precision = 6) {
3865
3831
  return `${whole.toString()}${frac !== 0n ? "." + frac.toString().padStart(precision, "0").replace(/0+$/, "") : ""}`;
3866
3832
  }
3867
3833
  function formatCoins(value, precision = 6) {
3868
- if (value === void 0)
3869
- return "N/A";
3834
+ if (value === void 0) return "N/A";
3870
3835
  return formatCoinsPure(value, precision);
3871
3836
  }
3872
3837
  function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
@@ -3878,13 +3843,12 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3878
3843
  let filePath = profile?.filePath ?? defaultPath;
3879
3844
  if (profile?.profileGas) {
3880
3845
  createDirectoryIfNotExist(filePath);
3881
- filePath = path2__default.join(filePath, `${profile.fileName}.json`);
3846
+ filePath = path__default.join(filePath, `${profile.fileName}.json`);
3882
3847
  gasInfo = readOrCreateJsonFile(filePath);
3883
3848
  }
3884
3849
  console.table(
3885
3850
  transactions.map((tx) => {
3886
- if (tx.description.type !== "generic")
3887
- return void 0;
3851
+ if (tx.description.type !== "generic") return void 0;
3888
3852
  const body = tx.inMessage?.info.type === "internal" ? tx.inMessage.body.beginParse() : void 0;
3889
3853
  const op = body === void 0 ? 0n : body.remainingBits >= 32 ? body.preloadUint(32) : 0n;
3890
3854
  const totalFees = formatCoins(tx.totalFees.coins);
@@ -3907,8 +3871,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3907
3871
  const addressString = tx.address.toString(16).length != 64 ? "UNKNOWN" : Address.parseRaw("1:" + tx.address.toString(16));
3908
3872
  const opString = op.toString() in opcodeInfo ? opcodeInfo[op.toString()] : op.toString();
3909
3873
  cumulativeFees += tx.totalFees.coins + (tx.description.actionPhase?.totalFwdFees ?? 0n);
3910
- if (profile?.profileGas)
3911
- gasInfo[opString] = formatCoins(cumulativeFees);
3874
+ if (profile?.profileGas) gasInfo[opString] = formatCoins(cumulativeFees);
3912
3875
  return {
3913
3876
  address: addressString,
3914
3877
  op: opString,
@@ -3925,10 +3888,9 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3925
3888
  };
3926
3889
  }).filter((v) => v !== void 0)
3927
3890
  );
3928
- if (profile?.profileGas)
3929
- sortAndSave(filePath, gasInfo);
3891
+ if (profile?.profileGas) sortAndSave(filePath, gasInfo);
3930
3892
  }
3931
3893
 
3932
- export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt, assertActiveCell, beginMessage, bigintToAddress, buildOnchainMetadata, computedGeneric, differentAddress, executeFrom, executeTill, extractConstants, extractEvents, findTransaction, formatCoinsPure, generateAllViewFunctions, generateTestUtilsCode, getCompiledCode, getContractsCodePath, getContractsPath, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSdkCodePath, getSdkPath, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, randomQueryId, recursiveGenConstructorCode, recursiveGenDeconstructorCode, recursiveGenTSTypes, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, sendRequest, storageCollected, to32ByteBuffer };
3933
- //# sourceMappingURL=out.js.map
3894
+ export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt, beginMessage, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractConstants, extractEvents, findDeepestCell, findTransaction, formatCoinsPure, generateAllViewFunctions, generateTestUtilsCode, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, randomQueryId, recursiveGenConstructorCode, recursiveGenDeconstructorCode, recursiveGenTSTypes, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, sendRequest, storageCollected, to32ByteBuffer };
3895
+ //# sourceMappingURL=index.mjs.map
3934
3896
  //# sourceMappingURL=index.mjs.map