use cosmwasm_std::{Binary, Decimal, Uint128}; use cw20::Cw20ReceiveMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; use crate::common::OrderBy; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { pub voting_token: String, pub quorum: Decimal, pub threshold: Decimal, pub voting_period: u64, pub timelock_period: u64, pub proposal_deposit: Uint128, pub snapshot_period: u64, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum PollMsg { CastVote { poll_id: u64, vote: VoteOption, amount: Uint128, }, Execute { poll_id: u64, }, ExecuteMsgs { poll_id: u64, }, Snapshot { poll_id: u64, }, End { poll_id: u64, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum StakingMsg { StakeInternal { sender: String, amount: Uint128, }, Unstake { amount: Option, }, UnstakeInternal { sender: String, amount: Option, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum AirdropMsg { Instantiate { start: u64, period: u64, reward_token: String, reward_amount: Uint128, }, Allocate { airdrop_id: u64, recipient: String, allocate_amount: Uint128, }, Deallocate { airdrop_id: u64, recipient: String, deallocate_amount: Uint128, }, Update { target: Option, }, Claim { target: Option, }, ClaimInternal { sender: String, airdrop_id: u64, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { Receive(Cw20ReceiveMsg), UpdateConfig { owner: Option, quorum: Option, threshold: Option, voting_period: Option, timelock_period: Option, proposal_deposit: Option, snapshot_period: Option, }, Poll(PollMsg), Staking(StakingMsg), Airdrop(AirdropMsg), } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum Cw20HookMsg { /// StakeVotingTokens a user can stake their mirror token to receive rewards /// or do vote on polls Stake {}, /// CreatePoll need to receive deposit from a proposer CreatePoll { title: String, category: PollCategory, description: String, link: Option, execute_msgs: Option>, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub struct PollExecuteMsg { pub order: u64, pub contract: String, pub msg: Binary, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { ApiVersion {}, Config {}, State {}, Staker { address: String, }, Stakers { start_after: Option, limit: Option, order: Option, }, Airdrop { airdrop_id: u64, }, Airdrops { start_after: Option, limit: Option, order_by: Option, }, Poll { poll_id: u64, }, Polls { start_after: Option, limit: Option, order_by: Option, }, PollsWithCategoryFilter { category_filter: Option, start_after: Option, limit: Option, order_by: Option, }, PollsWithStatusFilter { status_filter: Option, start_after: Option, limit: Option, order_by: Option, }, Voters { poll_id: u64, start_after: Option, limit: Option, order_by: Option, }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct ClaimableAirdrop { pub token: String, pub amount: Uint128, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct VoterInfo { pub vote: VoteOption, pub balance: Uint128, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum PollStatus { InProgress, Passed, Rejected, Executed, Expired, // Deprecated Failed, } impl fmt::Display for PollStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self) } } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum PollCategory { Core, Gateway, None, } impl fmt::Display for PollCategory { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self) } } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum VoteOption { Yes, No, } impl fmt::Display for VoteOption { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if *self == VoteOption::Yes { write!(f, "yes") } else { write!(f, "no") } } } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum MigrateMsg { State {}, General {}, }