diff --git a/contracts/identity/Identity.sol b/contracts/identity/Identity.sol index 27e523f..de89f6d 100644 --- a/contracts/identity/Identity.sol +++ b/contracts/identity/Identity.sol @@ -134,6 +134,7 @@ contract Identity is ERC725, ERC735 { public selfOnly { + require(_minimumApprovals > 0); minimumApprovalsByKeyType[_type] = _minimumApprovals; } diff --git a/contracts/identity/IdentityFactory.sol b/contracts/identity/IdentityFactory.sol new file mode 100644 index 0000000..6da2bf8 --- /dev/null +++ b/contracts/identity/IdentityFactory.sol @@ -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)); + } + +} diff --git a/contracts/identity/IdentityKernel.sol b/contracts/identity/IdentityKernel.sol new file mode 100644 index 0000000..7966b8b --- /dev/null +++ b/contracts/identity/IdentityKernel.sol @@ -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; + } +}