mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Completed governance in MoatAddress.
This commit is contained in:
parent
5eafbf733c
commit
0a12d26912
|
@ -10,34 +10,44 @@ contract AddressRegistry {
|
|||
event ResolverDisapproved(address user, address addr);
|
||||
|
||||
// Addresses managing the protocol governance
|
||||
mapping(address => bool) governors;
|
||||
mapping(address => bool) public governors;
|
||||
|
||||
// Address registry of connected smart contracts
|
||||
mapping(bytes32 => address) registry;
|
||||
mapping(bytes32 => address) public registry;
|
||||
|
||||
// Contract addresses having rights to perform tasks, approved by users
|
||||
// Resolver Contract >> User >> Approved
|
||||
mapping(address => mapping(address => bool)) resolvers;
|
||||
mapping(address => mapping(address => bool)) public resolvers;
|
||||
|
||||
}
|
||||
|
||||
|
||||
contract Governance is AddressRegistry {
|
||||
contract ManageRegistry is AddressRegistry {
|
||||
|
||||
function dummyfunction() public pure returns(bool) {
|
||||
return true;
|
||||
address public pendingAdmin;
|
||||
uint public pendingTime;
|
||||
|
||||
function setPendingAdmin() public {
|
||||
require(block.timestamp > pendingTime, "Pending!");
|
||||
registry[keccak256("admin")] = pendingAdmin;
|
||||
}
|
||||
|
||||
// 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 setAddr(string name, address newAddr) public {
|
||||
if (keccak256(name) != keccak256("admin")) {
|
||||
require(
|
||||
governors[msg.sender],
|
||||
"Permission Denied"
|
||||
);
|
||||
pendingAdmin = newAddr;
|
||||
pendingTime = block.timestamp + (24 * 60 * 60); // adding 24 hours
|
||||
} else {
|
||||
require(
|
||||
msg.sender == getAddr("admin"),
|
||||
"Permission Denied"
|
||||
);
|
||||
registry[keccak256(name)] = newAddr;
|
||||
emit AddressChanged(name, newAddr);
|
||||
}
|
||||
}
|
||||
|
||||
function getAddr(string name) public view returns(address addr) {
|
||||
|
@ -45,14 +55,6 @@ contract ManageRegistry is Governance {
|
|||
require(addr != address(0), "Not a valid address.");
|
||||
}
|
||||
|
||||
modifier onlyAdmin() {
|
||||
require(
|
||||
msg.sender == getAddr("admin"),
|
||||
"Permission Denied"
|
||||
);
|
||||
_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ contract MoatResolver is FeeDetail {
|
|||
fees = cut;
|
||||
}
|
||||
|
||||
function collectFees(address tokenAddress, uint amount) public onlyAdmin {
|
||||
function collectToken(address tokenAddress, uint amount) public onlyAdmin {
|
||||
if (tokenAddress == 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) {
|
||||
msg.sender.transfer(amount);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user