diff --git a/Cargo.lock b/Cargo.lock index db6cc9a22..b88db5e08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -533,6 +533,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-controllers" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bfeaf55f8dba5646cc3daddce17cd23a60f8e0c3fbacbe6735d287d7a6e33a" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 0.11.1", + "cw-utils 0.11.1", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-controllers" version = "0.13.4" @@ -764,6 +778,17 @@ dependencies = [ "cw-wormhole", ] +[[package]] +name = "cw-storage-plus" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d7ee1963302b0ac2a9d42fe0faec826209c17452bfd36fbfd9d002a88929261" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "cw-storage-plus" version = "0.13.4" @@ -822,6 +847,18 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-utils" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef842a1792e4285beff7b3b518705f760fa4111dc1e296e53f3e92d1ef7f6220" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-utils" version = "0.13.4" @@ -898,6 +935,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cw2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1d81d7c359d6c1fba3aa83dad7ec6f999e512571380ae62f81257c3db569743" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 0.11.1", + "schemars", + "serde", +] + [[package]] name = "cw2" version = "0.13.4" @@ -936,6 +985,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cw20" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9671d7edef5608acaf5b2f1e473ee3f501eced2cd4f7392e2106c8cf02ba0720" +dependencies = [ + "cosmwasm-std", + "cw-utils 0.11.1", + "schemars", + "serde", +] + [[package]] name = "cw20" version = "0.13.4" @@ -961,6 +1022,22 @@ dependencies = [ "serde", ] +[[package]] +name = "cw20-base" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f6fc8c4cd451b418fa4f1ac2ea70595811fa9d8b4033617fe47953d7a93ceb" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 0.11.1", + "cw-utils 0.11.1", + "cw2 0.11.1", + "cw20 0.11.1", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw20-base" version = "0.13.4" @@ -1637,6 +1714,7 @@ dependencies = [ "dao-voting-cw721-staked", "dao-voting-native-staked", "rand", + "stake-cw20", "voting", ] @@ -3197,6 +3275,24 @@ dependencies = [ "der", ] +[[package]] +name = "stake-cw20" +version = "0.2.6" +source = "git+https://github.com/DA0-DA0/dao-contracts.git?tag=v0.3.0#5d46fc6f4a9a2fed3a85e700215d0421e1c196be" +dependencies = [ + "cosmwasm-std", + "cosmwasm-storage", + "cw-controllers 0.11.1", + "cw-storage-plus 0.11.1", + "cw-utils 0.11.1", + "cw2 0.11.1", + "cw20 0.11.1", + "cw20-base 0.11.1", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "stake-cw20-external-rewards" version = "0.2.6" diff --git a/Cargo.toml b/Cargo.toml index 6d881582f..52803a2d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,3 +103,4 @@ cw20-stake-v1 = { package = "cw20-stake", version = "0.2.6", git = "https://gith cw20-staked-balance-voting-v1 = { package = "cw20-staked-balance-voting", 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" } voting-v1 = { package = "voting", version = "0.1.0", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" } +stake-cw20-v03 = { package = "stake-cw20", version = "0.2.6", git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v0.3.0" } diff --git a/contracts/external/dao-migrator/src/contract.rs b/contracts/external/dao-migrator/src/contract.rs index 0870c125a..86cd18ed8 100644 --- a/contracts/external/dao-migrator/src/contract.rs +++ b/contracts/external/dao-migrator/src/contract.rs @@ -366,8 +366,6 @@ pub fn reply(deps: DepsMut, env: Env, reply: Reply) -> Result Result { let proposal_counts = query_proposal_count_v1(deps, module_addrs.proposals.clone())?; let (proposals, sample_proposal_data) = query_proposal_v1(deps, module_addrs.proposals)?; diff --git a/contracts/external/dao-migrator/src/testing/helpers.rs b/contracts/external/dao-migrator/src/testing/helpers.rs index 9e05af99f..5da85a6bd 100644 --- a/contracts/external/dao-migrator/src/testing/helpers.rs +++ b/contracts/external/dao-migrator/src/testing/helpers.rs @@ -45,6 +45,7 @@ pub struct ModuleAddrs { pub enum VotingType { Cw4, Cw20, + Cw20V03, } pub fn get_v1_code_ids(app: &mut App) -> (CodeIds, V1CodeIds) { diff --git a/contracts/external/dao-migrator/src/testing/setup.rs b/contracts/external/dao-migrator/src/testing/setup.rs index f0d0bcec1..fd6c78717 100644 --- a/contracts/external/dao-migrator/src/testing/setup.rs +++ b/contracts/external/dao-migrator/src/testing/setup.rs @@ -3,6 +3,7 @@ use std::borrow::BorrowMut; use cosmwasm_std::{to_binary, Addr, WasmMsg}; use cw_multi_test::{next_block, App, AppResponse, Executor}; use dao_interface::{Admin, ModuleInstantiateInfo}; +use dao_testing::contracts::stake_cw20_v03_contract; use crate::{ testing::helpers::get_module_addrs, @@ -15,7 +16,7 @@ use super::helpers::{ }; pub fn init_v1(app: &mut App, sender: Addr, voting_type: VotingType) -> (Addr, V1CodeIds) { - let (code_ids, v1_code_ids) = get_v1_code_ids(app); + let (mut code_ids, mut v1_code_ids) = get_v1_code_ids(app); let (voting_code_id, msg) = match voting_type { VotingType::Cw4 => ( @@ -26,6 +27,17 @@ pub fn init_v1(app: &mut App, sender: Addr, voting_type: VotingType) -> (Addr, V code_ids.cw20_voting, to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), ), + VotingType::Cw20V03 => { + // The simple change we need to do is to swap the cw20_stake with the one in v0.3.0 + let v03_cw20_stake = app.store_code(stake_cw20_v03_contract()); + code_ids.cw20_stake = v03_cw20_stake; + v1_code_ids.cw20_stake = v03_cw20_stake; + + ( + code_ids.cw20_voting, + to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), + ) + } }; let core_addr = app @@ -92,7 +104,7 @@ pub fn init_v1_with_multiple_proposals( sender: Addr, voting_type: VotingType, ) -> (Addr, V1CodeIds) { - let (code_ids, v1_code_ids) = get_v1_code_ids(app); + let (mut code_ids, mut v1_code_ids) = get_v1_code_ids(app); let (voting_code_id, msg) = match voting_type { VotingType::Cw4 => ( @@ -103,6 +115,16 @@ pub fn init_v1_with_multiple_proposals( code_ids.cw20_voting, to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), ), + VotingType::Cw20V03 => { + let v03_cw20_stake = app.store_code(stake_cw20_v03_contract()); + code_ids.cw20_stake = v03_cw20_stake; + v1_code_ids.cw20_stake = v03_cw20_stake; + + ( + code_ids.cw20_voting, + to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), + ) + } }; let core_addr = app @@ -198,6 +220,8 @@ pub fn setup_dao_v1(voting_type: VotingType) -> (App, ModuleAddrs, V1CodeIds) { module_addrs.proposals[0].clone(), ), VotingType::Cw20 => set_cw20_to_dao(app.borrow_mut(), sender, module_addrs.clone()), + // Same as Cw20 + VotingType::Cw20V03 => set_cw20_to_dao(app.borrow_mut(), sender, module_addrs.clone()), }; (app, module_addrs, v1_code_ids) diff --git a/contracts/external/dao-migrator/src/testing/test_migration.rs b/contracts/external/dao-migrator/src/testing/test_migration.rs index 228602bcf..ee50a684b 100644 --- a/contracts/external/dao-migrator/src/testing/test_migration.rs +++ b/contracts/external/dao-migrator/src/testing/test_migration.rs @@ -33,6 +33,11 @@ pub fn basic_test(voting_type: VotingType, from_core: bool) { module_addrs.proposals[0].clone(), module_addrs.voting.clone(), ), + VotingType::Cw20V03 => query_state_v1_cw20( + &mut app, + module_addrs.proposals[0].clone(), + module_addrs.voting.clone(), + ), }; //NOTE: We add 1 to count because we create a new proposal in execute_migration test_state_v1.proposal_count += 1; @@ -57,6 +62,11 @@ pub fn basic_test(voting_type: VotingType, from_core: bool) { module_addrs.proposals[0].clone(), module_addrs.voting, ), + VotingType::Cw20V03 => query_state_v2_cw20( + &mut app, + module_addrs.proposals[0].clone(), + module_addrs.voting, + ), }; assert_eq!(test_state_v1, test_state_v2); @@ -81,10 +91,12 @@ fn test_execute_migration() { // Test basic migrator (not called from core) basic_test(VotingType::Cw20, false); basic_test(VotingType::Cw4, false); + basic_test(VotingType::Cw20V03, false); // Test basic migrator (called from core) basic_test(VotingType::Cw20, true); basic_test(VotingType::Cw4, true); + basic_test(VotingType::Cw20V03, true); } #[test] diff --git a/packages/dao-testing/Cargo.toml b/packages/dao-testing/Cargo.toml index d115b5f61..c81a979b1 100644 --- a/packages/dao-testing/Cargo.toml +++ b/packages/dao-testing/Cargo.toml @@ -44,3 +44,4 @@ dao-voting-cw4 = { workspace = true } dao-voting-cw721-staked = { workspace = true } dao-voting-native-staked = { workspace = true } voting-v1 = { workspace = true } +stake-cw20-v03 = { workspace = true } \ No newline at end of file diff --git a/packages/dao-testing/src/contracts.rs b/packages/dao-testing/src/contracts.rs index aa81b8241..c6df42b17 100644 --- a/packages/dao-testing/src/contracts.rs +++ b/packages/dao-testing/src/contracts.rs @@ -167,3 +167,12 @@ pub fn cw_vesting_contract() -> Box> { ); Box::new(contract) } + +pub fn stake_cw20_v03_contract() -> Box> { + let contract = ContractWrapper::new( + stake_cw20_v03::contract::execute, + stake_cw20_v03::contract::instantiate, + stake_cw20_v03::contract::query, + ); + Box::new(contract) +}