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

Custom Error Selectors for Contract Instances #5818

Open
mialbu opened this issue Oct 11, 2024 · 0 comments
Open

Custom Error Selectors for Contract Instances #5818

mialbu opened this issue Oct 11, 2024 · 0 comments
Assignees

Comments

@mialbu
Copy link

mialbu commented Oct 11, 2024

Describe the feature

I haven't found any solution for this problem using hardhat. So, if there is actually already a solution for this, I'd be delighted to get to know it.

Problem

I'm using mainly custom errors in my contracts and many of them are used in multiple places in a contract. When I'm testing the contract for these errors, I need to write down the custom error as a string every time. I can define constant values for each custom error that defines that string value, but it's not so nice to have to do that for each custom error.

So, for the following error:

error NoAuthorization();

I need to use the string "NoAuthorization" whenever I test this error occurrence:

await expect(myContract.connect(sender).pause()).to.be.revertedWithCustomError(myContract, "NoAuthorization");

Feature Request

I'd like to have access to a selector or some sort of reference of the custom errors of my contracts, so that I don't need to use a string value for them. This could look something similar to the following:

await expect(myContract.connect(sender).pause()).to.be.revertedWithCustomError(myContract.NoAuthorization);

Related to #3486

Search terms

Custom Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants
@kanej @mialbu and others