solidity
solidity copied to clipboard
Provide `type(C).functionSelectors`
Abstract
For implementing deployments and upgrades for ERC-2535 Diamonds it is necessary to get all the function selectors of a contract so they can be added to the diamond proxy.
For example here is the struct that needs be filled in order to upgrade or deploy a diamond:
enum FacetCutAction {Add, Replace, Remove}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
Motivation
It would be really useful if it was possible to fill this struct like this:
FacetCut memory facetCut = FacetCut(
address(MyContract),
FacetCutAction.Add,
type(MyContract).functionSelectors)
)
Code like that would be used in Foundry to deploy diamonds and make upgrades. Such code could also be useful in factory contracts that deploy diamonds.
This functionality is somewhat similar to type(I).interfaceId.