-
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] Investigate how to support the attach method #6442
[Typechain] Investigate how to support the attach method #6442
Conversation
🦋 Changeset detectedLatest commit: 8f2403d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 ↗︎
|
@@ -140,3 +142,37 @@ export function addJsExtensionsIfNeeded(content: string): string { | |||
`import ${imports} from ${quote}${path}/index.js${quote};`, | |||
); | |||
} | |||
|
|||
function addSupportForAttachMethod(modifiedContent: string): string { |
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.
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 theattach
method
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.
We discussed this possibility in the design doc but discarded it due to several maintenance complications
…Foundation/hardhat into add-attach-support-in-hh-typechain
@@ -140,3 +142,37 @@ export function addJsExtensionsIfNeeded(content: string): string { | |||
`import ${imports} from ${quote}${path}/index.js${quote};`, | |||
); | |||
} | |||
|
|||
function addSupportForAttachMethod(modifiedContent: string): string { | |||
const pattern = /class\s+(\w+)__factory/; // Pattern to find the contract name in factory files |
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.
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
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.