UNPKG

hardhat

Version:

Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.

81 lines 3.41 kB
let SolidityBuildSystemImplementation; class LazySolidityBuildSystem { #hooks; #options; #buildSystem; constructor(hooks, options) { this.#hooks = hooks; this.#options = options; } async getRootFilePaths(options = {}) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.getRootFilePaths(options); } async getScope(fsPath) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.getScope(fsPath); } isSuccessfulBuildResult(buildResult) { // Note: This duplicates the logic of the actual implementation because it's // a synchronous method, so we can't import the implementation. return buildResult instanceof Map; } async build(rootFiles, options) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.build(rootFiles, options); } async getCompilationJobs(rootFiles, options) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.getCompilationJobs(rootFiles, options); } async runCompilationJob(compilationJob, options) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.runCompilationJob(compilationJob, options); } async remapCompilerError(compilationJob, error, shouldShortenPaths) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.remapCompilerError(compilationJob, error, shouldShortenPaths); } async emitArtifacts(compilationJob, compilerOutput, options = {}) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.emitArtifacts(compilationJob, compilerOutput, options); } async cleanupArtifacts(rootFilePaths, options = {}) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.cleanupArtifacts(rootFilePaths, options); } async compileBuildInfo(buildInfo, options) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.compileBuildInfo(buildInfo, options); } async getArtifactsDirectory(scope) { const buildSystem = await this.#getBuildSystem(); return await buildSystem.getArtifactsDirectory(scope); } async #getBuildSystem() { if (SolidityBuildSystemImplementation === undefined) { const buildSystemModule = await import("../build-system/build-system.js"); SolidityBuildSystemImplementation = buildSystemModule.SolidityBuildSystemImplementation; } if (this.#buildSystem === undefined) { this.#buildSystem = new SolidityBuildSystemImplementation(this.#hooks, this.#options); } return this.#buildSystem; } } export default async () => { return { created: async (_context, hre) => { hre.solidity = new LazySolidityBuildSystem(hre.hooks, { solidityConfig: hre.config.solidity, projectRoot: hre.config.paths.root, soliditySourcesPaths: hre.config.paths.sources.solidity, artifactsPath: hre.config.paths.artifacts, cachePath: hre.config.paths.cache, solidityTestsPath: hre.config.paths.tests.solidity, }); }, }; }; //# sourceMappingURL=hre.js.map