UNPKG

@nomicfoundation/hardhat-foundry

Version:

Hardhat plugin that provides compatibility with Foundry-based projects remappings.

36 lines 1.5 kB
import * as path from "node:path"; import { HardhatError } from "@nomicfoundation/hardhat-errors"; import { hasFoundryConfig, getForgeRemappings, isForgeInstalled, } from "../foundry/forge.js"; /** * Hook handler that adds Foundry remappings from `forge remappings`. */ export default async () => { // State stored in closure - checked once per HRE lifetime let forgeInstalledChecked = false; let forgeIsInstalled = false; return { async readNpmPackageRemappings(context, packageName, packageVersion, packagePath, next) { const existingRemappings = await next(context, packageName, packageVersion, packagePath); if (!(await hasFoundryConfig(packagePath))) { return existingRemappings; } // Check forge installation only once if (!forgeInstalledChecked) { forgeInstalledChecked = true; forgeIsInstalled = await isForgeInstalled(); } if (!forgeIsInstalled) { throw new HardhatError(HardhatError.ERRORS.HARDHAT_FOUNDRY.GENERAL.FORGE_NOT_INSTALLED); } const forgeRemappings = await getForgeRemappings(packagePath); return [ ...existingRemappings, { remappings: forgeRemappings, source: path.join(packagePath, "foundry.toml"), }, ]; }, }; }; //# sourceMappingURL=solidity.js.map