From 9d7fc8588ef045280b544d2aace0d53a4324c71a Mon Sep 17 00:00:00 2001 From: alvarius Date: Wed, 25 Sep 2024 20:26:46 +0100 Subject: [PATCH] fix(world): resolve system namespace label (#3232) Co-authored-by: Kevin Ingersoll --- .changeset/heavy-donkeys-move.md | 6 ++++++ packages/world/ts/node/buildSystemsManifest.ts | 6 +++++- packages/world/ts/node/resolveSystems.ts | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/heavy-donkeys-move.md diff --git a/.changeset/heavy-donkeys-move.md b/.changeset/heavy-donkeys-move.md new file mode 100644 index 0000000000..a65d405281 --- /dev/null +++ b/.changeset/heavy-donkeys-move.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/world": patch +--- + +The `namespace` field in a multi-namespace config is now correctly resolved for systems. +This fixes a bug with root systems in a multi-namespace project. diff --git a/packages/world/ts/node/buildSystemsManifest.ts b/packages/world/ts/node/buildSystemsManifest.ts index 6bc40771e3..effd8a09bd 100644 --- a/packages/world/ts/node/buildSystemsManifest.ts +++ b/packages/world/ts/node/buildSystemsManifest.ts @@ -59,7 +59,11 @@ export async function buildSystemsManifest(opts: { rootDir: string; config: Worl const artifact = getSystemArtifact(system); const abi = artifact.abi.filter((item) => !excludedAbi.includes(formatAbiItem(item))); const worldAbi = system.deploy.registerWorldFunctions - ? abi.map((item) => (item.type === "function" ? { ...item, name: `${system.namespace}__${item.name}` } : item)) + ? abi.map((item) => + item.type === "function" + ? { ...item, name: system.namespace ? `${system.namespace}__${item.name}` : item.name } + : item, + ) : []; return { // labels diff --git a/packages/world/ts/node/resolveSystems.ts b/packages/world/ts/node/resolveSystems.ts index 152c1bb93a..596452b82f 100644 --- a/packages/world/ts/node/resolveSystems.ts +++ b/packages/world/ts/node/resolveSystems.ts @@ -31,9 +31,10 @@ export async function resolveSystems({ const systems = systemContracts .map((contract): ResolvedSystem => { const systemConfig = - config.namespaces[contract.namespaceLabel].systems[contract.systemLabel] ?? + config.namespaces[contract.namespaceLabel]?.systems[contract.systemLabel] ?? resolveNamespace({ label: contract.namespaceLabel, + namespace: config.namespaces[contract.namespaceLabel]?.namespace, systems: { [contract.systemLabel]: {}, },