@layerzerolabs/ton-sdk-tools 3.0.76 → 3.0.77
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 +7 -0
- package/dist/index.cjs +71 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.mjs +71 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1247,16 +1247,16 @@ function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
|
|
|
1247
1247
|
});
|
|
1248
1248
|
}
|
|
1249
1249
|
findContractDirs(rootDir);
|
|
1250
|
-
|
|
1250
|
+
for (const dir of contractDirs) {
|
|
1251
1251
|
const files = fs__namespace.readdirSync(dir).filter((file) => file.endsWith(".fc") || file.endsWith(".func"));
|
|
1252
|
-
|
|
1252
|
+
for (const file of files) {
|
|
1253
1253
|
const filePath = path__namespace.join(dir, file);
|
|
1254
1254
|
const contractName = snakeToCamelCase(path__namespace.basename(path__namespace.dirname(dir)) + "_" + path__namespace.basename(dir));
|
|
1255
1255
|
const content = fs__namespace.readFileSync(filePath, "utf-8");
|
|
1256
|
-
const functionRegex = /(
|
|
1256
|
+
const functionRegex = /(^\((?:[^()]+,\s*)*[^()]+\)|[\w:]+)\s+(\w+(?:::\w+)*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{/gm;
|
|
1257
1257
|
let match;
|
|
1258
1258
|
while ((match = functionRegex.exec(content)) !== null) {
|
|
1259
|
-
const [, returnType, name, argsString
|
|
1259
|
+
const [, returnType, name, argsString] = match;
|
|
1260
1260
|
if (name.includes("::New")) {
|
|
1261
1261
|
continue;
|
|
1262
1262
|
}
|
|
@@ -1275,48 +1275,63 @@ function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
|
|
|
1275
1275
|
if (!(contractName in viewFunctions)) {
|
|
1276
1276
|
viewFunctions[contractName] = [];
|
|
1277
1277
|
}
|
|
1278
|
+
const functionArgs = [
|
|
1279
|
+
"contract: ExtendedContract<TonContractWrapper>",
|
|
1280
|
+
...Object.entries(tsArgs).map(function([argName, argType]) {
|
|
1281
|
+
return `${argName}: ${argType}`;
|
|
1282
|
+
})
|
|
1283
|
+
];
|
|
1278
1284
|
const fnName = snakeToCamelCase("get_" + name);
|
|
1279
|
-
const code =
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
(
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1285
|
+
const code = [
|
|
1286
|
+
`static async ${fnName}(`,
|
|
1287
|
+
indent(functionArgs.join(",\n")),
|
|
1288
|
+
`): Promise<[${tsReturnTypes.join(", ")}]> {`
|
|
1289
|
+
];
|
|
1290
|
+
const hasArgs = Object.keys(tonArgs).length > 0;
|
|
1291
|
+
if (hasArgs) {
|
|
1292
|
+
code.push(indent(`const args: TupleItem[] = [`));
|
|
1293
|
+
const innerArgs = Object.entries(tonArgs).map(function([argName, argType]) {
|
|
1294
|
+
return `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(argName, argType)} }`;
|
|
1295
|
+
});
|
|
1296
|
+
code.push(indent(innerArgs.join(",\n"), 2));
|
|
1297
|
+
code.push(indent(`]`));
|
|
1298
|
+
}
|
|
1299
|
+
code.push(indent(`const stack = await contract.getViewFunction('${name}', ${hasArgs ? "args" : "[]"})`));
|
|
1300
|
+
const returnCalls = tonReturnTypes.map(function(_, index) {
|
|
1301
|
+
return `stack.${tonTypeToReadTupleFunction(tonReturnTypes[index])}`;
|
|
1302
|
+
});
|
|
1303
|
+
code.push(indent(`return [ ${returnCalls.join(", ")} ]`));
|
|
1304
|
+
code.push("}");
|
|
1295
1305
|
viewFunctions[contractName].push({
|
|
1296
1306
|
name: fnName,
|
|
1297
1307
|
args: tonArgs,
|
|
1298
1308
|
returnType: tonReturnTypes,
|
|
1299
|
-
code
|
|
1309
|
+
code: code.join("\n")
|
|
1300
1310
|
});
|
|
1301
1311
|
}
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1304
1314
|
return viewFunctions;
|
|
1305
1315
|
}
|
|
1316
|
+
function indent(input, count = 1) {
|
|
1317
|
+
return input.split("\n").map(function(line) {
|
|
1318
|
+
return `${" ".repeat(count)}${line}`;
|
|
1319
|
+
}).join("\n");
|
|
1320
|
+
}
|
|
1306
1321
|
function saveViewFunctions(viewFunctions, directory, filename) {
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
fs__namespace.writeFileSync(path__namespace.join(directory, filename),
|
|
1322
|
+
const generated = [
|
|
1323
|
+
file_signature_header,
|
|
1324
|
+
`import { Address, Cell, Tuple, TupleItem, beginCell } from '@ton/core'`,
|
|
1325
|
+
`import { ExtendedContract, TonContractWrapper } from '../wrappers'`,
|
|
1326
|
+
""
|
|
1327
|
+
];
|
|
1328
|
+
for (const [contractName, functions] of Object.entries(viewFunctions)) {
|
|
1329
|
+
generated.push(`export class ${contractName} {`);
|
|
1330
|
+
generated.push(functions.map((fn) => indent(fn.code)).join("\n\n"));
|
|
1331
|
+
generated.push(`}`);
|
|
1332
|
+
generated.push("");
|
|
1333
|
+
}
|
|
1334
|
+
fs__namespace.writeFileSync(path__namespace.join(directory, filename), generated.join("\n"));
|
|
1320
1335
|
}
|
|
1321
1336
|
var BaseWrapper = class {
|
|
1322
1337
|
constructor(address, init) {
|
|
@@ -1357,7 +1372,18 @@ var BaseWrapper = class {
|
|
|
1357
1372
|
return core.beginCell().storeUint(opcode, 32).storeUint(queryId ?? randomQueryId, 64);
|
|
1358
1373
|
}
|
|
1359
1374
|
};
|
|
1360
|
-
function
|
|
1375
|
+
function getSharedOptions(input) {
|
|
1376
|
+
const ret = {
|
|
1377
|
+
relativeSrcPath: "../../src",
|
|
1378
|
+
...input
|
|
1379
|
+
};
|
|
1380
|
+
if (ret.relativeSrcPath.endsWith("/")) {
|
|
1381
|
+
throw new Error("relativeSrcPath should not end with a /");
|
|
1382
|
+
}
|
|
1383
|
+
return ret;
|
|
1384
|
+
}
|
|
1385
|
+
function generateCommonTestUtils(directory, filename, optionsInput) {
|
|
1386
|
+
const options = getSharedOptions(optionsInput);
|
|
1361
1387
|
const savedCode = `import fs from 'fs'
|
|
1362
1388
|
|
|
1363
1389
|
import {
|
|
@@ -1416,7 +1442,7 @@ import {
|
|
|
1416
1442
|
TonObjectUnwrapper,
|
|
1417
1443
|
deconstructorMap,
|
|
1418
1444
|
keyMap,
|
|
1419
|
-
} from '
|
|
1445
|
+
} from '${options.relativeSrcPath}'
|
|
1420
1446
|
|
|
1421
1447
|
const RECURSIVE_DECODE = false
|
|
1422
1448
|
|
|
@@ -2901,7 +2927,7 @@ export async function txDecoder(
|
|
|
2901
2927
|
}
|
|
2902
2928
|
|
|
2903
2929
|
export async function runtimeDecoder(contract: SandboxContract<TonContractWrapper>, obj: Cell): Promise<void> {
|
|
2904
|
-
const { tonObjects } = require('
|
|
2930
|
+
const { tonObjects } = require('${options.relativeSrcPath}/offchain-helpers/allObjects') as { [key: string]: { [key: string]: any } }
|
|
2905
2931
|
|
|
2906
2932
|
const typeName = await TonObjectUnwrapper.getTypeOf(contract, obj)
|
|
2907
2933
|
|
|
@@ -2962,7 +2988,8 @@ export async function runtimeDecoder(contract: SandboxContract<TonContractWrappe
|
|
|
2962
2988
|
`;
|
|
2963
2989
|
fs__namespace.default.writeFileSync(path__namespace.default.join(directory, filename), savedCode);
|
|
2964
2990
|
}
|
|
2965
|
-
function generateSmlTestUtils(directory, filename) {
|
|
2991
|
+
function generateSmlTestUtils(directory, filename, optionsInput) {
|
|
2992
|
+
const options = getSharedOptions(optionsInput);
|
|
2966
2993
|
const savedCode = `import { Cell, toNano } from '@ton/core'
|
|
2967
2994
|
import { Blockchain, SandboxContract, SendMessageResult, TreasuryContract } from '@ton/sandbox'
|
|
2968
2995
|
import '@ton/test-utils'
|
|
@@ -2983,7 +3010,7 @@ import {
|
|
|
2983
3010
|
setDefaultEndpointConfig,
|
|
2984
3011
|
wireChannels,
|
|
2985
3012
|
} from './auto-utils-common'
|
|
2986
|
-
import { LzEventHandler, OPCODES, TonContractWrapper } from '
|
|
3013
|
+
import { LzEventHandler, OPCODES, TonContractWrapper } from '${options.relativeSrcPath}'
|
|
2987
3014
|
|
|
2988
3015
|
const SML_MANAGER_DEFAULT_VERSION = BigInt(1)
|
|
2989
3016
|
const SML_MANAGER_CUSTOM_VERSION = BigInt(2)
|
|
@@ -3324,7 +3351,8 @@ export async function wireFixturesTogetherWithSML(
|
|
|
3324
3351
|
`;
|
|
3325
3352
|
fs__namespace.default.writeFileSync(path__namespace.default.join(directory, filename), savedCode);
|
|
3326
3353
|
}
|
|
3327
|
-
function generateUlnTestUtils(directory, filename) {
|
|
3354
|
+
function generateUlnTestUtils(directory, filename, optionsInput) {
|
|
3355
|
+
const options = getSharedOptions(optionsInput);
|
|
3328
3356
|
const savedCode = `import { Address, Cell, TupleItemCell, beginCell, toNano } from '@ton/core'
|
|
3329
3357
|
import { Blockchain, SandboxContract, SendMessageResult, TreasuryContract } from '@ton/sandbox'
|
|
3330
3358
|
import { FlatTransactionComparable } from '@ton/test-utils'
|
|
@@ -3371,7 +3399,7 @@ import {
|
|
|
3371
3399
|
OPCODES,
|
|
3372
3400
|
TonContractWrapper,
|
|
3373
3401
|
TonObjectUnwrapper,
|
|
3374
|
-
} from '
|
|
3402
|
+
} from '${options.relativeSrcPath}'
|
|
3375
3403
|
|
|
3376
3404
|
const ULN_MANAGER_DEFAULT_VERSION = BigInt(1)
|
|
3377
3405
|
|