Skip to content

tipo159/contribution_weighted_voting_cdk_rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

contribution_weighted_voting_cdk_rs

Overview

This canister implements a voting system where the weight of a voter's vote is determined by their contribution to the poll. This canister is implemented in Rust using Rust Canister Development Kit.

Methods

createPoll(payload: PollPayload): Result<Poll, string>
Anyone can create a new poll with the following information: Name of the poll, Voting options and Voting deadline.
getPollByName(name: string): Result<Poll, string>
Anyone can get information about a poll by its name. Only the owner of the poll can get detailed information.
getAllPolls(): Vec<Poll>
Anyone can get information about all polls. Only the owner of the polls can get detailed information.
registerVoterToPoll(pollname: string, votername: string): Result<Voter, string>
Anyone can register themselves as a voter on the poll. The initial value of the voter's contribution is 1.0.
changeVoterContribution(pollname: string, votername: string, contribution: float32): Result<Voter, string>
Only the owner of the poll can change the contribution of a voter. The owner's own contribution cannot be changed.
voteToPoll(pollname: string, votername: string, option: string): Result<VotingDetail, string>
Only registered voters can vote to the poll.
getVotingResult(name: string): Result<Vec<string>, string>
After the poll closes, the owner of the poll and the voters can get the voting results.
removeExpiredPolls(overTime: int32): Vec<Poll>
Remove polls that have expired the voting deadline.

Test

The tests are written in bats.

Remaining issues

  • Bats hangs on last test, use Ctrl-C to continue.

Contribution

Contributions are welcome. Please open an issue or submit a pull request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published