feat: add new onSolcCompileComplete hook
Add a onSolcCompileComplete hook that is called immediately after solc compilation. The hook is invoked on execution of solc as part of the compilation job and passes the solc input, solc output along with the compilation job that they represent.
The hook is invoked whether the compilation is a success or not (i.e. there are compilation errors).
onSolcCompileComplete Hook
/**
* Hook triggered on the solc compile of a compilation job, providing the
* Solc input and output.
*
* @param context The hook context.
* @param solcConfig The configuration used to setup solc e.g. version.
* @param solcInput The solc input json passed to solc for this compilation
* job.
* @param solcOutput The solc output json received from solc for this
* compilation job.
* @param next A function to call the next handler for this hook, or the
* default implementation if no more handlers exist.
*/
onSolcCompileComplete(
context: HookContext,
solcConfig: SolcConfig,
solcInput: CompilerInput,
solcOutput: CompilerOutput,
next: (
nextContext: HookContext,
nextSolcConfig: SolcConfig,
nextSolcInput: CompilerInput,
nextSolcOutput: CompilerOutput,
) => Promise<void>,
): Promise<void>;
Resolve #7646
🦋 Changeset detected
Latest commit: de9228df18a9c215c0300085b501fac22b84d202
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| hardhat | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
up
@fvictorio queried the hook, arguing it should be something more like:
solcCompile(
context: HookContext,
solcConfig: SolcConfig,
solcInput: CompilerInput,
next: (
nextContext: HookContext,
nextSolcConfig: SolcConfig,
nextSolcInput: CompilerInput,
) => Promise<CompilerOutput>,
): Promise<CompilerOutput>;
So taking the input and giving the output.
This would work if we could do this if we include the solcConfig settings that OpenZeppelin required as well.
When I looked to implement this though I ran into the question of how to deal with the compiler. Is it passed in also? It seems like the hook should encapsulate the selection and retrieval of the compiler. But then should the hook pass the compiler back as a result, to allow it to be propagated up the call chain as runCompilationJob requires?