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

Add active threshold functionality to CW4 voting module, closes #781 #819

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fn setup_default_test(
amount: Uint128::new(8),
},
]),
None,
);
let proposal_modules: Vec<ProposalModule> = app
.wrap()
Expand Down Expand Up @@ -1385,6 +1386,7 @@ fn test_instantiate_with_zero_native_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down Expand Up @@ -1450,6 +1452,7 @@ fn test_instantiate_with_zero_cw20_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/pre-propose/dao-pre-propose-approver/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ fn setup_default_test(
amount: Uint128::new(8),
},
]),
None,
);
let proposal_modules: Vec<ProposalModule> = app
.wrap()
Expand Down Expand Up @@ -255,6 +256,7 @@ fn setup_default_test(
amount: Uint128::new(8),
},
]),
None,
);
let proposal_modules: Vec<ProposalModule> = app
.wrap()
Expand Down
3 changes: 3 additions & 0 deletions contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ fn setup_default_test(
amount: Uint128::new(8),
},
]),
None,
);
let proposal_modules: Vec<ProposalModule> = app
.wrap()
Expand Down Expand Up @@ -1088,6 +1089,7 @@ fn test_instantiate_with_zero_native_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down Expand Up @@ -1151,6 +1153,7 @@ fn test_instantiate_with_zero_cw20_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down
3 changes: 3 additions & 0 deletions contracts/pre-propose/dao-pre-propose-single/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fn setup_default_test(
amount: Uint128::new(8),
},
]),
None,
);
let proposal_modules: Vec<ProposalModule> = app
.wrap()
Expand Down Expand Up @@ -1024,6 +1025,7 @@ fn test_instantiate_with_zero_native_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down Expand Up @@ -1087,6 +1089,7 @@ fn test_instantiate_with_zero_cw20_deposit() {
amount: Uint128::new(8),
},
]),
None,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dao_interface::{
use dao_testing::contracts::{
cw4_group_contract, dao_dao_contract, dao_voting_cw4_contract, proposal_condorcet_contract,
};
use dao_voting::threshold::PercentageThreshold;
use dao_voting::threshold::{ActiveThreshold, PercentageThreshold};
use dao_voting_cw4::msg::GroupContract;

use crate::{
Expand All @@ -30,6 +30,7 @@ pub(crate) struct SuiteBuilder {
pub instantiate: InstantiateMsg,
with_proposal: Option<u32>,
with_voters: Vec<(String, u64)>,
active_threshold: Option<ActiveThreshold>,
}

impl Default for SuiteBuilder {
Expand All @@ -43,6 +44,7 @@ impl Default for SuiteBuilder {
},
with_proposal: None,
with_voters: vec![("sender".to_string(), 10)],
active_threshold: None,
}
}
}
Expand Down Expand Up @@ -93,6 +95,7 @@ impl SuiteBuilder {
cw4_group_code_id: cw4_id,
initial_members,
},
active_threshold: self.active_threshold.clone(),
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ pub fn _instantiate_with_cw4_groups_governance(
app: &mut App,
proposal_module_instantiate: InstantiateMsg,
initial_weights: Option<Vec<Cw20Coin>>,
active_threshold: Option<dao_voting::threshold::ActiveThreshold>,
) -> Addr {
let proposal_module_code_id = app.store_code(proposal_multiple_contract());
let cw4_id = app.store_code(cw4_group_contract());
Expand Down Expand Up @@ -813,6 +814,7 @@ pub fn _instantiate_with_cw4_groups_governance(
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
},
active_threshold,
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct CommonTest {
fn setup_test(messages: Vec<CosmosMsg>) -> CommonTest {
let mut app = App::default();
let instantiate = get_default_token_dao_proposal_module_instantiate(&mut app);
let core_addr = instantiate_with_staked_balances_governance(&mut app, instantiate, None);
let core_addr = instantiate_with_staked_balances_governance(&mut app, instantiate, None, None);
let proposal_module = query_single_proposal_module(&app, &core_addr);
let gov_token = query_dao_token(&app, &core_addr);

Expand Down Expand Up @@ -199,6 +199,7 @@ pub fn test_executed_prop_state_remains_after_vote_swing() {
amount: Uint128::new(30),
},
]),
None,
);
let proposal_module = query_single_proposal_module(&app, &core_addr);
let gov_token = query_dao_token(&app, &core_addr);
Expand Down Expand Up @@ -298,6 +299,7 @@ pub fn test_passed_prop_state_remains_after_vote_swing() {
amount: Uint128::new(30),
},
]),
None,
);
let proposal_module = query_single_proposal_module(&app, &core_addr);
let gov_token = query_dao_token(&app, &core_addr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ fn do_test_votes<F>(
setup_governance: F,
) -> (App, Addr)
where
F: Fn(&mut App, InstantiateMsg, Option<Vec<Cw20Coin>>) -> Addr,
F: Fn(
&mut App,
InstantiateMsg,
Option<Vec<Cw20Coin>>,
Option<dao_voting::threshold::ActiveThreshold>,
) -> Addr,
{
let mut app = App::default();

Expand Down Expand Up @@ -144,7 +149,7 @@ where
pre_propose_info,
};

let core_addr = setup_governance(&mut app, instantiate, Some(initial_balances));
let core_addr = setup_governance(&mut app, instantiate, Some(initial_balances), None);

let governance_modules: Vec<ProposalModule> = app
.wrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub(crate) fn instantiate_with_staked_cw721_governance(
app: &mut App,
proposal_module_instantiate: InstantiateMsg,
initial_balances: Option<Vec<Cw20Coin>>,
active_threshold: Option<ActiveThreshold>,
) -> Addr {
let proposal_module_code_id = app.store_code(proposal_single_contract());

Expand Down Expand Up @@ -230,6 +231,7 @@ pub(crate) fn instantiate_with_native_staked_balances_governance(
app: &mut App,
proposal_module_instantiate: InstantiateMsg,
initial_balances: Option<Vec<Cw20Coin>>,
active_threshold: Option<dao_voting::threshold::ActiveThreshold>,
) -> Addr {
let proposal_module_code_id = app.store_code(proposal_single_contract());

Expand Down Expand Up @@ -341,6 +343,7 @@ pub(crate) fn instantiate_with_staked_balances_governance(
app: &mut App,
proposal_module_instantiate: InstantiateMsg,
initial_balances: Option<Vec<Cw20Coin>>,
active_threshold: Option<dao_voting::threshold::ActiveThreshold>,
) -> Addr {
let proposal_module_code_id = app.store_code(proposal_single_contract());

Expand Down Expand Up @@ -542,6 +545,7 @@ pub(crate) fn instantiate_with_cw4_groups_governance(
app: &mut App,
proposal_module_instantiate: InstantiateMsg,
initial_weights: Option<Vec<Cw20Coin>>,
active_threshold: Option<ActiveThreshold>,
) -> Addr {
let proposal_module_code_id = app.store_code(proposal_single_contract());
let cw4_id = app.store_code(cw4_group_contract());
Expand Down Expand Up @@ -590,6 +594,7 @@ pub(crate) fn instantiate_with_cw4_groups_governance(
cw4_group_code_id: cw4_id,
initial_members: initial_weights,
},
active_threshold,
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
Expand Down
Loading
Loading