diff --git a/.changeset/odd-bags-compete.md b/.changeset/odd-bags-compete.md new file mode 100644 index 0000000000..e0899b05a0 --- /dev/null +++ b/.changeset/odd-bags-compete.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/cli": patch +--- + +Deploys will now always rebuild `IWorld.sol` interface (a workaround for https://github.com/foundry-rs/foundry/issues/6241) diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts index 62c658598f..36689081b3 100644 --- a/packages/cli/src/runDeploy.ts +++ b/packages/cli/src/runDeploy.ts @@ -7,7 +7,14 @@ import { privateKeyToAccount } from "viem/accounts"; import { loadConfig } from "@latticexyz/config/node"; import { StoreConfig } from "@latticexyz/store"; import { WorldConfig } from "@latticexyz/world"; -import { forge, getOutDirectory, getRemappings, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry"; +import { + forge, + getForgeConfig, + getOutDirectory, + getRemappings, + getRpcUrl, + getSrcDirectory, +} from "@latticexyz/common/foundry"; import chalk from "chalk"; import { execa } from "execa"; import { MUDError } from "@latticexyz/common/errors"; @@ -18,6 +25,9 @@ import { WorldDeploy } from "./deploy/common"; import { tablegen } from "@latticexyz/store/codegen"; import { worldgen } from "@latticexyz/world/node"; import { getExistingContracts } from "./utils/getExistingContracts"; +import { debug as parentDebug } from "./debug"; + +const debug = parentDebug.extend("runDeploy"); export const deployOptions = { configPath: { type: "string", desc: "Path to the config file" }, @@ -63,6 +73,20 @@ export async function runDeploy(opts: DeployOptions): Promise { if (!opts.skipBuild) { const outPath = path.join(srcDir, config.codegenDirectory); await Promise.all([tablegen(config, outPath, remappings), worldgen(config, getExistingContracts(srcDir), outPath)]); + + // TODO remove when https://github.com/foundry-rs/foundry/issues/6241 is resolved + const forgeConfig = await getForgeConfig(profile); + 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 }); await execa("mud", ["abi-ts"], { stdio: "inherit" }); } diff --git a/packages/common/src/foundry/index.ts b/packages/common/src/foundry/index.ts index 8ff7d8b199..b7f29ee61a 100644 --- a/packages/common/src/foundry/index.ts +++ b/packages/common/src/foundry/index.ts @@ -7,6 +7,8 @@ export interface ForgeConfig { script: string; out: string; libs: string[]; + cache: boolean; + cache_path: string; eth_rpc_url: string | null; // compiler