Rounds
To facilitate pairwise voting & funding distribution on Stellar
Rounds contract, is designed to facilitate pairwise voting and funding distribution on the Stellar blockchain. This contract enables users to create funding rounds, manage applications, conduct voting, and distribute funds based on community preferences.
Storage Structure
The contract uses a structured storage approach defined by the ContractKey
enum, which organizes various keys for managing the contract's state:
ContractKey Enum: Defines various keys for storing essential data:
ProtocolFeeRecipient: Address for receiving protocol fees.
ProtocolFee: The fee percentage charged for transactions.
FactoryOwner: Owner of the contract.
NextRoundId: Incremental integer to determine the next round ID.
NextPayoutId: Incremental integer for payout identification.
NextDepositId: Incremental integer for deposit identification.
ProjectPayoutIds: Stores payout IDs associated with projects.
TokenContract: Address of the XLM token contract.
ProjectContract: Reference to the project registry.
RoundInfo(u128): Stores detailed information about each round.
PayoutInfo: Key for storing payout details by ID.
DepositInfo: Key for storing deposit details by ID.
WhiteList(u128): Stores whitelisted voters for each round.
BlackList(u128): Stores blacklisted voters for each round.
ProjectApplicants(u128): Tracks project applicants for each round.
ApprovedProjects(u128): Stores IDs of approved projects.
Payouts(u128): Stores payout IDs for each round.
PayoutChallenges(u128): Tracks challenges related to payouts.
VotingState(u128): Stores the voting state of participants in each round.
Votes(u128): Records voting results for each round.
ProjectVotingCount(u128): Counts votes received by each project.
Admin(u128): Lists administrators for each round.
Deposit(u128): Tracks deposit IDs for rounds.
rust#[contracttype]
#[derive(Clone)]
pub enum ContractKey {
ProtocolFeeRecepient, // FEE_RECIPIENT
ProtocolFee, // FEE
FactoryOwner, // Owner for contract
NextRoundId, // Incremental integer to determine round_id
NextPayoutId, // Incremental integer to determine payout_id
NextDepositId, // Incremental integer to determine deposit_id
ProjectPayoutIds, // Storage key to store owned payout ids by project
TokenContract, // Storage key to store XLM token contract
ProjectContract, // Storage key to store project registry/details
RoundInfo(u128), // Storage key to store round details
PayoutInfo, // Key to store payout details by id
DepositInfo, // Key to store deposit details by id
WhiteList(u128), // Key to store whitelisted voters by round
BlackList(u128), // Key for blacklisted voters on round
ProjectApplicants(u128), // Store projects applicant/application for every round
ApprovedProjects(u128), // Store project ids that are already approved
Payouts(u128), // Store payout ids for round
PayoutChallenges(u128), // Store payout challenges
VotingState(u128), // Store voters' voting state in every round
Votes(u128), // Store voting results in every round
ProjectVotingCount(u128),// Store every voting count in project
Admin(u128), // Store admins for round
Deposit(u128), // Store deposit ids for round
}
Contract Error Codes
The contract defines several error codes to handle common issues that may arise during operation:
General Error Codes:
OwnerOrAdminOnly: Action restricted to the owner or admin only.
ContractNotInitialized: Indicates that the contract has not been initialized properly.
InsufficientBalance: Raised when there are insufficient funds for a transaction.
Round-Specific Error Codes:
VotingStartGreaterThanVotingEnd: Voting start time must be before end time.
ApplicationStartGreaterThanApplicationEnd: Application start time must be before end time.
Voting Error Codes:
VotingPeriodNotStarted: Voting has not yet begun.
AlreadyVoted: User has already cast their vote.
Application Error Codes:
ApplicationPeriodNotStarted: The application period has not started yet.
rust#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum Error {
OwnerOrAdminOnly = 5,
ContractNotInitialized = 26,
InsufficientBalance = 31,
IndexOutOfBound = 32,
SameOwner = 38,
}
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum RoundError {
VotingStartGreaterThanVotingEnd = 0,
ApplicationStartGreaterThanApplicationEnd = 1,
VotingStartLessThanApplicationEnd = 2,
AmountMustBeGreaterThanZero = 3,
ContactMustBeLessThanTen = 4,
}
Data Types
The contract includes various data structures to represent key elements within the GrantPicks ecosystem:
ApplicationStatus Enum: Represents the status of project applications (Pending, Approved, Rejected, Blacklisted).
Config Struct: Contains configuration settings such as owner address and protocol fee details.
rust#[contracttype]
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum ApplicationStatus {
Pending,
Approved,
Rejected,
Blacklisted,
}
RoundDetail Struct: Contains detailed information about each funding round.
id
: Unique identifier for the round.name
: Title of the round.description
: Description of what the round entails.voting_start_ms
: Start time of voting in milliseconds since epoch.
CreateRoundParams Struct: Parameters required to create a new funding round.
rust#[contracttype]
#[derive(Clone, Eq, PartialEq)]
pub struct RoundDetail {
pub id: u128,
pub name: String,
pub description: String,
pub contacts: Vec<Contact>,
pub voting_start_ms: u64,
pub voting_end_ms: u64,
}
For user faicing high level overview on rounds check out Stages of A Round
Last updated
Was this helpful?