-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5698 from NomicFoundation/core-in-hardhat-continu…
…ation `core` in `hardhat` continuation
- Loading branch information
Showing
35 changed files
with
1,776 additions
and
1,963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
const { createConfig } = require("../../config-v-next/eslint.cjs"); | ||
|
||
module.exports = createConfig(__filename); | ||
|
||
module.exports.rules["no-restricted-imports"][1].paths.push({ | ||
// TODO: Rename this once we migrate to the official package names | ||
name: "@ignored/hardhat-vnext-core", | ||
importNames: ["createBaseHardhatRuntimeEnvironment"], | ||
message: | ||
"Use `createHardhatRuntimeEnvironment` from `hre.js` instead of this function.", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
import { findClosestHardhatConfig } from "./internal/helpers/config-loading.js"; | ||
|
||
// Note: We import the builtin plugins' types here, so that any type extension | ||
// they may have gets loaded. | ||
import "./internal/builtin-plugins/index.js"; | ||
|
||
export type * from "./internal/core/config.js"; | ||
export * from "./internal/core/config.js"; | ||
|
||
/** | ||
* Attempts to find the nearest Hardhat config file, starting from the current | ||
* working directory. If no config file is found, an error is thrown. | ||
* | ||
* @returns The path to the nearest Hardhat config file. | ||
*/ | ||
export async function resolveHardhatConfigPath(): Promise<string> { | ||
const configPath = process.env.HARDHAT_CONFIG; | ||
export type { HardhatUserConfig } from "./types/config.js"; | ||
|
||
if (configPath !== undefined) { | ||
return configPath; | ||
} | ||
|
||
return findClosestHardhatConfig(); | ||
} | ||
// NOTE: We import the builtin plugins in this module, so that their | ||
// type-extensions are loaded then the user imports `hardhat/config`. | ||
import "./internal/builtin-plugins/index.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,6 @@ | ||
import type { UnsafeHardhatRuntimeEnvironmentOptions } from "./internal/core/types.js"; | ||
import type { HardhatUserConfig } from "./types/config.js"; | ||
import type { GlobalOptions } from "./types/global-options.js"; | ||
import type { HardhatRuntimeEnvironment } from "./types/hre.js"; | ||
// NOTE: We import the builtin plugins in this module, so that their | ||
// type-extensions are loaded then the user imports `hardhat/hre`. | ||
import "./internal/builtin-plugins/index.js"; | ||
|
||
import { BUILTIN_GLOBAL_OPTIONS_DEFINITIONS } from "./internal/builtin-global-options.js"; | ||
import { builtinPlugins } from "./internal/builtin-plugins/index.js"; | ||
import { resolveProjectRoot } from "./internal/core/hre.js"; | ||
import { | ||
buildGlobalOptionDefinitions, | ||
createBaseHardhatRuntimeEnvironment, | ||
resolvePluginList, | ||
} from "./internal/core/index.js"; | ||
|
||
/** | ||
* Creates an instances of the Hardhat Runtime Environment. | ||
* | ||
* @param config - The user's Hardhat configuration. | ||
* @param userProvidedGlobalOptions - The global options provided by the | ||
* user. | ||
* @param projectRoot - The root of the Hardhat project. Hardhat expects this | ||
* to be the root of the npm project containing your config file. If none is | ||
* provided, it will use the root of the npm project that contains the CWD. | ||
* @returns The Hardhat Runtime Environment. | ||
*/ | ||
export async function createHardhatRuntimeEnvironment( | ||
config: HardhatUserConfig, | ||
userProvidedGlobalOptions: Partial<GlobalOptions> = {}, | ||
projectRoot?: string, | ||
unsafeOptions: UnsafeHardhatRuntimeEnvironmentOptions = {}, | ||
): Promise<HardhatRuntimeEnvironment> { | ||
const resolvedProjectRoot = await resolveProjectRoot(projectRoot); | ||
|
||
if (unsafeOptions.resolvedPlugins === undefined) { | ||
const plugins = [...builtinPlugins, ...(config.plugins ?? [])]; | ||
|
||
const resolvedPlugins = await resolvePluginList( | ||
resolvedProjectRoot, | ||
plugins, | ||
); | ||
|
||
unsafeOptions.resolvedPlugins = resolvedPlugins; | ||
} | ||
|
||
if (unsafeOptions.globalOptionDefinitions === undefined) { | ||
const pluginGlobalOptionDefinitions = buildGlobalOptionDefinitions( | ||
unsafeOptions.resolvedPlugins, | ||
); | ||
|
||
const globalOptionDefinitions = new Map([ | ||
...BUILTIN_GLOBAL_OPTIONS_DEFINITIONS, | ||
...pluginGlobalOptionDefinitions, | ||
]); | ||
|
||
unsafeOptions.globalOptionDefinitions = globalOptionDefinitions; | ||
} | ||
|
||
return createBaseHardhatRuntimeEnvironment( | ||
config, | ||
userProvidedGlobalOptions, | ||
resolvedProjectRoot, | ||
unsafeOptions, | ||
); | ||
} | ||
export { resolveHardhatConfigPath } from "./internal/config-loading.js"; | ||
export { createHardhatRuntimeEnvironment } from "./internal/hre-intialization.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.