Open WeuFoundDev opened 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);
}
}
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
CommitteeType
: An enumeration representing the types of committees, which include "Technical" and "Research."
CommitteeMember
: A struct containing the rotation end timestamp for committee members.
sessionDuration
: The duration of a committee session in seconds.
sessionCount
: The number of sessions within a rotation period.
committees
: A mapping that associates committee types with committee members and their rotation end timestamps.
sessionKeys
: A mapping indicating addresses that are granted session keys for committee-related activities.
sessionExpiry
: A mapping to track the expiration timestamps of session keys.
multiSignAggreApprovals
: A mapping to track multi-signature approvals by session key holders.
Modifiers
onlySessionKey()
: A modifier that restricts functions to only be callable by addresses with valid session keys.
onlyOwnerOrAdmin()
: A modifier that allows only the contract owner or authorized session key holders to execute specific functions.
Functions
addSessionKey(address _sessionKey)
: Adds a session key for a specified address, extending its session expiry time.
rotateCommittee(CommitteeType _committeeType, address _newMember)
: Rotates committee members within a specified committee type.
addTechnicalCommitteeMember(address _memberAddress)
: Adds a new member to the Technical committee.
addResearchCommitteeMember(address _memberAddress)
: Adds a new member to the Research committee.
proposeChange(string memory _proposalDetails)
: Allows a session key holder to propose changes.
setDuration(uint256 _duration)
: Sets the duration of a committee session.
setCount(uint256 _count)
: Sets the number of sessions within a rotation period.
approveMultiSignAggre(uint256 _approvalIndex)
: Allows session key holders to approve multi-signature transactions.
endSession(address _sessionKey)
: Ends a session for a specific session key.
Events
SessionKeyAdded(address indexed sessionKey)
: Emitted when a new session key is added.
CommitteeMemberRotated(CommitteeType committeeType, address indexed oldMember, address indexed newMember)
: Emitted when a committee member is rotated.
ChangeProposed(address indexed proposer, string proposalDetails)
: Emitted when a change is proposed.
SessionEnded(address indexed sessionKey)
: Emitted when a session ends for a session key.
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.
1.change the construct to foundation committee and members to technical and research .
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