Last active
December 5, 2018 19:55
-
-
Save kyriediculous/1ce2ffbad74bd37692993146b69e5295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Dummy { | |
address impl; | |
constructor (address _impl) public { | |
impl = _impl; | |
} | |
function () public { | |
require(msg.sig != 0x0); | |
address _impl = impl; | |
assembly { | |
let ptr := mload(0x40) | |
calldatacopy(ptr, 0, calldatasize) | |
let result := delegatecall(gas, _impl, ptr, calldatasize, ptr, 0) | |
let size := returndatasize | |
returndatacopy(ptr, 0, size) | |
switch result | |
case 0 { revert(ptr, size) } | |
default { return(ptr, size) } | |
} | |
} | |
//This function can make the current instance upgradeable, instead of only newly spawned instances | |
// Acces control not included for simplicity (you could use Ownable.sol from OpenZeppelin) | |
function changeImplementation(address _impl) public { | |
impl = _impl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment