2019-03-09 21:26:18 +00:00
|
|
|
pragma solidity ^0.4.23;
|
2019-03-09 20:42:05 +00:00
|
|
|
|
2019-03-10 08:38:03 +00:00
|
|
|
|
2019-03-10 11:23:11 +00:00
|
|
|
import "./UserProxy.sol";
|
2019-03-09 20:42:05 +00:00
|
|
|
|
|
|
|
// ProxyRegistry
|
|
|
|
contract ProxyRegistry {
|
|
|
|
event Created(address indexed sender, address indexed owner, address proxy);
|
2019-03-10 08:38:03 +00:00
|
|
|
mapping(address => UserProxy) public proxies;
|
|
|
|
address public logicProxyAddr;
|
|
|
|
|
|
|
|
constructor(address logicProxyAddr_) public {
|
|
|
|
logicProxyAddr = logicProxyAddr_;
|
|
|
|
}
|
2019-03-09 20:42:05 +00:00
|
|
|
|
|
|
|
// deploys a new proxy instance
|
|
|
|
// sets owner of proxy to caller
|
2019-03-10 11:23:11 +00:00
|
|
|
function build(uint activeDays) public returns (UserProxy proxy) {
|
|
|
|
proxy = build(msg.sender, activeDays);
|
2019-03-09 20:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// deploys a new proxy instance
|
|
|
|
// sets custom owner of proxy
|
2019-03-10 11:23:11 +00:00
|
|
|
function build(address owner, uint activeDays) public returns (UserProxy proxy) {
|
|
|
|
require(
|
|
|
|
proxies[owner] == UserProxy(0) || proxies[owner].owner() != owner,
|
|
|
|
"multiple-proxy-per-user-not-allowed"
|
|
|
|
); // Not allow new proxy if the user already has one and remains being the owner
|
|
|
|
proxy = new UserProxy(logicProxyAddr, activeDays);
|
2019-03-09 20:42:05 +00:00
|
|
|
emit Created(msg.sender, owner, address(proxy));
|
|
|
|
proxy.setOwner(owner);
|
|
|
|
proxies[owner] = proxy;
|
|
|
|
}
|
|
|
|
}
|