1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
use crate::proposal::MultipleChoiceProposal;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Uint128};
use cw_hooks::Hooks;
use cw_storage_plus::{Item, Map};
use cw_utils::Duration;
use dao_voting::{
multiple_choice::{MultipleChoiceVote, VotingStrategy},
pre_propose::ProposalCreationPolicy,
};
/// The proposal module's configuration.
#[cw_serde]
pub struct Config {
/// The threshold a proposal must reach to complete.
pub voting_strategy: VotingStrategy,
/// The minimum amount of time a proposal must be open before
/// passing. A proposal may fail before this amount of time has
/// elapsed, but it will not pass. This can be useful for
/// preventing governance attacks wherein an attacker aquires a
/// large number of tokens and forces a proposal through.
pub min_voting_period: Option<Duration>,
/// The default maximum amount of time a proposal may be voted on
/// before expiring.
pub max_voting_period: Duration,
/// If set to true only members may execute passed
/// proposals. Otherwise, any address may execute a passed
/// proposal.
pub only_members_execute: bool,
/// Allows changing votes before the proposal expires. If this is
/// enabled proposals will not be able to complete early as final
/// vote information is not known until the time of proposal
/// expiration.
pub allow_revoting: bool,
/// The address of the DAO that this governance module is
/// associated with.
pub dao: Addr,
/// If set to true proposals will be closed if their execution
/// fails. Otherwise, proposals will remain open after execution
/// failure. For example, with this enabled a proposal to send 5
/// tokens out of a DAO's treasury with 4 tokens would be closed when
/// it is executed. With this disabled, that same proposal would
/// remain open until the DAO's treasury was large enough for it to be
/// executed.
pub close_proposal_on_execution_failure: bool,
}
// Each ballot stores a chosen vote and corresponding voting power and rationale.
#[cw_serde]
pub struct Ballot {
/// The amount of voting power behind the vote.
pub power: Uint128,
/// The position.
pub vote: MultipleChoiceVote,
/// An optional rationale for why this vote was cast.
pub rationale: Option<String>,
}
/// The current top level config for the module.
pub const CONFIG: Item<Config> = Item::new("config");
pub const PROPOSAL_COUNT: Item<u64> = Item::new("proposal_count");
pub const PROPOSALS: Map<u64, MultipleChoiceProposal> = Map::new("proposals");
pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("ballots");
/// Consumers of proposal state change hooks.
pub const PROPOSAL_HOOKS: Hooks = Hooks::new("proposal_hooks");
/// Consumers of vote hooks.
pub const VOTE_HOOKS: Hooks = Hooks::new("vote_hooks");
/// The address of the pre-propose module associated with this
/// proposal module (if any).
pub const CREATION_POLICY: Item<ProposalCreationPolicy> = Item::new("creation_policy");