-
Notifications
You must be signed in to change notification settings - Fork 91
Adding support for Hardhat 3 projects #631
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
base: dev
Are you sure you want to change the base?
Conversation
elopez
left a comment
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.
Hi, thanks for the PR! Here's some things I noticed from a first look at it.
elopez
left a comment
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.
There's a few failures on the CI lint jobs, can you take a look at those? thanks!
Yes on it |
|
Hi @elopez, anything else required here? |
|
Hi @imadarchid! Looks good from my side, thanks! I'm waiting for a review from @smonicas before we merge. |
|
Got it, thanks for the update @elopez! |
smonicas
left a comment
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.
Hi, thanks for the PR. Only one thing that Hardhat outputs in the stdout also Warnings for example if you are using a node version not officially supported.
WARNING: You are using Node.js 23.11.0 which is not supported by Hardhat.
Please upgrade to 22.10.0 or a later LTS version (even major version number)
In the _run_hardhat_console function we can filter that out and still try to continue the execution while showing a log to the user, just in case it can cause an actual problem. Adding something like the following would be good enough to handle this case, in the current code we would get an error when trying to deserialize the configuration since it's not a valid json.
brace_index = stdout.find('{')
if brace_index > 2:
LOGGER.info("Unexpected output from Hardhat, trying to parse it anyway: %s", stdout)
stdout = stdout[brace_index:]
Thanks for flagging this, I will address it in the code |
Summary
This PR adds initial support for Hardhat v3 projects in
crytic-compile. Hardhat v3 introduces breaking changes in artifact generation and path handling that cause the current parser to fail. The implementation remains fully backward-compatible with Hardhat v2.Context #629
Background
Hardhat v3 introduces:
Split artifacts: compiler outputs are now separated into multiple files, which breaks
crytic-compile’s assumption of a single artifact per contract.Prefixed paths: sources are now referenced using project/ and npm/ prefixes, affecting both project parsing and filename lookup during compilation.
Changes
Disclaimer
I am not yet fully familiar with the entire codebase, so there may be edge cases I missed. This PR should be considered a starting point for discussion.