@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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var fs2 = require('fs');
4
- var path2 = require('path');
3
+ var fs = require('fs');
4
+ var path = require('path');
5
5
  var core = require('@ton/core');
6
6
  var bigintBuffer = require('bigint-buffer');
7
7
  var crc32 = require('crc-32');
@@ -27,70 +27,12 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
31
- var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
30
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
31
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
32
32
  var crc32__namespace = /*#__PURE__*/_interopNamespace(crc32);
33
33
 
34
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
35
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
36
- }) : x)(function(x) {
37
- if (typeof require !== "undefined")
38
- return require.apply(this, arguments);
39
- throw Error('Dynamic require of "' + x + '" is not supported');
40
- });
41
- function thisPkgRoot(startDir = __dirname) {
42
- let currentDir = startDir;
43
- while (currentDir !== path2__namespace.default.parse(currentDir).root) {
44
- const packageJsonPath = path2__namespace.default.join(currentDir, "package.json");
45
- if (fs2__namespace.default.existsSync(packageJsonPath)) {
46
- return currentDir;
47
- }
48
- currentDir = path2__namespace.default.dirname(currentDir);
49
- }
50
- return "";
51
- }
52
- function assertActiveCell(state) {
53
- if (state.type !== "active") {
54
- throw new Error("Contract is not active");
55
- }
56
- if (!state.data) {
57
- throw new Error("Contract data is empty");
58
- }
59
- return core.Cell.fromBoc(state.data)[0];
60
- }
61
- function getContractsPath(overrideInputPath) {
62
- return overrideInputPath ?? process.env.CONTRACTS_FOLDER ?? path2__namespace.default.dirname(__require.resolve("@layerzerolabs/layerzero-v2-ton/package.json"));
63
- }
64
- function getSdkPath() {
65
- return process.env.SDK_FOLDER ?? thisPkgRoot();
66
- }
67
- function getContractsCodePath() {
68
- return path2__namespace.default.resolve(getContractsPath(), "src");
69
- }
70
- function getSdkCodePath() {
71
- return path2__namespace.default.resolve(getSdkPath(), "src");
72
- }
73
- function getContractBuildPath(name, overrideInputPath) {
74
- const contractsRoot = getContractsPath(overrideInputPath);
75
- const f = path2__namespace.default.join(contractsRoot, "build", `${name}.compiled.json`);
76
- if (!fs2__namespace.default.existsSync(f)) {
77
- const altPath = path2__namespace.default.dirname(__require.resolve("@layerzerolabs/layerzero-v2-ton/package.json"));
78
- const altF = path2__namespace.default.join(altPath, "build", `${name}.compiled.json`);
79
- if (fs2__namespace.default.existsSync(altF)) {
80
- return altF;
81
- } else {
82
- throw new Error(
83
- `Contract build file not found: ${f}, did you forget to run 'yarn compile' in ton/contracts?`
84
- );
85
- }
86
- }
87
- return f;
88
- }
89
- function getCompiledCode(name, overrideInputPath) {
90
- const compiledJson = fs2__namespace.default.readFileSync(getContractBuildPath(name, overrideInputPath), "utf-8");
91
- const { hex: code } = JSON.parse(compiledJson);
92
- return core.Cell.fromBoc(Buffer.from(code, "hex"))[0];
93
- }
34
+ // src/sdk-tools.ts
35
+ var cellFromArtifact = ({ hex }) => core.Cell.fromHex(hex);
94
36
  function getOpcodeCRC(input) {
95
37
  return BigInt(crc32__namespace.str(input) >>> 0);
96
38
  }
@@ -142,6 +84,18 @@ function isValidHex(str2) {
142
84
  const hexRegex = /^(0x)?[0-9A-Fa-f]+$/;
143
85
  return hexRegex.test(str2);
144
86
  }
87
+ function findDeepestCell(cell) {
88
+ const refs = Array.from({ length: cell.refs.length }, (_, i) => cell.refs.at(i));
89
+ if (refs.length === 0) {
90
+ return { subTreeCells: 1 };
91
+ }
92
+ let size = 0;
93
+ for (const ref of refs) {
94
+ if (!ref) continue;
95
+ size += findDeepestCell(ref).subTreeCells;
96
+ }
97
+ return { subTreeCells: size };
98
+ }
145
99
 
146
100
  // src/sdk-tools.ts
147
101
  var file_signature_header = `////// Generated by sdk/sdk-generator.ts`;
