Created
September 22, 2015 22:34
-
-
Save pipermerriam/c18b11cbce0b345cf106 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 AlarmAPI { | |
/* | |
* Account Management API | |
*/ | |
function accountBalances(address account) public returns (uint); | |
function withdraw(uint value) public; | |
/* | |
* Authorization API | |
*/ | |
function addAuthorization(address schedulerAddress) public; | |
/* | |
* Call Scheduling API | |
*/ | |
function scheduleCall(address contractAddress, bytes4 abiSignature, bytes32 dataHash, uint targetBlock, uint8 gracePeriod, uint nonce) public; | |
} | |
contract AlarmTester { | |
address owner; | |
function AlarmTester() { | |
owner = msg.sender; | |
} | |
function kill() { | |
if (msg.sender != owner) { | |
return; | |
} | |
alarm.withdraw(alarm.accountBalances(address(this))); | |
suicide(owner); | |
} | |
AlarmAPI alarm = AlarmAPI(0xb0059e72ae1802fa1e1add5e7d0cb0eec1cc0cc1); | |
uint8 gracePeriod = 255; | |
function setGracePeriod(uint8 v) public { | |
gracePeriod = v; | |
} | |
bool public flag; | |
function doIt() public { | |
flag = true; | |
} | |
function undoIt() public { | |
flag = false; | |
} | |
uint public value; | |
function setIt(uint value) public { | |
value = value; | |
} | |
function scheduleDoIt(uint delta) { | |
alarm.scheduleCall(address(this), bytes4(sha3("doIt()")), sha3(), block.number + delta, gracePeriod, 0); | |
} | |
function scheduleUndoIt(uint delta) { | |
alarm.scheduleCall(address(this), bytes4(sha3("undoIt()")), sha3(), block.number + delta, gracePeriod, 0); | |
} | |
function scheduleSetIt(uint delta, uint value) { | |
address(alarm).call(bytes4(sha3("registerData()")), value); | |
alarm.scheduleCall(address(this), bytes4(sha3("setIt(uint256)")), sha3(), block.number + delta, gracePeriod, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment