Skip to content

Instantly share code, notes, and snippets.

@joeykrug
Created June 1, 2017 23:21
Show Gist options
  • Save joeykrug/8e3766acf6d20d885723f63f02c26a7e to your computer and use it in GitHub Desktop.
Save joeykrug/8e3766acf6d20d885723f63f02c26a7e to your computer and use it in GitHub Desktop.
contract Dispatcher is Upgradeable {
function Dispatcher(address target) {
replace(target);
}
function initialize() {
// Should only be called by on target contracts, not on the dispatcher
throw;
}
function() {
bytes4 sig;
assembly { sig := calldataload(0) }
var len = _sizes[sig];
var target = _dest;
assembly {
// return _dest.delegatecall(msg.data)
calldatacopy(0x0, 0x0, calldatasize)
delegatecall(sub(gas, 10000), target, 0x0, calldatasize, 0, len)
return(0, len)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment