Skip to content

Commit

Permalink
refactor(cli): remove forge cache workaround (#2576)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Apr 1, 2024
1 parent 9e23976 commit 3b845d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .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.
20 changes: 2 additions & 18 deletions 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;
Expand All @@ -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" });
}

0 comments on commit 3b845d6

Please sign in to comment.