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

Add table layout for forge inspect <contract> abi #5165

Closed
zaevlad opened this issue Feb 4, 2023 · 4 comments · Fixed by #9705
Closed

Add table layout for forge inspect <contract> abi #5165

zaevlad opened this issue Feb 4, 2023 · 4 comments · Fixed by #9705
Labels
C-forge Command: forge Cmd-forge-inspect Command: forge inspect T-feature Type: feature
Milestone

Comments

@zaevlad
Copy link

zaevlad commented Feb 4, 2023

I guess it will be very useful to add a forge command to see all available functions in the contract as well as inherited in it.
For example, with a "forge functions -contract MyContract" user will get a table in the respond like:

Fisrt column - function name;
Second column - internal, external, payable, public;
Third - contract name (inherited one);
Probably, forth - inside functios;

So it will be much easier to see a contract stucture.

@zaevlad zaevlad changed the title Suggestion to add new forge command Suggestion to add a new forge command Feb 4, 2023
@mds1
Copy link
Collaborator

mds1 commented Feb 6, 2023

forge inspect <contract> abi will give you all this information, we just need to add support to convert it into a table format by appending the --pretty flag. Similar to forge inspect <contract> storage-layout --pretty

@zaevlad
Copy link
Author

zaevlad commented Feb 6, 2023

forge inspect <contract> abi will give you all this information, we just need to add support to convert it into a table format by appending the --pretty flag. Similar to forge inspect <contract> storage-layout --pretty

yea, that --pretty with storage looks cool! If you could do the same with ABI, it would be aawesome! Thanks!

@Evalir Evalir transferred this issue from foundry-rs/book Jun 16, 2023
@gakonst gakonst added this to Foundry Jun 16, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jun 16, 2023
@zerosnacks zerosnacks changed the title Suggestion to add a new forge command Add table layout for forge inspect <contract> abi Jun 28, 2024
@zerosnacks zerosnacks added C-forge Command: forge Cmd-forge-inspect Command: forge inspect labels Jun 28, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@grandizzy grandizzy added the T-feature Type: feature label Nov 23, 2024
@grandizzy
Copy link
Collaborator

we have the --pretty implemented, which would print something as below (not table)

forge inspect Counter abi --pretty
interface Counter {
    function getCounter() external view returns (uint256);
    function setCounter(uint256 count) external;
}

It's a little bit inconsistent and also json is default instead using the --json flag, @zerosnacks could you please chime in, is this something we'd want to make it consistent for all inspect commands by using --json flag and default to what's now behind --pretty flag?

@zerosnacks
Copy link
Member

zerosnacks commented Nov 25, 2024

I tend to agree

JSON is the default here because you are effectively just extracting fields from a JSON artifact

I think we should change it so that --json yields effectively what is shown now as default and change the default to a Markdown table report structure, not an interface.

This is in line with cast storage e.g.

$ cast storage 0x5FbDB2315678afecb367f032d93F642f64180aa3

| Name   | Type    | Slot | Offset | Bytes | Value | Hex Value                                                          | Contract                |
|--------|---------|------|--------|-------|-------|--------------------------------------------------------------------|-------------------------|
| number | uint256 | 0    | 0      | 32    | 0     | 0x0000000000000000000000000000000000000000000000000000000000000000 | src/Counter.sol:Counter |
$ cast storage 0x5FbDB2315678afecb367f032d93F642f64180aa3 --json

{
  "storage": [
    {
      "astId": 40179,
      "contract": "src/Counter.sol:Counter",
      "label": "number",
      "offset": 0,
      "slot": "0",
      "type": "t_uint256"
    }
  ],
  "types": {
    "t_uint256": {
      "encoding": "inplace",
      "label": "uint256",
      "numberOfBytes": "32"
    }
  },
  "values": [
    "0x0000000000000000000000000000000000000000000000000000000000000000"
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-inspect Command: forge inspect T-feature Type: feature
Projects
Archived in project
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants