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

Support of custom-errors on ABI #3656

Closed
gagiuntoli opened this issue Nov 10, 2022 · 6 comments
Closed

Support of custom-errors on ABI #3656

gagiuntoli opened this issue Nov 10, 2022 · 6 comments
Labels
T-feature Type: feature

Comments

@gagiuntoli
Copy link

gagiuntoli commented Nov 10, 2022

Component

Forge

Describe the feature you would like

I would like to have in the ABI of my contracts all the possible errors that are thrown through reverts on the called contracts.

For example:

error customErrorA();
error customErrorB();

contract A {
    function foo() {
         revert customErrorA();
    }

    function callB(address _addressB) {
         B(_addressB).bar()
    }
}

contract B {
    function bar() {
         revert customErrorB();
    }
}

I would like that the ABI of contract A knows about customErrorB().

I think this is the responsibility of the Solidity compiler rather than Foundry, even though, in the meantime, is there something implemented on Foundry to enable this support on the ABIs?

Additional context

No response

@gagiuntoli gagiuntoli added the T-feature Type: feature label Nov 10, 2022
@rkrasiuk
Copy link
Collaborator

there are probably ways to traverse the ast to get all possible errors, however that still would not become a part of the ABI. if anything, that would be an auxiliary output.
imo, the best way to think about this is that customErrorB is never instantiated in the context of contract A. when you are doing an external call, you are essentially agreeing that the transaction might revert with any error that might bubble up in the process. this description is similar to the edge case when contracts can emit the event that's not a part of their ABI (through preserved context during delegatecall).

closing this issue as won't do

@rkrasiuk rkrasiuk closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2022
@KholdStare
Copy link
Contributor

@rkrasiuk I think I agree with you about "auxiliary output". It doesn't have to be the ABI itself, but an "ABI-like" file that describes all of the errors accessible by calling a contract.

I think events are easier to deal with because a user has to actively "subscribe" to an event - pick something of interest and filter for it in the log, ignoring things they don't care about. With errors, there's no "subscribing" - you just get an error and you are forced to parse it, even if you have no clue where it came from.

Would you be open to an auxiliary output for that? Something like forge inspect <contract> errors?

@rkrasiuk rkrasiuk reopened this Nov 11, 2022
@rkrasiuk
Copy link
Collaborator

rkrasiuk commented Nov 11, 2022

@KholdStare agreed that it's a candidate for forge inspect. reopened this issue, but we'll prob keep it as a low prio. always appreciate contributions if anyone wants to pick it up!

@thedavidmeister
Copy link

i think i'm running into this when trying to deploy contracts via a script

in my case the "contract A" is the Script contract itself, so when i hit a custom error emitted by the constructor of the contract being deployed it is "contract B".

this means that any constructor errors are not decoded, which makes deploying via script much less ergonomic than it should be

@KholdStare
Copy link
Contributor

#5228 should help here.

@grandizzy
Copy link
Collaborator

a fix to decode with target abi was added in #7563 @mattsse

@mattsse mattsse closed this as completed Apr 16, 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
None yet
Development

No branches or pull requests

6 participants