Skip to content

Commit

Permalink
Progress on voting incentives
Browse files Browse the repository at this point in the history
Need to add tests
  • Loading branch information
ismellike committed Feb 7, 2024
1 parent 41b15fe commit ed344a4
Show file tree
Hide file tree
Showing 13 changed files with 1,143 additions and 186 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions contracts/external/dao-proposal-incentives/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ pub enum ContractError {

#[error("No reward per proposal given")]
NoRewardPerProposal {},

#[error("Proposal module is inactive")]
ProposalModuleIsInactive {},
}
14 changes: 11 additions & 3 deletions contracts/external/dao-proposal-incentives/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use cosmwasm_std::{Attribute, CosmosMsg, DepsMut, Env, MessageInfo, Response};
use cw20::Cw20ReceiveMsg;
use cw_ownable::{assert_owner, get_ownership};
use dao_hooks::proposal::ProposalHookMsg;
use dao_interface::{proposal::GenericProposalInfo, state::ProposalModule};
use dao_interface::{
proposal::GenericProposalInfo,
state::{ProposalModule, ProposalModuleStatus},
};
use dao_voting::status::Status;

use crate::{msg::ProposalIncentivesUnchecked, state::PROPOSAL_INCENTIVES, ContractError};
Expand All @@ -21,15 +24,19 @@ pub fn proposal_hook(

if let Some(owner) = ownership.owner {
// Validate the message is coming from a proposal module of the owner (DAO)
deps.querier.query_wasm_smart::<ProposalModule>(
let proposal_module = deps.querier.query_wasm_smart::<ProposalModule>(
owner,
&dao_interface::msg::QueryMsg::ProposalModule {
address: info.sender.to_string(),
},
)?;

// Check prop status and type of hook
// If the proposal module is disabled, then return error
if proposal_module.status == ProposalModuleStatus::Disabled {
return Err(ContractError::ProposalModuleIsInactive {});
}

// Check prop status and type of hook
if let ProposalHookMsg::ProposalStatusChanged { id, new_status, .. } = msg {
// If prop status is success, add message to pay out rewards
// Otherwise, do nothing
Expand Down Expand Up @@ -104,6 +111,7 @@ pub fn receive_cw20(
info: MessageInfo,
_cw20_receive_msg: Cw20ReceiveMsg,
) -> Result<Response, ContractError> {
// We do not check cw20, because the expected fund can change over time
Ok(Response::new()
.add_attribute("action", "receive_cw20")
.add_attribute("cw20", info.sender))
Expand Down
5 changes: 4 additions & 1 deletion contracts/external/dao-voting-incentives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name ="dao-voting-incentives"
authors = ["Jake Hartnell <[email protected]>"]
authors = ["Jake Hartnell <[email protected]>", "ismellike"]
description = "A contract that implements incentives for voting in a DAO."
edition = { workspace = true }
license = { workspace = true }
Expand All @@ -26,6 +26,9 @@ dao-interface = { workspace = true }
dao-voting = { workspace = true }
thiserror = { workspace = true }
cw-utils = { workspace = true }
cw-denom = { workspace = true }
cw-ownable = { workspace = true }
cw20 = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
Expand Down

This file was deleted.

Loading

0 comments on commit ed344a4

Please sign in to comment.