Last active
October 19, 2017 15:47
-
-
Save pirapira/6d32c42fc0ff32e2ebc08e50f477db35 to your computer and use it in GitHub Desktop.
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
// This code does not compile yet. | |
// Should Bamboo support this kind of nesting contracts, which represent substates and a superstate? | |
contract Alive(address hotWallet, address vaultKey, address recoveryKey) { | |
case(void destroy()) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Destroyed(); | |
} | |
case(void recover(address _newHotWallet)) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Alive(hotWallet, vaultKey, recoveryKey).Vault(); | |
} | |
contract Vault() { | |
case(void unvault(uint256 amount)) { | |
if (sender(msg) != vaultKey) abort; | |
uint256 unvaultPeriod = 60 * 60 * 24 * 7 * 2; // two weeks | |
if (now(block) + unvaultPeriod < now(block)) abort; | |
return then become Alive(hotWallet, vaultKey, recoveryKey).UnVaulting(now(block) + unvaultPeriod, amount); | |
} | |
} | |
contract UnVaulting(uint256 redeemtime, uint256 amount) { | |
case(void redeem()) { | |
if (amount > balance(this)) abort; | |
void = hotwallet.default() with amount reentrance { abort; }; | |
return then become Alive(hotwallet, vaultKey, recoveryKey).Vault(); | |
} | |
} | |
} | |
contract Destroyed() { | |
// any call just throws; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment