diff --git a/v-next/hardhat-ethers/src/internal/hardhat-helpers/hardhat-helpers.ts b/v-next/hardhat-ethers/src/internal/hardhat-helpers/hardhat-helpers.ts index 4be8c28db25..4d36ee7968d 100644 --- a/v-next/hardhat-ethers/src/internal/hardhat-helpers/hardhat-helpers.ts +++ b/v-next/hardhat-ethers/src/internal/hardhat-helpers/hardhat-helpers.ts @@ -4,7 +4,6 @@ import type { Libraries, } from "../../types.js"; import type { HardhatEthersProvider } from "../hardhat-ethers-provider/hardhat-ethers-provider.js"; -import type { HardhatEthersSigner } from "../signers/signers.js"; import type { ethers as EthersT } from "ethers"; import type { Abi, @@ -19,6 +18,8 @@ import { HardhatError, } from "@nomicfoundation/hardhat-errors"; +import { HardhatEthersSigner } from "../signers/signers.js"; + interface Link { sourceName: string; libraryName: string; @@ -68,11 +69,7 @@ export class HardhatHelpers { } public async getSigner(address: string): Promise { - const { HardhatEthersSigner: SignerWithAddressImpl } = await import( - "../signers/signers.js" - ); - - const signerWithAddress = await SignerWithAddressImpl.create( + const signerWithAddress = await HardhatEthersSigner.create( this.#provider, this.#networkName, this.#networkConfig, diff --git a/v-next/hardhat-utils/src/internal/lang.ts b/v-next/hardhat-utils/src/internal/lang.ts index 18cff830ae7..a2c75391db4 100644 --- a/v-next/hardhat-utils/src/internal/lang.ts +++ b/v-next/hardhat-utils/src/internal/lang.ts @@ -1,15 +1,10 @@ -import type rfdcT from "rfdc"; +import rfdc from "rfdc"; import { isObject } from "../lang.js"; -let clone: ReturnType | null = null; -export async function getDeepCloneFunction(): Promise<(input: T) => T> { - const { default: rfdc } = await import("rfdc"); - - if (clone === null) { - clone = rfdc(); - } +const clone = rfdc(); +export function getDeepCloneFunction(): (input: T) => T { return clone; } diff --git a/v-next/hardhat-utils/src/lang.ts b/v-next/hardhat-utils/src/lang.ts index 8b8089b646d..74dc986ad31 100644 --- a/v-next/hardhat-utils/src/lang.ts +++ b/v-next/hardhat-utils/src/lang.ts @@ -10,10 +10,8 @@ import { * @param value The value to clone. * @returns The deep clone of the provided value. */ -export async function deepClone(value: T): Promise { - const _deepClone = await getDeepCloneFunction(); - - return _deepClone(value); +export function deepClone(value: T): T { + return getDeepCloneFunction()(value); } /** diff --git a/v-next/hardhat-utils/test/lang.ts b/v-next/hardhat-utils/test/lang.ts index bcef6f047e6..cc60e0650ac 100644 --- a/v-next/hardhat-utils/test/lang.ts +++ b/v-next/hardhat-utils/test/lang.ts @@ -17,7 +17,7 @@ describe("lang", () => { describe("deepClone", () => { it("Should clone an object", async () => { const obj = { a: 1, b: 2, c: { d: 3 } }; - const clonedObj = await deepClone(obj); + const clonedObj = deepClone(obj); assert.deepEqual(clonedObj, obj); assert.notEqual(clonedObj, obj); @@ -27,7 +27,7 @@ describe("lang", () => { it("Should clone an array", async () => { const arr = [1, 2, [3]]; - const clonedArr = await deepClone(arr); + const clonedArr = deepClone(arr); assert.deepEqual(clonedArr, arr); assert.notEqual(clonedArr, arr); @@ -37,7 +37,7 @@ describe("lang", () => { it("Should clone a string", async () => { const str = "hello"; - const clonedStr = await deepClone(str); + const clonedStr = deepClone(str); assert.equal(clonedStr, str); expectTypeOf(clonedStr).toBeString(); @@ -45,7 +45,7 @@ describe("lang", () => { it("Should clone a number", async () => { const num = 42; - const clonedNum = await deepClone(num); + const clonedNum = deepClone(num); assert.equal(clonedNum, num); expectTypeOf(clonedNum).toBeNumber(); @@ -53,7 +53,7 @@ describe("lang", () => { it("Should clone null", async () => { const n = null; - const clonedN = await deepClone(n); + const clonedN = deepClone(n); assert.equal(clonedN, n); expectTypeOf(clonedN).toBeNull(); @@ -61,7 +61,7 @@ describe("lang", () => { it("Should clone undefined", async () => { const u = undefined; - const clonedU = await deepClone(u); + const clonedU = deepClone(u); assert.equal(clonedU, u); expectTypeOf(clonedU).toBeUndefined(); @@ -69,7 +69,7 @@ describe("lang", () => { it("Should reference a function", async () => { const fn = () => {}; - const clonedFn = await deepClone(fn); + const clonedFn = deepClone(fn); assert.equal(clonedFn, fn); expectTypeOf(clonedFn).toEqualTypeOf(); @@ -77,7 +77,7 @@ describe("lang", () => { it("Should clone a Date", async () => { const date = new Date(); - const clonedDate = await deepClone(date); + const clonedDate = deepClone(date); assert.deepEqual(clonedDate, date); assert.notEqual(clonedDate, date); @@ -89,7 +89,7 @@ describe("lang", () => { ["a", 1], ["b", 2], ]); - const clonedMap = await deepClone(map); + const clonedMap = deepClone(map); assert.deepEqual(clonedMap, map); assert.notEqual(clonedMap, map); @@ -98,7 +98,7 @@ describe("lang", () => { it("Should clone a Set", async () => { const set = new Set([1, 2]); - const clonedSet = await deepClone(set); + const clonedSet = deepClone(set); assert.deepEqual(clonedSet, set); assert.notEqual(clonedSet, set); @@ -107,7 +107,7 @@ describe("lang", () => { it("Should clone a Buffer", async () => { const buffer = Buffer.from("test"); - const clonedBuffer = await deepClone(buffer); + const clonedBuffer = deepClone(buffer); const expected: { [key: number]: number } = {}; for (let i = 0; i < buffer.length; i++) { @@ -124,7 +124,7 @@ describe("lang", () => { return arguments; } const args = testFunc(1, "2", false); - const clonedArgs = await deepClone(args); + const clonedArgs = deepClone(args); assert.deepEqual(clonedArgs, { "0": 1, "1": "2", "2": false }); expectTypeOf(clonedArgs).toHaveProperty("0").toBeNumber(); diff --git a/v-next/hardhat/src/internal/builtin-plugins/network-manager/config-resolution.ts b/v-next/hardhat/src/internal/builtin-plugins/network-manager/config-resolution.ts index 28a886425d0..b5ce087838c 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/network-manager/config-resolution.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/network-manager/config-resolution.ts @@ -224,7 +224,7 @@ export function resolveCoinbase( export async function resolveChainDescriptors( chainDescriptors: ChainDescriptorsUserConfig | undefined, ): Promise { - const resolvedChainDescriptors: ChainDescriptorsConfig = await deepClone( + const resolvedChainDescriptors: ChainDescriptorsConfig = deepClone( DEFAULT_CHAIN_DESCRIPTORS, ); diff --git a/v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts b/v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts index 8aee0826091..365f7dcfad2 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts @@ -12,6 +12,7 @@ import type { RequestHandler } from "../request-handlers/types.js"; import { AsyncMutex } from "@nomicfoundation/hardhat-utils/synchronization"; import { isJsonRpcResponse } from "../json-rpc.js"; +import { createHandlersArray } from "../request-handlers/handlers-array.js"; export default async (): Promise> => { // This map is essential for managing multiple network connections in Hardhat V3. @@ -37,10 +38,6 @@ export default async (): Promise> => { nextJsonRpcRequest: JsonRpcRequest, ) => Promise, ) { - const { createHandlersArray } = await import( - "../request-handlers/handlers-array.js" - ); - const requestHandlers = await initializationMutex.exclusiveRun( async () => { let handlersPerConnection = diff --git a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts index 4666e42982e..3a65a894687 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts @@ -130,7 +130,7 @@ export class CompilationJobImplementation implements CompilationJob { // from other files (e.g. new Foo()), and it won't output its bytecode if // it's not asked for. This would prevent EDR from doing any runtime // analysis. - const outputSelection = await deepClone(settings.outputSelection ?? {}); + const outputSelection = deepClone(settings.outputSelection ?? {}); outputSelection["*"] ??= {}; outputSelection["*"][""] ??= []; outputSelection["*"]["*"] ??= [];