base structure of upgradable republic

This commit is contained in:
Ricardo Guilherme Schmidt 2017-11-28 01:33:25 -02:00
commit c273f7ec1d
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
pragma solidity ^0.4.17;
/**
* @title DelegatedCall
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
* @dev Abstract contract that delegates calls by `delegated` modifier to result of `_target()`
*/
contract DelegatedCall {
/**
* @dev delegates the call of this function
*/
modifier delegated {
require(_target().delegatecall(msg.data)); //require successfull delegate call to remote `_target()`
assembly {
let outSize := returndatasize
let outDataPtr := mload(0x40) //load memory
returndatacopy(outDataPtr, 0, outSize) //copy last return into pointer
return(outDataPtr, outSize)
}
assert(false); //should never reach here
_; //never will execute local logic
}
/**
* @dev defines the address for delegation of calls
*/
function _target()
internal
constant
returns(address);
}