Last active
May 24, 2018 21:29
-
-
Save szerintedmi/995e10c145a17162fc88e5f5f35136ad to your computer and use it in GitHub Desktop.
StabiltyBoard delegateCall scripts
This file contains hidden or 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 StabiltyBoard { | |
address[] allSigners // all signers, even disabled ones | |
mapping(address => bool) isSigner; | |
enum ScriptState { New, Approved, Done , Failed } | |
struct Script { | |
ScriptState state; // do we want to calculate quorum at the time time of approve or execute call ? | |
uint signCount; | |
mapping(address => bool) signedBy; | |
address[] signers; // do we need iterable signers? | |
// do we need revokeApproval? if not then we don't need signCount; | |
} | |
mapping(address => Script) scripts; | |
address[] scriptAddresses; | |
approve(address scriptAddress); | |
execute(address scriptAddress) returns (bool success) { | |
Script script = scripts[scriptAddress] | |
require(script.status = ScriptState.Approved); | |
if(scriptAddress.delegatecall(bytes4(keccak256("execute()")))) { | |
script.status = ScriptState.Done; | |
return true; | |
} else { | |
script.status = ScriptState.Failed; | |
return false; | |
} | |
} | |
// ... adding and removing signers called from approved scripts too | |
addSigners(address[] signers) private; | |
removeSigners(address[] signers) private; | |
} | |
contract RestrictedContract | |
StabilityBoard stabilityBoard; | |
RestrictedFunction() { | |
require(msg.sender == stabilityBoard); // could make it a modifier | |
// ... | |
} | |
} | |
contract StablityBoardScript_00001 { | |
execute() { | |
calls to restricted contracts... | |
selfDesctruct(msg.sender); // shouldn't have balance but... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment