2019-02-22 17:00:57 +00:00
|
|
|
pragma solidity 0.5.0;
|
2018-10-25 12:59:05 +00:00
|
|
|
|
2019-01-27 17:50:14 +00:00
|
|
|
|
2018-10-24 17:12:07 +00:00
|
|
|
contract AddressRegistry {
|
2018-10-28 22:53:17 +00:00
|
|
|
event AddressSet(string name, address addr);
|
2018-10-29 11:19:01 +00:00
|
|
|
mapping(bytes32 => address) registry;
|
2018-10-27 11:11:57 +00:00
|
|
|
|
2018-10-28 22:53:17 +00:00
|
|
|
constructor() public {
|
|
|
|
registry[keccak256(abi.encodePacked("admin"))] = msg.sender;
|
2018-10-27 11:11:57 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 17:29:42 +00:00
|
|
|
function getAddr(string memory name) public view returns (address) {
|
2018-10-28 22:53:17 +00:00
|
|
|
return registry[keccak256(abi.encodePacked(name))];
|
2018-10-27 11:11:57 +00:00
|
|
|
}
|
2018-10-25 18:44:53 +00:00
|
|
|
|
2019-01-27 17:29:42 +00:00
|
|
|
function setAddr(string memory name, address addr) public {
|
|
|
|
require(msg.sender == getAddr("admin") || msg.sender == getAddr("owner"), "Permission Denied");
|
2018-10-28 22:53:17 +00:00
|
|
|
registry[keccak256(abi.encodePacked(name))] = addr;
|
|
|
|
emit AddressSet(name, addr);
|
2018-10-25 12:27:42 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 17:29:42 +00:00
|
|
|
}
|