From f4a22ef937a9cf440543a2ff0b55b7d8177cd7fe Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Fri, 18 Oct 2024 17:50:14 -0300 Subject: [PATCH 01/25] Initial attempt to support deploying libraries needed for modules --- packages/cli/src/deploy/common.ts | 1 + packages/cli/src/deploy/configToModules.ts | 24 +++++++++++++++- packages/cli/src/runDeploy.ts | 3 +- packages/cli/src/utils/getContractArtifact.ts | 28 +++++++++++-------- .../cli/src/utils/importContractArtifact.ts | 1 + 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/deploy/common.ts b/packages/cli/src/deploy/common.ts index f88db9f65f..1d492e4c07 100644 --- a/packages/cli/src/deploy/common.ts +++ b/packages/cli/src/deploy/common.ts @@ -113,6 +113,7 @@ export type Module = DeterministicContract & { readonly name: string; readonly installAsRoot: boolean; readonly installData: Hex; // TODO: figure out better naming for this + readonly libraries: readonly Library[]; /** * @internal * Optional modules warn instead of throw if they revert while being installed. diff --git a/packages/cli/src/deploy/configToModules.ts b/packages/cli/src/deploy/configToModules.ts index 73f4387f1d..501dcc4b3f 100644 --- a/packages/cli/src/deploy/configToModules.ts +++ b/packages/cli/src/deploy/configToModules.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import { Module } from "./common"; +import { Library, Module } from "./common"; import { encodeField } from "@latticexyz/protocol-parser/internal"; import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import { bytesToHex } from "viem"; @@ -7,6 +7,10 @@ import { createPrepareDeploy } from "./createPrepareDeploy"; import { World } from "@latticexyz/world"; import { importContractArtifact } from "../utils/importContractArtifact"; import { resolveWithContext } from "@latticexyz/world/internal"; +import { findLibraries } from "./findLibraries"; +import { getContractData } from "../utils/getContractData"; +import { createRequire } from "node:module"; +import { findUp } from "find-up"; /** 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 = { @@ -53,9 +57,26 @@ export async function configToModules( } } + const requirePath = await findUp("package.json", { cwd: process.cwd() }); + if (!requirePath) throw new Error("Could not find package.json to import relative to."); + const require = createRequire(requirePath); + const name = path.basename(artifactPath, ".json"); const artifact = await importContractArtifact({ artifactPath }); + const moduleOutDir = path.join(require.resolve(artifactPath), "../../"); + const libraries = findLibraries(moduleOutDir).map((library): Library => { + // foundry/solc flattens artifacts, so we just use the path basename + const contractData = getContractData(path.basename(library.path), library.name, moduleOutDir); + return { + path: library.path, + name: library.name, + abi: contractData.abi, + prepareDeploy: createPrepareDeploy(contractData.bytecode, contractData.placeholders), + deployedBytecodeSize: contractData.deployedBytecodeSize, + }; + }); + // TODO: replace args with something more strongly typed const installArgs = mod.args .map((arg) => resolveWithContext(arg, { config })) @@ -70,6 +91,7 @@ export async function configToModules( return { name, + libraries, installAsRoot: mod.root, installData: installArgs.length === 0 ? "0x" : installArgs[0], prepareDeploy: createPrepareDeploy(artifact.bytecode, artifact.placeholders), diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 078a6b0e80..30f9f7abad 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -91,6 +91,7 @@ export async function runDeploy(opts: DeployOptions): Promise { config, forgeOutDir: outDir, }); + const artifacts = await findContractArtifacts({ forgeOutDir: outDir }); // TODO: pass artifacts into configToModules (https://github.com/latticexyz/mud/issues/3153) const modules = await configToModules(config, outDir); @@ -149,7 +150,7 @@ export async function runDeploy(opts: DeployOptions): Promise { client, tables, systems, - libraries, + libraries: [...libraries, ...modules.flatMap((mod) => mod.libraries)], modules, artifacts, }); diff --git a/packages/cli/src/utils/getContractArtifact.ts b/packages/cli/src/utils/getContractArtifact.ts index 9b274b2c3a..147b96f5a9 100644 --- a/packages/cli/src/utils/getContractArtifact.ts +++ b/packages/cli/src/utils/getContractArtifact.ts @@ -11,18 +11,24 @@ export type GetContractArtifactResult = { deployedBytecodeSize: number; }; +function HexNotStrict(value: string): value is Hex { + return isHex(value, { strict: false }); +} + const bytecodeSchema = z.object({ - object: z.string().refine(isHex), - linkReferences: z.record( - z.record( - z.array( - z.object({ - start: z.number(), - length: z.number(), - }), + object: z.string().refine(HexNotStrict), + linkReferences: z + .record( + z.record( + z.array( + z.object({ + start: z.number(), + length: z.number(), + }), + ), ), - ), - ), + ) + .optional(), }); const artifactSchema = z.object({ @@ -34,7 +40,7 @@ const artifactSchema = z.object({ export function getContractArtifact(artifactJson: unknown): GetContractArtifactResult { // TODO: improve errors or replace with arktype? const artifact = artifactSchema.parse(artifactJson); - const placeholders = findPlaceholders(artifact.bytecode.linkReferences); + const placeholders = findPlaceholders(artifact.bytecode.linkReferences ?? {}); return { abi: artifact.abi, diff --git a/packages/cli/src/utils/importContractArtifact.ts b/packages/cli/src/utils/importContractArtifact.ts index 50c804f750..5920716814 100644 --- a/packages/cli/src/utils/importContractArtifact.ts +++ b/packages/cli/src/utils/importContractArtifact.ts @@ -25,6 +25,7 @@ export async function importContractArtifact({ let artfactJson; try { const requirePath = packageJsonPath ?? (await findUp("package.json", { cwd: process.cwd() })); + console.log({ requirePath }); if (!requirePath) throw new Error("Could not find package.json to import relative to."); const require = createRequire(requirePath); From 44228a854ffa9dfbe316050ccfc6c7d307ad4da5 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Fri, 18 Oct 2024 17:52:33 -0300 Subject: [PATCH 02/25] Remove console.log --- packages/cli/src/utils/importContractArtifact.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/utils/importContractArtifact.ts b/packages/cli/src/utils/importContractArtifact.ts index 5920716814..50c804f750 100644 --- a/packages/cli/src/utils/importContractArtifact.ts +++ b/packages/cli/src/utils/importContractArtifact.ts @@ -25,7 +25,6 @@ export async function importContractArtifact({ let artfactJson; try { const requirePath = packageJsonPath ?? (await findUp("package.json", { cwd: process.cwd() })); - console.log({ requirePath }); if (!requirePath) throw new Error("Could not find package.json to import relative to."); const require = createRequire(requirePath); From fd2cb00655dc3f0a34cd3caa516e71e9de359725 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Fri, 18 Oct 2024 18:19:06 -0300 Subject: [PATCH 03/25] minor changes --- packages/cli/src/deploy/configToModules.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/deploy/configToModules.ts b/packages/cli/src/deploy/configToModules.ts index 501dcc4b3f..d3ace1a416 100644 --- a/packages/cli/src/deploy/configToModules.ts +++ b/packages/cli/src/deploy/configToModules.ts @@ -57,13 +57,13 @@ export async function configToModules( } } + const name = path.basename(artifactPath, ".json"); + const artifact = await importContractArtifact({ artifactPath }); + const requirePath = await findUp("package.json", { cwd: process.cwd() }); if (!requirePath) throw new Error("Could not find package.json to import relative to."); const require = createRequire(requirePath); - const name = path.basename(artifactPath, ".json"); - const artifact = await importContractArtifact({ artifactPath }); - const moduleOutDir = path.join(require.resolve(artifactPath), "../../"); const libraries = findLibraries(moduleOutDir).map((library): Library => { // foundry/solc flattens artifacts, so we just use the path basename From ba714287d3d0c4b92bdfe38d64e61b830c7ecb4c Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 09:52:26 -0300 Subject: [PATCH 04/25] Refactor to do the module library search inside resolveConfig --- packages/cli/src/deploy/common.ts | 1 - packages/cli/src/deploy/configToModules.ts | 24 +--------------------- packages/cli/src/deploy/resolveConfig.ts | 17 ++++++++++++++- packages/cli/src/runDeploy.ts | 2 +- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/packages/cli/src/deploy/common.ts b/packages/cli/src/deploy/common.ts index 1d492e4c07..f88db9f65f 100644 --- a/packages/cli/src/deploy/common.ts +++ b/packages/cli/src/deploy/common.ts @@ -113,7 +113,6 @@ export type Module = DeterministicContract & { readonly name: string; readonly installAsRoot: boolean; readonly installData: Hex; // TODO: figure out better naming for this - readonly libraries: readonly Library[]; /** * @internal * Optional modules warn instead of throw if they revert while being installed. diff --git a/packages/cli/src/deploy/configToModules.ts b/packages/cli/src/deploy/configToModules.ts index d3ace1a416..73f4387f1d 100644 --- a/packages/cli/src/deploy/configToModules.ts +++ b/packages/cli/src/deploy/configToModules.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import { Library, Module } from "./common"; +import { Module } from "./common"; import { encodeField } from "@latticexyz/protocol-parser/internal"; import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import { bytesToHex } from "viem"; @@ -7,10 +7,6 @@ import { createPrepareDeploy } from "./createPrepareDeploy"; import { World } from "@latticexyz/world"; import { importContractArtifact } from "../utils/importContractArtifact"; import { resolveWithContext } from "@latticexyz/world/internal"; -import { findLibraries } from "./findLibraries"; -import { getContractData } from "../utils/getContractData"; -import { createRequire } from "node:module"; -import { findUp } from "find-up"; /** 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 = { @@ -60,23 +56,6 @@ export async function configToModules( const name = path.basename(artifactPath, ".json"); const artifact = await importContractArtifact({ artifactPath }); - const requirePath = await findUp("package.json", { cwd: process.cwd() }); - if (!requirePath) throw new Error("Could not find package.json to import relative to."); - const require = createRequire(requirePath); - - const moduleOutDir = path.join(require.resolve(artifactPath), "../../"); - const libraries = findLibraries(moduleOutDir).map((library): Library => { - // foundry/solc flattens artifacts, so we just use the path basename - const contractData = getContractData(path.basename(library.path), library.name, moduleOutDir); - return { - path: library.path, - name: library.name, - abi: contractData.abi, - prepareDeploy: createPrepareDeploy(contractData.bytecode, contractData.placeholders), - deployedBytecodeSize: contractData.deployedBytecodeSize, - }; - }); - // TODO: replace args with something more strongly typed const installArgs = mod.args .map((arg) => resolveWithContext(arg, { config })) @@ -91,7 +70,6 @@ export async function configToModules( return { name, - libraries, installAsRoot: mod.root, installData: installArgs.length === 0 ? "0x" : installArgs[0], prepareDeploy: createPrepareDeploy(artifact.bytecode, artifact.placeholders), diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index d49b00e95e..406462cad9 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -7,6 +7,8 @@ import { groupBy } from "@latticexyz/common/utils"; import { findLibraries } from "./findLibraries"; import { createPrepareDeploy } from "./createPrepareDeploy"; import { World } from "@latticexyz/world"; +import { findUp } from "find-up"; +import { createRequire } from "node:module"; // TODO: replace this with a manifest/combined config output @@ -22,7 +24,20 @@ export async function resolveConfig({ readonly systems: readonly System[]; readonly libraries: readonly Library[]; }> { - const libraries = findLibraries(forgeOutDir).map((library): Library => { + const requirePath = await findUp("package.json", { cwd: process.cwd() }); + if (!requirePath) throw new Error("Could not find package.json to import relative to."); + const require = createRequire(requirePath); + + const moduleOutDirs = config.modules.flatMap((mod) => { + if (mod.artifactPath == undefined) { + return []; + } + + const moduleOutDir = path.join(require.resolve(mod.artifactPath), "../../"); + return [moduleOutDir]; + }); + + const libraries = [forgeOutDir, ...moduleOutDirs].flatMap(findLibraries).map((library): Library => { // foundry/solc flattens artifacts, so we just use the path basename const contractData = getContractData(path.basename(library.path), library.name, forgeOutDir); return { diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 30f9f7abad..49e4f5c50c 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -150,7 +150,7 @@ export async function runDeploy(opts: DeployOptions): Promise { client, tables, systems, - libraries: [...libraries, ...modules.flatMap((mod) => mod.libraries)], + libraries, modules, artifacts, }); From 98ac5e9af0b235832bc5e6b6949eedb065ffbade Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 11:48:08 -0300 Subject: [PATCH 05/25] PR feedback --- packages/cli/src/deploy/resolveConfig.ts | 2 +- packages/cli/src/utils/getContractArtifact.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index 406462cad9..53551f4981 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -24,7 +24,7 @@ export async function resolveConfig({ readonly systems: readonly System[]; readonly libraries: readonly Library[]; }> { - const requirePath = await findUp("package.json", { cwd: process.cwd() }); + const requirePath = await findUp("package.json"); if (!requirePath) throw new Error("Could not find package.json to import relative to."); const require = createRequire(requirePath); diff --git a/packages/cli/src/utils/getContractArtifact.ts b/packages/cli/src/utils/getContractArtifact.ts index 147b96f5a9..9a2419d865 100644 --- a/packages/cli/src/utils/getContractArtifact.ts +++ b/packages/cli/src/utils/getContractArtifact.ts @@ -11,12 +11,12 @@ export type GetContractArtifactResult = { deployedBytecodeSize: number; }; -function HexNotStrict(value: string): value is Hex { +function isBytecode(value: string): value is Hex { return isHex(value, { strict: false }); } const bytecodeSchema = z.object({ - object: z.string().refine(HexNotStrict), + object: z.string().refine(isBytecode), linkReferences: z .record( z.record( From 4397e4a809a270ef6abedb36d25cf734311b1089 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 12:38:39 -0300 Subject: [PATCH 06/25] Add comment about path resolution --- packages/cli/src/deploy/resolveConfig.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index 53551f4981..f5635e1130 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -33,6 +33,7 @@ export async function resolveConfig({ return []; } + // Navigate up two dirs to get the contract output directory const moduleOutDir = path.join(require.resolve(mod.artifactPath), "../../"); return [moduleOutDir]; }); From 665394c91fe53ae089c9920cba96ea27c6cae038 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 13:24:35 -0300 Subject: [PATCH 07/25] Add pupet modules to e2e mud config --- e2e/packages/contracts/mud.config.ts | 48 +++++++++++++++++++ e2e/packages/contracts/worlds.json | 2 +- .../src/modules/erc20-puppet/ERC20Module.sol | 9 +--- .../modules/erc721-puppet/ERC721Module.sol | 9 +--- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/e2e/packages/contracts/mud.config.ts b/e2e/packages/contracts/mud.config.ts index db69f40144..cad7c7eab2 100644 --- a/e2e/packages/contracts/mud.config.ts +++ b/e2e/packages/contracts/mud.config.ts @@ -1,4 +1,27 @@ import { defineWorld } from "@latticexyz/world"; +import { encodeAbiParameters, stringToHex } from "viem"; + +const erc20ModuleArgs = encodeAbiParameters( + [ + { type: "bytes14" }, + { + type: "tuple", + components: [{ type: "uint8" }, { type: "string" }, { type: "string" }], + }, + ], + [stringToHex("MyToken", { size: 14 }), [18, "Worthless Token", "WT"]], +); + +const erc721ModuleArgs = encodeAbiParameters( + [ + { type: "bytes14" }, + { + type: "tuple", + components: [{ type: "string" }, { type: "string" }, { type: "string" }], + }, + ], + [stringToHex("MyNFT", { size: 14 }), ["No Valuable Token", "NVT", "http://www.example.com/base/uri/goes/here"]], +); export default defineWorld({ tables: { @@ -71,5 +94,30 @@ export default defineWorld({ "@latticexyz/world-modules/out/Unstable_CallWithSignatureModule.sol/Unstable_CallWithSignatureModule.json", root: true, }, + { + artifactPath: "@latticexyz/world-modules/out/PuppetModule.sol/PuppetModule.json", + root: false, + args: [], + }, + { + artifactPath: "@latticexyz/world-modules/out/ERC20Module.sol/ERC20Module.json", + root: false, + args: [ + { + type: "bytes", + value: erc20ModuleArgs, + }, + ], + }, + { + artifactPath: "@latticexyz/world-modules/out/ERC721Module.sol/ERC721Module.json", + root: false, + args: [ + { + type: "bytes", + value: erc721ModuleArgs, + }, + ], + }, ], }); diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index 436a70cafe..b6d469afda 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0x7de562d80d6c8672aa32654af67884f411976593" + "address": "0xa9ffe180fd843a0a598d4bfb1c1fd6e155f45724" } } \ No newline at end of file diff --git a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol index e53bbf8232..4cd58f8118 100644 --- a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol +++ b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol @@ -24,8 +24,6 @@ import { ERC20Metadata, ERC20MetadataData } from "./tables/ERC20Metadata.sol"; contract ERC20Module is Module { error ERC20Module_InvalidNamespace(bytes14 namespace); - address immutable registrationLibrary = address(new ERC20ModuleRegistrationLibrary()); - function install(bytes memory encodedArgs) public { // Require the module to not be installed with these args yet requireNotInstalled(__self, encodedArgs); @@ -40,10 +38,7 @@ contract ERC20Module is Module { // Register the ERC20 tables and system IBaseWorld world = IBaseWorld(_world()); - (bool success, bytes memory returnData) = registrationLibrary.delegatecall( - abi.encodeCall(ERC20ModuleRegistrationLibrary.register, (world, namespace)) - ); - if (!success) revertWithBytes(returnData); + ERC20ModuleRegistrationLib.register(world, namespace); // Initialize the Metadata ERC20Metadata.set(_metadataTableId(namespace), metadata); @@ -69,7 +64,7 @@ contract ERC20Module is Module { } } -contract ERC20ModuleRegistrationLibrary { +library ERC20ModuleRegistrationLib { /** * Register systems and tables for a new ERC20 token in a given namespace */ diff --git a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol index 33cbb8d858..9b8c16a1c5 100644 --- a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol +++ b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol @@ -27,8 +27,6 @@ import { ERC721Metadata, ERC721MetadataData } from "./tables/ERC721Metadata.sol" contract ERC721Module is Module { error ERC721Module_InvalidNamespace(bytes14 namespace); - address immutable registrationLibrary = address(new ERC721ModuleRegistrationLibrary()); - function install(bytes memory encodedArgs) public { // Require the module to not be installed with these args yet requireNotInstalled(__self, encodedArgs); @@ -43,10 +41,7 @@ contract ERC721Module is Module { // Register the ERC721 tables and system IBaseWorld world = IBaseWorld(_world()); - (bool success, bytes memory returnData) = registrationLibrary.delegatecall( - abi.encodeCall(ERC721ModuleRegistrationLibrary.register, (world, namespace)) - ); - if (!success) revertWithBytes(returnData); + ERC721ModuleRegistrationLib.register(world, namespace); // Initialize the Metadata ERC721Metadata.set(_metadataTableId(namespace), metadata); @@ -72,7 +67,7 @@ contract ERC721Module is Module { } } -contract ERC721ModuleRegistrationLibrary { +library ERC721ModuleRegistrationLib { /** * Register systems and tables for a new ERC721 token in a given namespace */ From 23ad6cf3b24b02b6aee1274e681df8ebdc3954a8 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 14:02:32 -0300 Subject: [PATCH 08/25] Use module out dir for finding libraries --- packages/cli/src/deploy/resolveConfig.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index f5635e1130..dee1d554ef 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -38,17 +38,19 @@ export async function resolveConfig({ return [moduleOutDir]; }); - const libraries = [forgeOutDir, ...moduleOutDirs].flatMap(findLibraries).map((library): Library => { - // foundry/solc flattens artifacts, so we just use the path basename - const contractData = getContractData(path.basename(library.path), library.name, forgeOutDir); - return { - path: library.path, - name: library.name, - abi: contractData.abi, - prepareDeploy: createPrepareDeploy(contractData.bytecode, contractData.placeholders), - deployedBytecodeSize: contractData.deployedBytecodeSize, - }; - }); + const libraries = [forgeOutDir, ...moduleOutDirs].flatMap((outDir) => + findLibraries(outDir).map((library): Library => { + // foundry/solc flattens artifacts, so we just use the path basename + const contractData = getContractData(path.basename(library.path), library.name, outDir); + return { + path: library.path, + name: library.name, + abi: contractData.abi, + prepareDeploy: createPrepareDeploy(contractData.bytecode, contractData.placeholders), + deployedBytecodeSize: contractData.deployedBytecodeSize, + }; + }), + ); const baseSystemContractData = getContractData("System.sol", "System", forgeOutDir); const baseSystemFunctions = baseSystemContractData.abi From 8e501014c38ca25bf9d312c04e63201d7944868c Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 14:09:18 -0300 Subject: [PATCH 09/25] Update e2e worlds.json --- e2e/packages/contracts/worlds.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index b6d469afda..21b4fe2251 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0xa9ffe180fd843a0a598d4bfb1c1fd6e155f45724" + "address": "0x7f09fa90db320f61bd649661f5f97aa079c1a736" } } \ No newline at end of file From 47fd22349984c22365aaff7cb135743263de26f9 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 18:31:49 -0300 Subject: [PATCH 10/25] Add erc20 module to e2e tests, local e2e tests working --- e2e/packages/contracts/mud.config.ts | 6 ++++++ e2e/packages/contracts/package.json | 1 + e2e/packages/contracts/worlds.json | 2 +- e2e/pnpm-lock.yaml | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/e2e/packages/contracts/mud.config.ts b/e2e/packages/contracts/mud.config.ts index cad7c7eab2..31466add2e 100644 --- a/e2e/packages/contracts/mud.config.ts +++ b/e2e/packages/contracts/mud.config.ts @@ -1,4 +1,5 @@ import { defineWorld } from "@latticexyz/world"; +import { defineERC20Config } from "@latticexyz/world-module-erc20"; import { encodeAbiParameters, stringToHex } from "viem"; const erc20ModuleArgs = encodeAbiParameters( @@ -119,5 +120,10 @@ export default defineWorld({ }, ], }, + defineERC20Config({ + namespace: "erc20Namespace", + name: "MyToken", + symbol: "MTK", + }), ], }); diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index 6863f55a98..ca08068992 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -16,6 +16,7 @@ "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/world": "link:../../../packages/world", + "@latticexyz/world-module-erc20": "link:../../../packages/world-module-erc20", "@latticexyz/world-modules": "link:../../../packages/world-modules", "dotenv": "^16.0.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index 21b4fe2251..d5c4c41b3b 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0x7f09fa90db320f61bd649661f5f97aa079c1a736" + "address": "0x086627188fe4cb73c04bedeace1281e74a6b76d1" } } \ No newline at end of file diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 8dd42d17f3..43d6c26fde 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -96,6 +96,9 @@ importers: '@latticexyz/world': specifier: link:../../../packages/world version: link:../../../packages/world + '@latticexyz/world-module-erc20': + specifier: link:../../../packages/world-module-erc20 + version: link:../../../packages/world-module-erc20 '@latticexyz/world-modules': specifier: link:../../../packages/world-modules version: link:../../../packages/world-modules From e59d442791005e71beede08c5dba3c6298a5df7a Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 19:07:27 -0300 Subject: [PATCH 11/25] Update worlds.json --- e2e/packages/contracts/worlds.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index d5c4c41b3b..4848458434 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0x086627188fe4cb73c04bedeace1281e74a6b76d1" + "address": "0xcbf80e1b5bafec05410e47033d74c6ec4479d385" } } \ No newline at end of file From 2855cdc0e1fc2b61a748060728bebeac3f2fd2fa Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Mon, 21 Oct 2024 19:31:29 -0300 Subject: [PATCH 12/25] Add erc20 module dev dependency to store-sync, as it needs to be resolved in tests --- packages/store-sync/package.json | 1 + pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 081a4879a3..560f209b88 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -92,6 +92,7 @@ "zustand": "^4.3.7" }, "devDependencies": { + "@latticexyz/world-module-erc20": "workspace:*", "@types/debug": "^4.1.7", "@types/node": "20.12.12", "@types/sql.js": "^1.4.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index daadc3d5c0..cc1131d61b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1173,6 +1173,9 @@ importers: specifier: ^4.3.7 version: 4.3.7(react@18.2.0) devDependencies: + '@latticexyz/world-module-erc20': + specifier: workspace:* + version: link:../world-module-erc20 '@types/debug': specifier: ^4.1.7 version: 4.1.7 From df8b52bb3dcf832d3d5311b7cef0d95aced84d2f Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 08:24:02 -0300 Subject: [PATCH 13/25] Remove modules to better understand e2e failures --- e2e/packages/contracts/mud.config.ts | 110 +++++++++++++-------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/e2e/packages/contracts/mud.config.ts b/e2e/packages/contracts/mud.config.ts index 31466add2e..990059a680 100644 --- a/e2e/packages/contracts/mud.config.ts +++ b/e2e/packages/contracts/mud.config.ts @@ -1,29 +1,29 @@ import { defineWorld } from "@latticexyz/world"; -import { defineERC20Config } from "@latticexyz/world-module-erc20"; -import { encodeAbiParameters, stringToHex } from "viem"; - -const erc20ModuleArgs = encodeAbiParameters( - [ - { type: "bytes14" }, - { - type: "tuple", - components: [{ type: "uint8" }, { type: "string" }, { type: "string" }], - }, - ], - [stringToHex("MyToken", { size: 14 }), [18, "Worthless Token", "WT"]], -); - -const erc721ModuleArgs = encodeAbiParameters( - [ - { type: "bytes14" }, - { - type: "tuple", - components: [{ type: "string" }, { type: "string" }, { type: "string" }], - }, - ], - [stringToHex("MyNFT", { size: 14 }), ["No Valuable Token", "NVT", "http://www.example.com/base/uri/goes/here"]], -); - +// import { defineERC20Config } from "@latticexyz/world-module-erc20"; +// import { encodeAbiParameters, stringToHex } from "viem"; +// +// const erc20ModuleArgs = encodeAbiParameters( +// [ +// { type: "bytes14" }, +// { +// type: "tuple", +// components: [{ type: "uint8" }, { type: "string" }, { type: "string" }], +// }, +// ], +// [stringToHex("MyToken", { size: 14 }), [18, "Worthless Token", "WT"]], +// ); +// +// const erc721ModuleArgs = encodeAbiParameters( +// [ +// { type: "bytes14" }, +// { +// type: "tuple", +// components: [{ type: "string" }, { type: "string" }, { type: "string" }], +// }, +// ], +// [stringToHex("MyNFT", { size: 14 }), ["No Valuable Token", "NVT", "http://www.example.com/base/uri/goes/here"]], +// ); +// export default defineWorld({ tables: { Number: { @@ -95,35 +95,35 @@ export default defineWorld({ "@latticexyz/world-modules/out/Unstable_CallWithSignatureModule.sol/Unstable_CallWithSignatureModule.json", root: true, }, - { - artifactPath: "@latticexyz/world-modules/out/PuppetModule.sol/PuppetModule.json", - root: false, - args: [], - }, - { - artifactPath: "@latticexyz/world-modules/out/ERC20Module.sol/ERC20Module.json", - root: false, - args: [ - { - type: "bytes", - value: erc20ModuleArgs, - }, - ], - }, - { - artifactPath: "@latticexyz/world-modules/out/ERC721Module.sol/ERC721Module.json", - root: false, - args: [ - { - type: "bytes", - value: erc721ModuleArgs, - }, - ], - }, - defineERC20Config({ - namespace: "erc20Namespace", - name: "MyToken", - symbol: "MTK", - }), + // { + // artifactPath: "@latticexyz/world-modules/out/PuppetModule.sol/PuppetModule.json", + // root: false, + // args: [], + // }, + // { + // artifactPath: "@latticexyz/world-modules/out/ERC20Module.sol/ERC20Module.json", + // root: false, + // args: [ + // { + // type: "bytes", + // value: erc20ModuleArgs, + // }, + // ], + // }, + // { + // artifactPath: "@latticexyz/world-modules/out/ERC721Module.sol/ERC721Module.json", + // root: false, + // args: [ + // { + // type: "bytes", + // value: erc721ModuleArgs, + // }, + // ], + // }, + // defineERC20Config({ + // namespace: "erc20Namespace", + // name: "MyToken", + // symbol: "MTK", + // }), ], }); From d1d4376c363862e2be3ff8ef840f8e92a9bce758 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 11:21:43 -0300 Subject: [PATCH 14/25] Add e2e module test package --- e2e/packages/contracts/mud.config.ts | 56 +------------- e2e/packages/contracts/package.json | 2 - e2e/packages/module-test/.gitignore | 9 +++ e2e/packages/module-test/foundry.toml | 21 +++++ e2e/packages/module-test/mud.config.ts | 60 +++++++++++++++ e2e/packages/module-test/package.json | 24 ++++++ e2e/packages/module-test/remappings.txt | 3 + .../module-test/src/codegen/world/IWorld.sol | 15 ++++ e2e/packages/module-test/test/Modules.t.sol | 19 +++++ e2e/pnpm-lock.yaml | 77 +++++++++---------- .../world-module-erc20/src/ERC20Module.sol | 15 +--- .../world-module-erc20/test/ERC20Module.t.sol | 5 +- 12 files changed, 191 insertions(+), 115 deletions(-) create mode 100644 e2e/packages/module-test/.gitignore create mode 100644 e2e/packages/module-test/foundry.toml create mode 100644 e2e/packages/module-test/mud.config.ts create mode 100644 e2e/packages/module-test/package.json create mode 100644 e2e/packages/module-test/remappings.txt create mode 100644 e2e/packages/module-test/src/codegen/world/IWorld.sol create mode 100644 e2e/packages/module-test/test/Modules.t.sol diff --git a/e2e/packages/contracts/mud.config.ts b/e2e/packages/contracts/mud.config.ts index 990059a680..db69f40144 100644 --- a/e2e/packages/contracts/mud.config.ts +++ b/e2e/packages/contracts/mud.config.ts @@ -1,29 +1,5 @@ import { defineWorld } from "@latticexyz/world"; -// import { defineERC20Config } from "@latticexyz/world-module-erc20"; -// import { encodeAbiParameters, stringToHex } from "viem"; -// -// const erc20ModuleArgs = encodeAbiParameters( -// [ -// { type: "bytes14" }, -// { -// type: "tuple", -// components: [{ type: "uint8" }, { type: "string" }, { type: "string" }], -// }, -// ], -// [stringToHex("MyToken", { size: 14 }), [18, "Worthless Token", "WT"]], -// ); -// -// const erc721ModuleArgs = encodeAbiParameters( -// [ -// { type: "bytes14" }, -// { -// type: "tuple", -// components: [{ type: "string" }, { type: "string" }, { type: "string" }], -// }, -// ], -// [stringToHex("MyNFT", { size: 14 }), ["No Valuable Token", "NVT", "http://www.example.com/base/uri/goes/here"]], -// ); -// + export default defineWorld({ tables: { Number: { @@ -95,35 +71,5 @@ export default defineWorld({ "@latticexyz/world-modules/out/Unstable_CallWithSignatureModule.sol/Unstable_CallWithSignatureModule.json", root: true, }, - // { - // artifactPath: "@latticexyz/world-modules/out/PuppetModule.sol/PuppetModule.json", - // root: false, - // args: [], - // }, - // { - // artifactPath: "@latticexyz/world-modules/out/ERC20Module.sol/ERC20Module.json", - // root: false, - // args: [ - // { - // type: "bytes", - // value: erc20ModuleArgs, - // }, - // ], - // }, - // { - // artifactPath: "@latticexyz/world-modules/out/ERC721Module.sol/ERC721Module.json", - // root: false, - // args: [ - // { - // type: "bytes", - // value: erc721ModuleArgs, - // }, - // ], - // }, - // defineERC20Config({ - // namespace: "erc20Namespace", - // name: "MyToken", - // symbol: "MTK", - // }), ], }); diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index ca08068992..58ec1e8474 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -16,8 +16,6 @@ "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/world": "link:../../../packages/world", - "@latticexyz/world-module-erc20": "link:../../../packages/world-module-erc20", - "@latticexyz/world-modules": "link:../../../packages/world-modules", "dotenv": "^16.0.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", diff --git a/e2e/packages/module-test/.gitignore b/e2e/packages/module-test/.gitignore new file mode 100644 index 0000000000..d2b0438d96 --- /dev/null +++ b/e2e/packages/module-test/.gitignore @@ -0,0 +1,9 @@ +out/ +cache/ +node_modules/ +bindings/ +artifacts/ +broadcast/ + +# Ignore all deploy artifacts +deploys/**/*.json diff --git a/e2e/packages/module-test/foundry.toml b/e2e/packages/module-test/foundry.toml new file mode 100644 index 0000000000..6ecb883f45 --- /dev/null +++ b/e2e/packages/module-test/foundry.toml @@ -0,0 +1,21 @@ +[profile.default] +solc = "0.8.24" +ffi = false +fuzz_runs = 256 +optimizer = true +optimizer_runs = 3000 +verbosity = 2 +src = "src" +test = "test" +out = "out" +allow_paths = [ + # pnpm symlinks to the project root's node_modules + "../../node_modules", + # we're also using linked mud packages from the monorepo + "../../../packages" +] +extra_output_files = [ + "abi", + "evm.bytecode" +] +fs_permissions = [{ access = "read", path = "./"}] diff --git a/e2e/packages/module-test/mud.config.ts b/e2e/packages/module-test/mud.config.ts new file mode 100644 index 0000000000..ab3f67c630 --- /dev/null +++ b/e2e/packages/module-test/mud.config.ts @@ -0,0 +1,60 @@ +import { defineWorld } from "@latticexyz/world"; +import { encodeAbiParameters, stringToHex } from "viem"; +import { defineERC20Config } from "@latticexyz/world-module-erc20"; + +const erc20ModuleArgs = encodeAbiParameters( + [ + { type: "bytes14" }, + { + type: "tuple", + components: [{ type: "uint8" }, { type: "string" }, { type: "string" }], + }, + ], + [stringToHex("MyToken", { size: 14 }), [18, "Worthless Token", "WT"]], +); + +const erc721ModuleArgs = encodeAbiParameters( + [ + { type: "bytes14" }, + { + type: "tuple", + components: [{ type: "string" }, { type: "string" }, { type: "string" }], + }, + ], + [stringToHex("MyNFT", { size: 14 }), ["No Valuable Token", "NVT", "http://www.example.com/base/uri/goes/here"]], +); + +export default defineWorld({ + modules: [ + { + artifactPath: "@latticexyz/world-modules/out/PuppetModule.sol/PuppetModule.json", + root: false, + args: [], + }, + { + artifactPath: "@latticexyz/world-modules/out/ERC20Module.sol/ERC20Module.json", + root: false, + args: [ + { + type: "bytes", + value: erc20ModuleArgs, + }, + ], + }, + { + artifactPath: "@latticexyz/world-modules/out/ERC721Module.sol/ERC721Module.json", + root: false, + args: [ + { + type: "bytes", + value: erc721ModuleArgs, + }, + ], + }, + defineERC20Config({ + namespace: "erc20Namespace", + name: "MyToken", + symbol: "MTK", + }), + ], +}); diff --git a/e2e/packages/module-test/package.json b/e2e/packages/module-test/package.json new file mode 100644 index 0000000000..0909408211 --- /dev/null +++ b/e2e/packages/module-test/package.json @@ -0,0 +1,24 @@ +{ + "name": "module-test", + "version": "0.0.0", + "private": true, + "license": "MIT", + "scripts": { + "build": "mud build", + "clean": "forge clean && shx rm -rf src/**/codegen", + "test": "mud test", + "test:ci": "pnpm run test" + }, + "devDependencies": { + "@latticexyz/cli": "link:../../../packages/cli", + "@latticexyz/store": "link:../../../packages/store", + "@latticexyz/world": "link:../../../packages/world", + "@latticexyz/world-module-erc20": "link:../../../packages/world-module-erc20", + "@latticexyz/world-modules": "link:../../../packages/world-modules", + "dotenv": "^16.0.3", + "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", + "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", + "prettier": "3.2.5", + "typescript": "5.4.2" + } +} diff --git a/e2e/packages/module-test/remappings.txt b/e2e/packages/module-test/remappings.txt new file mode 100644 index 0000000000..c4d992480e --- /dev/null +++ b/e2e/packages/module-test/remappings.txt @@ -0,0 +1,3 @@ +ds-test/=node_modules/ds-test/src/ +forge-std/=node_modules/forge-std/src/ +@latticexyz/=node_modules/@latticexyz/ diff --git a/e2e/packages/module-test/src/codegen/world/IWorld.sol b/e2e/packages/module-test/src/codegen/world/IWorld.sol new file mode 100644 index 0000000000..4761e84790 --- /dev/null +++ b/e2e/packages/module-test/src/codegen/world/IWorld.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; + +/** + * @title IWorld + * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) + * @notice This interface integrates all systems and associated function selectors + * that are dynamically registered in the World during deployment. + * @dev This is an autogenerated file; do not edit manually. + */ +interface IWorld is IBaseWorld {} diff --git a/e2e/packages/module-test/test/Modules.t.sol b/e2e/packages/module-test/test/Modules.t.sol new file mode 100644 index 0000000000..a6ce2c7560 --- /dev/null +++ b/e2e/packages/module-test/test/Modules.t.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; +import { ResourceIds } from "@latticexyz/store/src/codegen/index.sol"; + +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; +import { ResourceId, WorldResourceIdLib } from "@latticexyz/world/src/WorldResourceId.sol"; +import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; + +contract ModulesTest is MudTest { + function testModulesInstalled() public { + ResourceId erc20PuppetNamespaceId = WorldResourceIdLib.encodeNamespace("MyToken"); + ResourceId erc721PuppetNamespaceId = WorldResourceIdLib.encodeNamespace("MyNFT"); + ResourceId erc20NamespaceId = WorldResourceIdLib.encodeNamespace("erc20Namespace"); + + assertTrue(ResourceIds.getExists(erc20PuppetNamespaceId)); + assertTrue(ResourceIds.getExists(erc721PuppetNamespaceId)); + assertTrue(ResourceIds.getExists(erc20NamespaceId)); + } +} diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 43d6c26fde..b309f1e7a4 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -96,12 +96,6 @@ importers: '@latticexyz/world': specifier: link:../../../packages/world version: link:../../../packages/world - '@latticexyz/world-module-erc20': - specifier: link:../../../packages/world-module-erc20 - version: link:../../../packages/world-module-erc20 - '@latticexyz/world-modules': - specifier: link:../../../packages/world-modules - version: link:../../../packages/world-modules dotenv: specifier: ^16.0.3 version: 16.0.3 @@ -124,6 +118,39 @@ importers: specifier: 0.34.6 version: 0.34.6(happy-dom@12.10.3) + packages/module-test: + devDependencies: + '@latticexyz/cli': + specifier: link:../../../packages/cli + version: link:../../../packages/cli + '@latticexyz/store': + specifier: link:../../../packages/store + version: link:../../../packages/store + '@latticexyz/world': + specifier: link:../../../packages/world + version: link:../../../packages/world + '@latticexyz/world-module-erc20': + specifier: link:../../../packages/world-module-erc20 + version: link:../../../packages/world-module-erc20 + '@latticexyz/world-modules': + specifier: link:../../../packages/world-modules + version: link:../../../packages/world-modules + dotenv: + specifier: ^16.0.3 + version: 16.0.3 + ds-test: + specifier: https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0 + version: https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 + forge-std: + specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 + version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 + prettier: + specifier: 3.2.5 + version: 3.2.5 + typescript: + specifier: 5.4.2 + version: 5.4.2 + packages/sync-test: devDependencies: '@latticexyz/cli': @@ -640,11 +667,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - acorn@8.8.2: - resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} - engines: {node: '>=0.4.0'} - hasBin: true - ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -864,9 +886,6 @@ packages: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} - get-func-name@2.0.0: - resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} - get-func-name@2.0.2: resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} @@ -989,9 +1008,6 @@ packages: minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - mlly@1.2.1: - resolution: {integrity: sha512-1aMEByaWgBPEbWV2BOPEMySRrzl7rIHXmQxam4DM8jVjalTQDjpN2ZKOLUrwyhfZQO7IXHml2StcHMhooDeEEQ==} - mlly@1.5.0: resolution: {integrity: sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==} @@ -1048,9 +1064,6 @@ packages: path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} - pathe@1.1.0: - resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} - pathe@1.1.2: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} @@ -1217,9 +1230,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - ufo@1.1.2: - resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} - ufo@1.3.2: resolution: {integrity: sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==} @@ -1644,8 +1654,6 @@ snapshots: acorn@8.11.3: {} - acorn@8.8.2: {} - ansi-regex@5.0.1: {} ansi-styles@4.3.0: @@ -1820,8 +1828,6 @@ snapshots: get-caller-file@2.0.5: {} - get-func-name@2.0.0: {} - get-func-name@2.0.2: {} get-port@6.1.2: {} @@ -1915,7 +1921,7 @@ snapshots: loupe@2.3.6: dependencies: - get-func-name: 2.0.0 + get-func-name: 2.0.2 magic-string@0.30.5: dependencies: @@ -1931,13 +1937,6 @@ snapshots: minimist@1.2.8: {} - mlly@1.2.1: - dependencies: - acorn: 8.8.2 - pathe: 1.1.0 - pkg-types: 1.0.3 - ufo: 1.1.2 - mlly@1.5.0: dependencies: acorn: 8.11.3 @@ -1996,8 +1995,6 @@ snapshots: path-parse@1.0.7: {} - pathe@1.1.0: {} - pathe@1.1.2: {} pathval@1.1.1: {} @@ -2007,8 +2004,8 @@ snapshots: pkg-types@1.0.3: dependencies: jsonc-parser: 3.2.0 - mlly: 1.2.1 - pathe: 1.1.0 + mlly: 1.5.0 + pathe: 1.1.2 playwright-core@1.35.1: {} @@ -2159,8 +2156,6 @@ snapshots: typescript@5.4.2: {} - ufo@1.1.2: {} - ufo@1.3.2: {} viem@2.21.19(typescript@5.4.2)(zod@3.23.8): diff --git a/packages/world-module-erc20/src/ERC20Module.sol b/packages/world-module-erc20/src/ERC20Module.sol index 9ea71f2799..cab1a5b91d 100644 --- a/packages/world-module-erc20/src/ERC20Module.sol +++ b/packages/world-module-erc20/src/ERC20Module.sol @@ -17,8 +17,6 @@ contract ERC20Module is Module { error ERC20Module_InvalidNamespace(bytes14 namespace); error ERC20Module_NamespaceAlreadyExists(bytes14 namespace); - ERC20RegistryLib public immutable registryLib = new ERC20RegistryLib(); - function install(bytes memory encodedArgs) public { // TODO: we should probably check just for namespace, not for all args requireNotInstalled(__self, encodedArgs); @@ -44,7 +42,7 @@ contract ERC20Module is Module { // The token should have transferred the namespace ownership to this module in its constructor world.transferOwnership(namespaceId, _msgSender()); - registryLib.delegateRegister(world, namespaceId, address(token)); + ERC20RegistryLib.register(world, namespaceId, address(token)); } function installRoot(bytes memory) public pure { @@ -52,7 +50,7 @@ contract ERC20Module is Module { } } -contract ERC20RegistryLib { +library ERC20RegistryLib { function register(IBaseWorld world, ResourceId namespaceId, address token) public { ResourceId erc20RegistryTableId = ModuleConstants.registryTableId(); if (!ResourceIds.getExists(erc20RegistryTableId)) { @@ -63,12 +61,3 @@ contract ERC20RegistryLib { ERC20Registry.set(erc20RegistryTableId, namespaceId, address(token)); } } - -function delegateRegister(ERC20RegistryLib lib, IBaseWorld world, ResourceId namespaceId, address token) { - (bool success, bytes memory returnData) = address(lib).delegatecall( - abi.encodeCall(ERC20RegistryLib.register, (world, namespaceId, token)) - ); - if (!success) revertWithBytes(returnData); -} - -using { delegateRegister } for ERC20RegistryLib; diff --git a/packages/world-module-erc20/test/ERC20Module.t.sol b/packages/world-module-erc20/test/ERC20Module.t.sol index b0863581b6..17d85683d8 100644 --- a/packages/world-module-erc20/test/ERC20Module.t.sol +++ b/packages/world-module-erc20/test/ERC20Module.t.sol @@ -46,10 +46,7 @@ contract ERC20ModuleTest is Test, GasReporter { ResourceId erc20NamespaceId = WorldResourceIdLib.encodeNamespace(TestConstants.ERC20_NAMESPACE); // Token should retain access to the namespace - address token = ERC20Registry.get( - erc20RegistryTableId, - WorldResourceIdLib.encodeNamespace(TestConstants.ERC20_NAMESPACE) - ); + address token = ERC20Registry.get(erc20RegistryTableId, erc20NamespaceId); // Module should grant the token access to the token namespace assertTrue(ResourceAccess.get(erc20NamespaceId, token), "Token does not have access to its namespace"); From 7ca8bd0a4429f5e87c853332667b24bcbb79818d Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 11:30:01 -0300 Subject: [PATCH 15/25] Remove erc20 module from store-sync deps --- packages/store-sync/package.json | 1 - pnpm-lock.yaml | 3 --- 2 files changed, 4 deletions(-) diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 560f209b88..081a4879a3 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -92,7 +92,6 @@ "zustand": "^4.3.7" }, "devDependencies": { - "@latticexyz/world-module-erc20": "workspace:*", "@types/debug": "^4.1.7", "@types/node": "20.12.12", "@types/sql.js": "^1.4.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc1131d61b..daadc3d5c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1173,9 +1173,6 @@ importers: specifier: ^4.3.7 version: 4.3.7(react@18.2.0) devDependencies: - '@latticexyz/world-module-erc20': - specifier: workspace:* - version: link:../world-module-erc20 '@types/debug': specifier: ^4.1.7 version: 4.1.7 From a4c92b68819295f3331be894b758e809d11eb9c4 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 11:32:24 -0300 Subject: [PATCH 16/25] Add missing dep to module-test --- e2e/packages/module-test/package.json | 1 + e2e/pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/e2e/packages/module-test/package.json b/e2e/packages/module-test/package.json index 0909408211..59e7722f45 100644 --- a/e2e/packages/module-test/package.json +++ b/e2e/packages/module-test/package.json @@ -11,6 +11,7 @@ }, "devDependencies": { "@latticexyz/cli": "link:../../../packages/cli", + "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/world": "link:../../../packages/world", "@latticexyz/world-module-erc20": "link:../../../packages/world-module-erc20", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index b309f1e7a4..48f0bd3655 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -123,6 +123,9 @@ importers: '@latticexyz/cli': specifier: link:../../../packages/cli version: link:../../../packages/cli + '@latticexyz/schema-type': + specifier: link:../../../packages/schema-type + version: link:../../../packages/schema-type '@latticexyz/store': specifier: link:../../../packages/store version: link:../../../packages/store From f57e8b5fde1c3272259bcbc75428b9370ee717c9 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 11:40:57 -0300 Subject: [PATCH 17/25] Change anvil port so it doesn't conflict with contracts package tests --- e2e/packages/module-test/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/packages/module-test/package.json b/e2e/packages/module-test/package.json index 59e7722f45..5768d37df7 100644 --- a/e2e/packages/module-test/package.json +++ b/e2e/packages/module-test/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "mud build", "clean": "forge clean && shx rm -rf src/**/codegen", - "test": "mud test", + "test": "mud test --port 4243", "test:ci": "pnpm run test" }, "devDependencies": { From 7b05bf02f5665d58b79d1b05dc24ee93eac0d1fd Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 11:51:34 -0300 Subject: [PATCH 18/25] Add back missing dep to e2e contracts package --- e2e/packages/contracts/package.json | 1 + e2e/pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index 58ec1e8474..6863f55a98 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -16,6 +16,7 @@ "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/world": "link:../../../packages/world", + "@latticexyz/world-modules": "link:../../../packages/world-modules", "dotenv": "^16.0.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 48f0bd3655..492d29a78b 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -96,6 +96,9 @@ importers: '@latticexyz/world': specifier: link:../../../packages/world version: link:../../../packages/world + '@latticexyz/world-modules': + specifier: link:../../../packages/world-modules + version: link:../../../packages/world-modules dotenv: specifier: ^16.0.3 version: 16.0.3 From b8bf3f5d27ed4b9c57e617f243cbd312fe637b4e Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 14:00:36 -0300 Subject: [PATCH 19/25] Move puppet modules test to main test directory, and turn it into a package --- e2e/packages/contracts/worlds.json | 4 +-- e2e/packages/module-test/package.json | 25 ------------- e2e/pnpm-lock.yaml | 36 ------------------- package.json | 2 +- pnpm-lock.yaml | 27 ++++++++++++++ pnpm-workspace.yaml | 1 + .../puppet-modules}/.gitignore | 0 .../puppet-modules}/foundry.toml | 0 .../puppet-modules}/mud.config.ts | 6 ---- test/puppet-modules/package.json | 22 ++++++++++++ .../puppet-modules}/remappings.txt | 0 .../src/codegen/world/IWorld.sol | 0 .../puppet-modules}/test/Modules.t.sol | 2 -- 13 files changed, 53 insertions(+), 72 deletions(-) delete mode 100644 e2e/packages/module-test/package.json rename {e2e/packages/module-test => test/puppet-modules}/.gitignore (100%) rename {e2e/packages/module-test => test/puppet-modules}/foundry.toml (100%) rename {e2e/packages/module-test => test/puppet-modules}/mud.config.ts (88%) create mode 100644 test/puppet-modules/package.json rename {e2e/packages/module-test => test/puppet-modules}/remappings.txt (100%) rename {e2e/packages/module-test => test/puppet-modules}/src/codegen/world/IWorld.sol (100%) rename {e2e/packages/module-test => test/puppet-modules}/test/Modules.t.sol (83%) diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index 4848458434..fd5f58e5e9 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0xcbf80e1b5bafec05410e47033d74c6ec4479d385" + "address": "0x7de562d80d6c8672aa32654af67884f411976593" } -} \ No newline at end of file +} diff --git a/e2e/packages/module-test/package.json b/e2e/packages/module-test/package.json deleted file mode 100644 index 5768d37df7..0000000000 --- a/e2e/packages/module-test/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "module-test", - "version": "0.0.0", - "private": true, - "license": "MIT", - "scripts": { - "build": "mud build", - "clean": "forge clean && shx rm -rf src/**/codegen", - "test": "mud test --port 4243", - "test:ci": "pnpm run test" - }, - "devDependencies": { - "@latticexyz/cli": "link:../../../packages/cli", - "@latticexyz/schema-type": "link:../../../packages/schema-type", - "@latticexyz/store": "link:../../../packages/store", - "@latticexyz/world": "link:../../../packages/world", - "@latticexyz/world-module-erc20": "link:../../../packages/world-module-erc20", - "@latticexyz/world-modules": "link:../../../packages/world-modules", - "dotenv": "^16.0.3", - "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", - "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "prettier": "3.2.5", - "typescript": "5.4.2" - } -} diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 492d29a78b..efc3d77c56 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -121,42 +121,6 @@ importers: specifier: 0.34.6 version: 0.34.6(happy-dom@12.10.3) - packages/module-test: - devDependencies: - '@latticexyz/cli': - specifier: link:../../../packages/cli - version: link:../../../packages/cli - '@latticexyz/schema-type': - specifier: link:../../../packages/schema-type - version: link:../../../packages/schema-type - '@latticexyz/store': - specifier: link:../../../packages/store - version: link:../../../packages/store - '@latticexyz/world': - specifier: link:../../../packages/world - version: link:../../../packages/world - '@latticexyz/world-module-erc20': - specifier: link:../../../packages/world-module-erc20 - version: link:../../../packages/world-module-erc20 - '@latticexyz/world-modules': - specifier: link:../../../packages/world-modules - version: link:../../../packages/world-modules - dotenv: - specifier: ^16.0.3 - version: 16.0.3 - ds-test: - specifier: https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0 - version: https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 - forge-std: - specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 - version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 - prettier: - specifier: 3.2.5 - version: 3.2.5 - typescript: - specifier: 5.4.2 - version: 5.4.2 - packages/sync-test: devDependencies: '@latticexyz/cli': diff --git a/package.json b/package.json index 6241eb83cc..28c3acd943 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "type": "module", "scripts": { - "all-build": "for dir in packages/store packages/world packages/world-modules packages/cli test/mock-game-contracts e2e/packages/contracts examples/*/packages/contracts examples/multiple-namespaces templates/*/packages/contracts; do (cd \"$dir\" && pwd && pnpm build); done", + "all-build": "for dir in packages/store packages/world packages/world-modules packages/cli test/mock-game-contracts test/puppet-modules e2e/packages/contracts examples/*/packages/contracts examples/multiple-namespaces templates/*/packages/contracts; do (cd \"$dir\" && pwd && pnpm build); done", "all-install": "for dir in . docs e2e examples/* templates/*; do (cd \"$dir\" && pwd && pnpm install); done", "bench": "pnpm run --recursive bench", "build": "turbo run build --concurrency=100%", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index daadc3d5c0..5340428860 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1449,6 +1449,33 @@ importers: specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 + test/puppet-modules: + devDependencies: + '@latticexyz/cli': + specifier: workspace:* + version: link:../../packages/cli + '@latticexyz/schema-type': + specifier: workspace:* + version: link:../../packages/schema-type + '@latticexyz/store': + specifier: workspace:* + version: link:../../packages/store + '@latticexyz/world': + specifier: workspace:* + version: link:../../packages/world + '@latticexyz/world-modules': + specifier: workspace:* + version: link:../../packages/world-modules + dotenv: + specifier: ^16.0.3 + version: 16.0.3 + ds-test: + specifier: https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0 + version: https://codeload.github.com/dapphub/ds-test/tar.gz/e282159d5170298eb2455a6c05280ab5a73a4ef0 + forge-std: + specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1 + version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1 + test/ts-benchmarks: devDependencies: '@latticexyz/recs': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8a85755b53..29e13c6291 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,6 +1,7 @@ packages: - packages/* - test/mock-game-contracts + - test/puppet-modules - test/ts-benchmarks catalog: diff --git a/e2e/packages/module-test/.gitignore b/test/puppet-modules/.gitignore similarity index 100% rename from e2e/packages/module-test/.gitignore rename to test/puppet-modules/.gitignore diff --git a/e2e/packages/module-test/foundry.toml b/test/puppet-modules/foundry.toml similarity index 100% rename from e2e/packages/module-test/foundry.toml rename to test/puppet-modules/foundry.toml diff --git a/e2e/packages/module-test/mud.config.ts b/test/puppet-modules/mud.config.ts similarity index 88% rename from e2e/packages/module-test/mud.config.ts rename to test/puppet-modules/mud.config.ts index ab3f67c630..1a3fb308cd 100644 --- a/e2e/packages/module-test/mud.config.ts +++ b/test/puppet-modules/mud.config.ts @@ -1,6 +1,5 @@ import { defineWorld } from "@latticexyz/world"; import { encodeAbiParameters, stringToHex } from "viem"; -import { defineERC20Config } from "@latticexyz/world-module-erc20"; const erc20ModuleArgs = encodeAbiParameters( [ @@ -51,10 +50,5 @@ export default defineWorld({ }, ], }, - defineERC20Config({ - namespace: "erc20Namespace", - name: "MyToken", - symbol: "MTK", - }), ], }); diff --git a/test/puppet-modules/package.json b/test/puppet-modules/package.json new file mode 100644 index 0000000000..84c7489f70 --- /dev/null +++ b/test/puppet-modules/package.json @@ -0,0 +1,22 @@ +{ + "name": "puppet-modules-test", + "version": "0.0.0", + "private": true, + "license": "MIT", + "scripts": { + "build": "mud build", + "clean": "forge clean && shx rm -rf src/**/codegen", + "test": "mud test", + "test:ci": "pnpm run test" + }, + "devDependencies": { + "@latticexyz/cli": "workspace:*", + "@latticexyz/schema-type": "workspace:*", + "@latticexyz/store": "workspace:*", + "@latticexyz/world": "workspace:*", + "@latticexyz/world-modules": "workspace:*", + "dotenv": "^16.0.3", + "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", + "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1" + } +} diff --git a/e2e/packages/module-test/remappings.txt b/test/puppet-modules/remappings.txt similarity index 100% rename from e2e/packages/module-test/remappings.txt rename to test/puppet-modules/remappings.txt diff --git a/e2e/packages/module-test/src/codegen/world/IWorld.sol b/test/puppet-modules/src/codegen/world/IWorld.sol similarity index 100% rename from e2e/packages/module-test/src/codegen/world/IWorld.sol rename to test/puppet-modules/src/codegen/world/IWorld.sol diff --git a/e2e/packages/module-test/test/Modules.t.sol b/test/puppet-modules/test/Modules.t.sol similarity index 83% rename from e2e/packages/module-test/test/Modules.t.sol rename to test/puppet-modules/test/Modules.t.sol index a6ce2c7560..6581e8efc7 100644 --- a/e2e/packages/module-test/test/Modules.t.sol +++ b/test/puppet-modules/test/Modules.t.sol @@ -10,10 +10,8 @@ contract ModulesTest is MudTest { function testModulesInstalled() public { ResourceId erc20PuppetNamespaceId = WorldResourceIdLib.encodeNamespace("MyToken"); ResourceId erc721PuppetNamespaceId = WorldResourceIdLib.encodeNamespace("MyNFT"); - ResourceId erc20NamespaceId = WorldResourceIdLib.encodeNamespace("erc20Namespace"); assertTrue(ResourceIds.getExists(erc20PuppetNamespaceId)); assertTrue(ResourceIds.getExists(erc721PuppetNamespaceId)); - assertTrue(ResourceIds.getExists(erc20NamespaceId)); } } From 860af176472b6a0cea0f706f3c7cd7262c15359e Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 14:08:50 -0300 Subject: [PATCH 20/25] Revert change to worlds.json --- e2e/packages/contracts/worlds.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index fd5f58e5e9..436a70cafe 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -2,4 +2,4 @@ "31337": { "address": "0x7de562d80d6c8672aa32654af67884f411976593" } -} +} \ No newline at end of file From 6605d7a694b17e3cb030b2a50a50b1a3de26e8d3 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 14:23:45 -0300 Subject: [PATCH 21/25] Force add of .env for puppet-modules test --- test/puppet-modules/.env | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/puppet-modules/.env diff --git a/test/puppet-modules/.env b/test/puppet-modules/.env new file mode 100644 index 0000000000..d02fd07732 --- /dev/null +++ b/test/puppet-modules/.env @@ -0,0 +1,2 @@ +# Default Anvil private key +PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 From 2cbec495dbd785b3fa4231088876b63299038078 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 14:55:00 -0300 Subject: [PATCH 22/25] Update gas-report --- packages/world-module-erc20/gas-report.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/world-module-erc20/gas-report.json b/packages/world-module-erc20/gas-report.json index 8adb4db902..92485adbd0 100644 --- a/packages/world-module-erc20/gas-report.json +++ b/packages/world-module-erc20/gas-report.json @@ -135,7 +135,7 @@ "file": "test/ERC20Module.t.sol:ERC20ModuleTest", "test": "testInstall", "name": "install erc20 module", - "gasUsed": 4524262 + "gasUsed": 4523802 }, { "file": "test/ERC20Pausable.t.sol:ERC20PausableWithInternalStoreTest", From c9320ed9202d22db6524a1ca714e17660571ca8b Mon Sep 17 00:00:00 2001 From: V Date: Tue, 22 Oct 2024 15:05:59 -0300 Subject: [PATCH 23/25] Create gentle-carrots-kneel.md --- .changeset/gentle-carrots-kneel.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/gentle-carrots-kneel.md diff --git a/.changeset/gentle-carrots-kneel.md b/.changeset/gentle-carrots-kneel.md new file mode 100644 index 0000000000..bac11b2f41 --- /dev/null +++ b/.changeset/gentle-carrots-kneel.md @@ -0,0 +1,8 @@ +--- +"@latticexyz/cli": patch +"@latticexyz/world-module-erc20": patch +"@latticexyz/world-modules": patch +"puppet-modules-test": patch +--- + +World Modules (and contracts imported by them) can now use public library methods. From f1e6e2dbd7aed5015032646a80ecd36320f2b4c2 Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 15:11:08 -0300 Subject: [PATCH 24/25] Remove puppet module test from changeset --- .changeset/gentle-carrots-kneel.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changeset/gentle-carrots-kneel.md b/.changeset/gentle-carrots-kneel.md index bac11b2f41..227a687f9e 100644 --- a/.changeset/gentle-carrots-kneel.md +++ b/.changeset/gentle-carrots-kneel.md @@ -2,7 +2,6 @@ "@latticexyz/cli": patch "@latticexyz/world-module-erc20": patch "@latticexyz/world-modules": patch -"puppet-modules-test": patch --- World Modules (and contracts imported by them) can now use public library methods. From dc5ac428e8eeffc54468b18f10076f70db69d1ba Mon Sep 17 00:00:00 2001 From: Vicente Dragicevic Date: Tue, 22 Oct 2024 17:02:27 -0300 Subject: [PATCH 25/25] Split changeset in two (one for cli and one for token modules) --- .changeset/gentle-carrots-kneel.md | 4 +--- .changeset/little-ways-change.md | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changeset/little-ways-change.md diff --git a/.changeset/gentle-carrots-kneel.md b/.changeset/gentle-carrots-kneel.md index 227a687f9e..6280003cfc 100644 --- a/.changeset/gentle-carrots-kneel.md +++ b/.changeset/gentle-carrots-kneel.md @@ -1,7 +1,5 @@ --- "@latticexyz/cli": patch -"@latticexyz/world-module-erc20": patch -"@latticexyz/world-modules": patch --- -World Modules (and contracts imported by them) can now use public library methods. +Added support for deploying public libraries used within modules. diff --git a/.changeset/little-ways-change.md b/.changeset/little-ways-change.md new file mode 100644 index 0000000000..0be98f458f --- /dev/null +++ b/.changeset/little-ways-change.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/world-module-erc20": patch +"@latticexyz/world-modules": patch +--- + +Changed ERC20 and ERC721 related modules to use public library methods instead of manual `delegatecall`s.