@latticexyz/world 2.2.22-ca7a36a114ba65468662dbeef343129fa60f04eb → 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 +61 -41
- package/dist/node.js.map +1 -1
- package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
- package/out/AccessManagementSystemLib.sol/AccessManagementSystemLib.json +1 -1
- package/out/AccessManagementSystemLib.sol/_grantAccess_ResourceId_address.json +1 -1
- package/out/AccessManagementSystemLib.sol/_renounceOwnership_ResourceId.json +1 -1
- package/out/AccessManagementSystemLib.sol/_revokeAccess_ResourceId_address.json +1 -1
- package/out/AccessManagementSystemLib.sol/_transferOwnership_ResourceId_address.json +1 -1
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
- package/out/BalanceTransferSystemLib.sol/BalanceTransferSystemLib.json +1 -1
- package/out/BalanceTransferSystemLib.sol/_transferBalanceToAddress_ResourceId_address_uint256.json +1 -1
- package/out/BalanceTransferSystemLib.sol/_transferBalanceToNamespace_ResourceId_ResourceId_uint256.json +1 -1
- package/out/BatchCall.t.sol/BatchCallTest.json +1 -1
- package/out/BatchCall.t.sol/TestSystem.json +1 -1
- package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
- package/out/BatchCallSystemLib.sol/BatchCallSystemLib.json +1 -1
- package/out/BatchCallSystemLib.sol/_batchCallFrom_SystemCallFromDataArray.json +1 -1
- package/out/BatchCallSystemLib.sol/_batchCall_SystemCallDataArray.json +1 -1
- package/out/DelegationControl.sol/DelegationControl.json +1 -1
- package/out/DelegationControlMock.sol/DelegationControlMock.json +1 -1
- package/out/Factories.t.sol/FactoriesTest.json +1 -1
- package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
- package/out/InitModule.sol/InitModule.json +1 -1
- package/out/InitModule.t.sol/InitModuleTest.json +1 -1
- package/out/InitModule.t.sol/WorldMock.json +1 -1
- package/out/InitSystems.t.sol/LimitedCallContextTest.json +1 -1
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
- package/out/ModuleInstallationSystemLib.sol/ModuleInstallationSystemLib.json +1 -1
- package/out/ModuleInstallationSystemLib.sol/_installModule_IModule_bytes.json +1 -1
- package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
- package/out/RegistrationSystemLib.sol/RegistrationSystemLib.json +1 -1
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/StoreRegistrationSystemLib.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_registerStoreHook_ResourceId_IStoreHook_uint8.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_registerTable_ResourceId_FieldLayout_Schema_Schema_stringArray_stringArray.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_unregisterStoreHook_ResourceId_IStoreHook.json +1 -1
- package/out/System.sol/System.json +1 -1
- package/out/System.t.sol/SystemTest.json +1 -1
- package/out/System.t.sol/TestSystem.json +1 -1
- package/out/Utils.t.sol/UtilsTest.json +1 -1
- package/out/Utils.t.sol/UtilsTestSystem.json +1 -1
- package/out/World.t.sol/EchoSystemHook.json +1 -1
- package/out/World.t.sol/IWorldTestSystem.json +1 -1
- package/out/World.t.sol/PayableFallbackSystem.json +1 -1
- package/out/World.t.sol/RevertSystemHook.json +1 -1
- package/out/World.t.sol/WorldTest.json +1 -1
- package/out/World.t.sol/WorldTestSystem.json +1 -1
- package/out/WorldBalance.t.sol/WorldBalanceTest.json +1 -1
- package/out/WorldBalance.t.sol/WorldBalanceTestSystem.json +1 -1
- package/out/WorldDynamicUpdate.t.sol/UpdateInDynamicFieldTest.json +1 -1
- package/out/WorldFactory.sol/WorldFactory.json +1 -1
- package/out/WorldProxy.sol/WorldProxy.json +1 -1
- package/out/WorldProxy.t.sol/WorldProxyTest.json +1 -1
- package/out/WorldProxyFactory.sol/WorldProxyFactory.json +1 -1
- package/out/WorldProxyFactory.t.sol/WorldProxyFactoryTest.json +1 -1
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/WorldRegistrationSystemLib.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerDelegation_address_ResourceId_bytes.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerFunctionSelector_ResourceId_string.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerNamespaceDelegation_ResourceId_ResourceId_bytes.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerNamespace_ResourceId.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerRootFunctionSelector_ResourceId_string_string.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerSystemHook_ResourceId_ISystemHook_uint8.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerSystem_ResourceId_System_bool.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterDelegation_address.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterNamespaceDelegation_ResourceId.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterSystemHook_ResourceId_ISystemHook.json +1 -1
- package/out/build-info/{6366a746548e984842b93ef762b76b99.json → bf27acd14b2b959864c0abf4ffaa7965.json} +1 -1
- package/package.json +9 -9
- package/src/System.sol +1 -1
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";
|
@@ -557,7 +568,7 @@ function renderWorldInterface({
|
|
557
568
|
}
|
558
569
|
|
559
570
|
// ts/node/render-solidity/worldgen.ts
|
560
|
-
import
|
571
|
+
import fs2 from "node:fs/promises";
|
561
572
|
import path4 from "node:path";
|
562
573
|
import { formatAndWriteSolidity, contractToInterface } from "@latticexyz/common/codegen";
|
563
574
|
|
@@ -566,6 +577,7 @@ import { isHex } from "viem";
|
|
566
577
|
|
567
578
|
// ts/node/getSystemContracts.ts
|
568
579
|
import path3 from "node:path";
|
580
|
+
import fs from "node:fs/promises";
|
569
581
|
|
570
582
|
// ts/node/findSolidityFiles.ts
|
571
583
|
import path2 from "node:path";
|
@@ -5274,8 +5286,8 @@ var PathScurryBase = class {
|
|
5274
5286
|
*
|
5275
5287
|
* @internal
|
5276
5288
|
*/
|
5277
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
5278
|
-
this.#fs = fsFromOption(
|
5289
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
|
5290
|
+
this.#fs = fsFromOption(fs4);
|
5279
5291
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
5280
5292
|
cwd = fileURLToPath(cwd);
|
5281
5293
|
}
|
@@ -5833,8 +5845,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
5833
5845
|
/**
|
5834
5846
|
* @internal
|
5835
5847
|
*/
|
5836
|
-
newRoot(
|
5837
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
5848
|
+
newRoot(fs4) {
|
5849
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
5838
5850
|
}
|
5839
5851
|
/**
|
5840
5852
|
* Return true if the provided path string is an absolute path
|
@@ -5862,8 +5874,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
5862
5874
|
/**
|
5863
5875
|
* @internal
|
5864
5876
|
*/
|
5865
|
-
newRoot(
|
5866
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
5877
|
+
newRoot(fs4) {
|
5878
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
5867
5879
|
}
|
5868
5880
|
/**
|
5869
5881
|
* Return true if the provided path string is an absolute path
|
@@ -6951,19 +6963,25 @@ async function findSolidityFiles({ cwd, pattern = "**" }) {
|
|
6951
6963
|
}
|
6952
6964
|
|
6953
6965
|
// ts/node/getSystemContracts.ts
|
6966
|
+
import { parseSystem } from "@latticexyz/common/codegen";
|
6967
|
+
import { isDefined } from "@latticexyz/common/utils";
|
6954
6968
|
async function getSystemContracts({
|
6955
6969
|
rootDir,
|
6956
6970
|
config
|
6957
6971
|
}) {
|
6958
|
-
const
|
6972
|
+
const filePaths = await findSolidityFiles({
|
6959
6973
|
cwd: rootDir,
|
6960
6974
|
pattern: path3.join(config.sourceDirectory, "**")
|
6961
6975
|
});
|
6962
|
-
|
6963
|
-
(file) =>
|
6964
|
-
|
6965
|
-
|
6966
|
-
|
6976
|
+
const files = await Promise.all(
|
6977
|
+
filePaths.map(async (file) => {
|
6978
|
+
const source = await fs.readFile(path3.join(rootDir, file.filename), "utf-8");
|
6979
|
+
return { ...file, source };
|
6980
|
+
})
|
6981
|
+
);
|
6982
|
+
return files.map((file) => {
|
6983
|
+
const parsedSystem = parseSystem(file.source, file.basename);
|
6984
|
+
if (!parsedSystem) return;
|
6967
6985
|
const namespaceLabel = (() => {
|
6968
6986
|
if (!config.multipleNamespaces && config.namespace != null) return config.namespace;
|
6969
6987
|
const relativePath = path3.relative(path3.join(rootDir, config.sourceDirectory), file.filename);
|
@@ -6980,7 +6998,7 @@ async function getSystemContracts({
|
|
6980
6998
|
namespaceLabel,
|
6981
6999
|
systemLabel: file.basename
|
6982
7000
|
};
|
6983
|
-
});
|
7001
|
+
}).filter(isDefined);
|
6984
7002
|
}
|
6985
7003
|
|
6986
7004
|
// ts/node/resolveSystems.ts
|
@@ -7038,7 +7056,7 @@ async function worldgen({
|
|
7038
7056
|
config.codegen.outputDirectory,
|
7039
7057
|
config.codegen.worldgenDirectory
|
7040
7058
|
);
|
7041
|
-
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) => {
|
7042
7060
|
const interfaceName = `I${system.label}`;
|
7043
7061
|
const libraryName = `${system.label}Lib`;
|
7044
7062
|
const sourceDir = config.multipleNamespaces ? path4.join(config.sourceDirectory, "namespaces", system.namespaceLabel) : config.sourceDirectory;
|
@@ -7058,12 +7076,12 @@ async function worldgen({
|
|
7058
7076
|
if (clean) {
|
7059
7077
|
const libraryDirs = [...new Set(systems.map(({ libraryPath }) => path4.dirname(libraryPath)))];
|
7060
7078
|
await Promise.all([
|
7061
|
-
|
7062
|
-
...libraryDirs.map((dir) =>
|
7079
|
+
fs2.rm(worldgenOutDir, { recursive: true, force: true }),
|
7080
|
+
...libraryDirs.map((dir) => fs2.rm(dir, { recursive: true, force: true }))
|
7063
7081
|
]);
|
7064
7082
|
}
|
7065
7083
|
const outputPath = path4.join(worldgenOutDir, config.codegen.worldInterfaceName + ".sol");
|
7066
|
-
const worldImports = systems.map(
|
7084
|
+
const worldImports = systems.filter((system) => system.deploy.registerWorldFunctions).map(
|
7067
7085
|
(system) => ({
|
7068
7086
|
symbol: system.interfaceName,
|
7069
7087
|
path: "./" + path4.relative(path4.dirname(outputPath), system.interfacePath)
|
@@ -7073,22 +7091,24 @@ async function worldgen({
|
|
7073
7091
|
const worldImportPath = config.codegen.worldImportPath.startsWith(".") ? "./" + path4.relative(path4.dirname(outputPath), path4.join(rootDir, config.codegen.worldImportPath)) : config.codegen.worldImportPath;
|
7074
7092
|
await Promise.all(
|
7075
7093
|
systems.map(async (system) => {
|
7076
|
-
const source = await
|
7094
|
+
const source = await fs2.readFile(path4.join(rootDir, system.sourcePath), "utf8");
|
7077
7095
|
const { functions, errors, symbolImports } = contractToInterface(source, system.label);
|
7078
|
-
|
7079
|
-
|
7080
|
-
symbol,
|
7081
|
-
|
7082
|
-
|
7083
|
-
|
7084
|
-
|
7085
|
-
|
7086
|
-
|
7087
|
-
|
7088
|
-
|
7089
|
-
|
7090
|
-
|
7091
|
-
|
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
|
+
}
|
7092
7112
|
if (config.codegen.generateSystemLibraries) {
|
7093
7113
|
const systemImport = {
|
7094
7114
|
symbol: system.label,
|
@@ -7133,7 +7153,7 @@ async function worldgen({
|
|
7133
7153
|
import path5 from "node:path";
|
7134
7154
|
import { readFile } from "node:fs/promises";
|
7135
7155
|
import { type as type2 } from "arktype";
|
7136
|
-
import { indent, isDefined } from "@latticexyz/common/utils";
|
7156
|
+
import { indent, isDefined as isDefined2 } from "@latticexyz/common/utils";
|
7137
7157
|
import { size, sliceHex } from "viem";
|
7138
7158
|
|
7139
7159
|
// ts/node/common.ts
|
@@ -7211,7 +7231,7 @@ ${indent(artifact.message)}`);
|
|
7211
7231
|
return;
|
7212
7232
|
}
|
7213
7233
|
return artifact;
|
7214
|
-
}).filter(
|
7234
|
+
}).filter(isDefined2).filter(hasMetadata).map((artifact) => {
|
7215
7235
|
artifact;
|
7216
7236
|
const sourcePath = Object.keys(artifact.metadata.settings.compilationTarget)[0];
|
7217
7237
|
const name = artifact.metadata.settings.compilationTarget[sourcePath];
|
@@ -7320,7 +7340,7 @@ async function buildSystemsManifest(opts) {
|
|
7320
7340
|
}
|
7321
7341
|
|
7322
7342
|
// ts/node/loadSystemsManifest.ts
|
7323
|
-
import
|
7343
|
+
import fs3 from "node:fs/promises";
|
7324
7344
|
import path7 from "node:path";
|
7325
7345
|
import { type as type4 } from "arktype";
|
7326
7346
|
import { indent as indent2 } from "@latticexyz/common/utils";
|
@@ -7328,13 +7348,13 @@ var parseManifest = type4("string").pipe.try((s) => JSON.parse(s), SystemsManife
|
|
7328
7348
|
async function loadSystemsManifest(opts) {
|
7329
7349
|
const outFile = path7.join(opts.rootDir, systemsManifestFilename);
|
7330
7350
|
try {
|
7331
|
-
await
|
7351
|
+
await fs3.access(outFile, fs3.constants.F_OK | fs3.constants.R_OK);
|
7332
7352
|
} catch (error2) {
|
7333
7353
|
throw new Error(
|
7334
7354
|
`Systems manifest at "${systemsManifestFilename}" not found or not readable. Run \`mud build\` before trying again.`
|
7335
7355
|
);
|
7336
7356
|
}
|
7337
|
-
const json = await
|
7357
|
+
const json = await fs3.readFile(outFile, "utf8");
|
7338
7358
|
const manifest = parseManifest(json);
|
7339
7359
|
if (manifest instanceof type4.errors) {
|
7340
7360
|
throw new Error(
|