dao_proposal_single/
msg.rs

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