Skip to content

Comments

add abi support for hardhat compilation artifacts#1530

Merged
naps62 merged 11 commits intomainfrom
zpr/hardhat-abi
Jan 28, 2026
Merged

add abi support for hardhat compilation artifacts#1530
naps62 merged 11 commits intomainfrom
zpr/hardhat-abi

Conversation

@ZePedroResende
Copy link
Contributor

No description provided.

@ZePedroResende ZePedroResende self-assigned this Jan 26, 2026
@ZePedroResende ZePedroResende added the A-enhancement work towards a new feature label Jan 26, 2026
@naps62
Copy link
Member

naps62 commented Jan 28, 2026

@ZePedroResende looks good overall, but I'd prefer if we also rename things here. both the crate itself (maybe to sol_artifacts) and all mentions of foundry/forge, to be more framework-agnostic

@naps62 naps62 marked this pull request as ready for review January 28, 2026 12:11
@naps62 naps62 self-requested a review as a code owner January 28, 2026 12:11
Copilot AI review requested due to automatic review settings January 28, 2026 12:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for detecting and loading ABIs from Hardhat projects in addition to the existing Foundry project support.

Changes:

  • Renamed references from "foundry_roots" to "project_roots" to reflect support for both Foundry and Hardhat projects
  • Added detection for Hardhat config files (hardhat.config.ts, hardhat.config.js) alongside foundry.toml
  • Updated artifact directory detection to check for Hardhat's "artifacts/contracts" in addition to Foundry's "out"
  • Enhanced ABI parsing to handle Hardhat's bytecode format
  • Updated tests to verify both Foundry and Hardhat project detection

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
crates/forge/src/actor/mod.rs Main logic changes including project detection, directory blacklist constants, and test updates for Hardhat support
crates/forge/src/actor/ext.rs Renamed poll_foundry_roots to poll_project_roots for consistency
crates/forge/src/abi.rs Added fallback for parsing Hardhat's deployedBytecode format
Comments suppressed due to low confidence (1)

crates/forge/src/actor/mod.rs:358

  • The self.project_roots field is never updated after discovering new project roots. After calculating to_add and to_remove and performing the necessary operations, you need to add:
self.project_roots = roots;

at the end of this function (before the Ok(()) return) to keep the field synchronized with the discovered project roots.

    async fn update_project_roots(&mut self) -> Result<()> {
        let roots = self.find_project_roots().await?;
        trace!(roots = ?roots);

        let to_remove: Vec<_> = self
            .roots
            .iter()
            .filter(|p| !self.roots.contains(*p))
            .cloned()
            .collect();

        let to_add: Vec<_> = roots
            .iter()
            .filter(|p| !self.project_roots.contains(*p))
            .cloned()
            .collect();

        for path in to_add.iter() {
            self.scan_project(path).await?;
        }

        match self.watcher.as_mut() {
            Some(watcher) => {
                for path in to_remove {
                    watcher.unwatch(path.join("out"))?;
                }
                for path in to_add {
                    watcher.watch(path.join("out"), RecursiveMode::Recursive)?;
                }
            }

            None => {
                warn!("forge watcher not initialized");
            }
        }

        Ok(())

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@naps62 naps62 added A-feature A new finished feature and removed A-enhancement work towards a new feature labels Jan 28, 2026
@naps62 naps62 changed the title add abi support for hardhat projects add abi support for hardhat compilation artifacts Jan 28, 2026
@naps62 naps62 enabled auto-merge (squash) January 28, 2026 14:41
@naps62 naps62 merged commit 7ef880a into main Jan 28, 2026
7 checks passed
@naps62 naps62 deleted the zpr/hardhat-abi branch January 28, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-feature A new finished feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants