Giter Club home page Giter Club logo

voting-v1's People

Contributors

akorchyn avatar amityadav0 avatar kalloc avatar robert-zaremba avatar sczembor avatar vlodkomr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

voting-v1's Issues

voting mechanisms

How does the Transparency Commission start? Elected.

GWG serves the role of Election Committee

candidacy process via forum threads + polls

stake-weighted voting for constitution

  • quorum: 5%

stake-weighted ranking for elections

  • top 5 win

Fix the integration tests setup

Context

Traditionally, the NEAR core / examples smart contract put integration tests in a totally separate crate. For example the NFT reference implementation has integration tests outside of the NFT crate and outside of the main workspace (the integration-tests are not linked to the root workspace cargo file). Similarly the workspace-rs example doesn't put integration tests in a tests subdirectory of the contract crate.

This is not what a Rustacean would expect. Rust integration tests, per documentation are placed in /tests directory (sibling to the /src directory).

We tried to follow the Rust structure by moving the tests to the tests directory with a workspace setup, but unfortunately this doesn't work.

cd elections
cargo test

# wait 5min
# you will see error that crate "elections" is not found
error[E0433]: failed to resolve: use of undeclared crate or module elections
 --> elections/tests/iah.rs:7:5
  |
7 | use elections::proposal::{HouseType, TokenMetadata, SECOND, VOTE_COST};
  |     ^^^^^^^^^ use of undeclared crate or module elections

Moreover, any change in the file will cause long run of the tests, due to recompilation of the workspace.

Objectives

  1. find out why /elections/tests integration tests don't compile (what's wrong with the setup).
  2. Fix the setup with keeping integration tests in /elections/tests (rather than moving them to a separate workspace directory).
  3. Make sure the setup is efficient: edit in the file won't cause long wait of tests to compile.

Implement a users voting summary

Objective

Enhance the existing smart-contract to include a new view method that returns detailed voting participation information of all users.
This includes their voting choices (Approve, Reject, Abstain) across all proposals and the number of proposals they have created.

Existing Structure Summary

The current smart-contract includes structures for recording individual votes and proposals. However, it lacks a consolidated view of voting participation by each user.

Implementation Steps

1. Define New Structure CollectedResults

  • This structure will aggregate voting results for each user.
  • Fields:
    • approves: u16 - Total number of approvals.
    • rejects: u16 - Total number of rejections.
    • abstains: u16 - Total number of abstentions.
    • created: u16 - Number of proposals created by the user.

2. Add New Data Storage user_collected_results

  • Type: UnorderedMap<AccountId, CollectedResults>.
  • Purpose: Store the aggregated voting results for each user with ability to return the data in a single view method.

3. Develop a Method to Populate user_collected_results from Existing Data

  • Iterate over existing proposals.
  • For each proposal, update CollectedResults for each voter and the proposer.
  • Ensure data consistency and integrity during the aggregation process.

4. Modify Voting Mechanism to Update user_collected_results on Each Vote

  • When a vote is cast, update the corresponding user's CollectedResults in user_collected_results.
  • When a new proposal is created, increment the proposals_created count for the proposer in user_collected_results.

5. Create a View Method get_voting_participation

  • Returns: A list of all users along with their aggregated voting results.
  • Functionality: Provides a complete list of users along with their voting records and proposal counts.

Considerations

  • Performance: Ensure that the updates to user_collected_results are efficient, especially for large number of proposals and users.
  • Data Migration: Consider the need for data migration for existing proposals to populate user_collected_results.
  • Security: Review and test for potential security vulnerabilities, especially in the data aggregation logic.

Documentation

  • Update the contract documentation to reflect the new features and changes.

Smart-Contracts to Update

The following deployed smart-contracts will be updated with the new features:

  • congress-hom-v1.ndc-gwg.near
  • congress-tc-v1.ndc-gwg.near
  • congress-coa-v1.ndc-gwg.near

The current project repository is available at NEAR NDC Voting V1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.