-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPassportFactory.sol
58 lines (49 loc) · 2.14 KB
/
PassportFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/ownership/HasNoEther.sol";
import "openzeppelin-solidity/contracts/ownership/HasNoTokens.sol";
import "./Passport.sol";
/**
* @title PassportFactory
* @dev This contract works as a passport factory.
*/
contract PassportFactory is Ownable, HasNoEther, HasNoTokens {
IPassportLogicRegistry private registry;
/**
* @dev This event will be emitted every time a new passport is created
* @param passport representing the address of the passport created
* @param owner representing the address of the passport owner
*/
event PassportCreated(address indexed passport, address indexed owner);
/**
* @dev This event will be emitted every time a passport logic registry is changed
* @param oldRegistry representing the address of the old passport logic registry
* @param newRegistry representing the address of the new passport logic registry
*/
event PassportLogicRegistryChanged(address indexed oldRegistry, address indexed newRegistry);
constructor(IPassportLogicRegistry _registry) public {
_setRegistry(_registry);
}
function setRegistry(IPassportLogicRegistry _registry) public onlyOwner {
emit PassportLogicRegistryChanged(registry, _registry);
_setRegistry(_registry);
}
function getRegistry() external view returns (address) {
return registry;
}
/**
* @dev Creates new passport. The method should be called by the owner of the created passport.
* After the passport is created, the owner must call the claimOwnership() passport method to become a full owner.
* @return address of the created passport
*/
function createPassport() public returns (Passport) {
Passport pass = new Passport(registry);
pass.transferOwnership(msg.sender); // owner needs to call claimOwnership()
emit PassportCreated(pass, msg.sender);
return pass;
}
function _setRegistry(IPassportLogicRegistry _registry) internal {
require(address(_registry) != 0x0);
registry = _registry;
}
}