-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Typechain] generate types only for contracts and not test files #6400
base: v-next
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 739f6b3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -645,6 +638,13 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem { | |||
duplicatedContractNamesDeclarationFilePath, | |||
getDuplicatedContractNamesDeclarationFile(duplicatedNames), | |||
); | |||
|
|||
await this.#hooks.runHandlerChain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pato mentioned that probably this is the best place to add a hook that can emit the artifacts paths.
His message:
I think that we should change the moment when we generate the typechain types. Its now on build, but i believe it should be in cleanArtifacts. That already generates some typescript types for the artifacts. Especially when there are clashes between names. This would mean removing the hook, creating a new one after cleanupArtifacts, and using that one instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would mean we generate types only when the entire project is compiled - see
// If we recompiled the entire project we cleanup the artifacts |
To be fair, I also find hooking types generation to the cleanup step a little confusing. It is not obvious to know what the type generation has to do with cleanup without deeply understanding the internals. I think there might be some potential for the refactor in the cleanup function, but that's definitely out of the scope of this PR.
However, as far as when the type generation should get triggered, maybe it should be when the artifacts are emitted after all. But maybe we could add some option to the build
and consequently emitArtifacts
to control whether artifact declaration files -
hardhat/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts
Line 527 in 4554b50
const artifactsDeclarationFilePath = path.join( |
@@ -99,19 +98,20 @@ declare module "../../../types/hooks.js" { | |||
|
|||
export interface SolidityHooks { | |||
/** | |||
* Provide a handler for this hook to retrieve all artifacts created by a compilation job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old hook can be removed in favor of the new one. See previous comment for more details
@@ -0,0 +1,6 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a double check on this changeset, is this format acceptable for the v-next
?
Parent issue link