I have a contract (Implementation.sol) which delegatecalls the other contract (Attacker.sol) to selfdestruct. When I try to compile the Implementation.sol on Remix, I receive Expected primary expression
error for the line require(success && dat != byte(0x0), "call failed");
. Not sure what to do.
contract Implementation {
function delegateTheCall (address target, string calldata action, address to) public returns (bytes memory) {
(bool success,bytes memory dat) = target.delegatecall(abi.encodeWithSignature(action, to));
require(success && dat != byte(0x0), "call failed");
return dat;
}
dat.length != 0
instead ofdat != byte(0x0)
. But why having this condition? It's common for a function to return nothing and still succeed.