Skip to content

Prevent losing typechain types when compiling a subset of contracts#6458

Closed
antico5 wants to merge 1 commit intov-nextfrom
typechain_compilation_subset
Closed

Prevent losing typechain types when compiling a subset of contracts#6458
antico5 wants to merge 1 commit intov-nextfrom
typechain_compilation_subset

Conversation

@antico5
Copy link
Contributor

@antico5 antico5 commented Mar 10, 2025

When compiling a subset of contracts, only the generated artifacts were being passed to typechain, losing the types of any previously generated artifacts.

This PR changes that, so besides passing the current generated artifacts, it passes all available artifacts in the project.

I had to adapt the test cases a bit since apparently on windows the generated files have a different directory structure than in linux/mac when having multiple contracts.

Closes #6311

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2025

🦋 Changeset detected

Latest commit: dd31e81

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-typechain 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

@vercel
Copy link

vercel bot commented Mar 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 2:21pm

@github-project-automation github-project-automation bot moved this to Backlog in Hardhat Mar 10, 2025
@antico5 antico5 force-pushed the typechain_compilation_subset branch from 6b0283b to f7e49db Compare March 10, 2025 14:12
@antico5 antico5 force-pushed the typechain_compilation_subset branch from f7e49db to bc3bd6a Compare March 10, 2025 14:15
@antico5 antico5 force-pushed the typechain_compilation_subset branch from bc3bd6a to dd31e81 Compare March 10, 2025 14:21
@ChristopherDedominici
Copy link
Contributor

ChristopherDedominici commented Mar 11, 2025

Cool solution, I like it!
The only downside is that we do have to generate types for all the contracts, even though only a portion is compiled, but I don’t see any other solution.

@alcuadrado wdyt?

@antico5
Copy link
Contributor Author

antico5 commented Mar 11, 2025

Cool solution, I like it! The only downside is that we do have to generate types for all the contracts, even though only a portion is compiled, but I don’t see any other solution.

@alcuadrado wdyt?

I've checked typechain-ethers and there's no option to "merge" newly added artifacts into an existing type file (hardhat.d.ts). It just uses whatever is passed on allArtifacts

@alcuadrado
Copy link
Member

I think this PR was replaced by the (just merged) #6400

@ChristopherDedominici
Copy link
Contributor

I think this PR was replaced by the (just merged) #6400

@alcuadrado @antico5
No, the PR that Pato mentioned is generating types only for the contracts and not for the test contracts. This one, however, is introducing the possibility to generate types only for a subset of the contracts.

In the current version of hh-typechain, types can only be generated for all contracts at once. However, this PR allows users to generate types for a specific portion of the contracts without losing the previously generated types for contracts that are not being compiled.

So these 2 PRs are addressing different issues.

@antico5 You do have merge conflicts, though, because the hook used has changed

@schaable schaable added the v-next A Hardhat v3 development task label Apr 10, 2025
@kanej
Copy link
Member

kanej commented Aug 5, 2025

I am closing this as we need to rethink our approach after the changes to partial recompilation.

@kanej kanej closed this Aug 5, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Aug 5, 2025
@kanej kanej deleted the typechain_compilation_subset branch August 11, 2025 16:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

status:triaging v-next A Hardhat v3 development task

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Typechain] modify the plugin to generate types for a subset of contracts

5 participants