WeuFoundDev / Governance-token-contracts

Governance contract of INPUT (INT) | A development based minting tokens for developers and researchers ecosystem.
GNU General Public License v3.0
2 stars 0 forks source link

Create a contract for session keys for V1 ( technical (3) and research committee (1) #34

Open WeuFoundDev opened 1 year ago

WeuFoundDev commented 1 year ago

Session keys for round up for the foundation committee members . Period for technical committee rotation will be 25 timechains . And for research committee the same . for v2 council member session rotation will be only 5 timechains @vinaykumar0103 @123456788940

vinaykumar0103 commented 1 year ago

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

contract FoundationCommitteeV1 is Ownable, Pausable {
    enum CommitteeType { Technical, Research }

    struct CommitteeMember {
        uint256 rotationEnd; // End of the current rotation period
    }

    uint256 public sessionDuration = 7 days;
    uint256 public sessionCount = 5;
    uint256 public technicalRotationPeriod = 25; // Updated rotation period for technical committee
    uint256 public researchRotationPeriod = 25; // Updated rotation period for research committee

    mapping(CommitteeType => mapping(address => CommitteeMember)) public committees;
    mapping(address => bool) public sessionKeys;
    mapping(address => uint256) public sessionExpiry;
    mapping(address => mapping(uint256 => bool)) public multiSignAggreApprovals;

    event SessionKeyAdded(address indexed sessionKey);
    event CommitteeMemberRotated(CommitteeType committeeType, address indexed oldMember, address indexed newMember);
    event ChangeProposed(address indexed proposer, string proposalDetails);
    event SessionEnded(address indexed sessionKey);

    constructor() {
        sessionKeys[msg.sender] = true;
    }

    modifier onlySessionKey() {
        require(sessionKeys[msg.sender], "You are not a valid session key");
        require(sessionExpiry[msg.sender] >= block.timestamp, "Session key has expired");
        _;
    }

    modifier onlyOwnerOrAdmin() {
        require(owner() == msg.sender || sessionKeys[msg.sender], "Not authorized");
        _;
    }

   /**
     * @dev Adds a session key using the SR25519 cryptographic algorithm.
     * @param _sessionKey The address of the session key to be added.
     */
    function addSessionKey(address _sessionKey) external onlyOwnerOrAdmin {
        require(_sessionKey != address(0), "Invalid session key address");
        sessionKeys[_sessionKey] = true;
        sessionExpiry[_sessionKey] = block.timestamp + sessionDuration;
        emit SessionKeyAdded(_sessionKey);
    }

    function rotateCommittee(CommitteeType _committeeType, address _newMember) external onlySessionKey {
        require(_newMember != address(0), "Invalid new member address");
        uint256 rotationEnd = block.timestamp + (sessionCount * sessionDuration);

        committees[_committeeType][_newMember] = CommitteeMember({
            rotationEnd: rotationEnd
        });
        emit CommitteeMemberRotated(_committeeType, msg.sender, _newMember);
    }

    function addTechnicalCommitteeMember(address _memberAddress) external onlySessionKey {
        require(_memberAddress != address(0), "Invalid member address");
        committees[CommitteeType.Technical][_memberAddress] = CommitteeMember({
            rotationEnd: block.timestamp + (technicalRotationPeriod * sessionDuration)
        });
        emit CommitteeMemberRotated(CommitteeType.Technical, address(0), _memberAddress);
    }

    function addResearchCommitteeMember(address _memberAddress) external onlySessionKey {
        require(_memberAddress != address(0), "Invalid member address");
        committees[CommitteeType.Research][_memberAddress] = CommitteeMember({
            rotationEnd: block.timestamp + (researchRotationPeriod * sessionDuration)
        });
        emit CommitteeMemberRotated(CommitteeType.Research, address(0), _memberAddress);
    }

    function proposeChange(string memory _proposalDetails) external onlySessionKey {
        require(committees[CommitteeType.Technical][msg.sender].rotationEnd >= block.timestamp, "Technical committee rotation ended");

        emit ChangeProposed(msg.sender, _proposalDetails);
    }

    function setDuration(uint256 _duration) external onlyOwnerOrAdmin {
        sessionDuration = _duration;
    }

    function setCount(uint256 _count) external onlyOwnerOrAdmin {
        sessionCount = _count;
    }

    function setTechnicalRotationPeriod(uint256 _rotationPeriod) external onlyOwnerOrAdmin {
        technicalRotationPeriod = _rotationPeriod;
    }

    function setResearchRotationPeriod(uint256 _rotationPeriod) external onlyOwnerOrAdmin {
        researchRotationPeriod = _rotationPeriod;
    }

    function approveMultiSignAggre(uint256 _approvalIndex) external onlySessionKey {
        multiSignAggreApprovals[msg.sender][_approvalIndex] = true;
    }

    function endSession(address _sessionKey) external onlyOwnerOrAdmin {
        require(sessionKeys[_sessionKey], "Invalid session key address");
        sessionExpiry[_sessionKey] = 0;
        emit SessionEnded(_sessionKey);
    }
}
123456788940 commented 1 year ago

Foundation Committee v1 Smart Contract

This document provides an explanation of the "Foundation Committee v1" smart contract, which is designed to manage committee rotations and governance-related activities within a decentralized organization. The contract is written in Solidity and follows the ERC-20 standard.

Overview

The "Foundation Committee v1" contract is intended to facilitate the governance and decision-making processes of a decentralized organization. It allows the establishment of two types of committees: Technical and Research. Committee members are rotated based on session durations, and session keys are granted to authorized users who have the privilege to propose changes, rotate committee members, and approve multi-signature transactions.

Key Components

  1. CommitteeType: An enumeration representing the types of committees, which include "Technical" and "Research."

  2. CommitteeMember: A struct containing the rotation end timestamp for committee members.

  3. sessionDuration: The duration of a committee session in seconds.

  4. sessionCount: The number of sessions within a rotation period.

  5. committees: A mapping that associates committee types with committee members and their rotation end timestamps.

  6. sessionKeys: A mapping indicating addresses that are granted session keys for committee-related activities.

  7. sessionExpiry: A mapping to track the expiration timestamps of session keys.

  8. multiSignAggreApprovals: A mapping to track multi-signature approvals by session key holders.

Modifiers

Functions

Events

Usage

The "Foundation Committee v1" smart contract allows authorized session key holders to manage committee rotations, propose changes, and approve multi-signature transactions. The contract can be deployed on a blockchain network, and session keys can be granted to users who need to participate in governance activities.

Please note that this is a high-level overview of the contract. In practice, additional considerations such as security audits, testing, and integration with other governance mechanisms may be necessary.

Disclaimer: This document and the provided code are for educational purposes only. It is essential to thoroughly test and audit the smart contract before deploying it on a production network.

WeuFoundDev commented 1 year ago

1.change the construct to foundation committee and members to technical and research .

  1. Session duration will be in 4 hrs which will be acquainted into - 1 timechain = ?? sesssions ,, check in docs.
  2. for V1 the quorum is 100 percent otherwise , pseudo module will be implemented after 1 timechain passes . SO, he can only sign the transaction after 1 session of that period @vinaykumar0103