Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forge: forge selectors feature request meta issue #5012

Closed
lmanini opened this issue May 23, 2023 · 5 comments
Closed

Forge: forge selectors feature request meta issue #5012

lmanini opened this issue May 23, 2023 · 5 comments
Labels
T-feature Type: feature

Comments

@lmanini
Copy link
Contributor

lmanini commented May 23, 2023

Component

Forge

Describe the feature you would like

Main feature I'd like to add is a cmd to check for colliding method selectors between two given contracts.
@mds1 suggested to implement a forge selectors cmd and have the following initial subcommands:

  • forge selector collision for what my original PR does
  • forge selector list <options> to list function selectors and/or error selectors and/or event sigs for certain/all files in a project
  • forge selector upload to replace forge upload-selectors

Additional context

context: #4973

@mds1
Copy link
Collaborator

mds1 commented May 23, 2023

Thanks for opening this @lmanini. I'll defer to @mattsse and @Evalir but in the interest of keeping PRs easy to review/test, my suggestion would be as follows:

The first PR just structures things:

  • Adds the forge selectors subcommand with a forge selectors upload command that duplicates the forge upload-selectors functionality
  • Adds a warning to forge upload-selectors that it's deprecated and will be removed in v1 (cc @Evalir)

Then follow up PRs for:

  • forge selectors collision <ContractA> <ContractB>. Should be able to just specify contract names if there's no duplicate names, or use the ContractA.sol:ContractA` when there are duplicates. Should exit with an error on collision and print the colliding signatures and their selectors
  • forge selectors list prints all function selectors, error selectors, and event signatures for the src directory
    • Supports additive --functions, --errors, --events flags to specify a subset of the above, e.g. if you only want error selectors
    • Supports --contracts <ContractA> <ContractB> ... flag for limiting the contracts it's printed for
    • I'm open to other syntaxes/UX for the CLI args here

(Also I think forge selectors, plural, is better than forge selector, singular)

@lmanini
Copy link
Contributor Author

lmanini commented May 31, 2023

Should exit with an error on collision and print the colliding signatures and their selectors

Is there an example of how this should be handled? I was thinking of just doing a shell::println(Paint::red(...)). Do you have something else in mind?

@mds1
Copy link
Collaborator

mds1 commented May 31, 2023

std::process::exit(1) will exit the process with exit code 1 which indicates an error. So just call that after printing the relevant info

std::process::exit(1);

@lmanini
Copy link
Contributor Author

lmanini commented May 31, 2023

oh ok haha - just started off with rust, still got a long way to go

@zerosnacks
Copy link
Member

Marking as resolved by #5116 + #6205

Now yields:

$ forge selectors

Function selector utilities

Usage: forge selectors <COMMAND>

Commands:
  collision  Check for selector collisions between contracts [aliases: co]
  upload     Upload selectors to registry [aliases: up]
  list       List selectors from current workspace [aliases: ls]
  help       Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

3 participants