1use cosmwasm_std::{Binary, Decimal, Uint128};
2use cw20::Cw20ReceiveMsg;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use std::fmt;
6
7use crate::common::OrderBy;
8
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
10pub struct InstantiateMsg {
11 pub voting_token: String,
12 pub quorum: Decimal,
13 pub threshold: Decimal,
14 pub voting_period: u64,
15 pub timelock_period: u64,
16 pub proposal_deposit: Uint128,
17 pub snapshot_period: u64,
18}
19
20#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
21#[serde(rename_all = "snake_case")]
22pub enum PollMsg {
23 CastVote {
24 poll_id: u64,
25 vote: VoteOption,
26 amount: Uint128,
27 },
28 Execute {
29 poll_id: u64,
30 },
31 ExecuteMsgs {
32 poll_id: u64,
33 },
34 Snapshot {
35 poll_id: u64,
36 },
37 End {
38 poll_id: u64,
39 },
40}
41
42#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
43#[serde(rename_all = "snake_case")]
44pub enum StakingMsg {
45 StakeInternal {
46 sender: String,
47 amount: Uint128,
48 },
49 Unstake {
50 amount: Option<Uint128>,
51 },
52 UnstakeInternal {
53 sender: String,
54 amount: Option<Uint128>,
55 },
56}
57
58#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
59#[serde(rename_all = "snake_case")]
60pub enum AirdropMsg {
61 Instantiate {
62 start: u64,
63 period: u64,
64 reward_token: String,
65 reward_amount: Uint128,
66 },
67 Allocate {
68 airdrop_id: u64,
69 recipient: String,
70 allocate_amount: Uint128,
71 },
72 Deallocate {
73 airdrop_id: u64,
74 recipient: String,
75 deallocate_amount: Uint128,
76 },
77 Update {
78 target: Option<String>,
79 },
80 Claim {
81 target: Option<String>,
82 },
83 ClaimInternal {
84 sender: String,
85 airdrop_id: u64,
86 },
87}
88
89#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
90#[serde(rename_all = "snake_case")]
91pub enum ExecuteMsg {
92 Receive(Cw20ReceiveMsg),
93 UpdateConfig {
94 owner: Option<String>,
95 quorum: Option<Decimal>,
96 threshold: Option<Decimal>,
97 voting_period: Option<u64>,
98 timelock_period: Option<u64>,
99 proposal_deposit: Option<Uint128>,
100 snapshot_period: Option<u64>,
101 },
102 Poll(PollMsg),
103 Staking(StakingMsg),
104 Airdrop(AirdropMsg),
105}
106
107#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
108#[serde(rename_all = "snake_case")]
109pub enum Cw20HookMsg {
110 Stake {},
113 CreatePoll {
115 title: String,
116 category: PollCategory,
117 description: String,
118 link: Option<String>,
119 execute_msgs: Option<Vec<PollExecuteMsg>>,
120 },
121}
122
123#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
124#[serde(rename_all = "snake_case")]
125pub struct PollExecuteMsg {
126 pub order: u64,
127 pub contract: String,
128 pub msg: Binary,
129}
130
131#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
132#[serde(rename_all = "snake_case")]
133pub enum QueryMsg {
134 ApiVersion {},
135 Config {},
136 State {},
137 Staker {
138 address: String,
139 },
140 Stakers {
141 start_after: Option<String>,
142 limit: Option<u32>,
143 order: Option<OrderBy>,
144 },
145 Airdrop {
146 airdrop_id: u64,
147 },
148 Airdrops {
149 start_after: Option<u64>,
150 limit: Option<u32>,
151 order_by: Option<OrderBy>,
152 },
153 Poll {
154 poll_id: u64,
155 },
156 Polls {
157 start_after: Option<u64>,
158 limit: Option<u32>,
159 order_by: Option<OrderBy>,
160 },
161 PollsWithCategoryFilter {
162 category_filter: Option<PollCategory>,
163 start_after: Option<u64>,
164 limit: Option<u32>,
165 order_by: Option<OrderBy>,
166 },
167 PollsWithStatusFilter {
168 status_filter: Option<PollStatus>,
169 start_after: Option<u64>,
170 limit: Option<u32>,
171 order_by: Option<OrderBy>,
172 },
173 Voters {
174 poll_id: u64,
175 start_after: Option<String>,
176 limit: Option<u32>,
177 order_by: Option<OrderBy>,
178 },
179}
180
181#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
182pub struct ClaimableAirdrop {
183 pub token: String,
184 pub amount: Uint128,
185}
186
187#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
188pub struct VoterInfo {
189 pub vote: VoteOption,
190 pub balance: Uint128,
191}
192
193#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
194#[serde(rename_all = "snake_case")]
195pub enum PollStatus {
196 InProgress,
197 Passed,
198 Rejected,
199 Executed,
200 Expired, Failed,
202}
203
204impl fmt::Display for PollStatus {
205 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
206 write!(f, "{:?}", self)
207 }
208}
209
210#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
211#[serde(rename_all = "snake_case")]
212pub enum PollCategory {
213 Core,
214 Gateway,
215 None,
216}
217
218impl fmt::Display for PollCategory {
219 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
220 write!(f, "{:?}", self)
221 }
222}
223
224#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
225#[serde(rename_all = "snake_case")]
226pub enum VoteOption {
227 Yes,
228 No,
229}
230
231impl fmt::Display for VoteOption {
232 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
233 if *self == VoteOption::Yes {
234 write!(f, "yes")
235 } else {
236 write!(f, "no")
237 }
238 }
239}
240
241#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
242#[serde(rename_all = "snake_case")]
243pub enum MigrateMsg {
244 State {},
245 General {},
246}