From 3b845d6b23b950e30310886407de11bb33fd028c Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 1 Apr 2024 12:39:14 +0100 Subject: [PATCH] refactor(cli): remove forge cache workaround (#2576) --- .changeset/silver-dancers-compete.md | 5 +++++ packages/cli/src/build.ts | 20 ++------------------ 2 files changed, 7 insertions(+), 18 deletions(-) create mode 100644 .changeset/silver-dancers-compete.md diff --git a/.changeset/silver-dancers-compete.md b/.changeset/silver-dancers-compete.md new file mode 100644 index 0000000000..410357e65e --- /dev/null +++ b/.changeset/silver-dancers-compete.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/cli": patch +--- + +Remove workaround for generating `IWorld` interface from cached forge files as this was fixed by forge. diff --git a/packages/cli/src/build.ts b/packages/cli/src/build.ts index d359e5af28..77a010ebaf 100644 --- a/packages/cli/src/build.ts +++ b/packages/cli/src/build.ts @@ -1,16 +1,12 @@ -import { existsSync, readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { tablegen } from "@latticexyz/store/codegen"; import { worldgen } from "@latticexyz/world/node"; import { World as WorldConfig } from "@latticexyz/world"; import { worldToV1 } from "@latticexyz/world/config/v2"; -import { forge, getForgeConfig, getRemappings } from "@latticexyz/common/foundry"; +import { forge, getRemappings } from "@latticexyz/common/foundry"; import { getExistingContracts } from "./utils/getExistingContracts"; -import { debug as parentDebug } from "./debug"; import { execa } from "execa"; -const debug = parentDebug.extend("runDeploy"); - type BuildOptions = { foundryProfile?: string; srcDir: string; @@ -25,24 +21,12 @@ export async function build({ const config = worldToV1(configV2); const outPath = path.join(srcDir, config.codegenDirectory); const remappings = await getRemappings(foundryProfile); + await Promise.all([ tablegen(configV2, outPath, remappings), worldgen(configV2, getExistingContracts(srcDir), outPath), ]); - // TODO remove when https://github.com/foundry-rs/foundry/issues/6241 is resolved - const forgeConfig = await getForgeConfig(foundryProfile); - if (forgeConfig.cache) { - const cacheFilePath = path.join(forgeConfig.cache_path, "solidity-files-cache.json"); - if (existsSync(cacheFilePath)) { - debug("Unsetting cached content hash of IWorld.sol to force it to regenerate"); - const solidityFilesCache = JSON.parse(readFileSync(cacheFilePath, "utf8")); - const worldInterfacePath = path.join(outPath, "world", "IWorld.sol"); - solidityFilesCache["files"][worldInterfacePath]["contentHash"] = ""; - writeFileSync(cacheFilePath, JSON.stringify(solidityFilesCache, null, 2)); - } - } - await forge(["build"], { profile: foundryProfile }); await execa("mud", ["abi-ts"], { stdio: "inherit" }); }