I have a proxy contract that delegate calls to a target contract. The proxy is similar to DSProxy.
In it, there is an execute
function:
function execute(address target, bytes memory data) external payable returns (bytes memory response) {
// ...
(bool success, bytes memory returndata) = target.delegatecall(data);
// ...
}
Whose job is to delegate call to the provided target
and return the response
, which is of type bytes memory
.
Now, say that I am calling a target contract that returns a struct:
contract TargetEcho {
struct TargetStruct {
uint256 foo;
uint256 bar;
}
function echoStruct(TargetStruct calldata input) external pure returns (TargetStruct calldata) {
return input;
}
}
The Solidity compiler must do something to the TargetStruct calldata
return type. It must decode it somehow. How is it done?