@latticexyz/world 2.2.22-ab837ceb49fa77cc29487bb9df0c487975b37afe → 2.2.22-d83a0fd5283b7bea7e9a5372ea3c45ab9aea350f
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/node.js +32 -19
- package/dist/node.js.map +1 -1
- package/package.json +9 -9
package/dist/node.js
CHANGED
@@ -273,6 +273,9 @@ function renderSystemLibrary(options) {
|
|
273
273
|
} = options;
|
274
274
|
const functions = functionsInput.map((func) => ({
|
275
275
|
...func,
|
276
|
+
// Format parameters (add auxiliary argument names, replace calldata location)
|
277
|
+
parameters: formatParams(func.parameters),
|
278
|
+
// Remove `payable` from stateMutability for library functions
|
276
279
|
stateMutability: func.stateMutability.replace("payable", "")
|
277
280
|
}));
|
278
281
|
const imports = [
|
@@ -394,7 +397,7 @@ function renderErrors(errors) {
|
|
394
397
|
}
|
395
398
|
function renderUserTypeFunction(contractFunction, userTypeName) {
|
396
399
|
const { name, parameters, stateMutability, returnParameters } = contractFunction;
|
397
|
-
const args = [`${userTypeName} self`, ...parameters]
|
400
|
+
const args = [`${userTypeName} self`, ...parameters];
|
398
401
|
const functionSignature = `
|
399
402
|
function ${name}(
|
400
403
|
${renderArguments2(args)}
|
@@ -411,7 +414,7 @@ function renderUserTypeFunction(contractFunction, userTypeName) {
|
|
411
414
|
}
|
412
415
|
function renderCallWrapperFunction(contractFunction, callingFromRootSystemErrorName) {
|
413
416
|
const { name, parameters, stateMutability, returnParameters } = contractFunction;
|
414
|
-
const args = [`CallWrapper memory self`, ...parameters]
|
417
|
+
const args = [`CallWrapper memory self`, ...parameters];
|
415
418
|
const functionSignature = `
|
416
419
|
function ${name}(
|
417
420
|
${renderArguments2(args)}
|
@@ -455,7 +458,7 @@ function renderRootCallWrapperFunction(contractFunction, namespace) {
|
|
455
458
|
if (namespace === "" && stateMutability != "") {
|
456
459
|
return "";
|
457
460
|
}
|
458
|
-
const args = ["RootCallWrapper memory self", ...parameters]
|
461
|
+
const args = ["RootCallWrapper memory self", ...parameters];
|
459
462
|
const functionSignature = `
|
460
463
|
function ${name}(
|
461
464
|
${renderArguments2(args)}
|
@@ -516,6 +519,14 @@ function renderReturnParameters2(returnParameters) {
|
|
516
519
|
if (returnParameters.length == 0) return "";
|
517
520
|
return `returns (${renderArguments2(returnParameters)})`;
|
518
521
|
}
|
522
|
+
function formatParams(params) {
|
523
|
+
let auxCount = 0;
|
524
|
+
return params.map((arg) => arg.replace(/ calldata /, " memory ")).map((arg) => {
|
525
|
+
const items = arg.split(" ");
|
526
|
+
const needsAux = items.length === 1 || items.length === 2 && items[1] === "memory";
|
527
|
+
return needsAux ? `${arg} __aux${auxCount++}` : arg;
|
528
|
+
});
|
529
|
+
}
|
519
530
|
|
520
531
|
// ts/node/render-solidity/renderWorldInterface.ts
|
521
532
|
import { renderArguments as renderArguments3, renderedSolidityHeader as renderedSolidityHeader3, renderImports as renderImports3 } from "@latticexyz/common/codegen";
|
@@ -7045,7 +7056,7 @@ async function worldgen({
|
|
7045
7056
|
config.codegen.outputDirectory,
|
7046
7057
|
config.codegen.worldgenDirectory
|
7047
7058
|
);
|
7048
|
-
const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions).map((system) => {
|
7059
|
+
const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions || config.codegen.generateSystemLibraries).map((system) => {
|
7049
7060
|
const interfaceName = `I${system.label}`;
|
7050
7061
|
const libraryName = `${system.label}Lib`;
|
7051
7062
|
const sourceDir = config.multipleNamespaces ? path4.join(config.sourceDirectory, "namespaces", system.namespaceLabel) : config.sourceDirectory;
|
@@ -7070,7 +7081,7 @@ async function worldgen({
|
|
7070
7081
|
]);
|
7071
7082
|
}
|
7072
7083
|
const outputPath = path4.join(worldgenOutDir, config.codegen.worldInterfaceName + ".sol");
|
7073
|
-
const worldImports = systems.map(
|
7084
|
+
const worldImports = systems.filter((system) => system.deploy.registerWorldFunctions).map(
|
7074
7085
|
(system) => ({
|
7075
7086
|
symbol: system.interfaceName,
|
7076
7087
|
path: "./" + path4.relative(path4.dirname(outputPath), system.interfacePath)
|
@@ -7082,20 +7093,22 @@ async function worldgen({
|
|
7082
7093
|
systems.map(async (system) => {
|
7083
7094
|
const source = await fs2.readFile(path4.join(rootDir, system.sourcePath), "utf8");
|
7084
7095
|
const { functions, errors, symbolImports } = contractToInterface(source, system.label);
|
7085
|
-
|
7086
|
-
|
7087
|
-
symbol,
|
7088
|
-
|
7089
|
-
|
7090
|
-
|
7091
|
-
|
7092
|
-
|
7093
|
-
|
7094
|
-
|
7095
|
-
|
7096
|
-
|
7097
|
-
|
7098
|
-
|
7096
|
+
if (system.deploy.registerWorldFunctions) {
|
7097
|
+
const interfaceImports = symbolImports.map(
|
7098
|
+
({ symbol, path: importPath }) => ({
|
7099
|
+
symbol,
|
7100
|
+
path: importPath.startsWith(".") ? "./" + path4.relative(worldgenOutDir, path4.join(rootDir, path4.dirname(system.sourcePath), importPath)) : importPath
|
7101
|
+
})
|
7102
|
+
);
|
7103
|
+
const systemInterface = renderSystemInterface({
|
7104
|
+
name: system.interfaceName,
|
7105
|
+
functionPrefix: system.namespace === "" ? "" : `${system.namespace}__`,
|
7106
|
+
functions,
|
7107
|
+
errors,
|
7108
|
+
imports: interfaceImports
|
7109
|
+
});
|
7110
|
+
await formatAndWriteSolidity(systemInterface, system.interfacePath, "Generated system interface");
|
7111
|
+
}
|
7099
7112
|
if (config.codegen.generateSystemLibraries) {
|
7100
7113
|
const systemImport = {
|
7101
7114
|
symbol: system.label,
|