-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Issue Description:
You are to implement the voting system! Here's where judges and stakers cast their votes for artists in any given audition. The judges vote is actually a plus for their evaluation of the artist performance which is based on different skill sets of the artist and their performance, and this has been implemented, ensure to check the current state of the contract. The beauty is in the simplicity - one function that automatically detects if you're a judge or staker and assigns the right voting weight. The Judges vote is to complement a staker's vote.
Note: also provide an implementation to assign more voting weight to a celebrity artist who is a judge, get more voting weight than the regular judge.
Judges get their assigned weights, which is a way super much more bigger weight compared to the stakers, stakers get fixed 0.5 weight. Every vote requires an IPFS hash containing the voter's commentary (validated off-chain before reaching the contract). Real-time scoring updates immediately with each vote.
This makes the voting system transparent, anyone can see current standings at any time. No surprises, no manipulation. we are to achieve transparency with this voting system
📌 Requirements
- Unified Voting Function: Single function handles both judge and staker votes
- Automatic Role Detection: Contract determines if caller is judge(or a celebrity artist who gets to act as a judge too) or eligible staker
- IPFS Commentary Integration: Every vote requires pre-validated IPFS hash for reasoning (the reason for a vote should be given)
- Real-Time Score Updates: Artist scores update immediately with each vote
- Prevent Double Voting: Each voter can only vote once per artist
- Vote Weight Assignment: Judges get assigned weights so also celebrity artist acting as a Judge, stakers get fixed 0.5 weight for example
- Voting Window Management: Time-based voting periods with clear start/end
- Vote Storage: Comprehensive vote data storage for transparency
- Integration with Staking: Verify staker eligibility through staking contract which will be provided from this issue [BUIDL Audition Platform] (SC): Build Fixed-Amount Staking Contract for Voter Eligibility #101
- Event Emission: Detailed events for all voting activities
🔍 Implementation Approach
Note: This is but an example;
struct Vote {
voter: ContractAddress,
artist_id: u256,
audition_id: u256,
weight: u256,
vote_type: VoteType, // Judge or Staker
ipfs_content_hash: felt252, // Pre-validated commentary
timestamp: u64
}
enum VoteType {
Judge,
Staker
}
// Unified voting function pseudo-code
fn cast_vote(
audition_id: u256,
artist_id: u256,
ipfs_content_hash: felt252 // Pre-validated off-chain
) {
//possible logic flow
let caller = get_caller_address();
1. Prevent double voting
assert(!self.has_voted.read((caller, artist_id)));
2. Verify voting is active
assert(self.is_voting_active.read(audition_id));
3. Auto-detect role (judge or staker)
let (vote_weight, vote_type) = if self.is_judge(caller) {
(self.get_judge_weight(caller), VoteType::Judge)
} else {
// Verify staker eligibility
assert(self.staking_contract.is_eligible_voter(caller, audition_id));
(self.staker_base_weight.read(), VoteType::Staker)
};
4. Record vote and update scores
5. Mark as voted
6. Emit voting event
}
considering the psudo code, it's just an example just provide an implementation which will work perfectly
🎯 Testing Requirements
- Provide integration test to test unified function with both judge and staker votes
- Test automatic role detection accuracy
- Test double voting prevention
- Test real-time score updates
- Test IPFS hash integration
- Test voting window enforcement
- Test integration with staking contract
- Test comprehensive event emission
- Ensure to test your entire logic implementation asserting everything works as it should
- Test all edge cases
🚀 Expected Outcome
Seamless voting experience with automatic role detection, real-time transparency, and comprehensive vote tracking.
Please reach out to me on telegram https://t.me/MusicStrk_CJ/1