add upgradable instance factory and needed architecture

This commit is contained in:
Ricardo Guilherme Schmidt 2018-02-28 01:36:48 -03:00
parent ebbfbeb1a0
commit 5c9070f7dc
3 changed files with 46 additions and 0 deletions

View File

@ -134,6 +134,7 @@ contract Identity is ERC725, ERC735 {
public
selfOnly
{
require(_minimumApprovals > 0);
minimumApprovalsByKeyType[_type] = _minimumApprovals;
}

View File

@ -0,0 +1,32 @@
pragma solidity ^0.4.17;
import "../deploy/Factory.sol";
import "../deploy/UpdatableInstance.sol";
import "./IdentityKernel.sol";
contract IdentityFactory is Factory {
event IdentityCreated(address instance);
function IdentityFactory(bytes _infohash)
Factory(new IdentityKernel(), _infohash)
public
{
}
function createIdentity()
external
{
createIdentity(msg.sender);
}
function createIdentity(address _idOwner)
public
{
IdentityKernel instance = IdentityKernel(new UpdatableInstance(address(latestKernel)));
instance.initIdentity(_idOwner);
IdentityCreated(address(instance));
}
}

View File

@ -0,0 +1,13 @@
pragma solidity ^0.4.17;
import "../deploy/InstanceStorage.sol";
import "./Identity.sol";
contract IdentityKernel is InstanceStorage, Identity {
function initIdentity(address _caller) external {
require(minimumApprovalsByKeyType[MANAGEMENT_KEY] == 0);
_addKey(bytes32(_caller), MANAGEMENT_KEY, 0);
minimumApprovalsByKeyType[MANAGEMENT_KEY] = 1;
}
}