2018-10-27 11:11:57 +00:00
|
|
|
// addresses name - address, asset, resolver, moatkyber, moatmaker, admin
|
2018-10-26 16:16:23 +00:00
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
pragma solidity ^0.4.24;
|
|
|
|
|
2018-10-25 12:59:05 +00:00
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
contract AddressRegistry {
|
|
|
|
|
2018-10-27 11:11:57 +00:00
|
|
|
event AddressChanged(string name, address addr);
|
|
|
|
event ResolverApproved(address user, address addr);
|
|
|
|
event ResolverDisapproved(address user, address addr);
|
2018-10-24 17:12:07 +00:00
|
|
|
|
2018-10-27 11:11:57 +00:00
|
|
|
// Addresses managing the protocol governance
|
|
|
|
mapping(address => bool) governors;
|
|
|
|
|
|
|
|
// Address registry of connected smart contracts
|
|
|
|
mapping(bytes32 => address) registry;
|
|
|
|
|
|
|
|
// Contract addresses having rights to perform tasks, approved by users
|
|
|
|
// Resolver Contract >> User >> Approved
|
|
|
|
mapping(address => mapping(address => bool)) resolvers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
contract Governance is AddressRegistry {
|
|
|
|
|
|
|
|
// governance code goes here to update the admin in "registry" mapping
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
contract ManageRegistry is Governance {
|
|
|
|
|
|
|
|
function setAddr(string name, address newAddr) public onlyAdmin {
|
|
|
|
registry[keccak256(name)] = newAddr;
|
|
|
|
emit AddressChanged(name, newAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAddr(string name) public view returns(address addr) {
|
|
|
|
addr = registry[keccak256(name)];
|
|
|
|
require(addr != address(0), "Not a valid address.");
|
|
|
|
}
|
2018-10-25 18:44:53 +00:00
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
modifier onlyAdmin() {
|
|
|
|
require(
|
|
|
|
msg.sender == getAddr("admin"),
|
|
|
|
"Permission Denied"
|
|
|
|
);
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2018-10-27 11:11:57 +00:00
|
|
|
}
|
2018-10-24 17:12:07 +00:00
|
|
|
|
|
|
|
|
2018-10-27 11:11:57 +00:00
|
|
|
contract ManageResolvers is ManageRegistry {
|
2018-10-24 17:12:07 +00:00
|
|
|
|
2018-10-25 18:44:53 +00:00
|
|
|
function approveResolver() public {
|
2018-10-27 11:11:57 +00:00
|
|
|
resolvers[getAddr("resolver")][msg.sender] = true;
|
|
|
|
emit ResolverApproved(msg.sender, getAddr("resolver"));
|
2018-10-25 12:27:42 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 18:44:53 +00:00
|
|
|
function disapproveResolver() public {
|
2018-10-27 11:11:57 +00:00
|
|
|
resolvers[getAddr("resolver")][msg.sender] = false;
|
|
|
|
emit ResolverDisapproved(msg.sender, getAddr("resolver"));
|
2018-10-25 12:27:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isApprovedResolver(address user) public view returns(bool) {
|
2018-10-27 11:11:57 +00:00
|
|
|
return resolvers[getAddr("resolver")][user];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
contract InitRegistry is ManageResolvers {
|
|
|
|
|
|
|
|
constructor() public {
|
|
|
|
registry[keccak256("admin")] = msg.sender;
|
2018-10-25 12:27:42 +00:00
|
|
|
}
|
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
}
|