@latticexyz/world 2.2.22-ca7a36a114ba65468662dbeef343129fa60f04eb → 2.2.22-fb2745a7b2d4735a67adffa69e70ec7d1085f4da

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.
Files changed (71) hide show
  1. package/dist/node.js +47 -38
  2. package/dist/node.js.map +1 -1
  3. package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
  4. package/out/AccessManagementSystemLib.sol/AccessManagementSystemLib.json +1 -1
  5. package/out/AccessManagementSystemLib.sol/_grantAccess_ResourceId_address.json +1 -1
  6. package/out/AccessManagementSystemLib.sol/_renounceOwnership_ResourceId.json +1 -1
  7. package/out/AccessManagementSystemLib.sol/_revokeAccess_ResourceId_address.json +1 -1
  8. package/out/AccessManagementSystemLib.sol/_transferOwnership_ResourceId_address.json +1 -1
  9. package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
  10. package/out/BalanceTransferSystemLib.sol/BalanceTransferSystemLib.json +1 -1
  11. package/out/BalanceTransferSystemLib.sol/_transferBalanceToAddress_ResourceId_address_uint256.json +1 -1
  12. package/out/BalanceTransferSystemLib.sol/_transferBalanceToNamespace_ResourceId_ResourceId_uint256.json +1 -1
  13. package/out/BatchCall.t.sol/BatchCallTest.json +1 -1
  14. package/out/BatchCall.t.sol/TestSystem.json +1 -1
  15. package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
  16. package/out/BatchCallSystemLib.sol/BatchCallSystemLib.json +1 -1
  17. package/out/BatchCallSystemLib.sol/_batchCallFrom_SystemCallFromDataArray.json +1 -1
  18. package/out/BatchCallSystemLib.sol/_batchCall_SystemCallDataArray.json +1 -1
  19. package/out/DelegationControl.sol/DelegationControl.json +1 -1
  20. package/out/DelegationControlMock.sol/DelegationControlMock.json +1 -1
  21. package/out/Factories.t.sol/FactoriesTest.json +1 -1
  22. package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
  23. package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
  24. package/out/InitModule.sol/InitModule.json +1 -1
  25. package/out/InitModule.t.sol/InitModuleTest.json +1 -1
  26. package/out/InitModule.t.sol/WorldMock.json +1 -1
  27. package/out/InitSystems.t.sol/LimitedCallContextTest.json +1 -1
  28. package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
  29. package/out/ModuleInstallationSystemLib.sol/ModuleInstallationSystemLib.json +1 -1
  30. package/out/ModuleInstallationSystemLib.sol/_installModule_IModule_bytes.json +1 -1
  31. package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
  32. package/out/RegistrationSystemLib.sol/RegistrationSystemLib.json +1 -1
  33. package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
  34. package/out/StoreRegistrationSystemLib.sol/StoreRegistrationSystemLib.json +1 -1
  35. package/out/StoreRegistrationSystemLib.sol/_registerStoreHook_ResourceId_IStoreHook_uint8.json +1 -1
  36. package/out/StoreRegistrationSystemLib.sol/_registerTable_ResourceId_FieldLayout_Schema_Schema_stringArray_stringArray.json +1 -1
  37. package/out/StoreRegistrationSystemLib.sol/_unregisterStoreHook_ResourceId_IStoreHook.json +1 -1
  38. package/out/System.sol/System.json +1 -1
  39. package/out/System.t.sol/SystemTest.json +1 -1
  40. package/out/System.t.sol/TestSystem.json +1 -1
  41. package/out/Utils.t.sol/UtilsTest.json +1 -1
  42. package/out/Utils.t.sol/UtilsTestSystem.json +1 -1
  43. package/out/World.t.sol/EchoSystemHook.json +1 -1
  44. package/out/World.t.sol/IWorldTestSystem.json +1 -1
  45. package/out/World.t.sol/PayableFallbackSystem.json +1 -1
  46. package/out/World.t.sol/RevertSystemHook.json +1 -1
  47. package/out/World.t.sol/WorldTest.json +1 -1
  48. package/out/World.t.sol/WorldTestSystem.json +1 -1
  49. package/out/WorldBalance.t.sol/WorldBalanceTest.json +1 -1
  50. package/out/WorldBalance.t.sol/WorldBalanceTestSystem.json +1 -1
  51. package/out/WorldDynamicUpdate.t.sol/UpdateInDynamicFieldTest.json +1 -1
  52. package/out/WorldFactory.sol/WorldFactory.json +1 -1
  53. package/out/WorldProxy.sol/WorldProxy.json +1 -1
  54. package/out/WorldProxy.t.sol/WorldProxyTest.json +1 -1
  55. package/out/WorldProxyFactory.sol/WorldProxyFactory.json +1 -1
  56. package/out/WorldProxyFactory.t.sol/WorldProxyFactoryTest.json +1 -1
  57. package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
  58. package/out/WorldRegistrationSystemLib.sol/WorldRegistrationSystemLib.json +1 -1
  59. package/out/WorldRegistrationSystemLib.sol/_registerDelegation_address_ResourceId_bytes.json +1 -1
  60. package/out/WorldRegistrationSystemLib.sol/_registerFunctionSelector_ResourceId_string.json +1 -1
  61. package/out/WorldRegistrationSystemLib.sol/_registerNamespaceDelegation_ResourceId_ResourceId_bytes.json +1 -1
  62. package/out/WorldRegistrationSystemLib.sol/_registerNamespace_ResourceId.json +1 -1
  63. package/out/WorldRegistrationSystemLib.sol/_registerRootFunctionSelector_ResourceId_string_string.json +1 -1
  64. package/out/WorldRegistrationSystemLib.sol/_registerSystemHook_ResourceId_ISystemHook_uint8.json +1 -1
  65. package/out/WorldRegistrationSystemLib.sol/_registerSystem_ResourceId_System_bool.json +1 -1
  66. package/out/WorldRegistrationSystemLib.sol/_unregisterDelegation_address.json +1 -1
  67. package/out/WorldRegistrationSystemLib.sol/_unregisterNamespaceDelegation_ResourceId.json +1 -1
  68. package/out/WorldRegistrationSystemLib.sol/_unregisterSystemHook_ResourceId_ISystemHook.json +1 -1
  69. package/out/build-info/{6366a746548e984842b93ef762b76b99.json → bf27acd14b2b959864c0abf4ffaa7965.json} +1 -1
  70. package/package.json +9 -9
  71. package/src/System.sol +1 -1
