dao_proposal_multiple/
state.rs

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