diff --git a/.changeset/weak-masks-change.md b/.changeset/weak-masks-change.md new file mode 100644 index 0000000..b9ac0e0 --- /dev/null +++ b/.changeset/weak-masks-change.md @@ -0,0 +1,5 @@ +--- +"@foundry-rs/hardhat-forge": patch +--- + +Ignore metadata files when getting contract artifacts diff --git a/packages/hardhat-forge/src/forge/artifacts.ts b/packages/hardhat-forge/src/forge/artifacts.ts index 91e2575..13bb221 100644 --- a/packages/hardhat-forge/src/forge/artifacts.ts +++ b/packages/hardhat-forge/src/forge/artifacts.ts @@ -165,7 +165,7 @@ export class ForgeArtifacts implements IArtifacts { const paths = await glob(path.join(this._out, "**/*.json"), { ignore: path.join(this._buildInfo, "*.json"), }); - return paths.sort(); + return paths.filter((p) => !p.endsWith(".metadata.json")).sort(); } public async getBuildInfoPaths(): Promise { @@ -218,7 +218,7 @@ export class ForgeArtifacts implements IArtifacts { const paths = globSync(path.join(this._out, "**/*.json"), { ignore: path.join(this._buildInfo, "*.json"), }); - return paths.sort(); + return paths.filter((p) => !p.endsWith(".metadata.json")).sort(); } /** diff --git a/packages/hardhat-forge/test/project.test.ts b/packages/hardhat-forge/test/project.test.ts index 7cea578..7a78c57 100644 --- a/packages/hardhat-forge/test/project.test.ts +++ b/packages/hardhat-forge/test/project.test.ts @@ -48,8 +48,10 @@ describe("Integration tests", function () { it("Should write artifacts to disk", async function () { const artifacts = await this.hre.artifacts.getArtifactPaths(); const files = await getAllFiles(this.hre.config.paths.artifacts); - // filter out the debug files - const filtered = files.filter((f) => !f.includes(".dbg.json")); + // filter out the debug files and metadata + const filtered = files + .filter((f) => !f.includes(".dbg.json")) + .filter((f) => !f.includes(".metadata.json")); assert.equal(artifacts.length, filtered.length); for (const file of filtered) {