@@ -230,6 +184,7 @@ function tsTypeToTSGetterName(tsType, wrapperName = "platonic") {
230
184
  return `${wrapperName}.getClCell`;
231
185
  case "Tuple":
232
186
  return `${wrapperName}.getClObj`;
187
+ // TODO: this will definitely bite me in the future
233
188
  case "LzDict":
234
189
  return "getLzDict";
235
190
  default:
@@ -331,15 +286,15 @@ function mergeInputArgs(result, added) {
331
286
  }
332
287
  function parseDirectory(directoryPath) {
333
288
  let result = {};
334
- const items = fs2__namespace.readdirSync(directoryPath);
289
+ const items = fs__namespace.readdirSync(directoryPath);
335
290
  items.forEach((item) => {
336
- const itemPath = path2__namespace.join(directoryPath, item);
337
- const stats = fs2__namespace.statSync(itemPath);
291
+ const itemPath = path__namespace.join(directoryPath, item);
292
+ const stats = fs__namespace.statSync(itemPath);
338
293
  if (itemPath.includes("base_storage")) ;
339
294
  if (stats.isDirectory()) {
340
295
  result = mergeConstructorDicts(result, parseDirectory(itemPath));
341
- } else if (stats.isFile() && path2__namespace.extname(item) === ".fc" && !itemPath.includes("@ston-fi")) {
342
- const content = fs2__namespace.readFileSync(itemPath, "utf8");
296
+ } else if (stats.isFile() && path__namespace.extname(item) === ".fc" && !itemPath.includes("@ston-fi")) {
297
+ const content = fs__namespace.readFileSync(itemPath, "utf8");
343
298
  result = mergeConstructorDicts(result, parseClasses(content));
344
299
  }
345
300
  });
@@ -536,15 +491,24 @@ export class TonContractWrapper extends BaseWrapper {
536
491
  return ret.stack.readCell()
537
492
  }
538
493
 
539
- async getDictItem(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<Cell> {
494
+ async getDictCellItem(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<Cell> {
540
495
  const args: TupleItem[] = [
541
496
  { type: 'cell', cell: dict_cell },
542
497
  { type: 'int', value: key },
543
498
  ]
544
- const ret = await provider.get('cl::dict256::get', args)
499
+ const ret = await provider.get('cl::dict256::get<cellRef>', args)
545
500
  return ret.stack.readCell()
546
501
  }
547
502
 
503
+ async getDictUint256Item(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<bigint> {
504
+ const args: TupleItem[] = [
505
+ { type: 'cell', cell: dict_cell },
506
+ { type: 'int', value: key },
507
+ ]
508
+ const ret = await provider.get('cl::dict256::get<uint256>', args)
509
+ return ret.stack.readBigNumber()
510
+ }
511
+
548
512
  async getSetDictItem(provider: ContractProvider, dict_cell: Cell, key: bigint, value: Cell): Promise<Cell> {
549
513
  const args: TupleItem[] = [
550
514
  { type: 'cell', cell: dict_cell },
@@ -585,7 +549,7 @@ export class TonContractWrapper extends BaseWrapper {
585
549
  ${generatedMethods}
586
550
  }
587
551
  `;
588
- fs2__namespace.writeFileSync(path2__namespace.join(directory, "TonContractWrapper.ts"), savedCode);
552
+ fs__namespace.writeFileSync(path__namespace.join(directory, "TonContractWrapper.ts"), savedCode);
589
553
  }
590
554
  function saveAllTypes(tonObjects, directory) {
591
555
  const generatedTypes = Object.entries(tonObjects).filter(([_, tonObject]) => tonObject.attributes.length > 0).map(([_, tonObject]) => "export " + (tonObject.tsTypeCode ?? "")).join("");
@@ -623,8 +587,12 @@ export class LzDict {
623
587
  return new LzDict(beginCell().endCell())
624
588
  }
625
589
 
626
- async get(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<Cell> {
627
- return wrapper.getDictItem(this._cell, key)
590
+ async getCell(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<Cell> {
591
+ return wrapper.getDictCellItem(this._cell, key)
592
+ }
593
+
594
+ async getBigInt(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<bigint> {
595
+ return wrapper.getDictUint256Item(this._cell, key)
628
596
  }
629
597
 
630
598
  async set(key: bigint, value: Cell, wrapper: ExtendedContract<TonContractWrapper>): Promise<void> {
@@ -642,7 +610,7 @@ ${generatedTypes}
642
610
 
643
611
  ${generatedNameMap}
644
612
  `;
645
- fs2__namespace.writeFileSync(path2__namespace.join(directory, "allTypes.ts"), savedCode);
613
+ fs__namespace.writeFileSync(path__namespace.join(directory, "allTypes.ts"), savedCode);
646
614
  }
647
615
  function saveTonObjectUnwrapper(tonObjects, directory) {
648
616
  const allTypes = [
@@ -890,58 +858,42 @@ export class TonObjectUnwrapper {
890
858
  ${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructorCode ?? "").join("\n")}
891
859
  }
892
860
  `;
893
- fs2__namespace.writeFileSync(path2__namespace.join(directory, "TonObjectUnwrapper.ts"), savedCode);
861
+ fs__namespace.writeFileSync(path__namespace.join(directory, "TonObjectUnwrapper.ts"), savedCode);
894
862
  }
895
863
  function findClass(tonClasses, name) {
896
- if (name in tonClasses)
897
- return tonClasses[name];
864
+ if (name in tonClasses) return tonClasses[name];
898
865
  const lzName = "lz::" + name;
899
- if (lzName in tonClasses)
900
- return tonClasses[lzName];
866
+ if (lzName in tonClasses) return tonClasses[lzName];
901
867
  const mdName = "md::" + name;
902
- if (mdName in tonClasses)
903
- return tonClasses[mdName];
868
+ if (mdName in tonClasses) return tonClasses[mdName];
904
869
  const clName = "cl::" + name;
905
- if (clName in tonClasses)
906
- return tonClasses[clName];
870
+ if (clName in tonClasses) return tonClasses[clName];
907
871
  const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
908
- if (packetV1Key in tonClasses)
909
- return tonClasses[packetV1Key];
872
+ if (packetV1Key in tonClasses) return tonClasses[packetV1Key];
910
873
  const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
911
- if (packetV1UnderscoreKey in tonClasses)
912
- return tonClasses[packetV1UnderscoreKey];
874
+ if (packetV1UnderscoreKey in tonClasses) return tonClasses[packetV1UnderscoreKey];
913
875
  const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
914
- if (packetV2Key in tonClasses)
915
- return tonClasses[packetV2Key];
876
+ if (packetV2Key in tonClasses) return tonClasses[packetV2Key];
916
877
  const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
917
- if (packetV2UnderscoreKey in tonClasses)
918
- return tonClasses[packetV2UnderscoreKey];
878
+ if (packetV2UnderscoreKey in tonClasses) return tonClasses[packetV2UnderscoreKey];
919
879
  return void 0;
920
880
  }
921
881
  function findClassKey(tonClasses, name) {
922
- if (name in tonClasses)
923
- return name;
882
+ if (name in tonClasses) return name;
924
883
  const lzName = "lz::" + name;
925
- if (lzName in tonClasses)
926
- return lzName;
884
+ if (lzName in tonClasses) return lzName;
927
885
  const mdName = "md::" + name;
928
- if (mdName in tonClasses)
929
- return mdName;
886
+ if (mdName in tonClasses) return mdName;
930
887
  const clName = "cl::" + name;
931
- if (clName in tonClasses)
932
- return clName;
888
+ if (clName in tonClasses) return clName;
933
889
  const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
934
- if (packetV1Key in tonClasses)
935
- return packetV1Key;
890
+ if (packetV1Key in tonClasses) return packetV1Key;
936
891
  const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
937
- if (packetV1UnderscoreKey in tonClasses)
938
- return packetV1UnderscoreKey;
892
+ if (packetV1UnderscoreKey in tonClasses) return packetV1UnderscoreKey;
939
893
  const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
940
- if (packetV2Key in tonClasses)
941
- return packetV2Key;
894
+ if (packetV2Key in tonClasses) return packetV2Key;
942
895
  const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
943
- if (packetV2UnderscoreKey in tonClasses)
944
- return packetV2UnderscoreKey;
896
+ if (packetV2UnderscoreKey in tonClasses) return packetV2UnderscoreKey;
945
897
  return void 0;
946
898
  }
947
899
  function generateConstructorCodes(className, tonClasses) {
@@ -952,6 +904,10 @@ function generateConstructorCodes(className, tonClasses) {
952
904
  const { constructorInputArgs: inputArgs } = tonClass;
953
905
  const fnName = snakeToCamelCase(`getNew_${className}`);
954
906
  const scratchFnName = snakeToCamelCase(`getNew_${className}FromScratch`);
907
+ let methodIdName = `${className}::New`;
908
+ if (className.includes("::New")) {
909
+ methodIdName = className;
910
+ }
955
911
  tonClass.constructorName = fnName;
956
912
  tonClass.fromScratchConstructorName = scratchFnName;
957
913
  tonClass.nonClassConstructorArgs = {};
@@ -959,7 +915,7 @@ function generateConstructorCodes(className, tonClasses) {
959
915
  async ${fnName}(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
960
916
  ${Object.entries(inputArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
961
917
  }` : ""}): Promise<Cell> {
962
- const getResult = await provider.get('${className}::New', [
918
+ const getResult = await provider.get('${methodIdName}', [
963
919
  ${Object.entries(inputArgs).map(
964
920
  ([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
965
921
  ).join(",\n ")}
@@ -974,7 +930,7 @@ function generateConstructorCodes(className, tonClasses) {
974
930
  async ${fnName}Cell(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
975
931
  ${Object.entries(cellArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType, "Slice", true)}`).join(",\n ")}
976
932
  }` : ""}): Promise<Cell> {
977
- const getResult = await provider.get('${className}::New', [
933
+ const getResult = await provider.get('${methodIdName}', [
978
934
  ${Object.entries(cellArgs).map(
979
935
  ([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
980
936
  ).join(",\n ")}
@@ -1214,12 +1170,12 @@ function recursiveGenDeconstructorCode(classConstructors, key = "") {
1214
1170
  function getSpecificFiles(dirPath, includeName) {
1215
1171
  const files = [];
1216
1172
  function traverseDir(currentPath) {
1217
- const entries = fs2__namespace.readdirSync(currentPath, { withFileTypes: true });
1173
+ const entries = fs__namespace.readdirSync(currentPath, { withFileTypes: true });
1218
1174
  for (const entry of entries) {
1219
- const fullPath = path2__namespace.join(currentPath, entry.name);
1175
+ const fullPath = path__namespace.join(currentPath, entry.name);
1220
1176
  if (entry.isDirectory()) {
1221
1177
  traverseDir(fullPath);
1222
- } else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (path2__namespace.extname(entry.name) === ".fc" || path2__namespace.extname(entry.name) === ".func")) {
1178
+ } else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (path__namespace.extname(entry.name) === ".fc" || path__namespace.extname(entry.name) === ".func")) {
1223
1179
  files.push(fullPath);
1224
1180
  }
1225
1181
  }
@@ -1255,7 +1211,7 @@ export const tonObjects = {
1255
1211
  }
1256
1212
  tsCode += `} as const
1257
1213
  `;
1258
- fs2__namespace.writeFileSync(path2__namespace.resolve(filePath, fileName), tsCode, "utf8");
1214
+ fs__namespace.writeFileSync(path__namespace.resolve(filePath, fileName), tsCode, "utf8");
1259
1215
  }
1260
1216
  function tonConstNameToTSName(name) {
1261
1217
  return name.replace(/::/g, "_");
@@ -1275,7 +1231,7 @@ function extractConstants(fileNames, constType) {
1275
1231
  }
1276
1232
  const result = /* @__PURE__ */ new Map();
1277
1233
  for (const fileName of fileNames) {
1278
- const fileContent = fs2__namespace.readFileSync(fileName, "utf-8");
1234
+ const fileContent = fs__namespace.readFileSync(fileName, "utf-8");
1279
1235
  const lines = fileContent.split("\n");
1280
1236
  for (const line of lines) {
1281
1237
  const trimmedLine = line.trim();
@@ -1324,7 +1280,7 @@ function extractEvents(fileNames) {
1324
1280
  const eventRegex = /^const\s+(?:int\s+)?([\w:]+::[eE][vV][eE][nN][tT]::[\w:]+)\s*=\s*"([\w:]+)"[uc];$/;
1325
1281
  const result = /* @__PURE__ */ new Map();
1326
1282
  for (const fileName of fileNames) {
1327
- const fileContent = fs2__namespace.readFileSync(fileName, "utf-8");
1283
+ const fileContent = fs__namespace.readFileSync(fileName, "utf-8");
1328
1284
  const lines = fileContent.split("\n");
1329
1285
  for (const line of lines) {
1330
1286
  const trimmedLine = line.trim();
@@ -1345,7 +1301,7 @@ export const ${variableName} = {
1345
1301
  ${Array.from(events.entries()).map(([key, [rawValue, intValue]]) => ` ${key}: {stringValue: "${rawValue}", intValue: ${intValue}n},`).join("\n")}
1346
1302
  } as const
1347
1303
  `;
1348
- fs2__namespace.writeFileSync(path2__namespace.join(directory, filename), savedCode);
1304
+ fs__namespace.writeFileSync(path__namespace.join(directory, filename), savedCode);
1349
1305
  }
1350
1306
  function saveConstantsFile(constants, directory, variableName, filename) {
1351
1307
  const savedCode = `${file_signature_header}
@@ -1353,30 +1309,30 @@ export const ${variableName} = {
1353
1309
  ${Array.from(constants.entries()).map(([key, value]) => ` ${key}: ${value}n,`).join("\n")}
1354
1310
  } as const
1355
1311
  `;
1356
- fs2__namespace.writeFileSync(path2__namespace.join(directory, filename), savedCode);
1312
+ fs__namespace.writeFileSync(path__namespace.join(directory, filename), savedCode);
1357
1313
  }
1358
1314
  function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
1359
1315
  const contractDirs = [];
1360
1316
  const viewFunctions = {};
1361
1317
  function findContractDirs(dir) {
1362
- const entries = fs2__namespace.readdirSync(dir, { withFileTypes: true });
1318
+ const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
1363
1319
  const isAContractFolder = entries.some((entry) => !entry.isDirectory() && nameWhitelist.includes(entry.name));
1364
1320
  if (isAContractFolder && !blacklist.some((word) => dir.includes(word))) {
1365
1321
  contractDirs.push(dir);
1366
1322
  }
1367
1323
  entries.forEach((entry) => {
1368
1324
  if (entry.isDirectory()) {
1369
- findContractDirs(path2__namespace.join(dir, entry.name));
1325
+ findContractDirs(path__namespace.join(dir, entry.name));
1370
1326
  }
1371
1327
  });
1372
1328
  }
1373
1329
  findContractDirs(rootDir);
1374
1330
  contractDirs.forEach((dir) => {
1375
- const files = fs2__namespace.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
1331
+ const files = fs__namespace.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
1376
1332
  files.forEach((file) => {
1377
- const filePath = path2__namespace.join(dir, file);
1378
- const contractName = snakeToCamelCase(path2__namespace.basename(path2__namespace.dirname(dir)) + "_" + path2__namespace.basename(dir));
1379
- const content = fs2__namespace.readFileSync(filePath, "utf-8");
1333
+ const filePath = path__namespace.join(dir, file);
1334
+ const contractName = snakeToCamelCase(path__namespace.basename(path__namespace.dirname(dir)) + "_" + path__namespace.basename(dir));
1335
+ const content = fs__namespace.readFileSync(filePath, "utf-8");
1380
1336
  const functionRegex = /(\((?:[^()]+,\s*)*[^()]+\)|[\w:]+)\s+(\w+(?:::\w+)*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{([^}]*)\}/g;
1381
1337
  let match;
1382
1338
  while ((match = functionRegex.exec(content)) !== null) {
@@ -1440,7 +1396,7 @@ import { ExtendedContract, TonContractWrapper } from '../wrappers'
1440
1396
 
1441
1397
  ${generatedFunctions}
1442
1398
  `;
1443
- fs2__namespace.writeFileSync(path2__namespace.join(directory, filename), savedCode);
1399
+ fs__namespace.writeFileSync(path__namespace.join(directory, filename), savedCode);
1444
1400
  }
1445
1401
  var BaseWrapper = class {
1446
1402
  constructor(address, init) {
@@ -1493,6 +1449,16 @@ import {
1493
1449
  } from '@ton/sandbox'
1494
1450
  import { FlatTransactionComparable } from '@ton/test-utils'
1495
1451
 
1452
+ import ChannelArtifact from '@layerzerolabs/layerzero-v2-ton/build/Channel.compiled.json'
1453
+ import ControllerArtifact from '@layerzerolabs/layerzero-v2-ton/build/Controller.compiled.json'
1454
+ import EndpointArtifact from '@layerzerolabs/layerzero-v2-ton/build/Endpoint.compiled.json'
1455
+ import MultiSigArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSig.compiled.json'
1456
+ import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSigOrder.compiled.json'
1457
+ import SmlConnectionArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlConnection.compiled.json'
1458
+ import SmlManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlManager.compiled.json'
1459
+ import ZroMinterArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroMinter.compiled.json'
1460
+ import ZroWalletArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroWallet.compiled.json'
1461
+
1496
1462
  import {
1497
1463
  JettonMinter,
1498
1464
  JettonWallet,
@@ -1502,7 +1468,7 @@ import {
1502
1468
  Profile,
1503
1469
  TransferRequest,
1504
1470
  buildOnchainMetadata,
1505
- getCompiledCode,
1471
+ cellFromArtifact,
1506
1472
  getRandomInt,
1507
1473
  printTransactionTrace,
1508
1474
  } from '@layerzerolabs/ton-sdk-tools'
@@ -1790,6 +1756,10 @@ export async function buildNonceMd(nonce: bigint, allStorages: SandboxContract<T
1790
1756
  return allStorages.getObject('md::Nonce::New', [{ type: 'int', value: nonce }])
1791
1757
  }
1792
1758
 
1759
+ export async function buildLzReceivePrepareMd(nonce: bigint, nanotons: bigint, allStorages: SandboxContract<TonContractWrapper>): Promise<Cell> {
1760
+ return allStorages.getObject('md::LzReceivePrepare::New', [{ type: 'int', value: nonce }, { type: 'int', value: nanotons }])
1761
+ }
1762
+
1793
1763
  export function buildMessageBody(donationNanos: number, origin: Address, opcode: number, md: Cell): Cell {
1794
1764
  return beginMessage(opcode)
1795
1765
  .storeUint(donationNanos, 64)
@@ -2418,9 +2388,9 @@ export async function getZroWallet(
2418
2388
  {
2419
2389
  admin: ownerAddress,
2420
2390
  content: buildOnchainMetadata(zroOnchainMetaData),
2421
- wallet_code: getCompiledCode('ZroWallet'),
2391
+ wallet_code: cellFromArtifact(ZroWalletArtifact),
2422
2392
  },
2423
- getCompiledCode('ZroMinter')
2393
+ cellFromArtifact(ZroMinterArtifact)
2424
2394
  )
2425
2395
  )
2426
2396
 
@@ -2447,12 +2417,12 @@ export async function openAndDeployControllerViaMultiSig(
2447
2417
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2448
2418
  const controller: SandboxContract<TonContractWrapper> = blockchain.openContract(
2449
2419
  TonContractWrapper.create(
2450
- getCompiledCode('Controller'),
2420
+ cellFromArtifact(ControllerArtifact),
2451
2421
  await allStorages.getNewControllerCell({
2452
2422
  owner: addressToBigInt(multiSigContract.address),
2453
2423
  eid,
2454
- endpointCode: getCompiledCode('Endpoint'),
2455
- channelCode: getCompiledCode('Channel'),
2424
+ endpointCode: cellFromArtifact(EndpointArtifact),
2425
+ channelCode: cellFromArtifact(ChannelArtifact),
2456
2426
  })
2457
2427
  )
2458
2428
  )
@@ -2530,7 +2500,7 @@ export async function openAndDeployEndpoint(
2530
2500
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2531
2501
  const endpoint: SandboxContract<TonContractWrapper> = blockchain.openContract(
2532
2502
  TonContractWrapper.create(
2533
- getCompiledCode('Endpoint'),
2503
+ cellFromArtifact(EndpointArtifact),
2534
2504
  await controller.getNewEndpointCell({
2535
2505
  eid: srcEid,
2536
2506
  dstEid: dstEid,
@@ -2583,7 +2553,7 @@ export async function openAndDeployChannel(
2583
2553
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2584
2554
  const channel: SandboxContract<TonContractWrapper> = blockchain.openContract(
2585
2555
  TonContractWrapper.create(
2586
- getCompiledCode('Channel'),
2556
+ cellFromArtifact(ChannelArtifact),
2587
2557
  await srcFixture.controller.getNewChannelCell({
2588
2558
  owner: addressToBigInt(srcFixture.controller.address),
2589
2559
  path: srcFixture.path,
@@ -2636,15 +2606,15 @@ export async function openAndDeploySmlManager(
2636
2606
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2637
2607
  const smlManager: SandboxContract<TonContractWrapper> = blockchain.openContract(
2638
2608
  TonContractWrapper.create(
2639
- getCompiledCode('SmlManager'),
2609
+ cellFromArtifact(SmlManagerArtifact),
2640
2610
  await allStorages.getNewSmlManagerCell({
2641
2611
  owner: addressToBigInt(fixture.owner.address),
2642
2612
  eid: fixture.eid,
2643
2613
  version,
2644
2614
  controllerAddress: addressToBigInt(fixture.controller.address),
2645
- endpointCode: getCompiledCode('Endpoint'),
2646
- channelCode: getCompiledCode('Channel'),
2647
- smlConnectionCode: getCompiledCode('SmlConnection'),
2615
+ endpointCode: cellFromArtifact(EndpointArtifact),
2616
+ channelCode: cellFromArtifact(ChannelArtifact),
2617
+ smlConnectionCode: cellFromArtifact(SmlConnectionArtifact),
2648
2618
  })
2649
2619
  )
2650
2620
  )
@@ -2677,7 +2647,7 @@ export async function openAndDeploySmlConnection(
2677
2647
  ): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
2678
2648
  const smlConnection: SandboxContract<TonContractWrapper> = blockchain.openContract(
2679
2649
  TonContractWrapper.create(
2680
- getCompiledCode('SmlConnection'),
2650
+ cellFromArtifact(SmlConnectionArtifact),
2681
2651
  await allStorages.getNewSmlConnectionCell({
2682
2652
  owner: addressToBigInt(smlManager.address),
2683
2653
  path: srcFixture.path,
@@ -2708,7 +2678,7 @@ export async function openAndDeploySmlConnection(
2708
2678
  {
2709
2679
  from: srcFixture.oApp.address,
2710
2680
  to: smlManager.address,
2711
- op: Number(OPCODES.SmlManager_OP_DEPLOY_CONNECTION),
2681
+ op: Number(OPCODES.MsglibManager_OP_DEPLOY_CONNECTION),
2712
2682
  success: true,
2713
2683
  },
2714
2684
  {
@@ -2847,7 +2817,7 @@ export async function setupFixture(
2847
2817
 
2848
2818
  // =============================set up 3/3 multi-sig as the controller owner================================
2849
2819
 
2850
- addLibToBlockchain(blockchain, getCompiledCode('MultiSigOrder'))
2820
+ addLibToBlockchain(blockchain, cellFromArtifact(MultiSigOrderArtifact))
2851
2821
 
2852
2822
  const multiSigners = [multiSigOwner1, multiSigOwner2, multiSigOwner3]
2853
2823
  const proposers = await blockchain.createWallets(getRandomInt(10, 20))
@@ -2860,7 +2830,7 @@ export async function setupFixture(
2860
2830
  }
2861
2831
 
2862
2832
  const multiSigContract = blockchain.openContract(
2863
- Multisig.createFromConfig(multiSigConfig, getCompiledCode('MultiSig'))
2833
+ Multisig.createFromConfig(multiSigConfig, cellFromArtifact(MultiSigArtifact))
2864
2834
  )
2865
2835
 
2866
2836
  // deploy the multisig contract
@@ -2906,9 +2876,9 @@ export async function setupFixture(
2906
2876
  {
2907
2877
  admin: multiSigOwner1.address,
2908
2878
  content: buildOnchainMetadata(zroOnchainMetaData),
2909
- wallet_code: getCompiledCode('ZroWallet'),
2879
+ wallet_code: cellFromArtifact(ZroWalletArtifact),
2910
2880
  },
2911
- getCompiledCode('ZroMinter')
2881
+ cellFromArtifact(ZroMinterArtifact)
2912
2882
  )
2913
2883
  )
2914
2884
 
@@ -3177,7 +3147,7 @@ export async function wireFixturesTogetherWithSML(
3177
3147
  )
3178
3148
  }
3179
3149
  `;
3180
- fs2__namespace.default.writeFileSync(path2__namespace.default.join(directory, filename), savedCode);
3150
+ fs__namespace.default.writeFileSync(path__namespace.default.join(directory, filename), savedCode);
3181
3151
  }
3182
3152
 
3183
3153
  // src/externalWrappers/Multisig-Constants.ts
@@ -3481,15 +3451,12 @@ var getMsgPrices = (configRaw, workchain) => {
3481
3451
  };
3482
3452
  };
3483
3453
  var storageCollected = (trans) => {
3484
- if (trans.description.type !== "generic")
3485
- throw new Error("Expected generic transaction");
3454
+ if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
3486
3455
  return trans.description.storagePhase ? trans.description.storagePhase.storageFeesCollected : 0n;
3487
3456
  };
3488
3457
  var computedGeneric = (trans) => {
3489
- if (trans.description.type !== "generic")
3490
- throw new Error("Expected generic transaction");
3491
- if (trans.description.computePhase.type !== "vm")
3492
- throw new Error("Compute phase expected");
3458
+ if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
3459
+ if (trans.description.computePhase.type !== "vm") throw new Error("Compute phase expected");
3493
3460
  return trans.description.computePhase;
3494
3461
  };
3495
3462
  var Txiterator = class {
@@ -3506,8 +3473,7 @@ var Txiterator = class {
3506
3473
  throw new Error("MsgQueued is undefined");
3507
3474
  }
3508
3475
  const inMsg = curMsg.msg;
3509
- if (inMsg.info.type !== "internal")
3510
- throw new Error("Internal only");
3476
+ if (inMsg.info.type !== "internal") throw new Error("Internal only");
3511
3477
  const smc = await this.blockchain.getContract(inMsg.info.dest);
3512
3478
  const res = await smc.receiveMessage(inMsg, { now: this.blockchain.now });
3513
3479
  const bcRes = {
@@ -3846,20 +3812,20 @@ var decimalCount = 9;
3846
3812
  var decimal = pow10(decimalCount);
3847
3813
  var defaultPath = "gasInfo";
3848
3814
  function createDirectoryIfNotExist(directoryPath) {
3849
- if (!fs2__namespace.existsSync(directoryPath)) {
3850
- fs2__namespace.mkdirSync(directoryPath, { recursive: true });
3815
+ if (!fs__namespace.existsSync(directoryPath)) {
3816
+ fs__namespace.mkdirSync(directoryPath, { recursive: true });
3851
3817
  }
3852
3818
  }
3853
3819
  function sortAndSave(filePath, gasInfo) {
3854
3820
  const entries = Object.entries(gasInfo);
3855
3821
  const sortedEntries = entries.sort(([, valueA], [, valueB]) => parseFloat(valueA) - parseFloat(valueB));
3856
3822
  const jsonData = JSON.stringify(Object.fromEntries(sortedEntries), null, 2);
3857
- fs2__namespace.writeFileSync(filePath, `${jsonData}
3823
+ fs__namespace.writeFileSync(filePath, `${jsonData}
3858
3824
  `, "utf8");
3859
3825
  }
3860
3826
  function readOrCreateJsonFile(filePath) {
3861
- if (fs2__namespace.existsSync(filePath)) {
3862
- const fileContent = fs2__namespace.readFileSync(filePath, "utf8");
3827
+ if (fs__namespace.existsSync(filePath)) {
3828
+ const fileContent = fs__namespace.readFileSync(filePath, "utf8");
3863
3829
  return JSON.parse(fileContent);
3864
3830
  } else {
3865
3831
  return {};
@@ -3887,8 +3853,7 @@ function formatCoinsPure(value, precision = 6) {
3887
3853
  return `${whole.toString()}${frac !== 0n ? "." + frac.toString().padStart(precision, "0").replace(/0+$/, "") : ""}`;
3888
3854
  }
3889
3855
  function formatCoins(value, precision = 6) {
3890
- if (value === void 0)
3891
- return "N/A";
3856
+ if (value === void 0) return "N/A";
3892
3857
  return formatCoinsPure(value, precision);
3893
3858
  }
3894
3859
  function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
@@ -3900,13 +3865,12 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3900
3865
  let filePath = profile?.filePath ?? defaultPath;
3901
3866
  if (profile?.profileGas) {
3902
3867
  createDirectoryIfNotExist(filePath);
3903
- filePath = path2__namespace.default.join(filePath, `${profile.fileName}.json`);
3868
+ filePath = path__namespace.default.join(filePath, `${profile.fileName}.json`);
3904
3869
  gasInfo = readOrCreateJsonFile(filePath);
3905
3870
  }
3906
3871
  console.table(
3907
3872
  transactions.map((tx) => {
3908
- if (tx.description.type !== "generic")
3909
- return void 0;
3873
+ if (tx.description.type !== "generic") return void 0;
3910
3874
  const body = tx.inMessage?.info.type === "internal" ? tx.inMessage.body.beginParse() : void 0;
3911
3875
  const op = body === void 0 ? 0n : body.remainingBits >= 32 ? body.preloadUint(32) : 0n;
3912
3876
  const totalFees = formatCoins(tx.totalFees.coins);
@@ -3929,8 +3893,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3929
3893
  const addressString = tx.address.toString(16).length != 64 ? "UNKNOWN" : core.Address.parseRaw("1:" + tx.address.toString(16));
3930
3894
  const opString = op.toString() in opcodeInfo ? opcodeInfo[op.toString()] : op.toString();
3931
3895
  cumulativeFees += tx.totalFees.coins + (tx.description.actionPhase?.totalFwdFees ?? 0n);
3932
- if (profile?.profileGas)
3933
- gasInfo[opString] = formatCoins(cumulativeFees);
3896
+ if (profile?.profileGas) gasInfo[opString] = formatCoins(cumulativeFees);
3934
3897
  return {
3935
3898
  address: addressString,
3936
3899
  op: opString,
@@ -3947,8 +3910,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
3947
3910
  };
3948
3911
  }).filter((v) => v !== void 0)
3949
3912
  );
3950
- if (profile?.profileGas)
3951
- sortAndSave(filePath, gasInfo);
3913
+ if (profile?.profileGas) sortAndSave(filePath, gasInfo);
3952
3914
  }
3953
3915
 
3954
3916
  exports.BASE_CHAIN_ID = BASE_CHAIN_ID;
@@ -3966,29 +3928,25 @@ exports.Op = Op;
3966
3928
  exports.Order = Order;
3967
3929
  exports.Txiterator = Txiterator;
3968
3930
  exports.addressToBigInt = addressToBigInt;
3969
- exports.assertActiveCell = assertActiveCell;
3970
3931
  exports.beginMessage = beginMessage;
3971
3932
  exports.bigintToAddress = bigintToAddress;
3972
3933
  exports.buildOnchainMetadata = buildOnchainMetadata;
3934
+ exports.cellFromArtifact = cellFromArtifact;
3973
3935
  exports.computedGeneric = computedGeneric;
3974
3936
  exports.differentAddress = differentAddress;
3975
3937
  exports.executeFrom = executeFrom;
3976
3938
  exports.executeTill = executeTill;
3977
3939
  exports.extractConstants = extractConstants;
3978
3940
  exports.extractEvents = extractEvents;
3941
+ exports.findDeepestCell = findDeepestCell;
3979
3942
  exports.findTransaction = findTransaction;
3980
3943
  exports.formatCoinsPure = formatCoinsPure;
3981
3944
  exports.generateAllViewFunctions = generateAllViewFunctions;
3982
3945
  exports.generateTestUtilsCode = generateTestUtilsCode;
3983
- exports.getCompiledCode = getCompiledCode;
3984
- exports.getContractsCodePath = getContractsCodePath;
3985
- exports.getContractsPath = getContractsPath;
3986
3946
  exports.getMsgPrices = getMsgPrices;
3987
3947
  exports.getOpcodeCRC = getOpcodeCRC;
3988
3948
  exports.getRandom = getRandom;
3989
3949
  exports.getRandomInt = getRandomInt;
3990
- exports.getSdkCodePath = getSdkCodePath;
3991
- exports.getSdkPath = getSdkPath;
3992
3950
  exports.getSpecificFiles = getSpecificFiles;
3993
3951
  exports.jettonContentToCell = jettonContentToCell;
3994
3952
  exports.jettonMinterConfigToCell = jettonMinterConfigToCell;
@@ -4013,5 +3971,5 @@ exports.saveViewFunctions = saveViewFunctions;
4013
3971
  exports.sendRequest = sendRequest;
4014
3972
  exports.storageCollected = storageCollected;
4015
3973
  exports.to32ByteBuffer = to32ByteBuffer;
4016
- //# sourceMappingURL=out.js.map
3974
+ //# sourceMappingURL=index.cjs.map
4017
3975
  //# sourceMappingURL=index.cjs.map