@layerzerolabs/ton-sdk-tools 3.0.12-ton.0 → 3.0.13-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/CHANGELOG.md +6 -0
- package/dist/index.cjs +68 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.mjs +68 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cell, Builder, ContractProvider, Sender, SenderArguments, Address, SendMode, Contract, Transaction, TransactionComputeVm, Message } from '@ton/core';
|
|
2
2
|
import { BlockchainTransaction, Blockchain } from '@ton/sandbox';
|
|
3
3
|
import { FlatTransactionComparable } from '@ton/test-utils';
|
|
4
4
|
|
|
@@ -78,12 +78,18 @@ declare function saveConstantsFile(constants: Map<string, bigint>, directory: st
|
|
|
78
78
|
declare function generateAllViewFunctions(rootDir: string, nameWhitelist: string[], blacklist: string[]): TonViewFunctionsDict;
|
|
79
79
|
declare function saveViewFunctions(viewFunctions: TonViewFunctionsDict, directory: string, filename: string): void;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Wraps a blueprint-like artifact in a `Cell`. The constrains on the input type are loosened
|
|
83
|
+
* and only the `hex` property is made required.
|
|
84
|
+
*
|
|
85
|
+
* @param artifact Blueprint JSON artifact object
|
|
86
|
+
* @returns {Cell}
|
|
87
|
+
*/
|
|
88
|
+
declare const cellFromArtifact: ({ hex }: {
|
|
89
|
+
hex: string;
|
|
90
|
+
hash?: string | undefined;
|
|
91
|
+
hashBase64?: string | undefined;
|
|
92
|
+
}) => Cell;
|
|
87
93
|
declare function getOpcodeCRC(input: string): bigint;
|
|
88
94
|
declare const MASTER_CHAIN_ID = -1;
|
|
89
95
|
declare const BASE_CHAIN_ID = 0;
|
|
@@ -439,4 +445,4 @@ declare function printTransactionTrace(transactions: Transaction[], opcodeInfo:
|
|
|
439
445
|
[p: string]: string;
|
|
440
446
|
}, callerStack?: string, profile?: Profile): void;
|
|
441
447
|
|
|
442
|
-
export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type MetaType, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt,
|
|
448
|
+
export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type MetaType, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, beginMessage, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractConstants, extractEvents, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cell, Builder, ContractProvider, Sender, SenderArguments, Address, SendMode, Contract, Transaction, TransactionComputeVm, Message } from '@ton/core';
|
|
2
2
|
import { BlockchainTransaction, Blockchain } from '@ton/sandbox';
|
|
3
3
|
import { FlatTransactionComparable } from '@ton/test-utils';
|
|
4
4
|
|
|
@@ -78,12 +78,18 @@ declare function saveConstantsFile(constants: Map<string, bigint>, directory: st
|
|
|
78
78
|
declare function generateAllViewFunctions(rootDir: string, nameWhitelist: string[], blacklist: string[]): TonViewFunctionsDict;
|
|
79
79
|
declare function saveViewFunctions(viewFunctions: TonViewFunctionsDict, directory: string, filename: string): void;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Wraps a blueprint-like artifact in a `Cell`. The constrains on the input type are loosened
|
|
83
|
+
* and only the `hex` property is made required.
|
|
84
|
+
*
|
|
85
|
+
* @param artifact Blueprint JSON artifact object
|
|
86
|
+
* @returns {Cell}
|
|
87
|
+
*/
|
|
88
|
+
declare const cellFromArtifact: ({ hex }: {
|
|
89
|
+
hex: string;
|
|
90
|
+
hash?: string | undefined;
|
|
91
|
+
hashBase64?: string | undefined;
|
|
92
|
+
}) => Cell;
|
|
87
93
|
declare function getOpcodeCRC(input: string): bigint;
|
|
88
94
|
declare const MASTER_CHAIN_ID = -1;
|
|
89
95
|
declare const BASE_CHAIN_ID = 0;
|
|
@@ -439,4 +445,4 @@ declare function printTransactionTrace(transactions: Transaction[], opcodeInfo:
|
|
|
439
445
|
[p: string]: string;
|
|
440
446
|
}, callerStack?: string, profile?: Profile): void;
|
|
441
447
|
|
|
442
|
-
export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type MetaType, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt,
|
|
448
|
+
export { type Action, type Attribute, BASE_CHAIN_ID, BaseWrapper, type ConstructorArgs, type ConstructorCallGenerator, Errors, type FieldMap, type GasInfo, type InverseFieldMap, JettonMinter, type JettonMinterConfig, type JettonMinterContent, JettonWallet, type JettonWalletConfig, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, type MetaType, type Module, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, type MultisigConfig, type MultisigData, Op, Order, type OrderFullConfig, type OrderInitConfig, type Profile, type SendRequestOptions, type TonObject, type TonObjectsDict, type TonViewFunction, type TonViewFunctionsDict, type TransferRequest, Txiterator, type UpdateRequest, addressToBigInt, beginMessage, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractConstants, extractEvents, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
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
|
-
|
|
13
|
-
|
|
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
|
}
|
|
@@ -309,15 +251,15 @@ function mergeInputArgs(result, added) {
|
|
|
309
251
|
}
|
|
310
252
|
function parseDirectory(directoryPath) {
|
|
311
253
|
let result = {};
|
|
312
|
-
const items =
|
|
254
|
+
const items = fs.readdirSync(directoryPath);
|
|
313
255
|
items.forEach((item) => {
|
|
314
|
-
const itemPath =
|
|
315
|
-
const stats =
|
|
256
|
+
const itemPath = path.join(directoryPath, item);
|
|
257
|
+
const stats = fs.statSync(itemPath);
|
|
316
258
|
if (itemPath.includes("base_storage")) ;
|
|
317
259
|
if (stats.isDirectory()) {
|
|
318
260
|
result = mergeConstructorDicts(result, parseDirectory(itemPath));
|
|
319
|
-
} else if (stats.isFile() &&
|
|
320
|
-
const content =
|
|
261
|
+
} else if (stats.isFile() && path.extname(item) === ".fc" && !itemPath.includes("@ston-fi")) {
|
|
262
|
+
const content = fs.readFileSync(itemPath, "utf8");
|
|
321
263
|
result = mergeConstructorDicts(result, parseClasses(content));
|
|
322
264
|
}
|
|
323
265
|
});
|
|
@@ -563,7 +505,7 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
563
505
|
${generatedMethods}
|
|
564
506
|
}
|
|
565
507
|
`;
|
|
566
|
-
|
|
508
|
+
fs.writeFileSync(path.join(directory, "TonContractWrapper.ts"), savedCode);
|
|
567
509
|
}
|
|
568
510
|
function saveAllTypes(tonObjects, directory) {
|
|
569
511
|
const generatedTypes = Object.entries(tonObjects).filter(([_, tonObject]) => tonObject.attributes.length > 0).map(([_, tonObject]) => "export " + (tonObject.tsTypeCode ?? "")).join("");
|
|
@@ -620,7 +562,7 @@ ${generatedTypes}
|
|
|
620
562
|
|
|
621
563
|
${generatedNameMap}
|
|
622
564
|
`;
|
|
623
|
-
|
|
565
|
+
fs.writeFileSync(path.join(directory, "allTypes.ts"), savedCode);
|
|
624
566
|
}
|
|
625
567
|
function saveTonObjectUnwrapper(tonObjects, directory) {
|
|
626
568
|
const allTypes = [
|
|
@@ -868,7 +810,7 @@ export class TonObjectUnwrapper {
|
|
|
868
810
|
${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructorCode ?? "").join("\n")}
|
|
869
811
|
}
|
|
870
812
|
`;
|
|
871
|
-
|
|
813
|
+
fs.writeFileSync(path.join(directory, "TonObjectUnwrapper.ts"), savedCode);
|
|
872
814
|
}
|
|
873
815
|
function findClass(tonClasses, name) {
|
|
874
816
|
if (name in tonClasses)
|
|
@@ -1192,12 +1134,12 @@ function recursiveGenDeconstructorCode(classConstructors, key = "") {
|
|
|
1192
1134
|
function getSpecificFiles(dirPath, includeName) {
|
|
1193
1135
|
const files = [];
|
|
1194
1136
|
function traverseDir(currentPath) {
|
|
1195
|
-
const entries =
|
|
1137
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
1196
1138
|
for (const entry of entries) {
|
|
1197
|
-
const fullPath =
|
|
1139
|
+
const fullPath = path.join(currentPath, entry.name);
|
|
1198
1140
|
if (entry.isDirectory()) {
|
|
1199
1141
|
traverseDir(fullPath);
|
|
1200
|
-
} else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (
|
|
1142
|
+
} else if (entry.isFile() && entry.name.toLowerCase().includes(includeName) && (path.extname(entry.name) === ".fc" || path.extname(entry.name) === ".func")) {
|
|
1201
1143
|
files.push(fullPath);
|
|
1202
1144
|
}
|
|
1203
1145
|
}
|
|
@@ -1233,7 +1175,7 @@ export const tonObjects = {
|
|
|
1233
1175
|
}
|
|
1234
1176
|
tsCode += `} as const
|
|
1235
1177
|
`;
|
|
1236
|
-
|
|
1178
|
+
fs.writeFileSync(path.resolve(filePath, fileName), tsCode, "utf8");
|
|
1237
1179
|
}
|
|
1238
1180
|
function tonConstNameToTSName(name) {
|
|
1239
1181
|
return name.replace(/::/g, "_");
|
|
@@ -1253,7 +1195,7 @@ function extractConstants(fileNames, constType) {
|
|
|
1253
1195
|
}
|
|
1254
1196
|
const result = /* @__PURE__ */ new Map();
|
|
1255
1197
|
for (const fileName of fileNames) {
|
|
1256
|
-
const fileContent =
|
|
1198
|
+
const fileContent = fs.readFileSync(fileName, "utf-8");
|
|
1257
1199
|
const lines = fileContent.split("\n");
|
|
1258
1200
|
for (const line of lines) {
|
|
1259
1201
|
const trimmedLine = line.trim();
|
|
@@ -1302,7 +1244,7 @@ function extractEvents(fileNames) {
|
|
|
1302
1244
|
const eventRegex = /^const\s+(?:int\s+)?([\w:]+::[eE][vV][eE][nN][tT]::[\w:]+)\s*=\s*"([\w:]+)"[uc];$/;
|
|
1303
1245
|
const result = /* @__PURE__ */ new Map();
|
|
1304
1246
|
for (const fileName of fileNames) {
|
|
1305
|
-
const fileContent =
|
|
1247
|
+
const fileContent = fs.readFileSync(fileName, "utf-8");
|
|
1306
1248
|
const lines = fileContent.split("\n");
|
|
1307
1249
|
for (const line of lines) {
|
|
1308
1250
|
const trimmedLine = line.trim();
|
|
@@ -1323,7 +1265,7 @@ export const ${variableName} = {
|
|
|
1323
1265
|
${Array.from(events.entries()).map(([key, [rawValue, intValue]]) => ` ${key}: {stringValue: "${rawValue}", intValue: ${intValue}n},`).join("\n")}
|
|
1324
1266
|
} as const
|
|
1325
1267
|
`;
|
|
1326
|
-
|
|
1268
|
+
fs.writeFileSync(path.join(directory, filename), savedCode);
|
|
1327
1269
|
}
|
|
1328
1270
|
function saveConstantsFile(constants, directory, variableName, filename) {
|
|
1329
1271
|
const savedCode = `${file_signature_header}
|
|
@@ -1331,30 +1273,30 @@ export const ${variableName} = {
|
|
|
1331
1273
|
${Array.from(constants.entries()).map(([key, value]) => ` ${key}: ${value}n,`).join("\n")}
|
|
1332
1274
|
} as const
|
|
1333
1275
|
`;
|
|
1334
|
-
|
|
1276
|
+
fs.writeFileSync(path.join(directory, filename), savedCode);
|
|
1335
1277
|
}
|
|
1336
1278
|
function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
|
|
1337
1279
|
const contractDirs = [];
|
|
1338
1280
|
const viewFunctions = {};
|
|
1339
1281
|
function findContractDirs(dir) {
|
|
1340
|
-
const entries =
|
|
1282
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1341
1283
|
const isAContractFolder = entries.some((entry) => !entry.isDirectory() && nameWhitelist.includes(entry.name));
|
|
1342
1284
|
if (isAContractFolder && !blacklist.some((word) => dir.includes(word))) {
|
|
1343
1285
|
contractDirs.push(dir);
|
|
1344
1286
|
}
|
|
1345
1287
|
entries.forEach((entry) => {
|
|
1346
1288
|
if (entry.isDirectory()) {
|
|
1347
|
-
findContractDirs(
|
|
1289
|
+
findContractDirs(path.join(dir, entry.name));
|
|
1348
1290
|
}
|
|
1349
1291
|
});
|
|
1350
1292
|
}
|
|
1351
1293
|
findContractDirs(rootDir);
|
|
1352
1294
|
contractDirs.forEach((dir) => {
|
|
1353
|
-
const files =
|
|
1295
|
+
const files = fs.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
|
|
1354
1296
|
files.forEach((file) => {
|
|
1355
|
-
const filePath =
|
|
1356
|
-
const contractName = snakeToCamelCase(
|
|
1357
|
-
const content =
|
|
1297
|
+
const filePath = path.join(dir, file);
|
|
1298
|
+
const contractName = snakeToCamelCase(path.basename(path.dirname(dir)) + "_" + path.basename(dir));
|
|
1299
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
1358
1300
|
const functionRegex = /(\((?:[^()]+,\s*)*[^()]+\)|[\w:]+)\s+(\w+(?:::\w+)*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{([^}]*)\}/g;
|
|
1359
1301
|
let match;
|
|
1360
1302
|
while ((match = functionRegex.exec(content)) !== null) {
|
|
@@ -1418,7 +1360,7 @@ import { ExtendedContract, TonContractWrapper } from '../wrappers'
|
|
|
1418
1360
|
|
|
1419
1361
|
${generatedFunctions}
|
|
1420
1362
|
`;
|
|
1421
|
-
|
|
1363
|
+
fs.writeFileSync(path.join(directory, filename), savedCode);
|
|
1422
1364
|
}
|
|
1423
1365
|
var BaseWrapper = class {
|
|
1424
1366
|
constructor(address, init) {
|
|
@@ -1471,6 +1413,16 @@ import {
|
|
|
1471
1413
|
} from '@ton/sandbox'
|
|
1472
1414
|
import { FlatTransactionComparable } from '@ton/test-utils'
|
|
1473
1415
|
|
|
1416
|
+
import ChannelArtifact from '@layerzerolabs/layerzero-v2-ton/build/Channel.compiled.json'
|
|
1417
|
+
import ControllerArtifact from '@layerzerolabs/layerzero-v2-ton/build/Controller.compiled.json'
|
|
1418
|
+
import EndpointArtifact from '@layerzerolabs/layerzero-v2-ton/build/Endpoint.compiled.json'
|
|
1419
|
+
import MultiSigArtifact from '@layerzerolabs/layerzero-v2-ton/build/MultiSig.compiled.json'
|
|
1420
|
+
import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/build/MultiSigOrder.compiled.json'
|
|
1421
|
+
import SmlConnectionArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlConnection.compiled.json'
|
|
1422
|
+
import SmlManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlManager.compiled.json'
|
|
1423
|
+
import ZroMinterArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroMinter.compiled.json'
|
|
1424
|
+
import ZroWalletArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroWallet.compiled.json'
|
|
1425
|
+
|
|
1474
1426
|
import {
|
|
1475
1427
|
JettonMinter,
|
|
1476
1428
|
JettonWallet,
|
|
@@ -1480,7 +1432,7 @@ import {
|
|
|
1480
1432
|
Profile,
|
|
1481
1433
|
TransferRequest,
|
|
1482
1434
|
buildOnchainMetadata,
|
|
1483
|
-
|
|
1435
|
+
cellFromArtifact,
|
|
1484
1436
|
getRandomInt,
|
|
1485
1437
|
printTransactionTrace,
|
|
1486
1438
|
} from '@layerzerolabs/ton-sdk-tools'
|
|
@@ -1768,6 +1720,10 @@ export async function buildNonceMd(nonce: bigint, allStorages: SandboxContract<T
|
|
|
1768
1720
|
return allStorages.getObject('md::Nonce::New', [{ type: 'int', value: nonce }])
|
|
1769
1721
|
}
|
|
1770
1722
|
|
|
1723
|
+
export async function buildLzReceivePrepareMd(nonce: bigint, nanotons: bigint, allStorages: SandboxContract<TonContractWrapper>): Promise<Cell> {
|
|
1724
|
+
return allStorages.getObject('md::LzReceivePrepare::New', [{ type: 'int', value: nonce }, { type: 'int', value: nanotons }])
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1771
1727
|
export function buildMessageBody(donationNanos: number, origin: Address, opcode: number, md: Cell): Cell {
|
|
1772
1728
|
return beginMessage(opcode)
|
|
1773
1729
|
.storeUint(donationNanos, 64)
|
|
@@ -2396,9 +2352,9 @@ export async function getZroWallet(
|
|
|
2396
2352
|
{
|
|
2397
2353
|
admin: ownerAddress,
|
|
2398
2354
|
content: buildOnchainMetadata(zroOnchainMetaData),
|
|
2399
|
-
wallet_code:
|
|
2355
|
+
wallet_code: cellFromArtifact(ZroWalletArtifact),
|
|
2400
2356
|
},
|
|
2401
|
-
|
|
2357
|
+
cellFromArtifact(ZroMinterArtifact)
|
|
2402
2358
|
)
|
|
2403
2359
|
)
|
|
2404
2360
|
|
|
@@ -2425,12 +2381,12 @@ export async function openAndDeployControllerViaMultiSig(
|
|
|
2425
2381
|
): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
|
|
2426
2382
|
const controller: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2427
2383
|
TonContractWrapper.create(
|
|
2428
|
-
|
|
2384
|
+
cellFromArtifact(ControllerArtifact),
|
|
2429
2385
|
await allStorages.getNewControllerCell({
|
|
2430
2386
|
owner: addressToBigInt(multiSigContract.address),
|
|
2431
2387
|
eid,
|
|
2432
|
-
endpointCode:
|
|
2433
|
-
channelCode:
|
|
2388
|
+
endpointCode: cellFromArtifact(EndpointArtifact),
|
|
2389
|
+
channelCode: cellFromArtifact(ChannelArtifact),
|
|
2434
2390
|
})
|
|
2435
2391
|
)
|
|
2436
2392
|
)
|
|
@@ -2508,7 +2464,7 @@ export async function openAndDeployEndpoint(
|
|
|
2508
2464
|
): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
|
|
2509
2465
|
const endpoint: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2510
2466
|
TonContractWrapper.create(
|
|
2511
|
-
|
|
2467
|
+
cellFromArtifact(EndpointArtifact),
|
|
2512
2468
|
await controller.getNewEndpointCell({
|
|
2513
2469
|
eid: srcEid,
|
|
2514
2470
|
dstEid: dstEid,
|
|
@@ -2561,7 +2517,7 @@ export async function openAndDeployChannel(
|
|
|
2561
2517
|
): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
|
|
2562
2518
|
const channel: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2563
2519
|
TonContractWrapper.create(
|
|
2564
|
-
|
|
2520
|
+
cellFromArtifact(ChannelArtifact),
|
|
2565
2521
|
await srcFixture.controller.getNewChannelCell({
|
|
2566
2522
|
owner: addressToBigInt(srcFixture.controller.address),
|
|
2567
2523
|
path: srcFixture.path,
|
|
@@ -2614,15 +2570,15 @@ export async function openAndDeploySmlManager(
|
|
|
2614
2570
|
): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
|
|
2615
2571
|
const smlManager: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2616
2572
|
TonContractWrapper.create(
|
|
2617
|
-
|
|
2573
|
+
cellFromArtifact(SmlManagerArtifact),
|
|
2618
2574
|
await allStorages.getNewSmlManagerCell({
|
|
2619
2575
|
owner: addressToBigInt(fixture.owner.address),
|
|
2620
2576
|
eid: fixture.eid,
|
|
2621
2577
|
version,
|
|
2622
2578
|
controllerAddress: addressToBigInt(fixture.controller.address),
|
|
2623
|
-
endpointCode:
|
|
2624
|
-
channelCode:
|
|
2625
|
-
smlConnectionCode:
|
|
2579
|
+
endpointCode: cellFromArtifact(EndpointArtifact),
|
|
2580
|
+
channelCode: cellFromArtifact(ChannelArtifact),
|
|
2581
|
+
smlConnectionCode: cellFromArtifact(SmlConnectionArtifact),
|
|
2626
2582
|
})
|
|
2627
2583
|
)
|
|
2628
2584
|
)
|
|
@@ -2655,7 +2611,7 @@ export async function openAndDeploySmlConnection(
|
|
|
2655
2611
|
): Promise<[SandboxContract<TonContractWrapper>, SendMessageResult]> {
|
|
2656
2612
|
const smlConnection: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2657
2613
|
TonContractWrapper.create(
|
|
2658
|
-
|
|
2614
|
+
cellFromArtifact(SmlConnectionArtifact),
|
|
2659
2615
|
await allStorages.getNewSmlConnectionCell({
|
|
2660
2616
|
owner: addressToBigInt(smlManager.address),
|
|
2661
2617
|
path: srcFixture.path,
|
|
@@ -2825,7 +2781,7 @@ export async function setupFixture(
|
|
|
2825
2781
|
|
|
2826
2782
|
// =============================set up 3/3 multi-sig as the controller owner================================
|
|
2827
2783
|
|
|
2828
|
-
addLibToBlockchain(blockchain,
|
|
2784
|
+
addLibToBlockchain(blockchain, cellFromArtifact(MultiSigOrderArtifact))
|
|
2829
2785
|
|
|
2830
2786
|
const multiSigners = [multiSigOwner1, multiSigOwner2, multiSigOwner3]
|
|
2831
2787
|
const proposers = await blockchain.createWallets(getRandomInt(10, 20))
|
|
@@ -2838,7 +2794,7 @@ export async function setupFixture(
|
|
|
2838
2794
|
}
|
|
2839
2795
|
|
|
2840
2796
|
const multiSigContract = blockchain.openContract(
|
|
2841
|
-
Multisig.createFromConfig(multiSigConfig,
|
|
2797
|
+
Multisig.createFromConfig(multiSigConfig, cellFromArtifact(MultiSigArtifact))
|
|
2842
2798
|
)
|
|
2843
2799
|
|
|
2844
2800
|
// deploy the multisig contract
|
|
@@ -2884,9 +2840,9 @@ export async function setupFixture(
|
|
|
2884
2840
|
{
|
|
2885
2841
|
admin: multiSigOwner1.address,
|
|
2886
2842
|
content: buildOnchainMetadata(zroOnchainMetaData),
|
|
2887
|
-
wallet_code:
|
|
2843
|
+
wallet_code: cellFromArtifact(ZroWalletArtifact),
|
|
2888
2844
|
},
|
|
2889
|
-
|
|
2845
|
+
cellFromArtifact(ZroMinterArtifact)
|
|
2890
2846
|
)
|
|
2891
2847
|
)
|
|
2892
2848
|
|
|
@@ -3155,7 +3111,7 @@ export async function wireFixturesTogetherWithSML(
|
|
|
3155
3111
|
)
|
|
3156
3112
|
}
|
|
3157
3113
|
`;
|
|
3158
|
-
|
|
3114
|
+
fs__default.writeFileSync(path__default.join(directory, filename), savedCode);
|
|
3159
3115
|
}
|
|
3160
3116
|
|
|
3161
3117
|
// src/externalWrappers/Multisig-Constants.ts
|
|
@@ -3824,20 +3780,20 @@ var decimalCount = 9;
|
|
|
3824
3780
|
var decimal = pow10(decimalCount);
|
|
3825
3781
|
var defaultPath = "gasInfo";
|
|
3826
3782
|
function createDirectoryIfNotExist(directoryPath) {
|
|
3827
|
-
if (!
|
|
3828
|
-
|
|
3783
|
+
if (!fs.existsSync(directoryPath)) {
|
|
3784
|
+
fs.mkdirSync(directoryPath, { recursive: true });
|
|
3829
3785
|
}
|
|
3830
3786
|
}
|
|
3831
3787
|
function sortAndSave(filePath, gasInfo) {
|
|
3832
3788
|
const entries = Object.entries(gasInfo);
|
|
3833
3789
|
const sortedEntries = entries.sort(([, valueA], [, valueB]) => parseFloat(valueA) - parseFloat(valueB));
|
|
3834
3790
|
const jsonData = JSON.stringify(Object.fromEntries(sortedEntries), null, 2);
|
|
3835
|
-
|
|
3791
|
+
fs.writeFileSync(filePath, `${jsonData}
|
|
3836
3792
|
`, "utf8");
|
|
3837
3793
|
}
|
|
3838
3794
|
function readOrCreateJsonFile(filePath) {
|
|
3839
|
-
if (
|
|
3840
|
-
const fileContent =
|
|
3795
|
+
if (fs.existsSync(filePath)) {
|
|
3796
|
+
const fileContent = fs.readFileSync(filePath, "utf8");
|
|
3841
3797
|
return JSON.parse(fileContent);
|
|
3842
3798
|
} else {
|
|
3843
3799
|
return {};
|
|
@@ -3878,7 +3834,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3878
3834
|
let filePath = profile?.filePath ?? defaultPath;
|
|
3879
3835
|
if (profile?.profileGas) {
|
|
3880
3836
|
createDirectoryIfNotExist(filePath);
|
|
3881
|
-
filePath =
|
|
3837
|
+
filePath = path__default.join(filePath, `${profile.fileName}.json`);
|
|
3882
3838
|
gasInfo = readOrCreateJsonFile(filePath);
|
|
3883
3839
|
}
|
|
3884
3840
|
console.table(
|
|
@@ -3929,6 +3885,6 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3929
3885
|
sortAndSave(filePath, gasInfo);
|
|
3930
3886
|
}
|
|
3931
3887
|
|
|
3932
|
-
export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt,
|
|
3888
|
+
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, 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 };
|
|
3933
3889
|
//# sourceMappingURL=out.js.map
|
|
3934
3890
|
//# sourceMappingURL=index.mjs.map
|