2019-03-11 12:30:45 +00:00
|
|
|
pragma solidity ^0.5.0;
|
2019-03-10 08:38:03 +00:00
|
|
|
|
2019-03-10 07:40:51 +00:00
|
|
|
interface AddrRegistry {
|
2019-03-11 12:30:45 +00:00
|
|
|
function getAddr(string calldata) external view returns (address);
|
2019-03-10 07:40:51 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
|
2019-03-10 07:40:51 +00:00
|
|
|
contract AddressRegistry {
|
|
|
|
address public registry;
|
|
|
|
|
|
|
|
modifier onlyAdmin() {
|
2019-03-11 12:30:45 +00:00
|
|
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
2019-03-10 07:40:51 +00:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
function getAddress(string memory name) internal view returns (address) {
|
2019-03-10 07:40:51 +00:00
|
|
|
AddrRegistry addrReg = AddrRegistry(registry);
|
|
|
|
return addrReg.getAddr(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
contract LogicRegistry is AddressRegistry {
|
2019-03-10 07:40:51 +00:00
|
|
|
event DefaultLogicSet(address logicAddr);
|
|
|
|
event LogicSet(address logicAddr, bool isLogic);
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
mapping(address => bool) public defaultLogicProxies;
|
|
|
|
mapping(address => bool) public logicProxies;
|
2019-03-10 07:40:51 +00:00
|
|
|
|
|
|
|
constructor(address registry_) public {
|
|
|
|
registry = registry_;
|
|
|
|
}
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
function getLogic(address logicAddr) public view returns (bool) {
|
|
|
|
if (defaultLogicProxies[logicAddr]) {
|
2019-03-10 07:40:51 +00:00
|
|
|
return true;
|
2019-03-11 12:30:45 +00:00
|
|
|
} else if (logicProxies[logicAddr]) {
|
2019-03-10 07:40:51 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setLogic(address logicAddr, bool isLogic) public onlyAdmin {
|
|
|
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
2019-03-11 12:30:45 +00:00
|
|
|
logicProxies[logicAddr] = true;
|
2019-03-10 07:40:51 +00:00
|
|
|
emit LogicSet(logicAddr, isLogic);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setDefaultLogic(address logicAddr) public onlyAdmin {
|
|
|
|
require(msg.sender == getAddress("admin"), "Permission Denied");
|
2019-03-11 12:30:45 +00:00
|
|
|
defaultLogicProxies[logicAddr] = true;
|
2019-03-10 07:40:51 +00:00
|
|
|
emit DefaultLogicSet(logicAddr);
|
|
|
|
}
|
|
|
|
|
2019-03-11 12:30:45 +00:00
|
|
|
}
|