dao_pre_propose_base/
msg.rs

1use cosmwasm_schema::{cw_serde, schemars::JsonSchema, QueryResponses};
2use cw_denom::UncheckedDenom;
3use dao_interface::proposal::InfoResponse;
4use dao_voting::{
5    deposit::{CheckedDepositInfo, UncheckedDepositInfo},
6    pre_propose::PreProposeSubmissionPolicy,
7    status::Status,
8};
9
10#[cw_serde]
11pub struct InstantiateMsg<InstantiateExt> {
12    /// Information about the deposit requirements for this
13    /// module. None if no deposit.
14    pub deposit_info: Option<UncheckedDepositInfo>,
15    /// The policy dictating who is allowed to submit proposals.
16    pub submission_policy: PreProposeSubmissionPolicy,
17    /// Extension for instantiation. The default implementation will
18    /// do nothing with this data.
19    pub extension: InstantiateExt,
20}
21
22#[cw_serde]
23pub enum ExecuteMsg<ProposalMessage, ExecuteExt> {
24    /// Creates a new proposal in the pre-propose module. MSG will be
25    /// serialized and used as the proposal creation message.
26    Propose { msg: ProposalMessage },
27
28    /// Updates the configuration of this module. This will completely
29    /// override the existing configuration. This new configuration
30    /// will only apply to proposals created after the config is
31    /// updated. Only the DAO may execute this message.
32    UpdateConfig {
33        /// If None, will remove the deposit. Backwards compatible.
34        deposit_info: Option<UncheckedDepositInfo>,
35        /// If None, will leave the submission policy in the config as-is.
36        submission_policy: Option<PreProposeSubmissionPolicy>,
37    },
38
39    /// Perform more granular submission policy updates to allow for atomic
40    /// operations that don't override others.
41    UpdateSubmissionPolicy {
42        /// Optionally add to the denylist. Works for any submission policy.
43        denylist_add: Option<Vec<String>>,
44        /// Optionally remove from denylist. Works for any submission policy.
45        denylist_remove: Option<Vec<String>>,
46        /// If using specific policy, optionally update the `dao_members` flag.
47        set_dao_members: Option<bool>,
48        /// If using specific policy, optionally add to the allowlist.
49        allowlist_add: Option<Vec<String>>,
50        /// If using specific policy, optionally remove from the allowlist.
51        allowlist_remove: Option<Vec<String>>,
52    },
53
54    /// Withdraws funds inside of this contract to the message
55    /// sender. The contracts entire balance for the specifed DENOM is
56    /// withdrawn to the message sender. Only the DAO may call this
57    /// method.
58    ///
59    /// This is intended only as an escape hatch in the event of a
60    /// critical bug in this contract or it's proposal
61    /// module. Withdrawing funds will cause future attempts to return
62    /// proposal deposits to fail their transactions as the contract
63    /// will have insufficent balance to return them. In the case of
64    /// `cw-proposal-single` this transaction failure will cause the
65    /// module to remove the pre-propose module from its proposal hook
66    /// receivers.
67    ///
68    /// More likely than not, this should NEVER BE CALLED unless a bug
69    /// in this contract or the proposal module it is associated with
70    /// has caused it to stop receiving proposal hook messages, or if
71    /// a critical security vulnerability has been found that allows
72    /// an attacker to drain proposal deposits.
73    Withdraw {
74        /// The denom to withdraw funds for. If no denom is specified,
75        /// the denomination currently configured for proposal
76        /// deposits will be used.
77        ///
78        /// You may want to specify a denomination here if you are
79        /// withdrawing funds that were previously accepted for
80        /// proposal deposits but are not longer used due to an
81        /// `UpdateConfig` message being executed on the contract.
82        denom: Option<UncheckedDenom>,
83    },
84
85    /// Extension message. Contracts that extend this one should put
86    /// their custom execute logic here. The default implementation
87    /// will do nothing if this variant is executed.
88    Extension { msg: ExecuteExt },
89
90    /// Adds a proposal submitted hook. Fires when a new proposal is submitted
91    /// to the pre-propose contract. Only the DAO may call this method.
92    AddProposalSubmittedHook { address: String },
93
94    /// Removes a proposal submitted hook. Only the DAO may call this method.
95    RemoveProposalSubmittedHook { address: String },
96
97    /// Handles proposal hook fired by the associated proposal
98    /// module when a proposal is completed (ie executed or rejected).
99    /// By default, the base contract will return deposits
100    /// proposals, when they are closed, when proposals are executed, or,
101    /// if it is refunding failed.
102    ProposalCompletedHook {
103        proposal_id: u64,
104        new_status: Status,
105    },
106}
107
108#[cw_serde]
109#[derive(QueryResponses)]
110pub enum QueryMsg<QueryExt>
111where
112    QueryExt: JsonSchema,
113{
114    /// Gets the proposal module that this pre propose module is
115    /// associated with. Returns `Addr`.
116    #[returns(cosmwasm_std::Addr)]
117    ProposalModule {},
118    /// Gets the DAO (dao-dao-core) module this contract is associated
119    /// with. Returns `Addr`.
120    #[returns(cosmwasm_std::Addr)]
121    Dao {},
122    /// Returns contract version info.
123    #[returns(InfoResponse)]
124    Info {},
125    /// Gets the module's configuration.
126    #[returns(crate::state::Config)]
127    Config {},
128    /// Gets the deposit info for the proposal identified by
129    /// PROPOSAL_ID.
130    #[returns(DepositInfoResponse)]
131    DepositInfo { proposal_id: u64 },
132    /// Returns whether or not the address can submit proposals.
133    #[returns(bool)]
134    CanPropose { address: String },
135    /// Returns list of proposal submitted hooks.
136    #[returns(cw_hooks::HooksResponse)]
137    ProposalSubmittedHooks {},
138    /// Extension for queries. The default implementation will do
139    /// nothing if queried for will return `Binary::default()`.
140    #[returns(cosmwasm_std::Binary)]
141    QueryExtension { msg: QueryExt },
142}
143
144#[cw_serde]
145pub struct DepositInfoResponse {
146    /// The deposit that has been paid for the specified proposal.
147    pub deposit_info: Option<CheckedDepositInfo>,
148    /// The address that created the proposal.
149    pub proposer: cosmwasm_std::Addr,
150}
151
152#[cw_serde]
153pub enum MigrateMsg<MigrateExt>
154where
155    MigrateExt: JsonSchema,
156{
157    FromUnderV250 {
158        /// Optionally set a new submission policy with more granular controls.
159        /// If not set, the current policy will remain.
160        policy: Option<PreProposeSubmissionPolicy>,
161    },
162    Extension {
163        msg: MigrateExt,
164    },
165}