Skip to content

Commit

Permalink
Start v2 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 19, 2023
1 parent a438be5 commit 5974fc9
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 80 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ stake-cw20-v03 = { package = "stake-cw20", version = "0.2.6" }
# v2 dependencies. used for state migrations
cw-utils-v2 = { package = "cw-utils", version = "0.16" }
dao-dao-core-v2 = { package = "dao-dao-core", version = "2.2.0" }
dao-interface-v2 = { package = "dao-interface", version = "2.2.0" }
dao-proposal-single-v2 = { package = "dao-proposal-single", version = "2.2.0" }
voting-v2 = { package = "dao-voting", version = "2.2.0" }

Expand Down
1 change: 1 addition & 0 deletions ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fn main() -> Result<()> {
},
},
close_proposal_on_execution_failure: false,
timelock: None,
})?,
admin: Some(Admin::CoreModule {}),
label: "DAO DAO Proposal Module".to_string(),
Expand Down
18 changes: 10 additions & 8 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn create_dao(
label: "DAO DAO Pre-Propose Module".to_string(),
},
},
timelock: None,
})?,
admin: Some(Admin::CoreModule {}),
label: "DAO DAO Proposal Module".to_string(),
Expand Down Expand Up @@ -118,15 +119,16 @@ pub fn create_dao(
.unwrap();

let ProposalCreationPolicy::Module { addr: pre_propose } = chain
.orc
.query(
"dao_proposal_single",
&dao_proposal_single::msg::QueryMsg::ProposalCreationPolicy {}
).unwrap()
.data()
.unwrap()
.orc
.query(
"dao_proposal_single",
&dao_proposal_single::msg::QueryMsg::ProposalCreationPolicy {},
)
.unwrap()
.data()
.unwrap()
else {
panic!("expected pre-propose module")
panic!("expected pre-propose module")
};
chain
.orc
Expand Down
9 changes: 8 additions & 1 deletion contracts/external/dao-migrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cw20-stake = { workspace = true, features = ["library"] }
dao-voting-cw20-staked = { workspace = true, features = ["library"] }
cw20-base = { workspace = true, features = ["library"] }

# v1 migration
cw-utils-v1 = { workspace = true }
voting-v1 = { workspace = true }
cw-core-v1 = { workspace = true, features = ["library"] }
Expand All @@ -43,7 +44,13 @@ cw20-stake-v1 = { workspace = true, features = ["library"] }
cw-core-interface-v1 = { package = "cw-core-interface", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cw20-v1 = { version = "0.13", package = "cw20" }
cw4-v1 = { version = "0.13", package = "cw4" }
cw4-v1 = { version = "0.13", package = "cw4" }

# v2 migration
dao-dao-core-v2 = { workspace = true }
cw-utils-v2 = { workspace = true }
dao-proposal-single-v2 = { workspace = true, features = ["library"] }
voting-v2 = { workspace = true}

[dev-dependencies]
cosmwasm-schema = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/dao-migrator/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn execute_migration_v1_v2(
v1_code_ids.proposal_single,
v2_code_ids.proposal_single,
MigrationMsgs::DaoProposalSingle(
dao_proposal_single::msg::MigrateMsg::FromV1 {
dao_proposal_single_v2::msg::MigrateMsg::FromV1 {
close_proposal_on_execution_failure: proposal_params
.close_proposal_on_execution_failure,
pre_propose_info: proposal_params.pre_propose_info,
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/dao-migrator/src/testing/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn execute_migration(
ProposalParams {
close_proposal_on_execution_failure: true,
pre_propose_info:
dao_voting::pre_propose::PreProposeInfo::AnyoneMayPropose {},
voting_v2::pre_propose::PreProposeInfo::AnyoneMayPropose {},
},
)
})
Expand Down
12 changes: 6 additions & 6 deletions contracts/external/dao-migrator/src/testing/state_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use crate::utils::query_helpers::{
#[derive(PartialEq, Debug, Clone)]
pub struct TestState {
pub proposal_count: u64,
pub proposal: dao_proposal_single::proposal::SingleChoiceProposal,
pub proposal: dao_proposal_single_v2::proposal::SingleChoiceProposal,
pub total_power: Uint128,
pub single_power: Uint128,
}

pub fn query_proposal_v1(
app: &mut App,
proposal_addr: Addr,
) -> (u64, dao_proposal_single::proposal::SingleChoiceProposal) {
) -> (u64, dao_proposal_single_v2::proposal::SingleChoiceProposal) {
// proposal count
let proposal_count: u64 = app
.wrap()
Expand All @@ -41,7 +41,7 @@ pub fn query_proposal_v1(
.clone()
.proposal;

let proposal = dao_proposal_single::proposal::SingleChoiceProposal {
let proposal = dao_proposal_single_v2::proposal::SingleChoiceProposal {
title: proposal.title,
description: proposal.description,
proposer: proposal.proposer,
Expand All @@ -62,20 +62,20 @@ pub fn query_proposal_v1(
pub fn query_proposal_v2(
app: &mut App,
proposal_addr: Addr,
) -> (u64, dao_proposal_single::proposal::SingleChoiceProposal) {
) -> (u64, dao_proposal_single_v2::proposal::SingleChoiceProposal) {
// proposal count
let proposal_count: u64 = app
.wrap()
.query_wasm_smart(
proposal_addr.clone(),
&dao_proposal_single::msg::QueryMsg::ProposalCount {},
&dao_proposal_single_v2::msg::QueryMsg::ProposalCount {},
)
.unwrap();

// query proposal
let proposal = app
.wrap()
.query_wasm_smart::<dao_proposal_single::query::ProposalListResponse>(
.query_wasm_smart::<dao_proposal_single_v2::query::ProposalListResponse>(
proposal_addr,
&dao_proposal_single::msg::QueryMsg::ListProposals {
start_after: None,
Expand Down
4 changes: 2 additions & 2 deletions contracts/external/dao-migrator/src/testing/test_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ fn test_duplicate_proposal_params() {
module_addrs.proposals[0].to_string(),
ProposalParams {
close_proposal_on_execution_failure: true,
pre_propose_info: dao_voting::pre_propose::PreProposeInfo::AnyoneMayPropose {},
pre_propose_info: voting_v2::pre_propose::PreProposeInfo::AnyoneMayPropose {},
},
),
(
module_addrs.proposals[0].to_string(),
ProposalParams {
close_proposal_on_execution_failure: true,
pre_propose_info: dao_voting::pre_propose::PreProposeInfo::AnyoneMayPropose {},
pre_propose_info: voting_v2::pre_propose::PreProposeInfo::AnyoneMayPropose {},
},
),
];
Expand Down
6 changes: 3 additions & 3 deletions contracts/external/dao-migrator/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl V2CodeIds {
#[cw_serde]
pub struct ProposalParams {
pub close_proposal_on_execution_failure: bool,
pub pre_propose_info: dao_voting::pre_propose::PreProposeInfo,
pub pre_propose_info: voting_v2::pre_propose::PreProposeInfo,
}

#[cw_serde]
Expand All @@ -65,7 +65,7 @@ pub struct MigrationParams {
#[cw_serde]
#[serde(untagged)]
pub enum MigrationMsgs {
DaoProposalSingle(dao_proposal_single::msg::MigrateMsg),
DaoProposalSingle(dao_proposal_single_v2::msg::MigrateMsg),
DaoVotingCw4(dao_voting_cw4::msg::MigrateMsg),
Cw20Stake(cw20_stake::msg::MigrateMsg),
DaoVotingCw20Staked(dao_voting_cw20_staked::msg::MigrateMsg),
Expand Down Expand Up @@ -124,7 +124,7 @@ pub struct SingleProposalData {
#[cw_serde]
pub struct TestState {
pub proposal_counts: Vec<u64>,
pub proposals: Vec<dao_proposal_single::proposal::SingleChoiceProposal>,
pub proposals: Vec<dao_proposal_single_v2::proposal::SingleChoiceProposal>,
pub total_voting_power: Uint128,
/// This is the voting power of the proposer of the sample proposal
pub single_voting_power: Uint128,
Expand Down
4 changes: 2 additions & 2 deletions contracts/external/dao-migrator/src/utils/query_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cw_utils::Expiration;
use dao_voting::{
use cw_utils_v2::Expiration;
use voting_v2::{
status::Status,
threshold::{PercentageThreshold, Threshold},
voting::Votes,
Expand Down
16 changes: 8 additions & 8 deletions contracts/external/dao-migrator/src/utils/state_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn query_proposal_count_v2(deps: Deps, proposals_addrs: Vec<Addr>) -> StdRes
.map(|proposal_addr| {
deps.querier.query_wasm_smart(
proposal_addr,
&dao_proposal_single::msg::QueryMsg::ProposalCount {},
&dao_proposal_single_v2::msg::QueryMsg::ProposalCount {},
)
})
.collect()
Expand All @@ -35,7 +35,7 @@ pub fn query_proposal_v1(
proposals_addrs: Vec<Addr>,
) -> Result<
(
Vec<dao_proposal_single::proposal::SingleChoiceProposal>,
Vec<dao_proposal_single_v2::proposal::SingleChoiceProposal>,
SingleProposalData,
),
ContractError,
Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn query_proposal_v1(
});
}

Ok(dao_proposal_single::proposal::SingleChoiceProposal {
Ok(dao_proposal_single_v2::proposal::SingleChoiceProposal {
title: proposal.title,
description: proposal.description,
proposer: proposal.proposer,
Expand All @@ -85,7 +85,7 @@ pub fn query_proposal_v1(
allow_revoting: proposal.allow_revoting,
})
})
.collect::<Result<Vec<dao_proposal_single::proposal::SingleChoiceProposal>, ContractError>>(
.collect::<Result<Vec<dao_proposal_single_v2::proposal::SingleChoiceProposal>, ContractError>>(
)?;

Ok((proposals, sample_proposal.unwrap()))
Expand All @@ -96,7 +96,7 @@ pub fn query_proposal_v2(
proposals_addrs: Vec<Addr>,
) -> Result<
(
Vec<dao_proposal_single::proposal::SingleChoiceProposal>,
Vec<dao_proposal_single_v2::proposal::SingleChoiceProposal>,
SingleProposalData,
),
ContractError,
Expand All @@ -106,10 +106,10 @@ pub fn query_proposal_v2(
let proposals = proposals_addrs
.into_iter()
.map(|proposal_addr| {
let proposals: dao_proposal_single::query::ProposalListResponse =
let proposals: dao_proposal_single_v2::query::ProposalListResponse =
deps.querier.query_wasm_smart(
proposal_addr.clone(),
&dao_proposal_single::msg::QueryMsg::ReverseProposals {
&dao_proposal_single_v2::msg::QueryMsg::ReverseProposals {
start_before: None,
limit: None,
},
Expand All @@ -132,7 +132,7 @@ pub fn query_proposal_v2(

Ok(proposal)
})
.collect::<Result<Vec<dao_proposal_single::proposal::SingleChoiceProposal>, ContractError>>(
.collect::<Result<Vec<dao_proposal_single_v2::proposal::SingleChoiceProposal>, ContractError>>(
)?;

Ok((proposals, sample_proposal.unwrap()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn get_default_proposal_module_instantiate(
},
},
close_proposal_on_execution_failure: false,
timelock: None,
}
}

Expand Down Expand Up @@ -1204,6 +1205,7 @@ fn test_instantiate_with_zero_native_deposit() {
},
},
close_proposal_on_execution_failure: false,
timelock: None,
}
};

Expand Down Expand Up @@ -1267,6 +1269,7 @@ fn test_instantiate_with_zero_cw20_deposit() {
},
},
close_proposal_on_execution_failure: false,
timelock: None,
}
};

Expand Down
Loading

0 comments on commit 5974fc9

Please sign in to comment.