solidity icon indicating copy to clipboard operation
solidity copied to clipboard

`abi.encodeError(...)` for custom errors

Open hrkrshnn opened this issue 2 years ago • 2 comments

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, ...).

hrkrshnn avatar Aug 02 '22 11:08 hrkrshnn

Related bug: #13266.

cameel avatar Aug 03 '22 12:08 cameel

Decision to use abi.encodeError instead of abi.encodeCall.

hrkrshnn avatar Aug 03 '22 12:08 hrkrshnn

Is anyone attempting this? May I take it?

timweri avatar Aug 18 '22 15:08 timweri

@timweri Yeah go for it

hrkrshnn avatar Aug 25 '22 12:08 hrkrshnn

This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.

github-actions[bot] avatar Mar 30 '23 12:03 github-actions[bot]

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.

github-actions[bot] avatar Apr 08 '23 12:04 github-actions[bot]

This feature would be very useful when checking for errors in Forge:

vm.expectRevert(abi.encodeError(MyContract.MyError, arg1, arg2));

guidanoli avatar Nov 28 '23 02:11 guidanoli