foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(forge): new config option for filtering the contract artifacts which get generated

Open PaulRBerg opened this issue 2 years ago • 5 comments

Component

Forge

Describe the feature you would like

The idea is to introduce a new config option called filter (or sift) that accepts a list of whitelisted contracts:

[profile.artifacts]
filter = [
  "Foo",
  "Bar",
]

When it sees this config, Forge generates artifacts only for the members listed under filter, regardless of whatever other members may be present in the repository. Note that by "members" in this context, I mean any of the following:

  • contract
  • interface
  • abstract
  • library

The primary use case is shipping a Node.js package that should include only the production contracts' artifacts - though there may be more use cases than just that. Anything related to artifact generation may benefit from such a feature.

Additional context

In our project, we wrote a Bash script because we couldn't find a way to filter contracts with Foundry itself.

PaulRBerg avatar May 18 '23 19:05 PaulRBerg

Sharing the Bash scripts we have used to prepare the Sablier V2 artifacts:

  • https://github.com/sablier-labs/v2-core/blob/431f79c248bbb025f5581141cc605f220a0fb404/shell/prepare-artifacts.sh
  • https://github.com/sablier-labs/v2-periphery/blob/747fc5e789fc17b2a3c1560bf70b2bbcb597901f/shell/prepare-artifacts.sh

We would love to be able to delete the scripts 😁

PaulRBerg avatar Jul 07 '23 11:07 PaulRBerg

@PaulRBerg we have a PR in works https://github.com/foundry-rs/foundry/pull/8668 would this solve your request here too? thank you!

grandizzy avatar Oct 08 '24 12:10 grandizzy

Thanks @grandizzy, tagging @smol-ninja and @andreivladbrg for taking a look.

PaulRBerg avatar Oct 08 '24 12:10 PaulRBerg

@grandizzy as per this comment, that PR does not seem to solve this issue.

However, there is a mention of --skip flag that can be used to dictate artifacts. Is that something already a part of foundry (couldn't find it in the book though)?

smol-ninja avatar Oct 12 '24 15:10 smol-ninja

However, there is a mention of --skip flag that can be used to dictate artifacts. Is that something already a part of foundry (couldn't find it in the book though)?

nope, nothing yet, just wanted to check if the PR could work for you too. thank you

grandizzy avatar Oct 14 '24 05:10 grandizzy