Skip to content

Commit

Permalink
Do not auto-vote if user has no voting power
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Sep 22, 2024
1 parent 6674cc3 commit 97c8fde
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
23 changes: 19 additions & 4 deletions contracts/arena-core/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,30 @@ pub fn propose(
distribution.into_checked(deps.as_ref())?;
}

// Check voting power to auto vote
let dao = PrePropose::default().dao.load(deps.storage)?;
let voting_power: dao_interface::voting::VotingPowerAtHeightResponse =
deps.querier.query_wasm_smart(
dao,
&dao_interface::voting::Query::VotingPowerAtHeight {
address: originator.to_string(),
height: None,
},
)?;

// Construct message
let msg =
ProposeMessages::Propose(SingleChoiceProposeMsg {
title: msg.title,
description: msg.description,
vote: Some(SingleChoiceAutoVote {
vote: Vote::Yes,
rationale: None,
}),
vote: if voting_power.power.is_zero() {
None
} else {
Some(SingleChoiceAutoVote {
vote: Vote::Yes,
rationale: None,
})
},
msgs: vec![CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_json_binary(&arena_interface::competition::msg::ExecuteBase::<
Expand Down
16 changes: 16 additions & 0 deletions scripts/src/tests/arena_wager_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,22 @@ fn test_jailed_wager_resolved_by_dao() -> anyhow::Result<()> {
&[],
)?;

// Ensure other person can propose a result
arena.arena_wager_module.call_as(&user1).jail_competition(
Uint128::one(),
"Jailed Wager".to_string(),
"This wager needs DAO resolution".to_string(),
None,
Some(Distribution {
member_percentages: vec![MemberPercentage {
addr: user1.to_string(),
percentage: Decimal::one(),
}],
remainder_addr: user1.to_string(),
}),
&[],
)?;

// Check that the wager is jailed
let wager = arena.arena_wager_module.competition(Uint128::one())?;
assert_eq!(
Expand Down
18 changes: 11 additions & 7 deletions scripts/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
"neutron": {
"neutron-1": {
"code_ids": {
"arena_competition_enrollment": 1560,
"arena_core": 1564,
"arena_escrow": 1555,
"arena_league_module": 1558,
"arena_tournament_module": 1559,
"arena_wager_module": 1557
"arena_competition_enrollment": 2038,
"arena_core": 2034,
"arena_escrow": 2033,
"arena_league_module": 2036,
"arena_payment_registry": 2040,
"arena_token_gateway": 2039,
"arena_tournament_module": 2037,
"arena_wager_module": 2035,
"cw_abc": 2042,
"dao_dao_core": 2041
},
"default": {}
},
"pion-1": {
"code_ids": {
"arena_competition_enrollment": 6403,
"arena_core": 6440,
"arena_core": 6828,
"arena_escrow": 6398,
"arena_league_module": 6760,
"arena_payment_registry": 6405,
Expand Down

0 comments on commit 97c8fde

Please sign in to comment.