use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Uint128};
use dao_voting::veto::VetoConfig;
use crate::ContractError;
#[cw_serde]
pub struct V1CodeIds {
pub proposal_single: u64,
pub cw4_voting: u64,
pub cw20_stake: u64,
pub cw20_staked_balances_voting: u64,
}
impl V1CodeIds {
pub fn to(self) -> dao_interface::migrate_msg::V1CodeIds {
dao_interface::migrate_msg::V1CodeIds {
proposal_single: self.proposal_single,
cw4_voting: self.cw4_voting,
cw20_stake: self.cw20_stake,
cw20_staked_balances_voting: self.cw20_staked_balances_voting,
}
}
}
#[cw_serde]
pub struct V2CodeIds {
pub proposal_single: u64,
pub cw4_voting: u64,
pub cw20_stake: u64,
pub cw20_staked_balances_voting: u64,
}
impl V2CodeIds {
pub fn to(self) -> dao_interface::migrate_msg::V2CodeIds {
dao_interface::migrate_msg::V2CodeIds {
proposal_single: self.proposal_single,
cw4_voting: self.cw4_voting,
cw20_stake: self.cw20_stake,
cw20_staked_balances_voting: self.cw20_staked_balances_voting,
}
}
}
#[cw_serde]
pub struct ProposalParams {
pub close_proposal_on_execution_failure: bool,
pub pre_propose_info: dao_voting::pre_propose::PreProposeInfo,
pub veto: Option<VetoConfig>,
}
#[cw_serde]
pub struct MigrationParams {
pub migrate_stake_cw20_manager: Option<bool>,
pub proposal_params: Vec<(String, ProposalParams)>,
}
#[cw_serde]
#[serde(untagged)]
pub enum MigrationMsgs {
DaoProposalSingle(dao_proposal_single::msg::MigrateMsg),
DaoVotingCw4(dao_voting_cw4::msg::MigrateMsg),
Cw20Stake(cw20_stake::msg::MigrateMsg),
DaoVotingCw20Staked(dao_voting_cw20_staked::msg::MigrateMsg),
}
#[derive(Clone)]
pub struct CodeIdPair {
pub v1_code_id: u64,
pub v2_code_id: u64,
pub migrate_msg: MigrationMsgs,
}
impl CodeIdPair {
pub fn new(v1_code_id: u64, v2_code_id: u64, migrate_msg: MigrationMsgs) -> CodeIdPair {
CodeIdPair {
v1_code_id,
v2_code_id,
migrate_msg,
}
}
}
#[cw_serde]
#[derive(Default)]
pub struct ModulesAddrs {
pub voting: Option<Addr>,
pub proposals: Vec<Addr>,
}
impl ModulesAddrs {
pub fn verify(&self) -> Result<(), ContractError> {
if self.voting.is_none() {
return Err(ContractError::VotingModuleNotFound);
}
if self.proposals.is_empty() {
return Err(ContractError::DaoProposalSingleNotFound);
}
Ok(())
}
}
pub struct SingleProposalData {
pub proposer: Addr,
pub start_height: u64,
}
#[cw_serde]
pub struct TestState {
pub proposal_counts: Vec<u64>,
pub proposals: Vec<dao_proposal_single::proposal::SingleChoiceProposal>,
pub total_voting_power: Uint128,
pub single_voting_power: Uint128,
}