Skip to content

Commit 39130a4

Browse files
Merge branch 'v-next' into keystore-error-message
2 parents 209ea79 + 942d9af commit 39130a4

File tree

5 files changed

+75
-74
lines changed

5 files changed

+75
-74
lines changed

.changeset/olive-lobsters-carry.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@nomicfoundation/ignition-ui": patch
3+
"@nomicfoundation/hardhat-ignition": patch
4+
---
5+
6+
update mermaid version and re-enable visualize task (v3)

pnpm-lock.yaml

+24-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v-next/hardhat-ignition-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"eslint-plugin-mocha": "^9.0.0",
4040
"eslint-plugin-react-hooks": "^5.1.0",
4141
"eslint-plugin-react-refresh": "^0.4.18",
42-
"mermaid": "10.8.0",
42+
"mermaid": "10.9.3",
4343
"mocha": "^10.0.0",
4444
"prettier": "3.2.5",
4545
"react": "^18.2.0",

v-next/hardhat-ignition/src/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ const hardhatIgnitionPlugin: HardhatPlugin = {
9999
})
100100
.setAction(import.meta.resolve("./internal/tasks/wipe.js"))
101101
.build(),
102-
task(
103-
["ignition", "visualize"],
104-
"Not implemented yet - to be available soon",
105-
)
102+
task(["ignition", "visualize"], "Visualize a module as an HTML report")
106103
.addPositionalArgument({
107104
name: "modulePath",
108105
type: ArgumentType.FILE,
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,68 @@
11
import type { HardhatRuntimeEnvironment } from "hardhat/types/hre";
22
import type { NewTaskActionFunction } from "hardhat/types/tasks";
33

4-
// import path from "node:path";
4+
import path from "node:path";
55

6-
// import { HardhatError } from "@nomicfoundation/hardhat-errors";
7-
// import {
8-
// batches,
9-
// IgnitionError,
10-
// IgnitionModuleSerializer,
11-
// } from "@nomicfoundation/ignition-core";
6+
import { HardhatError } from "@nomicfoundation/hardhat-errors";
7+
import {
8+
batches,
9+
IgnitionError,
10+
IgnitionModuleSerializer,
11+
} from "@nomicfoundation/ignition-core";
1212

13-
// import { loadModule } from "../utils/load-module.js";
14-
// import { open } from "../utils/open.js";
15-
// import { shouldBeHardhatPluginError } from "../utils/shouldBeHardhatPluginError.js";
16-
// import { writeVisualization } from "../visualization/write-visualization.js";
17-
import chalk from "chalk";
13+
import { loadModule } from "../utils/load-module.js";
14+
import { open } from "../utils/open.js";
15+
import { shouldBeHardhatPluginError } from "../utils/shouldBeHardhatPluginError.js";
16+
import { writeVisualization } from "../visualization/write-visualization.js";
1817

1918
interface TaskVisualizeArguments {
2019
modulePath: string;
2120
noOpen: boolean;
2221
}
2322

2423
const visualizeTask: NewTaskActionFunction<TaskVisualizeArguments> = async (
25-
_args: { noOpen: boolean; modulePath: string },
26-
_hre: HardhatRuntimeEnvironment,
24+
{ noOpen, modulePath }: { noOpen: boolean; modulePath: string },
25+
hre: HardhatRuntimeEnvironment,
2726
) => {
28-
console.log(
29-
chalk.yellow(
30-
"This task will be implemented soon. Check back soon for more updates.",
31-
),
32-
);
27+
await hre.tasks.getTask("compile").run({ quiet: true });
3328

34-
return;
29+
const userModule = await loadModule(hre.config.paths.ignition, modulePath);
3530

36-
// await hre.tasks.getTask("compile").run({ quiet: true });
31+
if (userModule === undefined) {
32+
throw new HardhatError(HardhatError.ERRORS.IGNITION.NO_MODULES_FOUND);
33+
}
3734

38-
// const userModule = await loadModule(hre.config.paths.ignition, modulePath);
35+
try {
36+
const serializedIgnitionModule =
37+
IgnitionModuleSerializer.serialize(userModule);
3938

40-
// if (userModule === undefined) {
41-
// throw new HardhatError(HardhatError.ERRORS.IGNITION.NO_MODULES_FOUND);
42-
// } else {
43-
// try {
44-
// const serializedIgnitionModule =
45-
// IgnitionModuleSerializer.serialize(userModule);
39+
const batchInfo = batches(userModule);
4640

47-
// const batchInfo = batches(userModule);
41+
await writeVisualization(
42+
{ module: serializedIgnitionModule, batches: batchInfo },
43+
{
44+
cacheDir: hre.config.paths.cache,
45+
},
46+
);
47+
} catch (e) {
48+
if (e instanceof IgnitionError && shouldBeHardhatPluginError(e)) {
49+
throw new HardhatError(HardhatError.ERRORS.IGNITION.INTERNAL_ERROR, e);
50+
}
4851

49-
// await writeVisualization(
50-
// { module: serializedIgnitionModule, batches: batchInfo },
51-
// {
52-
// cacheDir: hre.config.paths.cache,
53-
// },
54-
// );
55-
// } catch (e) {
56-
// if (e instanceof IgnitionError && shouldBeHardhatPluginError(e)) {
57-
// throw new HardhatError(HardhatError.ERRORS.IGNITION.INTERNAL_ERROR, e);
58-
// }
52+
throw e;
53+
}
5954

60-
// throw e;
61-
// }
62-
// }
55+
if (!noOpen) {
56+
const indexFile = path.join(
57+
hre.config.paths.cache,
58+
"visualization",
59+
"index.html",
60+
);
6361

64-
// if (!noOpen) {
65-
// const indexFile = path.join(
66-
// hre.config.paths.cache,
67-
// "visualization",
68-
// "index.html",
69-
// );
62+
console.log(`Deployment visualization written to ${indexFile}`);
7063

71-
// console.log(`Deployment visualization written to ${indexFile}`);
72-
73-
// open(indexFile);
74-
// }
64+
open(indexFile);
65+
}
7566
};
7667

7768
export default visualizeTask;

0 commit comments

Comments
 (0)