argotorg / argotorg/solidity

Provide `type(C).functionSelectors`

Open
#16,295 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## 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:
```Solidity
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:
```Solidity
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`.

Contributor guide

Open the contributing guide

Research direction

No source files or tests are named in the issue. Start by locating the existing implementation and tests for type(I).interfaceId, then determine the compiler behavior and coverage needed for type(C).functionSelectors; done means the expression provides the selectors required by the FacetCut example.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.