solidity
solidity copied to clipboard
`abi.encodeError(...)` for custom errors
Abstract
The type-safe ab.encodeCall(f, args) should be extended for custom errors.
Motivation
It's very common in testing frameworks to encode custom errors (to check if a call reverts with the specified encoding). This is currently done by using abi.encodeWithSignature('error_signature", ...) or abi.encodeWithSelector(error.selector, ...).
Related bug: #13266.
Decision to use abi.encodeError instead of abi.encodeCall.
Is anyone attempting this? May I take it?
@timweri Yeah go for it
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.
Hi everyone! This issue has been automatically closed due to inactivity. If you think this issue is still relevant in the latest Solidity version and you have something to contribute, feel free to reopen. However, unless the issue is a concrete proposal that can be implemented, we recommend starting a language discussion on the forum instead.
This feature would be very useful when checking for errors in Forge:
vm.expectRevert(abi.encodeError(MyContract.MyError, arg1, arg2));