2018-02-28 01:36:48 -03:00
|
|
|
pragma solidity ^0.4.17;
|
|
|
|
|
|
|
|
import "../deploy/Factory.sol";
|
2018-03-04 03:31:07 -03:00
|
|
|
import "../deploy/DelayedUpdatableInstance.sol";
|
2018-02-28 01:36:48 -03:00
|
|
|
import "./IdentityKernel.sol";
|
|
|
|
|
2018-02-28 14:52:32 -04:00
|
|
|
|
2018-02-28 01:36:48 -03:00
|
|
|
contract IdentityFactory is Factory {
|
|
|
|
|
|
|
|
event IdentityCreated(address instance);
|
|
|
|
|
2018-05-13 05:46:14 -03:00
|
|
|
constructor()
|
2018-02-28 01:36:48 -03:00
|
|
|
public
|
2018-05-13 02:39:10 -03:00
|
|
|
Factory(new IdentityKernel())
|
2018-02-28 01:36:48 -03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function createIdentity()
|
|
|
|
external
|
2018-04-19 05:33:04 -03:00
|
|
|
returns (address)
|
2018-05-13 02:39:10 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
bytes32[] memory initKeys = new bytes32[](2);
|
|
|
|
uint256[] memory initPurposes = new uint256[](2);
|
|
|
|
uint256[] memory initTypes = new uint256[](2);
|
|
|
|
initKeys[0] = keccak256(msg.sender);
|
|
|
|
initKeys[1] = initKeys[0];
|
|
|
|
initPurposes[0] = 0;
|
|
|
|
initPurposes[1] = 1;
|
|
|
|
initTypes[0] = 0;
|
|
|
|
initTypes[1] = 0;
|
|
|
|
return createIdentity(
|
|
|
|
initKeys,
|
|
|
|
initPurposes,
|
|
|
|
initTypes,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
);
|
2018-02-28 01:36:48 -03:00
|
|
|
}
|
|
|
|
|
2018-05-13 02:39:10 -03:00
|
|
|
function createIdentity(
|
|
|
|
bytes32[] _keys,
|
|
|
|
uint256[] _purposes,
|
|
|
|
uint256[] _types,
|
|
|
|
uint256 _managerThreshold,
|
|
|
|
uint256 _actorThreshold,
|
|
|
|
address _recoveryContract
|
|
|
|
)
|
2018-02-28 01:36:48 -03:00
|
|
|
public
|
2018-04-19 05:33:04 -03:00
|
|
|
returns (address)
|
2018-02-28 01:36:48 -03:00
|
|
|
{
|
2018-03-04 03:31:07 -03:00
|
|
|
IdentityKernel instance = IdentityKernel(new DelayedUpdatableInstance(address(latestKernel)));
|
2018-05-13 02:39:10 -03:00
|
|
|
instance.initIdentity(_keys,_purposes,_types,_managerThreshold,_actorThreshold,_recoveryContract);
|
2018-04-19 05:33:04 -03:00
|
|
|
emit IdentityCreated(address(instance));
|
|
|
|
return instance;
|
2018-02-28 01:36:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|