-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: install module with delegation (#3586)
- Loading branch information
Showing
24 changed files
with
349 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@latticexyz/cli": patch | ||
"@latticexyz/world": patch | ||
--- | ||
|
||
Added `useDelegation` module config option to install modules using a temporary, unlimited delegation. This allows modules to install or upgrade systems and tables on your behalf. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@latticexyz/cli": patch | ||
"@latticexyz/world-module-metadata": patch | ||
--- | ||
|
||
Metadata module has been updated to install via delegation, making it easier for later module upgrades and to demonstrate modules installed via delegation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
"@latticexyz/world": patch | ||
--- | ||
|
||
Updated `encodeSystemCalls` and `encodeSystemCallsFrom` to include the `abi` in each call so that different systems/ABIs can be called in batch. Types have been improved to properly hint/narrow the expected arguments for each call. | ||
|
||
```diff | ||
-encodeSystemCalls(abi, [{ | ||
+encodeSystemCalls([{ | ||
+ abi, | ||
systemId: '0x...', | ||
functionName: '...', | ||
args: [...], | ||
}]); | ||
``` | ||
|
||
```diff | ||
-encodeSystemCallsFrom(from, abi, [{ | ||
+encodeSystemCallsFrom(from, [{ | ||
+ abi, | ||
systemId: '0x...', | ||
functionName: '...', | ||
args: [...], | ||
}]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/cli/src/deploy/compat/moduleArtifactPathFromName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Module } from "@latticexyz/world/internal"; | ||
import path from "node:path"; | ||
|
||
// Please don't add to this list! | ||
// | ||
// These are kept for backwards compatibility and assumes the downstream project has this module installed as a dependency. | ||
const knownModuleArtifacts = { | ||
KeysWithValueModule: "@latticexyz/world-modules/out/KeysWithValueModule.sol/KeysWithValueModule.json", | ||
KeysInTableModule: "@latticexyz/world-modules/out/KeysInTableModule.sol/KeysInTableModule.json", | ||
UniqueEntityModule: "@latticexyz/world-modules/out/UniqueEntityModule.sol/UniqueEntityModule.json", | ||
}; | ||
|
||
/** @internal For use with `config.modules.map(...)` */ | ||
export function moduleArtifactPathFromName( | ||
forgeOutDir: string, | ||
): (mod: Module) => Module & { readonly artifactPath: string } { | ||
return (mod) => { | ||
if (mod.artifactPath) return mod as never; | ||
if (!mod.name) throw new Error("No `artifactPath` provided for module."); | ||
|
||
const artifactPath = | ||
knownModuleArtifacts[mod.name as keyof typeof knownModuleArtifacts] ?? | ||
path.join(forgeOutDir, `${mod.name}.sol`, `${mod.name}.json`); | ||
|
||
console.warn( | ||
[ | ||
"", | ||
`⚠️ Your \`mud.config.ts\` is using a module with a \`name\`, but this option is deprecated.`, | ||
"", | ||
"To resolve this, you can replace this:", | ||
"", | ||
` name: ${JSON.stringify(mod.name)}`, | ||
"", | ||
"with this:", | ||
"", | ||
` artifactPath: ${JSON.stringify(artifactPath)}`, | ||
"", | ||
].join("\n"), | ||
); | ||
|
||
return { ...mod, artifactPath }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.