Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a users voting summary #148

Open
VlodkoMr opened this issue Feb 26, 2024 · 0 comments
Open

Implement a users voting summary #148

VlodkoMr opened this issue Feb 26, 2024 · 0 comments

Comments

@VlodkoMr
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant