From 97c8fde2232f1b318c345b10103f001ba2ee7192 Mon Sep 17 00:00:00 2001 From: ismellike Date: Sun, 22 Sep 2024 02:49:58 -0500 Subject: [PATCH] Do not auto-vote if user has no voting power --- contracts/arena-core/src/execute.rs | 23 +++++++++++++++++++---- scripts/src/tests/arena_wager_module.rs | 16 ++++++++++++++++ scripts/state.json | 18 +++++++++++------- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/contracts/arena-core/src/execute.rs b/contracts/arena-core/src/execute.rs index f2226b8..943e9e9 100644 --- a/contracts/arena-core/src/execute.rs +++ b/contracts/arena-core/src/execute.rs @@ -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::< diff --git a/scripts/src/tests/arena_wager_module.rs b/scripts/src/tests/arena_wager_module.rs index 9f528c8..bfecda3 100644 --- a/scripts/src/tests/arena_wager_module.rs +++ b/scripts/src/tests/arena_wager_module.rs @@ -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!( diff --git a/scripts/state.json b/scripts/state.json index efd7656..ad45870 100644 --- a/scripts/state.json +++ b/scripts/state.json @@ -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,