Last active
April 27, 2023 18:35
-
-
Save maheshmurthy/d8efb0ca95b1dcea1cfc08f676f43da7 to your computer and use it in GitHub Desktop.
Revisions
-
maheshmurthy renamed this gist
Apr 27, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
maheshmurthy created this gist
Apr 27, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ // 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; } }