Let's suppose I have a simple delegatecall based relay contract. It looks up the contract implementation from a registry and passes the call to the upgradeable implementation:
contract Relay {
address public registrarAddr;
string public name;
function Relay(address _registrarAddr, string _name) {
registrarAddr = _registrarAddr;
name = _name;
}
function getImplAddr() constant returns (address) {
Registrar registrar = Registrar(registrarAddr);
return registrar.addr(name);
}
function() {
address currentVersion = this.getImplAddr();
if(!currentVersion.delegatecall(msg.data)) throw;
}
}
As you see the current function() {}
has a special check for delegatecall
return values, as this is based on an example code.
The question is, how delegatecall
handle return values? Can I modify this delegatecall
hook to perform normal web3 contract.call().balanceOf(addr)
style functions for reading public values from the implementation contract? Or if I set up a relay contract do I need to have special logic in place to read the data from the contract what I would normally do with call()
? Are there any examples of such arrangements?