Skip to content

[Typechain] Investigate how to support the attach method#6442

Merged
ChristopherDedominici merged 8 commits intov-nextfrom
add-attach-support-in-hh-typechain
Mar 7, 2025
Merged

[Typechain] Investigate how to support the attach method#6442
ChristopherDedominici merged 8 commits intov-nextfrom
add-attach-support-in-hh-typechain

Conversation

@ChristopherDedominici
Copy link
Contributor

@ChristopherDedominici ChristopherDedominici commented Mar 4, 2025

Fixes this

Depends on: NomicFoundation/hardhat#6400.
This dependency exists because test files are still being compiled and do not extend ethers. However, since test files should not be compiled, this is not an issue.

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2025

🦋 Changeset detected

Latest commit: 8f2403d

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 4, 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 5, 2025 2:25pm

@ChristopherDedominici ChristopherDedominici added the v-next A Hardhat v3 development task label Mar 4, 2025
@ChristopherDedominici ChristopherDedominici self-assigned this Mar 4, 2025
@fvictorio fvictorio added this to Hardhat Mar 4, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Hardhat Mar 4, 2025
@ChristopherDedominici ChristopherDedominici moved this from Backlog to In Progress in Hardhat Mar 4, 2025
);
}

function addSupportForAttachMethod(modifiedContent: string): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the other logic in this file, since Typechain is no longer maintained, we cannot open PRs to the repository, so we need to find a workaround.

The logic behind this code is:

  • Identify the files that extend ContractFactory
  • Modify these files to add support for the attach method
  • Add the required ethers import to support the attach method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this possibility in the design doc but discarded it due to several maintenance complications

@ChristopherDedominici ChristopherDedominici marked this pull request as ready for review March 4, 2025 15:55
@ChristopherDedominici ChristopherDedominici moved this from In Progress to In Review in Hardhat Mar 4, 2025
}

function addSupportForAttachMethod(modifiedContent: string): string {
const pattern = /class\s+(\w+)__factory/; // Pattern to find the contract name in factory files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for other reviewers because I checked it myself, \w+ is equivalent to [a-zA-Z0-9_]+. So it should cover all the characters allowed in contract names 👍

…Foundation/hardhat into add-attach-support-in-hh-typechain
@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Mar 7, 2025
Merged via the queue into v-next with commit db98630 Mar 7, 2025
21 checks passed
@ChristopherDedominici ChristopherDedominici deleted the add-attach-support-in-hh-typechain branch March 7, 2025 15:32
@github-project-automation github-project-automation bot moved this from In Review to Done in Hardhat Mar 7, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

v-next A Hardhat v3 development task

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Typechain] Investigate how to support the attach method

3 participants