hardhat
hardhat copied to clipboard
Add a mechanism to provide extra selectors and custom errors
Hardhat can only decode selectors that are part of the project. We should add some mechanism to let users and plugins extend this.
This could be done with a file with a interface or something like that, but I think it would be even better to have some extensibility point that can asynchronously search for a selector. This would let us use things like Etherscan and 4bytes.
Related issue: #701
Replying to this comment by @fvictorio which now seems most relevant to be in this issue:
This would be great although really hard to do in the general case, because you only see a bunch of bytes and you need to guess the signature of the error.
Given the situation where Hardhat scripts are interacting with a contract via await hardhat.ethers.getContractAt(CONTRACT_ABI, CONTRACT_ADDRESS)
, modern versions of Solidity do have the custom errors in the ABI (they appear as objects with type
set to "error"). So, when generated that way, the signature of the custom errors should be known, correct?
Is there a technical limitation preventing Hardhat from using the custom error signatures in those ABIs (no need to "guess" at them)?
The problem in that case is that that information is mainly just passed to ethers (the hardhat-ethers
plugin itself doesn't do much).
In principle we could make the hardhat-ethers
plugin make extra work on those calls and, if it's connected to a Hardhat network, pass that extra information to the node so that it "knows" about those errors. But even doing that would require a mechanism to add those extra selectors/custom errors, which is what this issue is about.
Is there any update on this issue currently running into the same problem with some of my test when trying to integrate with another protocol.
Any news?