Skip to content

Commit

Permalink
Reverted migrator changes and added veto to migration params.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Dec 2, 2023
1 parent ede9401 commit 3d8d5c1
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 503 deletions.
592 changes: 225 additions & 367 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,5 @@ cw20-stake-reward-distributor-v1 = { package = "stake-cw20-reward-distributor",
cw20-stake-v1 = { package = "cw20-stake", version = "0.2.6" }
cw20-staked-balance-voting-v1 = { package = "cw20-staked-balance-voting", version = "0.1.0" }
cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0" }
voting-v1 = { package = "dao-voting", version = "0.1.0" }
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" }
dao-pre-propose-single-v2 = { package = "dao-pre-propose-single", version = "2.2.0" }
voting-v2 = { package = "dao-voting", version = "2.2.0"}

voting-v1 = { package = "dao-voting", version = "0.1.0" }
12 changes: 3 additions & 9 deletions contracts/external/dao-migrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ cw2 = { workspace = true }
cw20 = { workspace = true }
dao-interface = { workspace = true }

dao-dao-core = { workspace = true, features = ["library"] }
dao-dao-core = { workspace = true, features = ["library"] }
dao-voting = { workspace = true }
dao-proposal-single = { workspace = true, features = ["library"] }
dao-voting-cw4 = { workspace = true, features = ["library"] }
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 @@ -44,13 +45,6 @@ cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0", git
cw20-v1 = { version = "0.13", package = "cw20" }
cw4-v1 = { version = "0.13", package = "cw4" }

# v2 migration
dao-dao-core-v2 = { workspace = true }
dao-interface-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 }
cw-multi-test = { workspace = true }
Expand Down
17 changes: 9 additions & 8 deletions contracts/external/dao-migrator/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cosmwasm_std::{
StdResult, SubMsg, WasmMsg,
};
use cw2::set_contract_version;
use dao_interface_v2::{
use dao_interface::{
query::SubDao,
state::{ModuleInstantiateCallback, ProposalModule},
};
Expand Down Expand Up @@ -111,10 +111,11 @@ fn execute_migration_v1_v2(
v1_code_ids.proposal_single,
v2_code_ids.proposal_single,
MigrationMsgs::DaoProposalSingle(
dao_proposal_single_v2::msg::MigrateMsg::FromV1 {
dao_proposal_single::msg::MigrateMsg::FromV1 {
close_proposal_on_execution_failure: proposal_params
.close_proposal_on_execution_failure,
pre_propose_info: proposal_params.pre_propose_info,
veto: proposal_params.veto,
},
),
),
Expand Down Expand Up @@ -147,7 +148,7 @@ fn execute_migration_v1_v2(
// --------------------
let voting_module: Addr = deps.querier.query_wasm_smart(
info.sender.clone(),
&dao_interface_v2::msg::QueryMsg::VotingModule {},
&dao_interface::msg::QueryMsg::VotingModule {},
)?;

let voting_code_id =
Expand Down Expand Up @@ -227,7 +228,7 @@ fn execute_migration_v1_v2(
// We take all the proposal modules of the DAO.
let proposal_modules: Vec<ProposalModule> = deps.querier.query_wasm_smart(
info.sender.clone(),
&dao_interface_v2::msg::QueryMsg::ProposalModules {
&dao_interface::msg::QueryMsg::ProposalModules {
start_after: None,
limit: None,
},
Expand Down Expand Up @@ -305,7 +306,7 @@ fn execute_migration_v1_v2(
msgs.push(
WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_json_binary(&dao_interface_v2::msg::ExecuteMsg::UpdateSubDaos {
msg: to_json_binary(&dao_interface::msg::ExecuteMsg::UpdateSubDaos {
to_add: sub_daos,
to_remove: vec![],
})?,
Expand All @@ -318,7 +319,7 @@ fn execute_migration_v1_v2(
let proposal_hook_msg = SubMsg::reply_on_success(
WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_json_binary(&dao_interface_v2::msg::ExecuteMsg::ExecuteProposalHook { msgs })?,
msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?,
funds: vec![],
},
V1_V2_REPLY_ID,
Expand All @@ -345,11 +346,11 @@ pub fn reply(deps: DepsMut, env: Env, reply: Reply) -> Result<Response, Contract
// and only then delete our module if everything worked out.
let remove_msg = WasmMsg::Execute {
contract_addr: core_addr.to_string(),
msg: to_json_binary(&dao_interface_v2::msg::ExecuteMsg::ExecuteProposalHook {
msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook {
msgs: vec![WasmMsg::Execute {
contract_addr: core_addr.to_string(),
msg: to_json_binary(
&dao_interface_v2::msg::ExecuteMsg::UpdateProposalModules {
&dao_interface::msg::ExecuteMsg::UpdateProposalModules {
to_add: vec![],
to_disable: vec![env.contract.address.to_string()],
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/external/dao-migrator/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use dao_interface_v2::query::SubDao;
use dao_interface::query::SubDao;

use crate::types::{MigrationParams, V1CodeIds, V2CodeIds};

Expand Down
12 changes: 6 additions & 6 deletions contracts/external/dao-migrator/src/testing/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use cosmwasm_std::{
Uint128, WasmMsg,
};
use cw_multi_test::{next_block, App, Contract, ContractWrapper, Executor};
use dao_interface::query::SubDao;
use dao_testing::contracts::{
cw20_base_contract, cw20_staked_balances_voting_contract, cw4_group_contract,
v1_dao_dao_contract, v1_proposal_single_contract, v2_dao_dao_contract,
v2_proposal_single_contract,
cw20_base_contract, cw20_staked_balances_voting_contract, cw4_group_contract, dao_dao_contract,
proposal_single_contract, v1_dao_dao_contract, v1_proposal_single_contract,
};

use crate::{
Expand All @@ -28,7 +28,7 @@ pub struct CodeIds {
}

pub struct ExecuteParams {
pub sub_daos: Option<Vec<dao_interface_v2::query::SubDao>>,
pub sub_daos: Option<Vec<SubDao>>,
pub migrate_cw20: Option<bool>,
}

Expand Down Expand Up @@ -70,8 +70,8 @@ pub fn get_v1_code_ids(app: &mut App) -> (CodeIds, V1CodeIds) {

pub fn get_v2_code_ids(app: &mut App) -> (CodeIds, V2CodeIds) {
let code_ids = CodeIds {
core: app.store_code(v2_dao_dao_contract()),
proposal_single: app.store_code(v2_proposal_single_contract()),
core: app.store_code(dao_dao_contract()),
proposal_single: app.store_code(proposal_single_contract()),
cw20_base: app.store_code(cw20_base_contract()),
cw20_stake: app.store_code(v2_cw20_stake_contract()),
cw20_voting: app.store_code(dao_voting_cw20_staked_contract()),
Expand Down
68 changes: 33 additions & 35 deletions contracts/external/dao-migrator/src/testing/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::BorrowMut;

use cosmwasm_std::{to_json_binary, Addr, WasmMsg};
use cw_multi_test::{next_block, App, AppResponse, Executor};
use dao_interface_v2::state::{Admin, ModuleInstantiateInfo};
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_testing::contracts::stake_cw20_v03_contract;

use crate::{
Expand Down Expand Up @@ -274,7 +274,8 @@ pub fn execute_migration(
ProposalParams {
close_proposal_on_execution_failure: true,
pre_propose_info:
voting_v2::pre_propose::PreProposeInfo::AnyoneMayPropose {},
dao_voting::pre_propose::PreProposeInfo::AnyoneMayPropose {},
veto: None,
},
)
})
Expand All @@ -291,7 +292,7 @@ pub fn execute_migration(
WasmMsg::Migrate {
contract_addr: module_addrs.core.to_string(),
new_code_id: new_code_ids.core,
msg: to_json_binary(&dao_interface_v2::msg::MigrateMsg::FromV1 {
msg: to_json_binary(&dao_interface::msg::MigrateMsg::FromV1 {
dao_uri: None,
params: None,
})
Expand All @@ -300,27 +301,25 @@ pub fn execute_migration(
.into(),
WasmMsg::Execute {
contract_addr: module_addrs.core.to_string(),
msg: to_json_binary(
&dao_interface_v2::msg::ExecuteMsg::UpdateProposalModules {
to_add: vec![ModuleInstantiateInfo {
code_id: migrator_code_id,
msg: to_json_binary(&crate::msg::InstantiateMsg {
sub_daos: params.sub_daos.unwrap(),
migration_params: MigrationParams {
migrate_stake_cw20_manager: params.migrate_cw20,
proposal_params,
},
v1_code_ids,
v2_code_ids,
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
funds: vec![],
label: "migrator".to_string(),
}],
to_disable: vec![],
},
)
msg: to_json_binary(&dao_interface::msg::ExecuteMsg::UpdateProposalModules {
to_add: vec![ModuleInstantiateInfo {
code_id: migrator_code_id,
msg: to_json_binary(&crate::msg::InstantiateMsg {
sub_daos: params.sub_daos.unwrap(),
migration_params: MigrationParams {
migrate_stake_cw20_manager: params.migrate_cw20,
proposal_params,
},
v1_code_ids,
v2_code_ids,
})
.unwrap(),
admin: Some(Admin::CoreModule {}),
funds: vec![],
label: "migrator".to_string(),
}],
to_disable: vec![],
})
.unwrap(),
funds: vec![],
}
Expand Down Expand Up @@ -382,14 +381,14 @@ pub fn execute_migration_from_core(
.map(|addr| {
(
addr.clone().into(),
dao_interface_v2::migrate_msg::ProposalParams {
dao_interface::migrate_msg::ProposalParams {
close_proposal_on_execution_failure: true,
pre_propose_info:
dao_interface_v2::migrate_msg::PreProposeInfo::AnyoneMayPropose {},
dao_interface::migrate_msg::PreProposeInfo::AnyoneMayPropose {},
},
)
})
.collect::<Vec<(String, dao_interface_v2::migrate_msg::ProposalParams)>>();
.collect::<Vec<(String, dao_interface::migrate_msg::ProposalParams)>>();

app.execute_contract(
sender.clone(),
Expand All @@ -400,17 +399,16 @@ pub fn execute_migration_from_core(
msgs: vec![WasmMsg::Migrate {
contract_addr: module_addrs.core.to_string(),
new_code_id: new_code_ids.core,
msg: to_json_binary(&dao_interface_v2::msg::MigrateMsg::FromV1 {
msg: to_json_binary(&dao_interface::msg::MigrateMsg::FromV1 {
dao_uri: None,
params: Some(dao_interface_v2::migrate_msg::MigrateParams {
params: Some(dao_interface::migrate_msg::MigrateParams {
migrator_code_id,
params: dao_interface_v2::migrate_msg::MigrateV1ToV2 {
params: dao_interface::migrate_msg::MigrateV1ToV2 {
sub_daos: params.sub_daos.unwrap(),
migration_params:
dao_interface_v2::migrate_msg::MigrationModuleParams {
migrate_stake_cw20_manager: params.migrate_cw20,
proposal_params,
},
migration_params: dao_interface::migrate_msg::MigrationModuleParams {
migrate_stake_cw20_manager: params.migrate_cw20,
proposal_params,
},
v1_code_ids: v1_code_ids.to(),
v2_code_ids: v2_code_ids.to(),
},
Expand Down
15 changes: 8 additions & 7 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_v2::proposal::SingleChoiceProposal,
pub proposal: dao_proposal_single::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_v2::proposal::SingleChoiceProposal) {
) -> (u64, dao_proposal_single::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_v2::proposal::SingleChoiceProposal {
let proposal = dao_proposal_single::proposal::SingleChoiceProposal {
title: proposal.title,
description: proposal.description,
proposer: proposal.proposer,
Expand All @@ -54,6 +54,7 @@ pub fn query_proposal_v1(
status: v1_status_to_v2(proposal.status),
votes: v1_votes_to_v2(proposal.votes),
allow_revoting: proposal.allow_revoting,
veto: None,
};

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

// query proposal
let proposal = app
.wrap()
.query_wasm_smart::<dao_proposal_single_v2::query::ProposalListResponse>(
.query_wasm_smart::<dao_proposal_single::query::ProposalListResponse>(
proposal_addr,
&dao_proposal_single_v2::msg::QueryMsg::ListProposals {
&dao_proposal_single::msg::QueryMsg::ListProposals {
start_after: None,
limit: None,
},
Expand Down
Loading

0 comments on commit 3d8d5c1

Please sign in to comment.