From 0a253aa9b344cfbb2c8a44d56c3bbb947ab70c16 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 23 Feb 2018 15:01:35 -0400 Subject: [PATCH] Initial version of possible recovery contract (hasn't been tested yet) --- contracts/identity/Identity.sol | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/contracts/identity/Identity.sol b/contracts/identity/Identity.sol index 26afa9f..1aefc7b 100644 --- a/contracts/identity/Identity.sol +++ b/contracts/identity/Identity.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.17; import "./ERC725.sol"; import "./ERC735.sol"; - +import "./Recovery.sol"; contract Identity is ERC725, ERC735 { @@ -15,6 +15,8 @@ contract Identity is ERC725, ERC735 { mapping (uint256 => uint8) minimumApprovalsByKeyType; bytes32[] pendingTransactions; uint nonce = 0; + bool recoverySet; + Recovery recoveryContract; struct Transaction { address to; @@ -365,6 +367,38 @@ contract Identity is ERC725, ERC735 { { return claimsByType[_claimType]; } + +// ---- Recovery Specific Functions + event RecoverySetUp(address sender, bytes32[] recoveryHashes); + event RecoveryCompleted(bytes32 newManagementKey); + + function setupRecovery(bytes32[] _recoveryHashes) + public + managerOnly + { + require(recoverySet == false); + RecoverySetUp(msg.sender, _recoveryHashes); + recoveryContract = new Recovery(this, _recoveryHashes); + recoverySet = true; + } + + function completeRecovery() public { + require(recoverySet == true); + address newManager = recoveryContract.getNewManager(); + require(newManager != address(0x0)); + + RecoveryCompleted(bytes32(newManager)); + + bytes32[] memory managementKeys = getKeysByPurpose(MANAGEMENT_KEY); + for (uint256 i = 0; i < managementKeys.length; i++) { + _removeKey(managementKeys[i], MANAGEMENT_KEY); + } + addKey(bytes32(newManager), MANAGEMENT_KEY, 1); + setMiminumApprovalsByKeyType(MANAGEMENT_KEY, 1); + } + + + }