dao_proposal_multiple/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cw_utils::Duration;
3use dao_dao_macros::proposal_module_query;
4use dao_voting::{
5    multiple_choice::{MultipleChoiceVote, VotingStrategy},
6    pre_propose::PreProposeInfo,
7    proposal::MultipleChoiceProposeMsg,
8    veto::VetoConfig,
9};
10
11#[cw_serde]
12pub struct InstantiateMsg {
13    /// Voting params configuration
14    pub voting_strategy: VotingStrategy,
15    /// The minimum amount of time a proposal must be open before
16    /// passing. A proposal may fail before this amount of time has
17    /// elapsed, but it will not pass. This can be useful for
18    /// preventing governance attacks wherein an attacker aquires a
19    /// large number of tokens and forces a proposal through.
20    pub min_voting_period: Option<Duration>,
21    /// The amount of time a proposal can be voted on before expiring
22    pub max_voting_period: Duration,
23    /// If set to true only members may execute passed
24    /// proposals. Otherwise, any address may execute a passed
25    /// proposal.
26    pub only_members_execute: bool,
27    /// Allows changing votes before the proposal expires. If this is
28    /// enabled proposals will not be able to complete early as final
29    /// vote information is not known until the time of proposal
30    /// expiration.
31    pub allow_revoting: bool,
32    /// Information about what addresses may create proposals.
33    pub pre_propose_info: PreProposeInfo,
34    /// If set to true proposals will be closed if their execution
35    /// fails. Otherwise, proposals will remain open after execution
36    /// failure. For example, with this enabled a proposal to send 5
37    /// tokens out of a DAO's treasury with 4 tokens would be closed when
38    /// it is executed. With this disabled, that same proposal would
39    /// remain open until the DAO's treasury was large enough for it to be
40    /// executed.
41    pub close_proposal_on_execution_failure: bool,
42    /// Optional veto configuration for proposal execution.
43    /// If set, proposals can only be executed after the timelock
44    /// delay expiration.
45    /// During this period an oversight account (`veto.vetoer`) can
46    /// veto the proposal.
47    pub veto: Option<VetoConfig>,
48}
49
50#[cw_serde]
51pub enum ExecuteMsg {
52    /// Creates a proposal in the governance module.
53    Propose(MultipleChoiceProposeMsg),
54    /// Votes on a proposal. Voting power is determined by the DAO's
55    /// voting power module.
56    Vote {
57        /// The ID of the proposal to vote on.
58        proposal_id: u64,
59        /// The senders position on the proposal.
60        vote: MultipleChoiceVote,
61        /// An optional rationale for why this vote was cast. This can
62        /// be updated, set, or removed later by the address casting
63        /// the vote.
64        rationale: Option<String>,
65    },
66    /// Causes the messages associated with a passed proposal to be
67    /// executed by the DAO.
68    Execute {
69        /// The ID of the proposal to execute.
70        proposal_id: u64,
71    },
72    /// Callable only if veto is configured
73    Veto {
74        /// The ID of the proposal to veto.
75        proposal_id: u64,
76    },
77    /// Closes a proposal that has failed (either not passed or timed
78    /// out). If applicable this will cause the proposal deposit
79    /// associated wth said proposal to be returned.
80    Close {
81        /// The ID of the proposal to close.
82        proposal_id: u64,
83    },
84    /// Updates the governance module's config.
85    UpdateConfig {
86        /// The new proposal voting strategy. This will only apply
87        /// to proposals created after the config update.
88        voting_strategy: VotingStrategy,
89        /// The minimum amount of time a proposal must be open before
90        /// passing. A proposal may fail before this amount of time has
91        /// elapsed, but it will not pass. This can be useful for
92        /// preventing governance attacks wherein an attacker aquires a
93        /// large number of tokens and forces a proposal through.
94        min_voting_period: Option<Duration>,
95        /// The default maximum amount of time a proposal may be voted
96        /// on before expiring. This will only apply to proposals
97        /// created after the config update.
98        max_voting_period: Duration,
99        /// If set to true only members may execute passed
100        /// proposals. Otherwise, any address may execute a passed
101        /// proposal. Applies to all outstanding and future proposals.
102        only_members_execute: bool,
103        /// Allows changing votes before the proposal expires. If this is
104        /// enabled proposals will not be able to complete early as final
105        /// vote information is not known until the time of proposal
106        /// expiration.
107        allow_revoting: bool,
108        /// The address if tge DAO that this governance module is
109        /// associated with.
110        dao: String,
111        /// If set to true proposals will be closed if their execution
112        /// fails. Otherwise, proposals will remain open after execution
113        /// failure. For example, with this enabled a proposal to send 5
114        /// tokens out of a DAO's treasury with 4 tokens would be closed when
115        /// it is executed. With this disabled, that same proposal would
116        /// remain open until the DAO's treasury was large enough for it to be
117        /// executed.
118        close_proposal_on_execution_failure: bool,
119        /// Optional time delay on proposal execution, during which the
120        /// proposal may be vetoed.
121        veto: Option<VetoConfig>,
122    },
123    /// Updates the sender's rationale for their vote on the specified
124    /// proposal. Errors if no vote vote has been cast.
125    UpdateRationale {
126        proposal_id: u64,
127        rationale: Option<String>,
128    },
129    /// Update's the proposal creation policy used for this
130    /// module. Only the DAO may call this method.
131    UpdatePreProposeInfo {
132        info: PreProposeInfo,
133    },
134    AddProposalHook {
135        address: String,
136    },
137    RemoveProposalHook {
138        address: String,
139    },
140    AddVoteHook {
141        address: String,
142    },
143    RemoveVoteHook {
144        address: String,
145    },
146}
147
148#[proposal_module_query]
149#[cw_serde]
150#[derive(QueryResponses)]
151pub enum QueryMsg {
152    /// Gets the governance module's config.
153    #[returns(crate::state::Config)]
154    Config {},
155    /// Gets information about a proposal.
156    #[returns(crate::query::ProposalResponse)]
157    Proposal { proposal_id: u64 },
158    /// Lists all the proposals that have been cast in this module.
159    #[returns(crate::query::ProposalListResponse)]
160    ListProposals {
161        start_after: Option<u64>,
162        limit: Option<u64>,
163    },
164    /// Lists all of the proposals that have been cast in this module
165    /// in decending order of proposal ID.
166    #[returns(crate::query::ProposalListResponse)]
167    ReverseProposals {
168        start_before: Option<u64>,
169        limit: Option<u64>,
170    },
171    /// Returns a voters position on a proposal.
172    #[returns(crate::query::VoteResponse)]
173    GetVote { proposal_id: u64, voter: String },
174    /// Lists all of the votes that have been cast on a proposal.
175    #[returns(crate::query::VoteListResponse)]
176    ListVotes {
177        proposal_id: u64,
178        start_after: Option<String>,
179        limit: Option<u64>,
180    },
181    /// Returns the number of proposals that have been created in this module.
182    #[returns(::std::primitive::u64)]
183    ProposalCount {},
184    /// Gets the current proposal creation policy for this module.
185    #[returns(::dao_voting::pre_propose::ProposalCreationPolicy)]
186    ProposalCreationPolicy {},
187    /// Lists all of the consumers of proposal hooks for this module.
188    #[returns(::cw_hooks::HooksResponse)]
189    ProposalHooks {},
190    /// Lists all of the consumers of vote hooks for this module.
191    #[returns(::cw_hooks::HooksResponse)]
192    VoteHooks {},
193}
194
195#[cw_serde]
196pub struct VoteMsg {
197    pub proposal_id: u64,
198    pub vote: MultipleChoiceVote,
199}
200
201#[cw_serde]
202pub enum MigrateMsg {
203    FromV1 {
204        /// This field was not present in DAO DAO v1. To migrate, a
205        /// value must be specified.
206        ///
207        /// If set to true proposals will be closed if their execution
208        /// fails. Otherwise, proposals will remain open after execution
209        /// failure. For example, with this enabled a proposal to send 5
210        /// tokens out of a DAO's treasury with 4 tokens would be closed when
211        /// it is executed. With this disabled, that same proposal would
212        /// remain open until the DAO's treasury was large enough for it to be
213        /// executed.
214        close_proposal_on_execution_failure: bool,
215        /// This field was not present in DAO DAO v1. To migrate, a
216        /// value must be specified.
217        ///
218        /// This contains information about how a pre-propose module may be configured.
219        /// If set to "AnyoneMayPropose", there will be no pre-propose module and consequently,
220        /// no deposit or membership checks when submitting a proposal. The "ModuleMayPropose"
221        /// option allows for instantiating a prepropose module which will handle deposit verification and return logic.
222        pre_propose_info: PreProposeInfo,
223        /// This field was not present in DAO DAO v1. To migrate, a
224        /// value must be specified.
225        ///
226        /// optional configuration for veto feature
227        veto: Option<VetoConfig>,
228    },
229    FromCompatible {},
230}