package/dist/node.js CHANGED
@@ -557,7 +557,7 @@ function renderWorldInterface({
557
557
  }
558
558
 
559
559
  // ts/node/render-solidity/worldgen.ts
560
- import fs from "node:fs/promises";
560
+ import fs2 from "node:fs/promises";
561
561
  import path4 from "node:path";
562
562
  import { formatAndWriteSolidity, contractToInterface } from "@latticexyz/common/codegen";
563
563
 
@@ -566,6 +566,7 @@ import { isHex } from "viem";
566
566
 
567
567
  // ts/node/getSystemContracts.ts
568
568
  import path3 from "node:path";
569
+ import fs from "node:fs/promises";
569
570
 
570
571
  // ts/node/findSolidityFiles.ts
571
572
  import path2 from "node:path";
@@ -5274,8 +5275,8 @@ var PathScurryBase = class {
5274
5275
  *
5275
5276
  * @internal
5276
5277
  */
5277
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs3 = defaultFS } = {}) {
5278
- this.#fs = fsFromOption(fs3);
5278
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
5279
+ this.#fs = fsFromOption(fs4);
5279
5280
  if (cwd instanceof URL || cwd.startsWith("file://")) {
5280
5281
  cwd = fileURLToPath(cwd);
5281
5282
  }
@@ -5833,8 +5834,8 @@ var PathScurryWin32 = class extends PathScurryBase {
5833
5834
  /**
5834
5835
  * @internal
5835
5836
  */
5836
- newRoot(fs3) {
5837
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs3 });
5837
+ newRoot(fs4) {
5838
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
5838
5839
  }
5839
5840
  /**
5840
5841
  * Return true if the provided path string is an absolute path
@@ -5862,8 +5863,8 @@ var PathScurryPosix = class extends PathScurryBase {
5862
5863
  /**
5863
5864
  * @internal
5864
5865
  */
5865
- newRoot(fs3) {
5866
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs3 });
5866
+ newRoot(fs4) {
5867
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
5867
5868
  }
