-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 support for custom errors #1525
Conversation
@@ -45,6 +46,7 @@ export interface SourceReference { | |||
contract?: string; | |||
function?: string; | |||
line: number; | |||
range: [number, number]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this. Why was this added? Pretty sure I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used in ErrorInferrer.filterRedundantFrames
type: StackTraceEntryType.CUSTOM_ERROR; | ||
message: string; | ||
sourceReference: SourceReference; | ||
isInvalidOpcodeError: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this field is necessary. Aren't they always reverts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, both for panic and custom errors. I removed it in aced929.
@@ -84,6 +86,13 @@ export interface PanicErrorStackTraceEntry { | |||
isInvalidOpcodeError: boolean; | |||
} | |||
|
|||
export interface CustomErrorStackTraceEntry { | |||
type: StackTraceEntryType.CUSTOM_ERROR; | |||
message: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the message here? The return data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the already parsed error message. I'll add a comment explaining that.
@@ -0,0 +1,46 @@ | |||
import * as abi from "@ethersproject/abi"; | |||
|
|||
export class AbiHelpers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good. It's even simpler than what I had in mind :)
I'm not sure how to review the tests though. Can you point me to the ones you think are important?
The two new directories are custom-errors and panic-codes. There's also the (skipped) try-catch-uncaught which is a known bug. |
I tested this with the recent 0.8.5 release of solidity and there is only one test failing. It's a very specific test, and it fails because a redundant frame is not properly removed. I don't think it's a blocker, though, so I'll open an issue to track that and expand on the failing test and why it fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Depends on #1452.