Skip to content

Instantly share code, notes, and snippets.

@maheshmurthy
Last active April 27, 2023 18:35
Show Gist options
  • Select an option

  • Save maheshmurthy/d8efb0ca95b1dcea1cfc08f676f43da7 to your computer and use it in GitHub Desktop.

Select an option

Save maheshmurthy/d8efb0ca95b1dcea1cfc08f676f43da7 to your computer and use it in GitHub Desktop.

Revisions

  1. maheshmurthy renamed this gist Apr 27, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. maheshmurthy created this gist Apr 27, 2023.
    45 changes: 45 additions & 0 deletions gistfile1.txt
    Original 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;
    }
    }