5868
5869
  /**
5869
5870
  * Return true if the provided path string is an absolute path
@@ -6951,19 +6952,25 @@ async function findSolidityFiles({ cwd, pattern = "**" }) {
6951
6952
  }
6952
6953
 
6953
6954
  // ts/node/getSystemContracts.ts
6955
+ import { parseSystem } from "@latticexyz/common/codegen";
6956
+ import { isDefined } from "@latticexyz/common/utils";
6954
6957
  async function getSystemContracts({
6955
6958
  rootDir,
6956
6959
  config
6957
6960
  }) {
6958
- const solidityFiles = await findSolidityFiles({
6961
+ const filePaths = await findSolidityFiles({
6959
6962
  cwd: rootDir,
6960
6963
  pattern: path3.join(config.sourceDirectory, "**")
6961
6964
  });
6962
- return solidityFiles.filter(
6963
- (file) => file.basename.endsWith("System") && // exclude the base System contract
6964
- file.basename !== "System" && // exclude interfaces
6965
- !/^I[A-Z]/.test(file.basename)
6966
- ).map((file) => {
6965
+ const files = await Promise.all(
6966
+ filePaths.map(async (file) => {
6967
+ const source = await fs.readFile(path3.join(rootDir, file.filename), "utf-8");
6968
+ return { ...file, source };
6969
+ })
6970
+ );
6971
+ return files.map((file) => {
6972
+ const parsedSystem = parseSystem(file.source, file.basename);
6973
+ if (!parsedSystem) return;
6967
6974
  const namespaceLabel = (() => {
6968
6975
  if (!config.multipleNamespaces && config.namespace != null) return config.namespace;
6969
6976
  const relativePath = path3.relative(path3.join(rootDir, config.sourceDirectory), file.filename);
@@ -6980,7 +6987,7 @@ async function getSystemContracts({
6980
6987
  namespaceLabel,
6981
6988
  systemLabel: file.basename
6982
6989
  };
6983
- });
6990
+ }).filter(isDefined);
6984
6991
  }
6985
6992
 
6986
6993
  // ts/node/resolveSystems.ts
@@ -7038,7 +7045,7 @@ async function worldgen({
7038
7045
  config.codegen.outputDirectory,
7039
7046
  config.codegen.worldgenDirectory
7040
7047
  );
7041
- const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions).map((system) => {
7048
+ const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions || config.codegen.generateSystemLibraries).map((system) => {
7042
7049
  const interfaceName = `I${system.label}`;
7043
7050
  const libraryName = `${system.label}Lib`;
7044
7051
  const sourceDir = config.multipleNamespaces ? path4.join(config.sourceDirectory, "namespaces", system.namespaceLabel) : config.sourceDirectory;
@@ -7058,12 +7065,12 @@ async function worldgen({
7058
7065
  if (clean) {
7059
7066
  const libraryDirs = [...new Set(systems.map(({ libraryPath }) => path4.dirname(libraryPath)))];
7060
7067
  await Promise.all([
7061
- fs.rm(worldgenOutDir, { recursive: true, force: true }),
7062
- ...libraryDirs.map((dir) => fs.rm(dir, { recursive: true, force: true }))
7068
+ fs2.rm(worldgenOutDir, { recursive: true, force: true }),
7069
+ ...libraryDirs.map((dir) => fs2.rm(dir, { recursive: true, force: true }))
7063
7070
  ]);
7064
7071
  }
7065
7072
  const outputPath = path4.join(worldgenOutDir, config.codegen.worldInterfaceName + ".sol");
7066
- const worldImports = systems.map(
7073
+ const worldImports = systems.filter((system) => system.deploy.registerWorldFunctions).map(
7067
7074
  (system) => ({
7068
7075
  symbol: system.interfaceName,
7069
7076
  path: "./" + path4.relative(path4.dirname(outputPath), system.interfacePath)
@@ -7073,22 +7080,24 @@ async function worldgen({
7073
7080
  const worldImportPath = config.codegen.worldImportPath.startsWith(".") ? "./" + path4.relative(path4.dirname(outputPath), path4.join(rootDir, config.codegen.worldImportPath)) : config.codegen.worldImportPath;
7074
7081
  await Promise.all(
7075
7082
  systems.map(async (system) => {
7076
- const source = await fs.readFile(path4.join(rootDir, system.sourcePath), "utf8");
7083
+ const source = await fs2.readFile(path4.join(rootDir, system.sourcePath), "utf8");
7077
7084
  const { functions, errors, symbolImports } = contractToInterface(source, system.label);
7078
- const interfaceImports = symbolImports.map(
7079
- ({ symbol, path: importPath }) => ({
7080
- symbol,
7081
- path: importPath.startsWith(".") ? "./" + path4.relative(worldgenOutDir, path4.join(rootDir, path4.dirname(system.sourcePath), importPath)) : importPath
7082
- })
7083
- );
7084
- const systemInterface = renderSystemInterface({
7085
- name: system.interfaceName,
7086
- functionPrefix: system.namespace === "" ? "" : `${system.namespace}__`,
7087
- functions,
7088
- errors,
7089
- imports: interfaceImports
7090
- });
7091
- await formatAndWriteSolidity(systemInterface, system.interfacePath, "Generated system interface");
7085
+ if (system.deploy.registerWorldFunctions) {
7086
+ const interfaceImports = symbolImports.map(
7087
+ ({ symbol, path: importPath }) => ({
7088
+ symbol,
7089
+ path: importPath.startsWith(".") ? "./" + path4.relative(worldgenOutDir, path4.join(rootDir, path4.dirname(system.sourcePath), importPath)) : importPath
7090
+ })
7091
+ );
7092
+ const systemInterface = renderSystemInterface({
7093
+ name: system.interfaceName,
7094
+ functionPrefix: system.namespace === "" ? "" : `${system.namespace}__`,
7095
+ functions,
7096
+ errors,
7097
+ imports: interfaceImports
7098
+ });
7099
+ await formatAndWriteSolidity(systemInterface, system.interfacePath, "Generated system interface");
7100
+ }
7092
7101
  if (config.codegen.generateSystemLibraries) {
7093
7102
  const systemImport = {
7094
7103
  symbol: system.label,
@@ -7133,7 +7142,7 @@ async function worldgen({
7133
7142
  import path5 from "node:path";
7134
7143
  import { readFile } from "node:fs/promises";
7135
7144
  import { type as type2 } from "arktype";
7136
- import { indent, isDefined } from "@latticexyz/common/utils";
7145
+ import { indent, isDefined as isDefined2 } from "@latticexyz/common/utils";
7137
7146
  import { size, sliceHex } from "viem";
7138
7147
 
7139
7148
  // ts/node/common.ts
@@ -7211,7 +7220,7 @@ ${indent(artifact.message)}`);
7211
7220
  return;
7212
7221
  }
7213
7222
  return artifact;
7214
- }).filter(isDefined).filter(hasMetadata).map((artifact) => {
7223
+ }).filter(isDefined2).filter(hasMetadata).map((artifact) => {
7215
7224
  artifact;
7216
7225
  const sourcePath = Object.keys(artifact.metadata.settings.compilationTarget)[0];
7217
7226
  const name = artifact.metadata.settings.compilationTarget[sourcePath];
@@ -7320,7 +7329,7 @@ async function buildSystemsManifest(opts) {
7320
7329
  }
7321
7330
 
7322
7331
  // ts/node/loadSystemsManifest.ts
7323
- import fs2 from "node:fs/promises";
7332
+ import fs3 from "node:fs/promises";
7324
7333
  import path7 from "node:path";
7325
7334
  import { type as type4 } from "arktype";
7326
7335
  import { indent as indent2 } from "@latticexyz/common/utils";
@@ -7328,13 +7337,13 @@ var parseManifest = type4("string").pipe.try((s) => JSON.parse(s), SystemsManife
7328
7337
  async function loadSystemsManifest(opts) {
7329
7338
  const outFile = path7.join(opts.rootDir, systemsManifestFilename);
7330
7339
  try {
7331
- await fs2.access(outFile, fs2.constants.F_OK | fs2.constants.R_OK);
7340
+ await fs3.access(outFile, fs3.constants.F_OK | fs3.constants.R_OK);
7332
7341
  } catch (error2) {
7333
7342
  throw new Error(
7334
7343
  `Systems manifest at "${systemsManifestFilename}" not found or not readable. Run \`mud build\` before trying again.`
7335
7344
  );
7336
7345
  }
7337
- const json = await fs2.readFile(outFile, "utf8");
7346
+ const json = await fs3.readFile(outFile, "utf8");
7338
7347
  const manifest = parseManifest(json);
7339
7348
  if (manifest instanceof type4.errors) {
7340
7349
  throw new Error(