Skip to content

Conversation

@silasdavis
Copy link

Foundry seems to duplicate some imported sub-files within a contract, for example:

<foundry root>/src/parts/primitives/Foo.sol

Is defined only once, and imported from <foundry root>/src/Bar.sol

But ends up appearing twice in artifacts directory:

<foundry root>/out/Foo.sol/Foo.json
<foundry root>/out/primitives/Foo.sol/Foo.json

In this case getArtifactPaths() in the Foundry plugin pick up the same contracts twice since they end up existing in multiple subdirectories of out/. I don't think there is a reliable to heuristic to de-duplicate them at this level.

It seems like duck-typing contracts by the ABI should be fine and may help other plugin sources. it could always be disabled by default and enabled via an option at the cost of yet more config

…ical ABIs

Foundry seems to duplicate some imported sub-files within a contract,
for example:

`<foundry root>/src/parts/primitives/Foo.sol`

Is defined only once, and imported from `<foundry root>/src/Bar.sol`

But ends up appearing twice in artifacts directory:

```
<foundry root>/out/Foo.sol/Foo.json
<foundry root>/out/primitives/Foo.sol/Foo.json
```

In this case `getArtifactPaths()` in the Foundry plugin pick up the same
contracts twice since they end up existing in multiple subdirectories of `out/`. I
don't think there is a reliable to heuristic to de-duplicate them at
this level.

It seems like duck-typing contracts by the ABI should be fine and may
help other plugin sources. it could always be disabled by default and enabled via an option at the cost of yet more config

Signed-off-by: Silas Davis <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2025

⚠️ No Changeset found

Latest commit: a5c31d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jun 2, 2025

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

Name Status Preview Comments Updated (UTC)
wagmi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 0:08am

@silasdavis
Copy link
Author

I just want to put this out for a sense check before going to town on the rest of contribution requirements, let me know what you think.

@silasdavis
Copy link
Author

A bit more on why these duplicates might be seen from foundry,

These snippets are are target from two duplicated foundry artifacts.

the first appears under out/:

      "compilationTarget": {
        "src/Foo.sol": "Foo"
      },

the second under out/src/:

      "compilationTarget": {
        "../project/src/Foo.sol": "Foo"
      },

Where we are compiling in the Foundry project project, but we do have some other Foundry projects that import from each other, so it seems to be that the way Foundry processes the Solidity compiler output causes these duplicates, which probably isn't really a bug, so would be nice if wagmi supports this.

@silasdavis
Copy link
Author

silasdavis commented Jun 3, 2025

I've implemented a similar fix in the foundry.ts plugin source itself which I am using as a local vendored patch, let me know if you'd prefer that version.

@tmm tmm force-pushed the main branch 4 times, most recently from dbb8093 to 5937456 Compare September 19, 2025 17:26
@jxom jxom force-pushed the main branch 2 times, most recently from 27f0d04 to 7d15f06 Compare September 24, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant