Take the following low-level call written in Solidity:
(bool success, bytes memory response) =
address(proxy).call(abi.encodeWithSelector(plugins.reverter.withReasonString.selector));
I know that this call will revert because I wrote the plugins.reverter
contract (this is a test):
contract TargetReverter {
function withReasonString() external pure {
revert("You shall not pass");
}
}
I want to ABI decode the response
into a string, but I cannot make it work. The following code does not work:
abi.decode(response, (string));
I imagine that this is because response
starts with a 4-byte function selector:
0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000012596f75207368616c6c206e6f7420706173730000000000000000000000000000
How can I turn the bytes above into a string?