Skip to content

Commit

Permalink
refactor: switch to run chain for hre init
Browse files Browse the repository at this point in the history
  • Loading branch information
kanej committed Sep 12, 2024
1 parent d3dbdef commit 08f0627
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion v-next/hardhat/src/internal/hre-intialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function createHardhatRuntimeEnvironment(
const resolvedProjectRoot = await resolveProjectRoot(projectRoot);

if (unsafeOptions.resolvedPlugins === undefined) {
const plugins = [...(config.plugins ?? []), ...builtinPlugins];
const plugins = [...builtinPlugins, ...(config.plugins ?? [])];

const resolvedPlugins = await resolvePluginList(
resolvedProjectRoot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { describe, it } from "node:test";
import { task } from "../../src/config.js";
import { createMockHardhatRuntimeEnvironment } from "../test-helpers/create-mock-hardhat-runtime-environment.js";

describe.only("createMockHardhatRuntimeEnvironment", () => {
it.only("should allow plugins that leverage the artifact hre object", async () => {
describe("createMockHardhatRuntimeEnvironment", () => {
it("should allow plugins that leverage the artifact hre object", async () => {
// arrange
const exampleArtifact: Artifact = {
_format: "hh-sol-artifact-1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
CompilerOutput,
} from "../../src/types/artifacts.js";
import type { GlobalOptions } from "../../src/types/global-options.js";
import type { HookContext } from "../../src/types/hooks.js";
import type { HardhatRuntimeEnvironment } from "../../src/types/hre.js";
import type { HardhatPlugin } from "../../src/types/plugins.js";

Expand Down Expand Up @@ -133,15 +132,20 @@ export async function createMockHardhatRuntimeEnvironment(

const mockArtifactsPlugin: HardhatPlugin = {
id: "mock-artifacts",
// dependencies: [async () => artifacts],
dependencies: [async () => artifacts],
hookHandlers: {
hre: async () => {
return {
created: async (
_context: HookContext,
hre: HardhatRuntimeEnvironment,
): Promise<void> => {
hre.artifacts = new MockArtifactsManager();
context,
hre,
next,
): Promise<HardhatRuntimeEnvironment> => {
const updatedHre = await next(context, hre);

updatedHre.artifacts = new MockArtifactsManager();

return updatedHre;
},
};
},
Expand Down

0 comments on commit 08f0627

Please sign in to comment.