Skip to content

Conversation

@mattsse
Copy link
Member

@mattsse mattsse commented Sep 28, 2022

Motivation

Closes #3399

Brute forces custom error decoding.

  error MyError(address);

will be decoded and printed to console as:

Error: reverted with 'Custom Error 73ea2a7f:(0x0000000000000000000000000000000000000001)'

Note: the decoding impl could be further optimized by manually counting words but this should be sufficient

Solution

@mattsse mattsse added the T-feature Type: feature label Sep 28, 2022
@gakonst
Copy link
Member

gakonst commented Sep 28, 2022

Can we instead log the name instead of "Custom Error"? Isn't that info accessible from the ABI?

@mattsse
Copy link
Member Author

mattsse commented Sep 28, 2022

we already check against the abi object, but only we have one, which is not the case in anvil for example.

instead the logs will look like

eth_sendRawTransaction

    Transaction: 0x0e2e9603e80d290b3896dab17fe2527c7222f9eb8ee49a44492fae6bd07ae89c
    Gas used: 21448
    Error: reverted with 'Custom Error 73ea2a7f:(0x0000000000000000000000000000000000000001)'

    Block Number: 3
    Block Hash: 0x5e7ddf9ac9f01609077ac31e2e8ebf5b5b85f9f727f62549d74664a5c1c24d58
    Block Time: "Wed, 28 Sep 2022 20:14:28 +0000"

@gakonst gakonst merged commit 637313c into foundry-rs:master Sep 29, 2022
iFrostizz pushed a commit to iFrostizz/foundry that referenced this pull request Nov 9, 2022
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

Successfully merging this pull request may close these issues.

decode any custom error codes on revert

2 participants