Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): always rebuild IWorld ABI #1929

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-bags-compete.md
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 25 additions & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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" },
Expand Down Expand Up @@ -63,6 +73,20 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
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" });
}
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/foundry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface ForgeConfig {
script: string;
out: string;
libs: string[];
cache: boolean;
cache_path: string;
eth_rpc_url: string | null;

// compiler
Expand Down
Loading