foundry-rs / foundry-rs/foundry

feat(cast): Get interface of proxy implementation with `cast interface`

Open
#4,651 0 comments 0 reactions 0 assignees View on GitHub
C-cast P-normal T-feature
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
16h 38m
Merged PRs (30d)
511

Description

### Component

Cast

### Describe the feature you would like

Currently when using `cast interface` with an upgradeable proxy contract, it only generates the interface of the proxy and does not include the implementation functions which are usually of more interest.

At least for standard transparent proxy implementations where etherscan also provides the `read as proxy` / `write as proxy` options, it should be possible to get the abi of the implementation contract and generate an interface based on that.

Imo there are two options regarding the interface here:
1. Always add the functions of the implementation contract to the interface (in addition to the proxy / update functions)
2. Add `--as-proxy` flag to get the implementation interface instead of the proxy interface.

In the case of a simple proxy this just removes the extra step of the user having to manually look up the implementation address.
It would be more powerful though, if we could get this to work for Diamond proxys, where figuring out all the facets implementation manually can be non-trivial / time consuming. Being able to assemble the full contract interface automatically could be a big help there.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the `cast interface` command entry point and trace how it obtains the proxy ABI. Investigate how transparent proxies and Diamond proxy facets could expose implementation functions; done means defining and implementing a supported interface-selection behavior, including the proposed proxy and implementation functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, solidity
Domain
blockchain, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.