Skip to content

Commit

Permalink
Merge pull request #5658 from NomicFoundation/refactor/remove-experim…
Browse files Browse the repository at this point in the history
…ental-trace-hooks

refactor!: Remove the experimental MessageTrace hook
  • Loading branch information
Xanewok authored Aug 21, 2024
2 parents 4210416 + 46cd7a1 commit 466c8da
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-apes-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Removed the experimentalAddHardhatNetworkMessageTraceHook API
1 change: 0 additions & 1 deletion packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ async function main() {
taskDefinitions,
scopesDefinitions,
envExtenders,
ctx.experimentalHardhatNetworkMessageTraceHooks,
userConfig,
providerExtenders
);
Expand Down
5 changes: 0 additions & 5 deletions packages/hardhat-core/src/internal/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ConfigExtender,
EnvironmentExtender,
ExperimentalHardhatNetworkMessageTraceHook,
HardhatRuntimeEnvironment,
ProviderExtender,
} from "../types";
Expand Down Expand Up @@ -60,10 +59,6 @@ export class HardhatContext {

public readonly configExtenders: ConfigExtender[] = [];

// NOTE: This is experimental and will be removed. Please contact our team if
// you are planning to use it.
public readonly experimentalHardhatNetworkMessageTraceHooks: ExperimentalHardhatNetworkMessageTraceHook[] =
[];
private _filesLoadedBeforeConfig?: string[];
private _filesLoadedAfterConfig?: string[];

Expand Down
10 changes: 0 additions & 10 deletions packages/hardhat-core/src/internal/core/config/config-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ConfigurableScopeDefinition,
ConfigurableTaskDefinition,
EnvironmentExtender,
ExperimentalHardhatNetworkMessageTraceHook,
ProviderExtender,
TaskArguments,
} from "../../../types";
Expand Down Expand Up @@ -167,15 +166,6 @@ export function extendProvider(extender: ProviderExtender) {
ctx.providerExtenders.push(extender);
}

// NOTE: This is experimental and will be removed. Please contact our team
// if you are planning to use it.
export function experimentalAddHardhatNetworkMessageTraceHook(
hook: ExperimentalHardhatNetworkMessageTraceHook
) {
const ctx = HardhatContext.getHardhatContext();
ctx.experimentalHardhatNetworkMessageTraceHooks.push(hook);
}

/**
* This object provides methods to interact with the configuration variables.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
Artifacts,
BoundExperimentalHardhatNetworkMessageTraceHook,
EIP1193Provider,
EthereumProvider,
HardhatConfig,
Expand Down Expand Up @@ -50,7 +49,6 @@ export async function createProvider(
config: HardhatConfig,
networkName: string,
artifacts?: Artifacts,
experimentalHardhatNetworkMessageTraceHooks: BoundExperimentalHardhatNetworkMessageTraceHook[] = [],
extenders: ProviderExtender[] = []
): Promise<EthereumProvider> {
let eip1193Provider: EIP1193Provider;
Expand Down Expand Up @@ -108,7 +106,6 @@ export async function createProvider(
hardhatNetConfig.initialDate !== undefined
? parseDateString(hardhatNetConfig.initialDate)
: undefined,
experimentalHardhatNetworkMessageTraceHooks,
forkConfig,
forkCachePath:
paths !== undefined ? getForkCacheDirPath(paths) : undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { MessageTrace } from "../hardhat-network/stack-traces/message-trace";

import debug from "debug";

import {
Artifacts as IArtifacts,
EnvironmentExtender,
ExperimentalHardhatNetworkMessageTraceHook,
HardhatArguments,
HardhatConfig,
HardhatRuntimeEnvironment,
Expand Down Expand Up @@ -78,7 +75,6 @@ export class Environment implements HardhatRuntimeEnvironment {
public readonly tasks: TasksMap,
public readonly scopes: ScopesMap,
environmentExtenders: EnvironmentExtender[] = [],
experimentalHardhatNetworkMessageTraceHooks: ExperimentalHardhatNetworkMessageTraceHook[] = [],
public readonly userConfig: HardhatUserConfig = {},
providerExtenders: ProviderExtender[] = []
) {
Expand All @@ -105,10 +101,6 @@ export class Environment implements HardhatRuntimeEnvironment {
config,
networkName,
this.artifacts,
experimentalHardhatNetworkMessageTraceHooks.map(
(hook) => (trace: MessageTrace, isCallMessageTrace: boolean) =>
hook(this, trace, isCallMessageTrace)
),
providerExtenders
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
Artifacts,
BoundExperimentalHardhatNetworkMessageTraceHook,
CompilerInput,
CompilerOutput,
EIP1193Provider,
Expand Down Expand Up @@ -116,7 +115,6 @@ interface HardhatNetworkProviderConfig {
initialBaseFeePerGas?: number;
initialDate?: Date;
coinbase?: string;
experimentalHardhatNetworkMessageTraceHooks?: BoundExperimentalHardhatNetworkMessageTraceHook[];
forkConfig?: ForkConfig;
forkCachePath?: string;
enableTransientStorage: boolean;
Expand Down
1 change: 0 additions & 1 deletion packages/hardhat-core/src/internal/lib/hardhat-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ if (HardhatContext.isCreated()) {
ctx.tasksDSL.getTaskDefinitions(),
ctx.tasksDSL.getScopesDefinitions(),
ctx.environmentExtenders,
ctx.experimentalHardhatNetworkMessageTraceHooks,
userConfig,
ctx.providerExtenders
);
Expand Down
1 change: 0 additions & 1 deletion packages/hardhat-core/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ if (!HardhatContext.isCreated()) {
ctx.tasksDSL.getTaskDefinitions(),
ctx.tasksDSL.getScopesDefinitions(),
ctx.environmentExtenders,
ctx.experimentalHardhatNetworkMessageTraceHooks,
userConfig,
ctx.providerExtenders
);
Expand Down
18 changes: 0 additions & 18 deletions packages/hardhat-core/src/types/experimental.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/hardhat-core/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./config";
export * from "./experimental";
export * from "./provider";
export * from "./runtime";
export * from "./artifacts";
Expand Down
14 changes: 2 additions & 12 deletions packages/hardhat-core/test/internal/core/providers/construction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import {
import { ERRORS } from "../../../../src/internal/core/errors-list";
import { numberToRpcQuantity } from "../../../../src/internal/core/jsonrpc/types/base-types";
import { BackwardsCompatibilityProviderAdapter } from "../../../../src/internal/core/providers/backwards-compatibility";
import {
BoundExperimentalHardhatNetworkMessageTraceHook,
HardhatConfig,
} from "../../../../src/types";
import { HardhatConfig } from "../../../../src/types";
import {
applyProviderWrappers,
createProvider,
Expand Down Expand Up @@ -46,7 +43,6 @@ describe("Base provider creation", () => {

it("Should extend the base provider by calling each supplied extender", async () => {
const artifacts = undefined;
const hooks: BoundExperimentalHardhatNetworkMessageTraceHook[] = [];

const identity = (obj: any) => obj;
const extenders = [sinon.spy(identity), sinon.spy(identity)];
Expand All @@ -60,13 +56,7 @@ describe("Base provider creation", () => {
},
paths: undefined,
} as unknown as HardhatConfig;
const provider = await createProvider(
config,
"net",
artifacts,
hooks,
extenders
);
const provider = await createProvider(config, "net", artifacts, extenders);

assert.instanceOf(provider, BackwardsCompatibilityProviderAdapter);
for (const extender of extenders) {
Expand Down

0 comments on commit 466c8da

Please sign in to comment.