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-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
|
|
|
}
|
|
|
|
|
2018-10-28 22:53:17 +00:00
|
|
|
function getAddr(string name) public view returns(address) {
|
|
|
|
return registry[keccak256(abi.encodePacked(name))];
|
2018-10-27 11:11:57 +00:00
|
|
|
}
|
2018-10-25 18:44:53 +00:00
|
|
|
|
2018-10-28 22:53:17 +00:00
|
|
|
function setAddr(string name, address addr) public {
|
2018-10-28 17:36:35 +00:00
|
|
|
require(
|
2018-10-28 22:53:17 +00:00
|
|
|
msg.sender == getAddr("admin") ||
|
|
|
|
msg.sender == getAddr("owner"),
|
2018-10-28 17:36:35 +00:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2018-10-28 16:59:07 +00:00
|
|
|
}
|