dao_interface/msg.rs
1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::{CosmosMsg, Empty};
3use cw_utils::Duration;
4
5use crate::state::Config;
6use crate::{migrate_msg::MigrateParams, query::SubDao, state::ModuleInstantiateInfo};
7
8/// Information about an item to be stored in the items list.
9#[cw_serde]
10pub struct InitialItem {
11 /// The name of the item.
12 pub key: String,
13 /// The value the item will have at instantiation time.
14 pub value: String,
15}
16
17#[cw_serde]
18pub struct InstantiateMsg {
19 /// Optional Admin with the ability to execute DAO messages
20 /// directly. Useful for building SubDAOs controlled by a parent
21 /// DAO. If no admin is specified the contract is set as its own
22 /// admin so that the admin may be updated later by governance.
23 pub admin: Option<String>,
24 /// The name of the core contract.
25 pub name: String,
26 /// A description of the core contract.
27 pub description: String,
28 /// An image URL to describe the core module contract.
29 pub image_url: Option<String>,
30
31 /// If true the contract will automatically add received cw20
32 /// tokens to its treasury.
33 pub automatically_add_cw20s: bool,
34 /// If true the contract will automatically add received cw721
35 /// tokens to its treasury.
36 pub automatically_add_cw721s: bool,
37
38 /// Instantiate information for the core contract's voting
39 /// power module.
40 pub voting_module_instantiate_info: ModuleInstantiateInfo,
41 /// Instantiate information for the core contract's proposal modules.
42 /// NOTE: the pre-propose-base package depends on it being the case
43 /// that the core module instantiates its proposal module.
44 pub proposal_modules_instantiate_info: Vec<ModuleInstantiateInfo>,
45
46 /// The items to instantiate this DAO with. Items are arbitrary
47 /// key-value pairs whose contents are controlled by governance.
48 ///
49 /// It is an error to provide two items with the same key.
50 pub initial_items: Option<Vec<InitialItem>>,
51 /// Implements the DAO Star standard: <https://daostar.one/EIP>
52 pub dao_uri: Option<String>,
53}
54
55#[cw_serde]
56pub enum ExecuteMsg {
57 /// Callable by the Admin, if one is configured.
58 /// Executes messages in order.
59 ExecuteAdminMsgs { msgs: Vec<CosmosMsg<Empty>> },
60 /// Callable by proposal modules. The DAO will execute the
61 /// messages in the hook in order.
62 ExecuteProposalHook { msgs: Vec<CosmosMsg<Empty>> },
63 /// Pauses the DAO for a set duration.
64 /// When paused the DAO is unable to execute proposals
65 Pause { duration: Duration },
66 /// Unpauses the DAO
67 Unpause {},
68 /// Executed when the contract receives a cw20 token. Depending on
69 /// the contract's configuration the contract will automatically
70 /// add the token to its treasury.
71 Receive(cw20::Cw20ReceiveMsg),
72 /// Executed when the contract receives a cw721 token. Depending
73 /// on the contract's configuration the contract will
74 /// automatically add the token to its treasury.
75 ReceiveNft(cw721::Cw721ReceiveMsg),
76 /// Removes an item from the governance contract's item map.
77 RemoveItem { key: String },
78 /// Adds an item to the governance contract's item map. If the
79 /// item already exists the existing value is overridden. If the
80 /// item does not exist a new item is added.
81 SetItem { key: String, value: String },
82 /// Callable by the admin of the contract. If ADMIN is None the
83 /// admin is set as the contract itself so that it may be updated
84 /// later by vote. If ADMIN is Some a new admin is proposed and
85 /// that new admin may become the admin by executing the
86 /// `AcceptAdminNomination` message.
87 ///
88 /// If there is already a pending admin nomination the
89 /// `WithdrawAdminNomination` message must be executed before a
90 /// new admin may be nominated.
91 NominateAdmin { admin: Option<String> },
92 /// Callable by a nominated admin. Admins are nominated via the
93 /// `NominateAdmin` message. Accepting a nomination will make the
94 /// nominated address the new admin.
95 ///
96 /// Requiring that the new admin accepts the nomination before
97 /// becoming the admin protects against a typo causing the admin
98 /// to change to an invalid address.
99 AcceptAdminNomination {},
100 /// Callable by the current admin. Withdraws the current admin
101 /// nomination.
102 WithdrawAdminNomination {},
103 /// Callable by the core contract. Replaces the current
104 /// governance contract config with the provided config.
105 UpdateConfig { config: Config },
106 /// Updates the list of cw20 tokens this contract has registered.
107 UpdateCw20List {
108 to_add: Vec<String>,
109 to_remove: Vec<String>,
110 },
111 /// Updates the list of cw721 tokens this contract has registered.
112 UpdateCw721List {
113 to_add: Vec<String>,
114 to_remove: Vec<String>,
115 },
116 /// Updates the governance contract's governance modules. Module
117 /// instantiate info in `to_add` is used to create new modules and
118 /// install them.
119 UpdateProposalModules {
120 /// NOTE: the pre-propose-base package depends on it being the
121 /// case that the core module instantiates its proposal module.
122 to_add: Vec<ModuleInstantiateInfo>,
123 to_disable: Vec<String>,
124 },
125 /// Callable by the core contract. Replaces the current
126 /// voting module with a new one instantiated by the governance
127 /// contract.
128 UpdateVotingModule { module: ModuleInstantiateInfo },
129 /// Update the core module to add/remove SubDAOs and their charters
130 UpdateSubDaos {
131 to_add: Vec<SubDao>,
132 to_remove: Vec<String>,
133 },
134}
135
136#[cw_serde]
137#[derive(QueryResponses)]
138pub enum QueryMsg {
139 /// Get's the DAO's admin. Returns `Addr`.
140 #[returns(cosmwasm_std::Addr)]
141 Admin {},
142 /// Get's the currently nominated admin (if any).
143 #[returns(crate::query::AdminNominationResponse)]
144 AdminNomination {},
145 /// Gets the contract's config.
146 #[returns(Config)]
147 Config {},
148 /// Gets the token balance for each cw20 registered with the
149 /// contract.
150 #[returns(crate::query::Cw20BalanceResponse)]
151 Cw20Balances {
152 start_after: Option<String>,
153 limit: Option<u32>,
154 },
155 /// Lists the addresses of the cw20 tokens in this contract's
156 /// treasury.
157 #[returns(Vec<cosmwasm_std::Addr>)]
158 Cw20TokenList {
159 start_after: Option<String>,
160 limit: Option<u32>,
161 },
162 /// Lists the addresses of the cw721 tokens in this contract's
163 /// treasury.
164 #[returns(Vec<cosmwasm_std::Addr>)]
165 Cw721TokenList {
166 start_after: Option<String>,
167 limit: Option<u32>,
168 },
169 /// Dumps all of the core contract's state in a single
170 /// query. Useful for frontends as performance for queries is more
171 /// limited by network times than compute times.
172 #[returns(crate::query::DumpStateResponse)]
173 DumpState {},
174 /// Gets the address associated with an item key.
175 #[returns(crate::query::GetItemResponse)]
176 GetItem { key: String },
177 /// Lists all of the items associted with the contract. For
178 /// example, given the items `{ "group": "foo", "subdao": "bar"}`
179 /// this query would return `[("group", "foo"), ("subdao",
180 /// "bar")]`.
181 #[returns(Vec<String>)]
182 ListItems {
183 start_after: Option<String>,
184 limit: Option<u32>,
185 },
186 /// Returns contract version info
187 #[returns(crate::voting::InfoResponse)]
188 Info {},
189 /// Gets all proposal modules associated with the
190 /// contract.
191 #[returns(Vec<crate::state::ProposalModule>)]
192 ProposalModules {
193 start_after: Option<String>,
194 limit: Option<u32>,
195 },
196 /// Gets the active proposal modules associated with the
197 /// contract.
198 #[returns(Vec<crate::state::ProposalModule>)]
199 ActiveProposalModules {
200 start_after: Option<String>,
201 limit: Option<u32>,
202 },
203 /// Gets the number of active and total proposal modules
204 /// registered with this module.
205 #[returns(crate::query::ProposalModuleCountResponse)]
206 ProposalModuleCount {},
207 /// Returns information about if the contract is currently paused.
208 #[returns(crate::query::PauseInfoResponse)]
209 PauseInfo {},
210 /// Gets the contract's voting module.
211 #[returns(cosmwasm_std::Addr)]
212 VotingModule {},
213 /// Returns all SubDAOs with their charters in a vec.
214 /// start_after is bound exclusive and asks for a string address.
215 #[returns(Vec<crate::query::SubDao>)]
216 ListSubDaos {
217 start_after: Option<String>,
218 limit: Option<u32>,
219 },
220 /// Implements the DAO Star standard: <https://daostar.one/EIP>
221 #[returns(crate::query::DaoURIResponse)]
222 DaoURI {},
223 /// Returns the voting power for an address at a given height.
224 #[returns(crate::voting::VotingPowerAtHeightResponse)]
225 VotingPowerAtHeight {
226 address: String,
227 height: Option<u64>,
228 },
229 /// Returns the total voting power at a given block height.
230 #[returns(crate::voting::TotalPowerAtHeightResponse)]
231 TotalPowerAtHeight { height: Option<u64> },
232}
233
234#[allow(clippy::large_enum_variant)]
235#[cw_serde]
236pub enum MigrateMsg {
237 FromV1 {
238 dao_uri: Option<String>,
239 params: Option<MigrateParams>,
240 },
241 FromCompatible {},
242}