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-25 04:52:53 +00:00
|
|
|
event AddressChanged(string name, address target);
|
|
|
|
mapping(bytes32 => address) internal addressRegistry;
|
2018-10-24 17:12:07 +00:00
|
|
|
|
2018-10-25 18:44:53 +00:00
|
|
|
// Resolver Contract Addresses >> Asset Owner Address >> Bool
|
|
|
|
mapping(address => mapping(address => bool)) allowedResolver;
|
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
modifier onlyAdmin() {
|
|
|
|
require(
|
|
|
|
msg.sender == getAddr("admin"),
|
|
|
|
"Permission Denied"
|
|
|
|
);
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() public {
|
2018-10-25 04:52:53 +00:00
|
|
|
addressRegistry[keccak256("admin")] = msg.sender;
|
2018-10-24 17:12:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 04:52:53 +00:00
|
|
|
function setAddr(string name, address newAddress) public onlyAdmin {
|
|
|
|
addressRegistry[keccak256(name)] = newAddress;
|
|
|
|
emit AddressChanged(name, newAddress);
|
2018-10-24 17:12:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 04:52:53 +00:00
|
|
|
function getAddr(string name) public view returns(address addr) {
|
|
|
|
addr = addressRegistry[keccak256(name)];
|
|
|
|
require(addr != address(0), "Not a valid address.");
|
2018-10-24 17:12:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 18:44:53 +00:00
|
|
|
function approveResolver() public {
|
2018-10-25 12:27:42 +00:00
|
|
|
allowedResolver[getAddr("resolver")][msg.sender] = true;
|
|
|
|
}
|
|
|
|
|
2018-10-25 18:44:53 +00:00
|
|
|
function disapproveResolver() public {
|
2018-10-25 12:27:42 +00:00
|
|
|
allowedResolver[getAddr("resolver")][msg.sender] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isApprovedResolver(address user) public view returns(bool) {
|
|
|
|
return allowedResolver[getAddr("resolver")][user];
|
|
|
|
}
|
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
}
|