foundry-rs / foundry-rs/foundry
feat(`forge bind`): dedupe generated alloy type bindings by sharing types
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 510
Description
### Component
Forge
### Describe the feature you would like
Currently alloy bindings are all separate in their own submodule, if multiple child contracts uses the same library, e.g. contract B and C uses library A, then types in library A will appear in both the bindings of B and C in the current version of `forge bind --aloy`
a concrete example is:
https://github.com/EspressoSystems/espresso-network/tree/ace0e437e653187a9cd8e50fd71da6403c18f3ef/contracts/rust/adapter/src/bindings
you will find `pub mod BN254 { pub struct G1Point }` both in `lightclient.rs` and `iplonkverifier.sol` and `plonkverifier.sol` and they are all mutually incompatible types (or different types)
This create pains because any additional methods written for one of the types won't be translated over to another. (e.g. the `From for G1Point`)
This doesn't used to be a problem in `ethers-rs`'s bindings, because the `share_types.rs` logic, where shared types are extrapolated out into a separate files and all other modules inherits from that.
This issue requests a similar feature in alloy bindings.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.