Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 3db53e2

Browse files
authored
Governance: Rename vote_threshold_percentage to community_vote_threshold (#3132)
1 parent e59a0dc commit 3db53e2

File tree

12 files changed

+90
-91
lines changed

12 files changed

+90
-91
lines changed

governance/chat/program/tests/program_test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use spl_governance::{
1010
deposit_governing_tokens,
1111
},
1212
state::{
13-
enums::{MintMaxVoteWeightSource, VoteThresholdPercentage},
13+
enums::{MintMaxVoteWeightSource, VoteThreshold},
1414
governance::{get_governance_address, GovernanceConfig},
1515
proposal::{get_proposal_address, VoteType},
1616
realm::get_realm_address,
@@ -183,7 +183,7 @@ impl GovernanceChatProgramTest {
183183
min_council_weight_to_create_proposal: 2,
184184
min_transaction_hold_up_time: 10,
185185
max_voting_time: 10,
186-
vote_threshold_percentage: VoteThresholdPercentage::YesVote(60),
186+
community_vote_threshold: VoteThreshold::YesVotePercentage(60),
187187
vote_tipping: spl_governance::state::enums::VoteTipping::Strict,
188188
proposal_cool_off_time: 0,
189189
};

governance/program/src/processor/process_create_proposal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn process_create_proposal(
148148

149149
max_vote_weight: None,
150150
max_voting_time: None,
151-
vote_threshold_percentage: None,
151+
vote_threshold: None,
152152

153153
reserved: [0; 64],
154154
};

governance/program/src/state/enums.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ impl Default for ProposalState {
140140
/// The type of the vote threshold percentage used to resolve a vote on a Proposal
141141
#[repr(C)]
142142
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
143-
pub enum VoteThresholdPercentage {
144-
/// Voting threshold of Yes votes in % required to tip the vote
143+
pub enum VoteThreshold {
144+
/// Voting threshold of Yes votes in % required to tip the vote (Approval Quorum)
145145
/// It's the percentage of tokens out of the entire pool of governance tokens eligible to vote
146146
/// Note: If the threshold is below or equal to 50% then an even split of votes ex: 50:50 or 40:40 is always resolved as Defeated
147147
/// In other words a '+1 vote' tie breaker is always required to have a successful vote
148-
YesVote(u8),
148+
YesVotePercentage(u8),
149149

150150
/// The minimum number of votes in % out of the entire pool of governance tokens eligible to vote
151151
/// which must be cast for the vote to be valid
152152
/// Once the quorum is achieved a simple majority (50%+1) of Yes votes is required for the vote to succeed
153153
/// Note: Quorum is not implemented in the current version
154-
Quorum(u8),
154+
QuorumPercentage(u8),
155155
}
156156

157157
/// The type of vote tipping to use on a Proposal.

governance/program/src/state/governance.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use borsh::maybestd::io::Write;
44
use crate::{
55
error::GovernanceError,
66
state::{
7-
enums::{GovernanceAccountType, VoteThresholdPercentage, VoteTipping},
7+
enums::{GovernanceAccountType, VoteThreshold, VoteTipping},
88
legacy::{is_governance_v1_account_type, GovernanceV1},
99
realm::assert_is_valid_realm,
1010
},
@@ -23,9 +23,9 @@ use spl_governance_tools::{
2323
#[repr(C)]
2424
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
2525
pub struct GovernanceConfig {
26-
/// The type of the vote threshold used for voting
26+
/// The type of the vote threshold used for community vote
2727
/// Note: In the current version only YesVote threshold is supported
28-
pub vote_threshold_percentage: VoteThresholdPercentage,
28+
pub community_vote_threshold: VoteThreshold,
2929

3030
/// Minimum community weight a governance token owner must possess to be able to create a proposal
3131
pub min_community_weight_to_create_proposal: u64,
@@ -377,8 +377,8 @@ pub fn assert_valid_create_governance_args(
377377
pub fn assert_is_valid_governance_config(
378378
governance_config: &GovernanceConfig,
379379
) -> Result<(), ProgramError> {
380-
match governance_config.vote_threshold_percentage {
381-
VoteThresholdPercentage::YesVote(yes_vote_threshold_percentage) => {
380+
match governance_config.community_vote_threshold {
381+
VoteThreshold::YesVotePercentage(yes_vote_threshold_percentage) => {
382382
if !(1..=100).contains(&yes_vote_threshold_percentage) {
383383
return Err(GovernanceError::InvalidVoteThresholdPercentage.into());
384384
}

governance/program/src/state/legacy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::state::{
44
enums::{
55
GovernanceAccountType, InstructionExecutionFlags, ProposalState,
6-
TransactionExecutionStatus, VoteThresholdPercentage,
6+
TransactionExecutionStatus, VoteThreshold,
77
},
88
governance::GovernanceConfig,
99
proposal_transaction::InstructionData,
@@ -247,7 +247,7 @@ pub struct ProposalV1 {
247247
/// The vote threshold percentage at the time Proposal was decided
248248
/// It's used to show correct vote results for historical proposals in cases when the threshold
249249
/// was changed for governance config after vote was completed.
250-
pub vote_threshold_percentage: Option<VoteThresholdPercentage>,
250+
pub vote_threshold: Option<VoteThreshold>,
251251

252252
/// Proposal name
253253
pub name: String,

0 commit comments

Comments
 (0)