Created
February 13, 2020 00:56
-
-
Save ngmachado/b1406cb43e1efc1b6b32c3a47de9de3c 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
pragma solidity >=0.6.0 <0.7.0; | |
interface IERC2429 { | |
function defineHardRecovery(bytes32 _rootTree) external; | |
} | |
/* | |
Example of a recovery account as DMS and Will. | |
This contract define a new root as a mandatory recovery. A mandatory recovrey dont have a wait time to be active. After the activation is set, only the peers can recovery the account. We can think as the analogic lawyers :) gthat can prove the incapacity of the user. | |
*/ | |
contract DMS { | |
uint256 public lastPing; | |
uint256 public increment; | |
bytes32 lastAction; | |
address public controller; | |
//Social Recovery System Contract | |
IERC2429 public SRS | |
constructor(uint256 _increment, bytes32 _lastAction) public { | |
lastPing = now; | |
increment = _increment; | |
controller = msg.sender; | |
lastAction = _lastAction; | |
} | |
function inControl() external returns(bool) { | |
return lastPing + increment > now; | |
} | |
function ping() external onlyController { | |
lastPing = now; | |
} | |
//when is time, anyone can activate the will. | |
//this function define a new recovery tree in SRS | |
//This new tree is mandatory no wait time. | |
function activateLastAction() external { | |
require(lastPing + increment < now, 'not in time'); | |
SRS.defineHardRecovery(lastAction); | |
//bounty for activating last Action =) | |
selfdestruct(msg.sender); | |
} | |
modifier onlyController { | |
require(msg.sender == controller, 'not controller'); | |
_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment