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); |     event ResolverDisapproved(address user, address addr); | ||||||
| 
 | 
 | ||||||
|     // Addresses managing the protocol governance |     // Addresses managing the protocol governance | ||||||
|     mapping(address => bool) governors; |     mapping(address => bool) public governors; | ||||||
| 
 | 
 | ||||||
|     // Address registry of connected smart contracts |     // 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 |     // Contract addresses having rights to perform tasks, approved by users | ||||||
|     // Resolver Contract >> User >> Approved |     // 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) { |     address public pendingAdmin; | ||||||
|         return true; |     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 |     function setAddr(string name, address newAddr) public { | ||||||
| 
 |         if (keccak256(name) != keccak256("admin")) { | ||||||
| } |             require( | ||||||
| 
 |                 governors[msg.sender], | ||||||
| 
 |                 "Permission Denied" | ||||||
| contract ManageRegistry is Governance { |             ); | ||||||
| 
 |             pendingAdmin = newAddr; | ||||||
|     function setAddr(string name, address newAddr) public onlyAdmin { |             pendingTime = block.timestamp + (24 * 60 * 60); // adding 24 hours | ||||||
|         registry[keccak256(name)] = newAddr; |         } else { | ||||||
|         emit AddressChanged(name, newAddr); |             require( | ||||||
|  |                 msg.sender == getAddr("admin"), | ||||||
|  |                 "Permission Denied" | ||||||
|  |             ); | ||||||
|  |             registry[keccak256(name)] = newAddr; | ||||||
|  |             emit AddressChanged(name, newAddr); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function getAddr(string name) public view returns(address addr) { |     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."); |         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; |         fees = cut; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function collectFees(address tokenAddress, uint amount) public onlyAdmin { |     function collectToken(address tokenAddress, uint amount) public onlyAdmin { | ||||||
|         if (tokenAddress == 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) { |         if (tokenAddress == 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) { | ||||||
|             msg.sender.transfer(amount); |             msg.sender.transfer(amount); | ||||||
|         } else { |         } else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Sowmayjain
						Sowmayjain