Skip to content

Commit

Permalink
Nio Governance System (#258)
Browse files Browse the repository at this point in the history
* Add NioGovernor contract with OpenZeppelin governance extensions and custom quorum, voting, and proposal handling logic.

* Added NioGuardians ERC721 contract with minting and burning functionality, and unit tests for NioGovernor including proposal creation and voting.

* Refactored NioGovernor tests to include multiple NioGuardians, added constants for voting delay and period, and implemented helper functions for proposal creation, voting, and execution.

* Fix formatting issues and correct logic in NioGovernor.t.sol by adjusting voting delay usage and proposal voting mechanism.

* Add execution delay and governor role constants, update accessManager setup, and include proposal execution plan and queueing in NioGovernorTest.

* Remove unnecessary newline in NioGovernor.t.sol to improve code readability.

* Add NiosElection contract with election management, candidate declaration, voting, and result computation functionalities.

* Rename NiosElection to NioElection and add unit tests for NioElection contract.

* Refactor NioElection contract, update dependencies, and enhance test setup with new user creation method.

* Added BridgedKinto integration to NioElection contract and implemented clock functions in BridgedKinto.sol for timestamp-based voting.

* Refactor NioElection contract to introduce election phases, improve voting logic, and add new tests.

* Refactor NioElection contract to enhance error handling and improve test coverage with additional test cases and setup.

* Refactor NioElection contract and tests: rename candidate-related functions and events, add multiple users in BaseTest, and update unit tests for multi-user scenarios.

* Remove Ownable inheritance and disqualifyCandidate functionality from NioElection contract and related tests.

* Refactor NioElection contract to rename phases and entities, add nominee structure, update voting logic, and enhance tests.

* Refactor NioElection contract to support multiple elections, add electionId to events, and update tests accordingly.

* Refactored NioElection contract to simplify getCurrentPhase function and removed redundant view functions and related tests.

* Refactor voting logic to allow multiple votes per candidate/nominee and update tests accordingly.

* Add KYC check in vote functions and initialize winner loop in finalizeElection function.

* Added functions to retrieve detailed election information, candidates, nominees, votes, elected Nios, and voter participation in NioElection contract.

* Refactor NioElection.sol to use consistent parameter naming by removing underscores from electionId and related variables.

* Implement logic to mint and burn Nio NFTs for election winners based on the number of Nios to elect.

* Refactor KintoID.sol, NioElection.sol, NioGuardians.sol, and test files to improve access control, add virtual overrides, enhance logging, and update test setups.

* Refactor NioElection contract to use getCurrentElectionId and add public view functions for election details, candidates, nominees, and votes; remove console logs from tests.

* Refactor test functions in NioElection.t.sol to use pluralized helper function names and add election start step in testVoteForNominee.

* Refactor NioElection contract and tests: fix import quotes, add internal vote amounts, and organize test functions with comments.

* Fix return statements and improve test coverage in NioElection and BridgedKinto contracts.

* Add test for Nio election sorting and verification of NFT balances for elected and non-elected Nios.

* Refactor variable names from 'wallets' to 'users' and 'users' to 'signers' for clarity across multiple test files.

* Add setUp function in KintoIDTest to upgrade KintoID and undo the harness.

* Add comprehensive documentation and comments to NioElection.sol for better code clarity and maintainability.

* Refactor variable names in NioElection.sol for consistency and clarity.

* Add tests to ensure voting reverts when KYC is revoked for both candidates and nominees.

* Add assertions for election time, candidate and nominee lengths, and used votes in NioElection tests.

* Refactor `isElectedNio` function to be public and update unit tests to verify its behavior before and after election.

* Refactor `nonces` function parameter name in `BridgedKinto.sol` and add additional assertions in `BridgedKinto.t.sol` unit tests.

* Add unit tests for NioGuardians contract including minting, burning, ownership, voting power, and transfer restrictions.

* Added detailed documentation and comments to NioGuardians contract functions and errors for better code clarity and maintainability.

* Add detailed comments to NioGovernor.sol and new unit tests for proposalNeedsQueuing and cancelProposal in NioGovernor.t.sol.

* Remove InsufficientEligibleCandidates error and update election logic to handle fewer winners than required, add unit test for this scenario.

* Add duplicate candidate check in NioElection and prevent delegation in NioGuardians.

* Remove unused import and redundant constant, update event parameter names in NioElection.sol for clarity.

* Refactor candidate eligibility check to use isEligibleForElection and add corresponding unit tests.

* Add slither-disable-next-line comment to suppress weak-prng warning in NioElection.sol.

* Fix slither warning in NioElection.sol and add delegateBySig revert test in NioGuardians.t.sol.

* Add MAX_NOMINEES constant and MaxNomineesReached error to NioElection contract, and implement corresponding test case.

* Added upgradeability to NioElection contract with Initializable, UUPSUpgradeable, and OwnableUpgradeable.
  • Loading branch information
ylv-io authored Oct 22, 2024
1 parent 9d273c5 commit 90a6418
Show file tree
Hide file tree
Showing 18 changed files with 2,075 additions and 84 deletions.
8 changes: 4 additions & 4 deletions src/KintoID.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract KintoID is
uint256 public override lastMonitoredAt;

// Metadata for each minted token
mapping(address => IKintoID.Metadata) private _kycmetas;
mapping(address => IKintoID.Metadata) internal _kycmetas;

/// @dev We include a nonce in every hashed message, and increment the nonce as part of a
/// state-changing operation, so as to prevent replay attacks, i.e. the reuse of a signature.
Expand Down Expand Up @@ -351,7 +351,7 @@ contract KintoID is
* @param _days Days to be checked.
* @return true if the account was monitored in the last x days.
*/
function isSanctionsMonitored(uint32 _days) public view override returns (bool) {
function isSanctionsMonitored(uint32 _days) public view virtual override returns (bool) {
return block.timestamp - lastMonitoredAt < _days * (1 days);
}

Expand All @@ -360,7 +360,7 @@ contract KintoID is
* @param _account account to be checked.
* @return true if the account is sanctions safe.
*/
function isSanctionsSafe(address _account) public view override returns (bool) {
function isSanctionsSafe(address _account) public view virtual override returns (bool) {
return isSanctionsMonitored(7) && _kycmetas[_account].sanctionsCount == 0;
}

Expand All @@ -370,7 +370,7 @@ contract KintoID is
* @param _countryId country id to be checked.
* @return true if the account is sanctions safe in a given country.
*/
function isSanctionsSafeIn(address _account, uint16 _countryId) external view override returns (bool) {
function isSanctionsSafeIn(address _account, uint16 _countryId) external view virtual override returns (bool) {
return isSanctionsMonitored(7) && !_kycmetas[_account].sanctions.get(_countryId);
}

Expand Down
Loading

0 comments on commit 90a6418

Please sign in to comment.