Last active
April 27, 2023 18:35
-
-
Save maheshmurthy/d8efb0ca95b1dcea1cfc08f676f43da7 to your computer and use it in GitHub Desktop.
Very first DelegateRegistry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Very first version | |
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.9; | |
import "solmate/src/auth/Owned.sol"; | |
contract DelegateRegistry is Owned { | |
enum DelegateStatus {ACTIVE, WITHDRAWN, INVALID, AWAY} | |
event DelegateInfo(string indexed _daoName, address indexed _delegate, string _statement, string _interests); | |
struct Delegate { | |
address delegate; | |
string statement; | |
string interests; | |
DelegateStatus status; | |
} | |
constructor() Owned(msg.sender) {} | |
mapping(string => uint) public daoRegistry; | |
mapping(string => mapping(address => Delegate)) public daoDelegates; | |
function registerDAO(string memory daoName) public onlyOwner { | |
daoRegistry[daoName] = 1; | |
} | |
function selfRegisterDelegateEmit(string memory daoName, | |
string calldata statement, string calldata interests) public { | |
require(daoRegistry[daoName] == 1, "DAO not registered"); | |
emit DelegateInfo(daoName, msg.sender, statement, interests); | |
} | |
function selfRegisterDelegate(string memory daoName, | |
string calldata statement, string calldata interests) public { | |
require(daoRegistry[daoName] == 1, "DAO not registered"); | |
Delegate memory d = Delegate({delegate:msg.sender, | |
statement:statement, interests:interests, status: DelegateStatus.ACTIVE}); | |
daoDelegates[daoName][msg.sender] = d; | |
} | |
function updateDelegateInfo(string memory daoName, | |
string calldata statement, string calldata interests) public { | |
daoDelegates[daoName][msg.sender].statement = statement; | |
daoDelegates[daoName][msg.sender].interests = interests; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment