foundry
foundry copied to clipboard
forge bind generates extraneous bindings
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (54e02a7 2023-02-15T19:38:32.464976Z)
What command(s) is the bug in?
forge bind
Operating System
macOS (Apple Silicon)
Describe the bug
Running forge bind
tends to generate more bindings than expected, resulting in larger-than-needed crates with irrelevant modules. For example, running forge bind --bindings-path ./bindings --crate-name bindings
in the ArtGobblers repo generates a crate with 37 modules. Most users would likely expect only 7 modules to be created here (one for each contract in the src directory).
The issue seems to be that forge bind
generates a binding module for every artifact generated by forge build
, while excluding certain patterns here. However, it's easy for the list to fall out of date (for example, when new Std contracts are added).
Another issue is that bindings are generated for each contract in the inheritance graph. If I have contract A is ERC20
in my src
directory, I likely only want to generate bindings for A
, not both A
and ERC20
.
One possible solution might be generate bindings only for contracts defined in the src
directory, instead of the current approach of generating contracts for every artifact in the build output, and then filtering out the test/script contracts.