Skip to content

Commit ca160e5

Browse files
authored
Merge pull request #7045 from NomicFoundation/ignition-deployment-dir-rule
fix: change deployment folder rule for ignition
2 parents a3d397d + 4b8d464 commit ca160e5

File tree

7 files changed

+43
-13
lines changed

7 files changed

+43
-13
lines changed

.changeset/sour-pandas-attend.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@nomicfoundation/hardhat-ignition-ethers": patch
3+
"@nomicfoundation/hardhat-ignition-viem": patch
4+
"@nomicfoundation/hardhat-ignition": patch
5+
---
6+
7+
Fix rule for determining whether local files are written for an Ignition deployment ([#6999](https://github.com/NomicFoundation/hardhat/issues/6999))

v-next/hardhat-ignition-ethers/src/internal/ethers-ignition-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class EthersIgnitionHelperImpl<ChainTypeT extends ChainType | string>
143143
const deploymentId = resolveDeploymentId(givenDeploymentId, chainId);
144144

145145
const deploymentDir =
146-
this.#connection.networkName === "default"
146+
this.#connection.networkConfig.type === "edr"
147147
? undefined
148148
: path.join(
149149
this.#hardhatConfig.paths.ignition,

v-next/hardhat-ignition-viem/src/internal/viem-ignition-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class ViemIgnitionHelperImpl<ChainTypeT extends ChainType | string>
146146
const deploymentId = resolveDeploymentId(givenDeploymentId, chainId);
147147

148148
const deploymentDir =
149-
this.#connection.networkName === "default"
149+
this.#connection.networkConfig.type === "edr"
150150
? undefined
151151
: path.join(
152152
this.#hardhatConfig.paths.ignition,

v-next/hardhat-ignition/src/internal/tasks/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ const taskDeploy: NewTaskActionFunction<TaskDeployArguments> = async (
8686
);
8787

8888
const deploymentDir =
89-
connection.networkName === "hardhat" && !writeLocalhostDeployment
89+
connection.networkConfig.type === "edr" && !writeLocalhostDeployment
9090
? undefined
9191
: path.join(hre.config.paths.ignition, "deployments", deploymentId);
92+
9293
if (chainId !== 31337) {
9394
if (process.env.HARDHAT_IGNITION_CONFIRM_DEPLOYMENT === undefined) {
9495
const prompt = await Prompt({

v-next/hardhat-ignition/test/deploy/reset.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
1+
import path, { dirname } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
14
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
5+
import { remove } from "@nomicfoundation/hardhat-utils/fs";
26
import { status } from "@nomicfoundation/ignition-core";
37
import { assert } from "chai";
48

59
import { HardhatArtifactResolver } from "../../src/helpers/hardhat-artifact-resolver.js";
610
import { useFileIgnitionProject } from "../test-helpers/use-ignition-project.js";
711

12+
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
14+
const deploymentId = "custom-reset-id";
15+
const deploymentDir = path.join(
16+
path.resolve(__dirname, `../fixture-projects/${deploymentId}/ignition`),
17+
"deployments",
18+
"chain-31337",
19+
);
20+
821
describe("reset flag", function () {
9-
useFileIgnitionProject("reset-flag", "custom-reset-id");
22+
useFileIgnitionProject("reset-flag", deploymentId);
23+
24+
beforeEach("clean filesystem", async function () {
25+
// make sure nothing is left over from a previous test
26+
await remove(deploymentDir);
27+
});
28+
29+
afterEach("clean filesystem", async function () {
30+
// cleanup
31+
await remove(deploymentDir);
32+
});
1033

1134
before(async function () {
1235
process.env.HARDHAT_IGNITION_CONFIRM_DEPLOYMENT = "false";
1336
process.env.HARDHAT_IGNITION_CONFIRM_RESET = "false";
1437
});
1538

16-
// TODO: Re-enable once the logic for creating the deploymentDir based on the ephemeral network is fixed
17-
it.skip("should reset a deployment", async function () {
39+
it("should reset a deployment", async function () {
1840
await this.hre.tasks.getTask(["ignition", "deploy"]).run({
1941
modulePath: "./ignition/modules/FirstPass.js",
20-
deploymentId: "custom-reset-id",
21-
reset: true,
42+
deploymentId,
43+
writeLocalhostDeployment: true,
44+
reset: false,
2245
});
2346

2447
await this.hre.tasks.getTask(["ignition", "deploy"]).run({
2548
modulePath: "./ignition/modules/SecondPass.js",
26-
deploymentId: "custom-reset-id",
49+
deploymentId,
50+
writeLocalhostDeployment: true,
2751
reset: true,
2852
});
2953

v-next/hardhat-ignition/test/deploy/writeLocalhost.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ describe("localhost deployment flag", function () {
3737
assert(await exists(deploymentDir), "Deployment was not written to disk");
3838
});
3939

40-
// TODO: Re-enable once the logic for creating the deploymentDir based on the ephemeral network is fixed
41-
it.skip("false should not write deployment to disk", async function () {
40+
it("false should not write deployment to disk", async function () {
4241
await this.hre.tasks.getTask(["ignition", "deploy"]).run({
4342
modulePath: "./ignition/modules/OwnModule.js",
4443
writeLocalhostDeployment: false,

v-next/hardhat-ignition/test/plan/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import { useEphemeralIgnitionProject } from "../test-helpers/use-ignition-projec
88
describe("visualize", () => {
99
useEphemeralIgnitionProject("minimal");
1010

11-
// TODO: HH3 bring back visualization
12-
it.skip("should create a visualization", async function () {
11+
it("should create a visualization", async function () {
1312
const visualizationPath = path.resolve("../minimal/cache/visualization");
1413
await emptyDir(visualizationPath);
1514

0 commit comments

Comments
 (0)