1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{Addr, Uint128};
3use dao_voting::veto::VetoConfig;
4
5use crate::ContractError;
6
7#[cw_serde]
8pub struct V1CodeIds {
9 pub proposal_single: u64,
10 pub cw4_voting: u64,
11 pub cw20_stake: u64,
12 pub cw20_staked_balances_voting: u64,
13}
14
15impl V1CodeIds {
16 pub fn to(self) -> dao_interface::migrate_msg::V1CodeIds {
17 dao_interface::migrate_msg::V1CodeIds {
18 proposal_single: self.proposal_single,
19 cw4_voting: self.cw4_voting,
20 cw20_stake: self.cw20_stake,
21 cw20_staked_balances_voting: self.cw20_staked_balances_voting,
22 }
23 }
24}
25
26#[cw_serde]
27pub struct V2CodeIds {
28 pub proposal_single: u64,
29 pub cw4_voting: u64,
30 pub cw20_stake: u64,
31 pub cw20_staked_balances_voting: u64,
32}
33
34impl V2CodeIds {
35 pub fn to(self) -> dao_interface::migrate_msg::V2CodeIds {
36 dao_interface::migrate_msg::V2CodeIds {
37 proposal_single: self.proposal_single,
38 cw4_voting: self.cw4_voting,
39 cw20_stake: self.cw20_stake,
40 cw20_staked_balances_voting: self.cw20_staked_balances_voting,
41 }
42 }
43}
44
45#[cw_serde]
47pub struct ProposalParams {
48 pub close_proposal_on_execution_failure: bool,
49 pub pre_propose_info: dao_voting::pre_propose::PreProposeInfo,
50 pub veto: Option<VetoConfig>,
51}
52
53#[cw_serde]
54pub struct MigrationParams {
55 pub migrate_stake_cw20_manager: Option<bool>,
61 pub proposal_params: Vec<(String, ProposalParams)>,
64}
65
66#[cw_serde]
68#[serde(untagged)]
69pub enum MigrationMsgs {
70 DaoProposalSingle(dao_proposal_single::msg::MigrateMsg),
71 DaoVotingCw4(dao_voting_cw4::msg::MigrateMsg),
72 Cw20Stake(cw20_stake::msg::MigrateMsg),
73 DaoVotingCw20Staked(dao_voting_cw20_staked::msg::MigrateMsg),
74}
75
76#[derive(Clone)]
78pub struct CodeIdPair {
79 pub v1_code_id: u64,
81 pub v2_code_id: u64,
83 pub migrate_msg: MigrationMsgs,
85}
86
87impl CodeIdPair {
88 pub fn new(v1_code_id: u64, v2_code_id: u64, migrate_msg: MigrationMsgs) -> CodeIdPair {
89 CodeIdPair {
90 v1_code_id,
91 v2_code_id,
92 migrate_msg,
93 }
94 }
95}
96
97#[cw_serde]
99#[derive(Default)]
100pub struct ModulesAddrs {
101 pub voting: Option<Addr>,
102 pub proposals: Vec<Addr>,
103}
104
105impl ModulesAddrs {
106 pub fn verify(&self) -> Result<(), ContractError> {
107 if self.voting.is_none() {
108 return Err(ContractError::VotingModuleNotFound);
109 }
110
111 if self.proposals.is_empty() {
112 return Err(ContractError::DaoProposalSingleNotFound);
113 }
114 Ok(())
115 }
116}
117
118pub struct SingleProposalData {
121 pub proposer: Addr,
122 pub start_height: u64,
123}
124
125#[cw_serde]
127pub struct TestState {
128 pub proposal_counts: Vec<u64>,
129 pub proposals: Vec<dao_proposal_single::proposal::SingleChoiceProposal>,
130 pub total_voting_power: Uint128,
131 pub single_voting_power: Uint128,
133}