diff --git a/ci/bootstrap-env/src/main.rs b/ci/bootstrap-env/src/main.rs index 85fd119a5..d8117c8f5 100644 --- a/ci/bootstrap-env/src/main.rs +++ b/ci/bootstrap-env/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Result; use cosm_orc::orchestrator::{Coin, Key, SigningKey}; use cosm_orc::{config::cfg::Config, orchestrator::cosm_orc::CosmOrc}; -use cosmwasm_std::{to_binary, Decimal, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, Decimal, Empty, Uint128}; use cw20::Cw20Coin; use dao_interface::state::{Admin, ModuleInstantiateInfo}; use dao_voting::{ @@ -55,7 +55,7 @@ fn main() -> Result<()> { automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: orc.contract_map.code_id("dao_voting_cw20_staked")?, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: orc.contract_map.code_id("cw20_base")?, label: "DAO DAO Gov token".to_string(), @@ -79,7 +79,7 @@ fn main() -> Result<()> { }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: orc.contract_map.code_id("dao_proposal_single")?, - msg: to_binary(&dao_proposal_single::msg::InstantiateMsg { + msg: to_json_binary(&dao_proposal_single::msg::InstantiateMsg { min_voting_period: None, threshold: Threshold::ThresholdQuorum { threshold: PercentageThreshold::Majority {}, @@ -91,7 +91,7 @@ fn main() -> Result<()> { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: orc.contract_map.code_id("dao_pre_propose_single")?, - msg: to_binary(&dao_pre_propose_single::InstantiateMsg { + msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::VotingModuleToken {}, amount: Uint128::new(1000000000), diff --git a/ci/integration-tests/src/helpers/helper.rs b/ci/integration-tests/src/helpers/helper.rs index bcfd0e26d..e4f4678cf 100644 --- a/ci/integration-tests/src/helpers/helper.rs +++ b/ci/integration-tests/src/helpers/helper.rs @@ -1,7 +1,7 @@ use super::chain::Chain; use anyhow::Result; use cosm_orc::orchestrator::SigningKey; -use cosmwasm_std::{to_binary, CosmosMsg, Decimal, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, CosmosMsg, Decimal, Empty, Uint128}; use cw20::Cw20Coin; use cw_utils::Duration; use dao_interface::query::DumpStateResponse; @@ -39,7 +39,7 @@ pub fn create_dao( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: chain.orc.contract_map.code_id("dao_voting_cw20_staked")?, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: chain.orc.contract_map.code_id("cw20_base")?, label: "DAO DAO Gov token".to_string(), @@ -63,7 +63,7 @@ pub fn create_dao( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: chain.orc.contract_map.code_id("dao_proposal_single")?, - msg: to_binary(&dao_proposal_single::msg::InstantiateMsg { + msg: to_json_binary(&dao_proposal_single::msg::InstantiateMsg { min_voting_period: None, threshold: Threshold::ThresholdQuorum { threshold: PercentageThreshold::Majority {}, @@ -76,7 +76,7 @@ pub fn create_dao( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: chain.orc.contract_map.code_id("dao_pre_propose_single")?, - msg: to_binary(&dao_pre_propose_single::InstantiateMsg { + msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::VotingModuleToken {}, amount: DEPOSIT_AMOUNT, @@ -187,7 +187,7 @@ pub fn stake_tokens(chain: &mut Chain, how_many: u128, key: &SigningKey) { &cw20::Cw20ExecuteMsg::Send { contract: chain.orc.contract_map.address("cw20_stake").unwrap(), amount: Uint128::new(how_many), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, key, vec![], diff --git a/ci/integration-tests/src/tests/cw20_stake_test.rs b/ci/integration-tests/src/tests/cw20_stake_test.rs index 13cb0d226..4250441d5 100644 --- a/ci/integration-tests/src/tests/cw20_stake_test.rs +++ b/ci/integration-tests/src/tests/cw20_stake_test.rs @@ -1,5 +1,5 @@ use crate::helpers::{chain::Chain, helper::create_dao}; -use cosmwasm_std::{to_binary, Uint128}; +use cosmwasm_std::{to_json_binary, Uint128}; use cw20_stake::{msg::StakedValueResponse, state::Config}; use dao_interface::voting::VotingPowerAtHeightResponse; use std::time::Duration; @@ -79,7 +79,7 @@ fn execute_stake_tokens(chain: &mut Chain) { &cw20_base::msg::ExecuteMsg::Send { contract: staking_addr, amount: Uint128::new(100), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &user_key, vec![], diff --git a/ci/integration-tests/src/tests/cw_core_test.rs b/ci/integration-tests/src/tests/cw_core_test.rs index 348ac3925..904003d4e 100644 --- a/ci/integration-tests/src/tests/cw_core_test.rs +++ b/ci/integration-tests/src/tests/cw_core_test.rs @@ -3,7 +3,7 @@ use crate::helpers::helper::create_dao; use assert_matches::assert_matches; use cosm_orc::orchestrator::error::CosmwasmError::TxError; use cosm_orc::orchestrator::error::ProcessError; -use cosmwasm_std::{to_binary, Addr, CosmosMsg, Decimal, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, Decimal, Uint128}; use cw20_stake::msg::{StakedValueResponse, TotalValueResponse}; use cw_utils::Duration; @@ -40,7 +40,7 @@ fn execute_execute_admin_msgs(chain: &mut Chain) { &dao_interface::msg::ExecuteMsg::ExecuteAdminMsgs { msgs: vec![CosmosMsg::Wasm(cosmwasm_std::WasmMsg::Execute { contract_addr: dao.addr, - msg: to_binary(&dao_interface::msg::ExecuteMsg::Pause { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::Pause { duration: Duration::Time(100), }) .unwrap(), @@ -79,7 +79,7 @@ fn execute_execute_admin_msgs(chain: &mut Chain) { &dao_interface::msg::ExecuteMsg::ExecuteAdminMsgs { msgs: vec![CosmosMsg::Wasm(cosmwasm_std::WasmMsg::Execute { contract_addr: dao.addr, - msg: to_binary(&dao_interface::msg::ExecuteMsg::Pause { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::Pause { duration: Duration::Height(100), }) .unwrap(), @@ -139,7 +139,7 @@ fn execute_items(chain: &mut Chain) { &dao_interface::msg::ExecuteMsg::ExecuteAdminMsgs { msgs: vec![CosmosMsg::Wasm(cosmwasm_std::WasmMsg::Execute { contract_addr: dao.addr.clone(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::SetItem { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::SetItem { key: "meme".to_string(), value: "foobar".to_string(), }) @@ -174,7 +174,7 @@ fn execute_items(chain: &mut Chain) { &dao_interface::msg::ExecuteMsg::ExecuteAdminMsgs { msgs: vec![CosmosMsg::Wasm(cosmwasm_std::WasmMsg::Execute { contract_addr: dao.addr, - msg: to_binary(&dao_interface::msg::ExecuteMsg::RemoveItem { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::RemoveItem { key: "meme".to_string(), }) .unwrap(), diff --git a/ci/integration-tests/src/tests/proposal_gas_test.rs b/ci/integration-tests/src/tests/proposal_gas_test.rs index e6fa015a9..3c19c559a 100644 --- a/ci/integration-tests/src/tests/proposal_gas_test.rs +++ b/ci/integration-tests/src/tests/proposal_gas_test.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, CosmosMsg, Empty, WasmMsg}; +use cosmwasm_std::{to_json_binary, CosmosMsg, Empty, WasmMsg}; use dao_proposal_single::query::ProposalResponse; use dao_voting::voting::Vote; use test_context::test_context; @@ -15,7 +15,7 @@ fn mint_mint_mint_mint(cw721: &str, owner: &str, mints: u64) -> Vec { .map(|mint| { WasmMsg::Execute { contract_addr: cw721.to_string(), - msg: to_binary(&cw721_base::msg::ExecuteMsg::Mint::{ + msg: to_json_binary(&cw721_base::msg::ExecuteMsg::Mint::{ token_id: mint.to_string(), owner: owner.to_string(), token_uri: Some("https://bafkreibufednctf2f2bpduiibgkvpqcw5rtdmhqh2htqx3qbdnji4h55hy.ipfs.nftstorage.link".to_string()), diff --git a/contracts/dao-dao-core/src/contract.rs b/contracts/dao-dao-core/src/contract.rs index 21e38784e..a4eb2d9dc 100644 --- a/contracts/dao-dao-core/src/contract.rs +++ b/contracts/dao-dao-core/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Order, + from_json_binary, to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Order, Reply, Response, StdError, StdResult, SubMsg, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -579,22 +579,22 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { pub fn query_admin(deps: Deps) -> StdResult { let admin = ADMIN.load(deps.storage)?; - to_binary(&admin) + to_json_binary(&admin) } pub fn query_admin_nomination(deps: Deps) -> StdResult { let nomination = NOMINATED_ADMIN.may_load(deps.storage)?; - to_binary(&AdminNominationResponse { nomination }) + to_json_binary(&AdminNominationResponse { nomination }) } pub fn query_config(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config) + to_json_binary(&config) } pub fn query_voting_module(deps: Deps) -> StdResult { let voting_module = VOTING_MODULE.load(deps.storage)?; - to_binary(&voting_module) + to_json_binary(&voting_module) } pub fn query_proposal_modules( @@ -615,7 +615,7 @@ pub fn query_proposal_modules( // // Even if this does lock up one can determine the existing // proposal modules by looking at past transactions on chain. - to_binary(&paginate_map_values( + to_json_binary(&paginate_map_values( deps, &PROPOSAL_MODULES, start_after @@ -645,7 +645,7 @@ pub fn query_active_proposal_modules( let limit = limit.unwrap_or(values.len() as u32); - to_binary::>( + to_json_binary::>( &values .into_iter() .filter(|module: &ProposalModule| module.status == ProposalModuleStatus::Enabled) @@ -668,7 +668,7 @@ fn get_pause_info(deps: Deps, env: Env) -> StdResult { } pub fn query_paused(deps: Deps, env: Env) -> StdResult { - to_binary(&get_pause_info(deps, env)?) + to_json_binary(&get_pause_info(deps, env)?) } pub fn query_dump_state(deps: Deps, env: Env) -> StdResult { @@ -683,7 +683,7 @@ pub fn query_dump_state(deps: Deps, env: Env) -> StdResult { let version = get_contract_version(deps.storage)?; let active_proposal_module_count = ACTIVE_PROPOSAL_MODULE_COUNT.load(deps.storage)?; let total_proposal_module_count = TOTAL_PROPOSAL_MODULE_COUNT.load(deps.storage)?; - to_binary(&DumpStateResponse { + to_json_binary(&DumpStateResponse { admin, config, version, @@ -705,7 +705,7 @@ pub fn query_voting_power_at_height( voting_module, &voting::Query::VotingPowerAtHeight { height, address }, )?; - to_binary(&voting_power) + to_json_binary(&voting_power) } pub fn query_total_power_at_height(deps: Deps, height: Option) -> StdResult { @@ -713,17 +713,17 @@ pub fn query_total_power_at_height(deps: Deps, height: Option) -> StdResult let total_power: voting::TotalPowerAtHeightResponse = deps .querier .query_wasm_smart(voting_module, &voting::Query::TotalPowerAtHeight { height })?; - to_binary(&total_power) + to_json_binary(&total_power) } pub fn query_get_item(deps: Deps, item: String) -> StdResult { let item = ITEMS.may_load(deps.storage, item)?; - to_binary(&GetItemResponse { item }) + to_json_binary(&GetItemResponse { item }) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } pub fn query_list_items( @@ -731,7 +731,7 @@ pub fn query_list_items( start_after: Option, limit: Option, ) -> StdResult { - to_binary(&paginate_map( + to_json_binary(&paginate_map( deps, &ITEMS, start_after, @@ -745,7 +745,7 @@ pub fn query_cw20_list( start_after: Option, limit: Option, ) -> StdResult { - to_binary(&paginate_map_keys( + to_json_binary(&paginate_map_keys( deps, &CW20_LIST, start_after @@ -761,7 +761,7 @@ pub fn query_cw721_list( start_after: Option, limit: Option, ) -> StdResult { - to_binary(&paginate_map_keys( + to_json_binary(&paginate_map_keys( deps, &CW721_LIST, start_after @@ -802,7 +802,7 @@ pub fn query_cw20_balances( }) }) .collect::>>()?; - to_binary(&balances) + to_json_binary(&balances) } pub fn query_list_sub_daos( @@ -830,18 +830,18 @@ pub fn query_list_sub_daos( }) .collect(); - to_binary(&subdaos) + to_json_binary(&subdaos) } pub fn query_dao_uri(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&DaoURIResponse { + to_json_binary(&DaoURIResponse { dao_uri: config.dao_uri, }) } pub fn query_proposal_module_count(deps: Deps) -> StdResult { - to_binary(&ProposalModuleCountResponse { + to_json_binary(&ProposalModuleCountResponse { active_proposal_module_count: ACTIVE_PROPOSAL_MODULE_COUNT.load(deps.storage)?, total_proposal_module_count: TOTAL_PROPOSAL_MODULE_COUNT.load(deps.storage)?, }) @@ -904,10 +904,10 @@ pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result Result from_binary::(&data) + Some(data) => from_json_binary::(&data) .map(|m| m.msgs) .unwrap_or_else(|_| vec![]), None => vec![], @@ -978,7 +978,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result from_binary::(&data) + Some(data) => from_json_binary::(&data) .map(|m| m.msgs) .unwrap_or_else(|_| vec![]), None => vec![], diff --git a/contracts/dao-dao-core/src/tests.rs b/contracts/dao-dao-core/src/tests.rs index 577552e85..3ab01632e 100644 --- a/contracts/dao-dao-core/src/tests.rs +++ b/contracts/dao-dao-core/src/tests.rs @@ -2,7 +2,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{ from_slice, testing::{mock_dependencies, mock_env}, - to_binary, Addr, CosmosMsg, Empty, Storage, Uint128, WasmMsg, + to_json_binary, Addr, CosmosMsg, Empty, Storage, Uint128, WasmMsg, }; use cw2::{set_contract_version, ContractVersion}; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; @@ -117,7 +117,7 @@ fn test_instantiate_with_n_gov_modules(n: usize) { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -125,7 +125,7 @@ fn test_instantiate_with_n_gov_modules(n: usize) { proposal_modules_instantiate_info: (0..n) .map(|n| ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: format!("governance module {n}"), @@ -191,7 +191,7 @@ fn test_instantiate_with_submessage_failure() { let mut governance_modules = (0..3) .map(|n| ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: format!("governance module {n}"), @@ -199,14 +199,14 @@ fn test_instantiate_with_submessage_failure() { .collect::>(); governance_modules.push(ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary("bad").unwrap(), + msg: to_json_binary("bad").unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "I have a bad instantiate message".to_string(), }); governance_modules.push(ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "Everybody knowing @@ -225,7 +225,7 @@ makes wickedness." automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw20_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -256,14 +256,14 @@ fn test_update_config() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -311,7 +311,7 @@ fn test_update_config() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateConfig { + msg: to_json_binary(&ExecuteMsg::UpdateConfig { config: expected_config.clone(), }) .unwrap(), @@ -355,14 +355,14 @@ fn test_swap_governance(swaps: Vec<(u32, u32)>) { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: propmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: propmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -426,7 +426,7 @@ fn test_swap_governance(swaps: Vec<(u32, u32)>) { let to_add: Vec<_> = (0..add) .map(|n| ModuleInstantiateInfo { code_id: propmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: format!("governance module {n}"), @@ -447,7 +447,7 @@ fn test_swap_governance(swaps: Vec<(u32, u32)>) { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }) + msg: to_json_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }) .unwrap(), } .into()], @@ -534,14 +534,14 @@ fn test_removed_modules_can_not_execute() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -577,7 +577,7 @@ fn test_removed_modules_can_not_execute() { let to_add = vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "new governance module".to_string(), @@ -593,7 +593,7 @@ fn test_removed_modules_can_not_execute() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }).unwrap(), + msg: to_json_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }).unwrap(), } .into()], }, @@ -609,7 +609,7 @@ fn test_removed_modules_can_not_execute() { // earlier. This should fail as we have been removed. let to_add = vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "new governance module".to_string(), @@ -624,7 +624,7 @@ fn test_removed_modules_can_not_execute() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateProposalModules { + msg: to_json_binary(&ExecuteMsg::UpdateProposalModules { to_add: to_add.clone(), to_disable: to_disable.clone(), }) @@ -666,7 +666,7 @@ fn test_removed_modules_can_not_execute() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }).unwrap(), + msg: to_json_binary(&ExecuteMsg::UpdateProposalModules { to_add, to_disable }).unwrap(), } .into()], }, @@ -695,14 +695,14 @@ fn test_module_already_disabled() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -749,10 +749,10 @@ fn test_module_already_disabled() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateProposalModules { + msg: to_json_binary(&ExecuteMsg::UpdateProposalModules { to_add: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -797,14 +797,14 @@ fn test_swap_voting_module() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -848,10 +848,10 @@ fn test_swap_voting_module() { msgs: vec![WasmMsg::Execute { contract_addr: gov_addr.to_string(), funds: vec![], - msg: to_binary(&ExecuteMsg::UpdateVotingModule { + msg: to_json_binary(&ExecuteMsg::UpdateVotingModule { module: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -901,14 +901,14 @@ fn test_permissions() { image_url: None, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -935,7 +935,7 @@ fn test_permissions() { ExecuteMsg::UpdateVotingModule { module: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -1003,14 +1003,14 @@ fn do_standard_instantiate(auto_add: bool, admin: Option) -> (Addr, App) automatically_add_cw721s: auto_add, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: voting_id, - msg: to_binary(&voting_instantiate).unwrap(), + msg: to_json_binary(&voting_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -1058,7 +1058,7 @@ fn test_admin_permissions() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1077,7 +1077,7 @@ fn test_admin_permissions() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1108,7 +1108,7 @@ fn test_admin_permissions() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::NominateAdmin { + msg: to_json_binary(&ExecuteMsg::NominateAdmin { admin: Some("meow".to_string()), }) .unwrap(), @@ -1131,7 +1131,7 @@ fn test_admin_permissions() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_with_admin_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1150,7 +1150,7 @@ fn test_admin_permissions() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_with_admin_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1395,7 +1395,7 @@ fn test_admin_nomination() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1416,7 +1416,7 @@ fn test_admin_nomination() { &ExecuteMsg::ExecuteAdminMsgs { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -1637,14 +1637,14 @@ fn test_list_items() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: voting_id, - msg: to_binary(&voting_instantiate).unwrap(), + msg: to_json_binary(&voting_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -1771,14 +1771,14 @@ fn test_instantiate_with_items() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: voting_id, - msg: to_binary(&voting_instantiate).unwrap(), + msg: to_json_binary(&voting_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -1893,7 +1893,7 @@ fn test_cw20_receive_auto_add() { &cw20::Cw20ExecuteMsg::Send { contract: gov_addr.to_string(), amount: Uint128::new(1), - msg: to_binary(&"").unwrap(), + msg: to_json_binary(&"").unwrap(), }, &[], ) @@ -2028,7 +2028,7 @@ fn test_cw20_receive_no_auto_add() { &cw20::Cw20ExecuteMsg::Send { contract: gov_addr.to_string(), amount: Uint128::new(1), - msg: to_binary(&"").unwrap(), + msg: to_json_binary(&"").unwrap(), }, &[], ) @@ -2125,7 +2125,7 @@ fn test_cw721_receive() { &cw721_base::msg::ExecuteMsg::, Empty>::SendNft { contract: gov_addr.to_string(), token_id: "ekez".to_string(), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -2255,7 +2255,7 @@ fn test_cw721_receive_no_auto_add() { &cw721_base::msg::ExecuteMsg::, Empty>::SendNft { contract: gov_addr.to_string(), token_id: "ekez".to_string(), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -2380,7 +2380,7 @@ fn test_pause() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -2442,7 +2442,7 @@ fn test_pause() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -2468,7 +2468,7 @@ fn test_pause() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -2504,7 +2504,7 @@ fn test_pause() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![WasmMsg::Execute { contract_addr: core_addr.to_string(), - msg: to_binary(&ExecuteMsg::Pause { + msg: to_json_binary(&ExecuteMsg::Pause { duration: Duration::Height(10), }) .unwrap(), @@ -2604,14 +2604,14 @@ fn test_migrate_from_compatible() { automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: voting_id, - msg: to_binary(&voting_instantiate).unwrap(), + msg: to_json_binary(&voting_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "governance module".to_string(), @@ -2640,7 +2640,7 @@ fn test_migrate_from_compatible() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: core_addr.to_string(), new_code_id: gov_id, - msg: to_binary(&MigrateMsg::FromCompatible {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromCompatible {}).unwrap(), }), ) .unwrap(); @@ -2692,20 +2692,20 @@ fn test_migrate_from_beta() { automatically_add_cw721s: false, voting_module_instantiate_info: v1::msg::ModuleInstantiateInfo { code_id: voting_id, - msg: to_binary(&voting_instantiate).unwrap(), + msg: to_json_binary(&voting_instantiate).unwrap(), admin: v1::msg::Admin::CoreContract {}, label: "voting module".to_string(), }, proposal_modules_instantiate_info: vec![ v1::msg::ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&proposal_instantiate).unwrap(), + msg: to_json_binary(&proposal_instantiate).unwrap(), admin: v1::msg::Admin::CoreContract {}, label: "governance module 1".to_string(), }, v1::msg::ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&proposal_instantiate).unwrap(), + msg: to_json_binary(&proposal_instantiate).unwrap(), admin: v1::msg::Admin::CoreContract {}, label: "governance module 2".to_string(), }, @@ -2729,7 +2729,7 @@ fn test_migrate_from_beta() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: core_addr.to_string(), new_code_id: core_id, - msg: to_binary(&MigrateMsg::FromV1 { + msg: to_json_binary(&MigrateMsg::FromV1 { dao_uri: None, params: None, }) @@ -2758,7 +2758,7 @@ fn test_migrate_from_beta() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: core_addr.to_string(), new_code_id: core_id, - msg: to_binary(&MigrateMsg::FromV1 { + msg: to_json_binary(&MigrateMsg::FromV1 { dao_uri: None, params: None, }) @@ -2788,7 +2788,7 @@ fn test_migrate_mock() { let proposal_modules_key = Addr::unchecked("addr"); let old_map: Map = Map::new("proposal_modules"); let path = old_map.key(proposal_modules_key.clone()); - deps.storage.set(&path, &to_binary(&Empty {}).unwrap()); + deps.storage.set(&path, &to_json_binary(&Empty {}).unwrap()); // Write to storage in old config format #[cw_serde] @@ -2860,7 +2860,7 @@ fn test_execute_stargate_msg() { &ExecuteMsg::ExecuteProposalHook { msgs: vec![CosmosMsg::Stargate { type_url: "foo_type".to_string(), - value: to_binary("foo_bin").unwrap(), + value: to_json_binary("foo_bin").unwrap(), }], }, &[], @@ -2889,7 +2889,7 @@ fn test_module_prefixes() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -2897,21 +2897,21 @@ fn test_module_prefixes() { proposal_modules_instantiate_info: vec![ ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "proposal module 1".to_string(), }, ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "proposal module 2".to_string(), }, ModuleInstantiateInfo { code_id: govmod_id, - msg: to_binary(&govmod_instantiate).unwrap(), + msg: to_json_binary(&govmod_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "proposal module 2".to_string(), diff --git a/contracts/external/cw-admin-factory/src/tests.rs b/contracts/external/cw-admin-factory/src/tests.rs index 27221cb31..3bee180ee 100644 --- a/contracts/external/cw-admin-factory/src/tests.rs +++ b/contracts/external/cw-admin-factory/src/tests.rs @@ -2,7 +2,7 @@ use std::vec; use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info}, - to_binary, Addr, Binary, Empty, Reply, SubMsg, SubMsgResponse, SubMsgResult, WasmMsg, + to_json_binary, Addr, Binary, Empty, Reply, SubMsg, SubMsgResponse, SubMsgResult, WasmMsg, }; use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor}; @@ -82,7 +82,7 @@ pub fn test_set_admin() { automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw20_code_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "voting module".to_string(), @@ -90,14 +90,14 @@ pub fn test_set_admin() { proposal_modules_instantiate_info: vec![ ModuleInstantiateInfo { code_id: cw20_code_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "prop module".to_string(), }, ModuleInstantiateInfo { code_id: cw20_code_id, - msg: to_binary(&cw20_instantiate).unwrap(), + msg: to_json_binary(&cw20_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "prop module 2".to_string(), @@ -111,7 +111,7 @@ pub fn test_set_admin() { Addr::unchecked("CREATOR"), factory_addr, &ExecuteMsg::InstantiateContractWithSelfAdmin { - instantiate_msg: to_binary(&instantiate_core).unwrap(), + instantiate_msg: to_json_binary(&instantiate_core).unwrap(), code_id: cw_core_code_id, label: "my contract".to_string(), }, diff --git a/contracts/external/cw-fund-distributor/src/contract.rs b/contracts/external/cw-fund-distributor/src/contract.rs index 2e5d4b2d1..8e658905a 100644 --- a/contracts/external/cw-fund-distributor/src/contract.rs +++ b/contracts/external/cw-fund-distributor/src/contract.rs @@ -10,7 +10,7 @@ use crate::state::{ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Env, Fraction, MessageInfo, + to_json_binary, Addr, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Env, Fraction, MessageInfo, Order, Response, StdError, StdResult, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -247,7 +247,7 @@ fn get_cw20_claim_wasm_messages( messages.push(WasmMsg::Execute { contract_addr: addr, - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: sender.to_string(), amount: entitlement, })?, @@ -406,7 +406,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { pub fn query_voting_contract(deps: Deps) -> StdResult { let contract = VOTING_CONTRACT.load(deps.storage)?; let distribution_height = DISTRIBUTION_HEIGHT.load(deps.storage)?; - to_binary(&VotingContractResponse { + to_json_binary(&VotingContractResponse { contract, distribution_height, }) @@ -414,7 +414,7 @@ pub fn query_voting_contract(deps: Deps) -> StdResult { pub fn query_total_power(deps: Deps) -> StdResult { let total_power: Uint128 = TOTAL_POWER.may_load(deps.storage)?.unwrap_or_default(); - to_binary(&TotalPowerResponse { total_power }) + to_json_binary(&TotalPowerResponse { total_power }) } pub fn query_native_denoms(deps: Deps) -> StdResult { @@ -429,7 +429,7 @@ pub fn query_native_denoms(deps: Deps) -> StdResult { }); } - to_binary(&denom_responses) + to_json_binary(&denom_responses) } pub fn query_cw20_tokens(deps: Deps) -> StdResult { @@ -444,7 +444,7 @@ pub fn query_cw20_tokens(deps: Deps) -> StdResult { }); } - to_binary(&cw20_responses) + to_json_binary(&cw20_responses) } pub fn query_native_entitlement(deps: Deps, sender: Addr, denom: String) -> StdResult { @@ -461,7 +461,7 @@ pub fn query_native_entitlement(deps: Deps, sender: Addr, denom: String) -> StdR total_bal.multiply_ratio(relative_share.numerator(), relative_share.denominator()); let entitlement = total_share.checked_sub(prev_claim)?; - to_binary(&NativeEntitlementResponse { + to_json_binary(&NativeEntitlementResponse { amount: entitlement, denom, }) @@ -483,7 +483,7 @@ pub fn query_cw20_entitlement(deps: Deps, sender: Addr, token: String) -> StdRes total_bal.multiply_ratio(relative_share.numerator(), relative_share.denominator()); let entitlement = total_share.checked_sub(prev_claim)?; - to_binary(&CW20EntitlementResponse { + to_json_binary(&CW20EntitlementResponse { amount: entitlement, token_contract: token, }) @@ -514,7 +514,7 @@ pub fn query_native_entitlements( }); } - to_binary(&entitlements) + to_json_binary(&entitlements) } pub fn query_cw20_entitlements( @@ -544,7 +544,7 @@ pub fn query_cw20_entitlements( }); } - to_binary(&entitlements) + to_json_binary(&entitlements) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/external/cw-fund-distributor/src/testing/adversarial_tests.rs b/contracts/external/cw-fund-distributor/src/testing/adversarial_tests.rs index ff07edbff..8df033529 100644 --- a/contracts/external/cw-fund-distributor/src/testing/adversarial_tests.rs +++ b/contracts/external/cw-fund-distributor/src/testing/adversarial_tests.rs @@ -1,6 +1,6 @@ use crate::msg::ExecuteMsg::ClaimAll; use crate::msg::{ExecuteMsg, InstantiateMsg}; -use cosmwasm_std::{to_binary, Addr, Binary, Coin, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Empty, Uint128}; use cw20::{BalanceResponse, Cw20Coin}; use cw_multi_test::{next_block, App, BankSudo, Contract, ContractWrapper, Executor, SudoMsg}; use cw_utils::Duration; @@ -127,7 +127,7 @@ fn setup_test(initial_balances: Vec) -> BaseTest { &cw20_base::msg::ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) diff --git a/contracts/external/cw-fund-distributor/src/testing/tests.rs b/contracts/external/cw-fund-distributor/src/testing/tests.rs index 6c3f2a254..544856b81 100644 --- a/contracts/external/cw-fund-distributor/src/testing/tests.rs +++ b/contracts/external/cw-fund-distributor/src/testing/tests.rs @@ -3,7 +3,7 @@ use crate::msg::{ NativeEntitlementResponse, QueryMsg, TotalPowerResponse, VotingContractResponse, }; use crate::ContractError; -use cosmwasm_std::{to_binary, Addr, Binary, Coin, Empty, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Empty, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, BankSudo, Contract, ContractWrapper, Executor, SudoMsg}; @@ -114,7 +114,7 @@ fn setup_test(initial_balances: Vec) -> BaseTest { &cw20_base::msg::ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -1044,7 +1044,7 @@ pub fn test_redistribute_unclaimed_funds() { WasmMsg::Migrate { contract_addr: distributor_address.to_string(), new_code_id: distributor_id, - msg: to_binary(migrate_msg).unwrap(), + msg: to_json_binary(migrate_msg).unwrap(), } .into(), ) @@ -1121,7 +1121,7 @@ pub fn test_unauthorized_redistribute_unclaimed_funds() { WasmMsg::Migrate { contract_addr: distributor_address.to_string(), new_code_id: distributor_id, - msg: to_binary(migrate_msg).unwrap(), + msg: to_json_binary(migrate_msg).unwrap(), } .into(), ) diff --git a/contracts/external/cw-payroll-factory/src/contract.rs b/contracts/external/cw-payroll-factory/src/contract.rs index aa7af2b65..aad8d44dc 100644 --- a/contracts/external/cw-payroll-factory/src/contract.rs +++ b/contracts/external/cw-payroll-factory/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Order, Reply, + from_json_binary, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Order, Reply, Response, StdResult, SubMsg, WasmMsg, }; use cosmwasm_std::{Addr, Coin}; @@ -72,7 +72,7 @@ pub fn execute_receive_cw20( // Only accepts cw20 tokens nonpayable(&info)?; - let msg: ReceiveMsg = from_binary(&receive_msg.msg)?; + let msg: ReceiveMsg = from_json_binary(&receive_msg.msg)?; if TMP_INSTANTIATOR_INFO.may_load(deps.storage)?.is_some() { return Err(ContractError::Reentrancy); @@ -147,7 +147,7 @@ pub fn instantiate_contract( let instantiate = WasmMsg::Instantiate { admin: instantiate_msg.owner.clone(), code_id, - msg: to_binary(&instantiate_msg)?, + msg: to_json_binary(&instantiate_msg)?, funds: funds.unwrap_or_default(), label, }; @@ -194,7 +194,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } QueryMsg::ListVestingContractsReverse { start_before, @@ -209,7 +209,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } QueryMsg::ListVestingContractsByInstantiator { instantiator, @@ -231,7 +231,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } QueryMsg::ListVestingContractsByInstantiatorReverse { instantiator, @@ -253,7 +253,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } QueryMsg::ListVestingContractsByRecipient { recipient, @@ -275,7 +275,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } QueryMsg::ListVestingContractsByRecipientReverse { recipient, @@ -297,10 +297,10 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { .flat_map(|vc| Ok::(vc?.1)) .collect(); - Ok(to_binary(&res)?) + Ok(to_json_binary(&res)?) } - QueryMsg::Ownership {} => to_binary(&cw_ownable::get_ownership(deps.storage)?), - QueryMsg::CodeId {} => to_binary(&VESTING_CODE_ID.load(deps.storage)?), + QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), + QueryMsg::CodeId {} => to_json_binary(&VESTING_CODE_ID.load(deps.storage)?), } } @@ -339,10 +339,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result StdResult { let counterparty_one = COUNTERPARTY_ONE.load(deps.storage)?; let counterparty_two = COUNTERPARTY_TWO.load(deps.storage)?; - to_binary(&StatusResponse { + to_json_binary(&StatusResponse { counterparty_one, counterparty_two, }) diff --git a/contracts/external/cw-token-swap/src/state.rs b/contracts/external/cw-token-swap/src/state.rs index 7ea5cd1a5..6f971629b 100644 --- a/contracts/external/cw-token-swap/src/state.rs +++ b/contracts/external/cw-token-swap/src/state.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, BankMsg, Coin, CosmosMsg, Deps, StdError, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Deps, StdError, Uint128, WasmMsg}; use cw_storage_plus::Item; use crate::{ @@ -85,7 +85,7 @@ impl CheckedTokenInfo { amount, } => WasmMsg::Execute { contract_addr: contract_addr.into_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: recipient.to_string(), amount, })?, @@ -133,7 +133,7 @@ mod tests { CosmosMsg::Wasm(WasmMsg::Execute { funds: vec![], contract_addr: "ekez_token".to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: "ekez".to_string(), amount: Uint128::new(100) }) diff --git a/contracts/external/cw-token-swap/src/tests.rs b/contracts/external/cw-token-swap/src/tests.rs index 7e6073f20..e2d2a9913 100644 --- a/contracts/external/cw-token-swap/src/tests.rs +++ b/contracts/external/cw-token-swap/src/tests.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ testing::{mock_dependencies, mock_env}, - to_binary, Addr, Coin, Empty, Uint128, + to_json_binary, Addr, Coin, Empty, Uint128, }; use cw20::Cw20Coin; use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor, SudoMsg}; @@ -95,7 +95,7 @@ fn test_simple_escrow() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -209,7 +209,7 @@ fn test_withdraw() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -380,7 +380,7 @@ fn test_withdraw_post_completion() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -618,7 +618,7 @@ fn test_fund_non_counterparty() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -714,7 +714,7 @@ fn test_fund_twice() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -763,7 +763,7 @@ fn test_fund_twice() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.into_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -835,7 +835,7 @@ fn test_fund_invalid_amount() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(10), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -1022,7 +1022,7 @@ fn test_fund_invalid_cw20() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -1041,7 +1041,7 @@ fn test_fund_invalid_cw20() { &cw20::Cw20ExecuteMsg::Send { contract: escrow.to_string(), amount: Uint128::new(100), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) diff --git a/contracts/external/cw-tokenfactory-issuer/src/contract.rs b/contracts/external/cw-tokenfactory-issuer/src/contract.rs index 2883087c6..2a5039afe 100644 --- a/contracts/external/cw-tokenfactory-issuer/src/contract.rs +++ b/contracts/external/cw-tokenfactory-issuer/src/contract.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, }; use cosmwasm_std::{CosmosMsg, Reply}; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -133,30 +133,30 @@ pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> Result StdResult { match msg { QueryMsg::Allowlist { start_after, limit } => { - to_binary(&queries::query_allowlist(deps, start_after, limit)?) + to_json_binary(&queries::query_allowlist(deps, start_after, limit)?) } QueryMsg::BeforeSendHookInfo {} => { - to_binary(&queries::query_before_send_hook_features(deps)?) + to_json_binary(&queries::query_before_send_hook_features(deps)?) } QueryMsg::BurnAllowance { address } => { - to_binary(&queries::query_burn_allowance(deps, address)?) + to_json_binary(&queries::query_burn_allowance(deps, address)?) } QueryMsg::BurnAllowances { start_after, limit } => { - to_binary(&queries::query_burn_allowances(deps, start_after, limit)?) + to_json_binary(&queries::query_burn_allowances(deps, start_after, limit)?) } - QueryMsg::Denom {} => to_binary(&queries::query_denom(deps)?), + QueryMsg::Denom {} => to_json_binary(&queries::query_denom(deps)?), QueryMsg::Denylist { start_after, limit } => { - to_binary(&queries::query_denylist(deps, start_after, limit)?) + to_json_binary(&queries::query_denylist(deps, start_after, limit)?) } - QueryMsg::IsAllowed { address } => to_binary(&queries::query_is_allowed(deps, address)?), - QueryMsg::IsDenied { address } => to_binary(&queries::query_is_denied(deps, address)?), - QueryMsg::IsFrozen {} => to_binary(&queries::query_is_frozen(deps)?), - QueryMsg::Ownership {} => to_binary(&queries::query_owner(deps)?), + QueryMsg::IsAllowed { address } => to_json_binary(&queries::query_is_allowed(deps, address)?), + QueryMsg::IsDenied { address } => to_json_binary(&queries::query_is_denied(deps, address)?), + QueryMsg::IsFrozen {} => to_json_binary(&queries::query_is_frozen(deps)?), + QueryMsg::Ownership {} => to_json_binary(&queries::query_owner(deps)?), QueryMsg::MintAllowance { address } => { - to_binary(&queries::query_mint_allowance(deps, address)?) + to_json_binary(&queries::query_mint_allowance(deps, address)?) } QueryMsg::MintAllowances { start_after, limit } => { - to_binary(&queries::query_mint_allowances(deps, start_after, limit)?) + to_json_binary(&queries::query_mint_allowances(deps, start_after, limit)?) } } } diff --git a/contracts/external/cw-vesting/src/contract.rs b/contracts/external/cw-vesting/src/contract.rs index 70c0cea96..eddfe51bc 100644 --- a/contracts/external/cw-vesting/src/contract.rs +++ b/contracts/external/cw-vesting/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Binary, Coin, CosmosMsg, DelegationResponse, Deps, DepsMut, + from_json_binary, to_json_binary, Binary, Coin, CosmosMsg, DelegationResponse, Deps, DepsMut, DistributionMsg, Env, MessageInfo, Response, StakingMsg, StakingQuery, StdResult, Timestamp, Uint128, }; @@ -137,7 +137,7 @@ pub fn execute_receive_cw20( // Only accepts cw20 tokens nonpayable(&info)?; - let msg: ReceiveMsg = from_binary(&receive_msg.msg)?; + let msg: ReceiveMsg = from_json_binary(&receive_msg.msg)?; match msg { ReceiveMsg::Fund {} => { @@ -446,20 +446,20 @@ pub fn execute_register_slash( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::Ownership {} => to_binary(&cw_ownable::get_ownership(deps.storage)?), - QueryMsg::Info {} => to_binary(&PAYMENT.get_vest(deps.storage)?), - QueryMsg::Distributable { t } => to_binary(&PAYMENT.distributable( + QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), + QueryMsg::Info {} => to_json_binary(&PAYMENT.get_vest(deps.storage)?), + QueryMsg::Distributable { t } => to_json_binary(&PAYMENT.distributable( deps.storage, &PAYMENT.get_vest(deps.storage)?, t.unwrap_or(env.block.time), )?), QueryMsg::Stake(q) => PAYMENT.query_stake(deps.storage, q), - QueryMsg::Vested { t } => to_binary( + QueryMsg::Vested { t } => to_json_binary( &PAYMENT .get_vest(deps.storage)? .vested(t.unwrap_or(env.block.time)), ), - QueryMsg::TotalToVest {} => to_binary(&PAYMENT.get_vest(deps.storage)?.total()), - QueryMsg::VestDuration {} => to_binary(&PAYMENT.duration(deps.storage)?), + QueryMsg::TotalToVest {} => to_json_binary(&PAYMENT.get_vest(deps.storage)?.total()), + QueryMsg::VestDuration {} => to_json_binary(&PAYMENT.duration(deps.storage)?), } } diff --git a/contracts/external/cw-vesting/src/tests.rs b/contracts/external/cw-vesting/src/tests.rs index c9f78099c..bff5f8f11 100644 --- a/contracts/external/cw-vesting/src/tests.rs +++ b/contracts/external/cw-vesting/src/tests.rs @@ -1,5 +1,5 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; -use cosmwasm_std::{coins, to_binary, Addr, Coin, Decimal, Empty, Uint128, Validator}; +use cosmwasm_std::{coins, to_json_binary, Addr, Coin, Decimal, Empty, Uint128, Validator}; use cw20::{Cw20Coin, Cw20ExecuteMsg, Cw20ReceiveMsg}; use cw_denom::{CheckedDenom, UncheckedDenom}; use cw_multi_test::{ @@ -170,7 +170,7 @@ fn setup_test_case(app: &mut App, msg: InstantiateMsg, funds: &[Coin]) -> TestCa let msg = Cw20ExecuteMsg::Send { contract: cw_vesting_addr.to_string(), amount: msg.total, - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }; app.execute_contract( Addr::unchecked(OWNER), @@ -509,7 +509,7 @@ fn test_catch_imposter_cw20() { let msg = Cw20ExecuteMsg::Send { contract: cw_vesting_addr.to_string(), amount: Uint128::new(TOTAL_VEST), - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }; // Errors that cw20 does not match what was expected @@ -595,7 +595,7 @@ fn test_execution_rejection_recv() { Cw20ReceiveMsg { sender: "random".to_string(), amount: Uint128::new(100), - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }, ) .unwrap_err(); @@ -608,7 +608,7 @@ fn test_execution_rejection_recv() { Cw20ReceiveMsg { sender: "random".to_string(), amount: Uint128::new(101), - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }, ) .unwrap_err(); diff --git a/contracts/external/cw721-roles/src/contract.rs b/contracts/external/cw721-roles/src/contract.rs index 2fc13bc37..6d087c578 100644 --- a/contracts/external/cw721-roles/src/contract.rs +++ b/contracts/external/cw721-roles/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Order, Response, + from_json_binary, to_json_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Order, Response, StdResult, SubMsg, Uint64, }; use cw4::{ @@ -154,7 +154,7 @@ pub fn execute_burn( token_id: String, ) -> Result { // Lookup the owner of the NFT - let owner: OwnerOfResponse = from_binary(&Cw721Roles::default().query( + let owner: OwnerOfResponse = from_json_binary(&Cw721Roles::default().query( deps.as_ref(), env.clone(), QueryMsg::OwnerOf { @@ -164,7 +164,7 @@ pub fn execute_burn( )?)?; // Get the weight of the token - let nft_info: NftInfoResponse = from_binary(&Cw721Roles::default().query( + let nft_info: NftInfoResponse = from_json_binary(&Cw721Roles::default().query( deps.as_ref(), env.clone(), QueryMsg::NftInfo { @@ -438,14 +438,14 @@ pub fn execute_update_token_weight( pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::Extension { msg } => match msg { - QueryExt::Hooks {} => to_binary(&HOOKS.query_hooks(deps)?), + QueryExt::Hooks {} => to_json_binary(&HOOKS.query_hooks(deps)?), QueryExt::ListMembers { start_after, limit } => { - to_binary(&query_list_members(deps, start_after, limit)?) + to_json_binary(&query_list_members(deps, start_after, limit)?) } QueryExt::Member { addr, at_height } => { - to_binary(&query_member(deps, addr, at_height)?) + to_json_binary(&query_member(deps, addr, at_height)?) } - QueryExt::TotalWeight { at_height } => to_binary(&query_total_weight(deps, at_height)?), + QueryExt::TotalWeight { at_height } => to_json_binary(&query_total_weight(deps, at_height)?), }, _ => Cw721Roles::default().query(deps, env, msg), } diff --git a/contracts/external/cw721-roles/src/tests.rs b/contracts/external/cw721-roles/src/tests.rs index 0783af57a..005c2e61f 100644 --- a/contracts/external/cw721-roles/src/tests.rs +++ b/contracts/external/cw721-roles/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Binary}; +use cosmwasm_std::{to_json_binary, Addr, Binary}; use cw4::{HooksResponse, Member, MemberListResponse, MemberResponse, TotalWeightResponse}; use cw721::{NftInfoResponse, OwnerOfResponse}; use cw_multi_test::{App, Executor}; @@ -276,7 +276,7 @@ fn test_send_permissions() { let msg = ExecuteMsg::SendNft { contract: cw721_staked_addr.to_string(), token_id: "1".to_string(), - msg: to_binary(&Binary::default()).unwrap(), + msg: to_json_binary(&Binary::default()).unwrap(), }; app.execute_contract(Addr::unchecked(ALICE), cw721_addr.clone(), &msg, &[]) .unwrap_err(); diff --git a/contracts/external/dao-migrator/src/contract.rs b/contracts/external/dao-migrator/src/contract.rs index ae91152d5..55c6beb5f 100644 --- a/contracts/external/dao-migrator/src/contract.rs +++ b/contracts/external/dao-migrator/src/contract.rs @@ -3,7 +3,7 @@ use std::{collections::HashSet, env}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, + to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg, WasmMsg, }; use cw2::set_contract_version; @@ -42,10 +42,10 @@ pub fn instantiate( CORE_ADDR.save(deps.storage, &info.sender)?; Ok( - Response::default().set_data(to_binary(&ModuleInstantiateCallback { + Response::default().set_data(to_json_binary(&ModuleInstantiateCallback { msgs: vec![WasmMsg::Execute { contract_addr: env.contract.address.to_string(), - msg: to_binary(&MigrateV1ToV2 { + msg: to_json_binary(&MigrateV1ToV2 { sub_daos: msg.sub_daos, migration_params: msg.migration_params, v1_code_ids: msg.v1_code_ids, @@ -168,7 +168,7 @@ fn execute_migration_v1_v2( WasmMsg::Migrate { contract_addr: voting_module.to_string(), new_code_id: voting_pair.v2_code_id, - msg: to_binary(&voting_pair.migrate_msg).unwrap(), + msg: to_json_binary(&voting_pair.migrate_msg).unwrap(), } .into(), ); @@ -212,7 +212,7 @@ fn execute_migration_v1_v2( WasmMsg::Migrate { contract_addr: cw20_staked_addr.to_string(), new_code_id: staking_pair.v2_code_id, - msg: to_binary(&staking_pair.migrate_msg).unwrap(), + msg: to_json_binary(&staking_pair.migrate_msg).unwrap(), } .into(), ); @@ -276,7 +276,7 @@ fn execute_migration_v1_v2( WasmMsg::Migrate { contract_addr: module.address.to_string(), new_code_id: proposal_pair.v2_code_id, - msg: to_binary(&proposal_pair.migrate_msg).unwrap(), + msg: to_json_binary(&proposal_pair.migrate_msg).unwrap(), } .into(), ); @@ -305,7 +305,7 @@ fn execute_migration_v1_v2( msgs.push( WasmMsg::Execute { contract_addr: info.sender.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::UpdateSubDaos { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::UpdateSubDaos { to_add: sub_daos, to_remove: vec![], })?, @@ -318,7 +318,7 @@ fn execute_migration_v1_v2( let proposal_hook_msg = SubMsg::reply_on_success( WasmMsg::Execute { contract_addr: info.sender.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, funds: vec![], }, V1_V2_REPLY_ID, @@ -345,10 +345,10 @@ pub fn reply(deps: DepsMut, env: Env, reply: Reply) -> Result (Addr, V let (voting_code_id, msg) = match voting_type { VotingType::Cw4 => ( code_ids.cw4_voting, - to_binary(&get_cw4_init_msg(code_ids.clone())).unwrap(), + to_json_binary(&get_cw4_init_msg(code_ids.clone())).unwrap(), ), VotingType::Cw20 => ( code_ids.cw20_voting, - to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), + to_json_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 @@ -35,7 +35,7 @@ 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(), + to_json_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), ) } }; @@ -59,7 +59,7 @@ pub fn init_v1(app: &mut App, sender: Addr, voting_type: VotingType) -> (Addr, V }, proposal_modules_instantiate_info: vec![cw_core_v1::msg::ModuleInstantiateInfo { code_id: code_ids.proposal_single, - msg: to_binary(&cw_proposal_single_v1::msg::InstantiateMsg { + msg: to_json_binary(&cw_proposal_single_v1::msg::InstantiateMsg { threshold: voting_v1::Threshold::AbsolutePercentage { percentage: voting_v1::PercentageThreshold::Majority {}, }, @@ -109,11 +109,11 @@ pub fn init_v1_with_multiple_proposals( let (voting_code_id, msg) = match voting_type { VotingType::Cw4 => ( code_ids.cw4_voting, - to_binary(&get_cw4_init_msg(code_ids.clone())).unwrap(), + to_json_binary(&get_cw4_init_msg(code_ids.clone())).unwrap(), ), VotingType::Cw20 => ( code_ids.cw20_voting, - to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), + to_json_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), ), VotingType::Cw20V03 => { let v03_cw20_stake = app.store_code(stake_cw20_v03_contract()); @@ -122,7 +122,7 @@ pub fn init_v1_with_multiple_proposals( ( code_ids.cw20_voting, - to_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), + to_json_binary(&get_cw20_init_msg(code_ids.clone())).unwrap(), ) } }; @@ -147,7 +147,7 @@ pub fn init_v1_with_multiple_proposals( proposal_modules_instantiate_info: vec![ cw_core_v1::msg::ModuleInstantiateInfo { code_id: code_ids.proposal_single, - msg: to_binary(&cw_proposal_single_v1::msg::InstantiateMsg { + msg: to_json_binary(&cw_proposal_single_v1::msg::InstantiateMsg { threshold: voting_v1::Threshold::AbsolutePercentage { percentage: voting_v1::PercentageThreshold::Majority {}, }, @@ -163,7 +163,7 @@ pub fn init_v1_with_multiple_proposals( }, cw_core_v1::msg::ModuleInstantiateInfo { code_id: code_ids.proposal_single, - msg: to_binary(&cw_proposal_single_v1::msg::InstantiateMsg { + msg: to_json_binary(&cw_proposal_single_v1::msg::InstantiateMsg { threshold: voting_v1::Threshold::AbsolutePercentage { percentage: voting_v1::PercentageThreshold::Majority {}, }, @@ -291,7 +291,7 @@ pub fn execute_migration( WasmMsg::Migrate { contract_addr: module_addrs.core.to_string(), new_code_id: new_code_ids.core, - msg: to_binary(&dao_interface::msg::MigrateMsg::FromV1 { + msg: to_json_binary(&dao_interface::msg::MigrateMsg::FromV1 { dao_uri: None, params: None, }) @@ -300,10 +300,10 @@ pub fn execute_migration( .into(), WasmMsg::Execute { contract_addr: module_addrs.core.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::UpdateProposalModules { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::UpdateProposalModules { to_add: vec![ModuleInstantiateInfo { code_id: migrator_code_id, - msg: to_binary(&crate::msg::InstantiateMsg { + msg: to_json_binary(&crate::msg::InstantiateMsg { sub_daos: params.sub_daos.unwrap(), migration_params: MigrationParams { migrate_stake_cw20_manager: params.migrate_cw20, @@ -398,7 +398,7 @@ 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_binary(&dao_interface::msg::MigrateMsg::FromV1 { + msg: to_json_binary(&dao_interface::msg::MigrateMsg::FromV1 { dao_uri: None, params: Some(dao_interface::migrate_msg::MigrateParams { migrator_code_id, diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/src/contract.rs b/contracts/pre-propose/dao-pre-propose-approval-single/src/contract.rs index a0ad2b764..9de5f586f 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/src/contract.rs +++ b/contracts/pre-propose/dao-pre-propose-approval-single/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Order, Response, StdResult, SubMsg, + to_json_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Order, Response, StdResult, SubMsg, WasmMsg, }; use cw2::set_contract_version; @@ -107,7 +107,7 @@ pub fn execute_propose( .prepare_hooks(deps.storage, |a| { let execute_msg = WasmMsg::Execute { contract_addr: a.into_string(), - msg: to_binary(&ExecuteBase::::Propose { + msg: to_json_binary(&ExecuteBase::::Propose { msg: ApproverProposeMessage::Propose { title: propose_msg_internal.title.clone(), description: propose_msg_internal.description.clone(), @@ -169,7 +169,7 @@ pub fn execute_approve( let propose_messsage = WasmMsg::Execute { contract_addr: proposal_module.into_string(), - msg: to_binary(&ProposeMessageInternal::Propose(proposal.msg))?, + msg: to_json_binary(&ProposeMessageInternal::Propose(proposal.msg))?, funds: vec![], }; PENDING_PROPOSALS.remove(deps.storage, id); @@ -221,7 +221,7 @@ pub fn execute_reject( Ok(Response::default() .add_attribute("method", "proposal_rejected") .add_attribute("proposal", id.to_string()) - .add_attribute("deposit_info", to_binary(&deposit)?.to_string()) + .add_attribute("deposit_info", to_json_binary(&deposit)?.to_string()) .add_messages(messages)) } @@ -296,11 +296,11 @@ pub fn execute_remove_approver_hook( pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::QueryExtension { msg } => match msg { - QueryExt::Approver {} => to_binary(&APPROVER.load(deps.storage)?), + QueryExt::Approver {} => to_json_binary(&APPROVER.load(deps.storage)?), QueryExt::PendingProposal { id } => { - to_binary(&PENDING_PROPOSALS.load(deps.storage, id)?) + to_json_binary(&PENDING_PROPOSALS.load(deps.storage, id)?) } - QueryExt::PendingProposals { start_after, limit } => to_binary(&paginate_map_values( + QueryExt::PendingProposals { start_after, limit } => to_json_binary(&paginate_map_values( deps, &PENDING_PROPOSALS, start_after, @@ -310,7 +310,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { QueryExt::ReversePendingProposals { start_before, limit, - } => to_binary(&paginate_map_values( + } => to_json_binary(&paginate_map_values( deps, &PENDING_PROPOSALS, start_before, diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs index cf6eaf5ca..a53aeddd8 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coins, from_slice, to_binary, Addr, Coin, Empty, Uint128}; +use cosmwasm_std::{coins, from_slice, to_json_binary, Addr, Coin, Empty, Uint128}; use cw2::ContractVersion; use cw20::Cw20Coin; use cw_denom::UncheckedDenom; @@ -62,7 +62,7 @@ fn get_default_proposal_module_instantiate( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info, open_proposal_submission, extension: InstantiateExt { @@ -122,7 +122,7 @@ fn setup_default_test( let core_addr = instantiate_with_cw4_groups_governance( app, dao_proposal_single_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -1186,7 +1186,7 @@ fn test_instantiate_with_zero_native_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Native("ujuno".to_string()), @@ -1213,7 +1213,7 @@ fn test_instantiate_with_zero_native_deposit() { instantiate_with_cw4_groups_governance( &mut app, dao_proposal_single_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -1250,7 +1250,7 @@ fn test_instantiate_with_zero_cw20_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Cw20(cw20_addr.into_string()), @@ -1277,7 +1277,7 @@ fn test_instantiate_with_zero_cw20_deposit() { instantiate_with_cw4_groups_governance( &mut app, dao_proposal_single_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs b/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs index c1e52ecd3..193a63216 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, + to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, WasmMsg, }; use cw2::set_contract_version; @@ -50,18 +50,18 @@ pub fn instantiate( let addr = deps.api.addr_validate(&msg.pre_propose_approval_contract)?; PRE_PROPOSE_APPROVAL_CONTRACT.save(deps.storage, &addr)?; - Ok(resp.set_data(to_binary(&ModuleInstantiateCallback { + Ok(resp.set_data(to_json_binary(&ModuleInstantiateCallback { msgs: vec![ CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: addr.to_string(), - msg: to_binary(&PreProposeApprovalExecuteMsg::AddProposalSubmittedHook { + msg: to_json_binary(&PreProposeApprovalExecuteMsg::AddProposalSubmittedHook { address: env.contract.address.to_string(), })?, funds: vec![], }), CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: addr.to_string(), - msg: to_binary(&PreProposeApprovalExecuteMsg::Extension { + msg: to_json_binary(&PreProposeApprovalExecuteMsg::Extension { msg: ApprovalExt::UpdateApprover { address: env.contract.address.to_string(), }, @@ -128,7 +128,7 @@ pub fn execute_propose( let propose_messsage = WasmMsg::Execute { contract_addr: proposal_module.into_string(), - msg: to_binary(&sanitized_msg)?, + msg: to_json_binary(&sanitized_msg)?, funds: vec![], }; Ok(Response::default().add_message(propose_messsage)) @@ -156,14 +156,14 @@ pub fn execute_proposal_completed( let msg = match new_status { Status::Closed => Some(WasmMsg::Execute { contract_addr: approval_contract.into_string(), - msg: to_binary(&PreProposeApprovalExecuteMsg::Extension { + msg: to_json_binary(&PreProposeApprovalExecuteMsg::Extension { msg: ApprovalExt::Reject { id: pre_propose_id }, })?, funds: vec![], }), Status::Executed => Some(WasmMsg::Execute { contract_addr: approval_contract.into_string(), - msg: to_binary(&PreProposeApprovalExecuteMsg::Extension { + msg: to_json_binary(&PreProposeApprovalExecuteMsg::Extension { msg: ApprovalExt::Approve { id: pre_propose_id }, })?, funds: vec![], @@ -186,7 +186,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::QueryExtension { msg } => match msg { QueryExt::PreProposeApprovalContract {} => { - to_binary(&PRE_PROPOSE_APPROVAL_CONTRACT.load(deps.storage)?) + to_json_binary(&PRE_PROPOSE_APPROVAL_CONTRACT.load(deps.storage)?) } }, _ => PrePropose::default().query(deps, env, msg), diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs index a52c91042..f36996207 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coins, from_slice, to_binary, Addr, Coin, Empty, Uint128}; +use cosmwasm_std::{coins, from_slice, to_json_binary, Addr, Coin, Empty, Uint128}; use cw2::ContractVersion; use cw20::Cw20Coin; use cw_denom::UncheckedDenom; @@ -86,7 +86,7 @@ fn get_proposal_module_approval_single_instantiate( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info, open_proposal_submission, extension: InstantiateExt { @@ -122,7 +122,7 @@ fn get_proposal_module_approver_instantiate( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&ApproverInstantiateMsg { + msg: to_json_binary(&ApproverInstantiateMsg { pre_propose_approval_contract, }) .unwrap(), @@ -184,7 +184,7 @@ fn setup_default_test( let core_addr = instantiate_with_cw4_groups_governance( app, dps_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -238,7 +238,7 @@ fn setup_default_test( let _approver_core_addr = instantiate_with_cw4_groups_governance( app, dps_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), diff --git a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs index 2de6ee79c..e70816c3a 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coins, from_slice, to_binary, Addr, Coin, Decimal, Empty, Uint128}; +use cosmwasm_std::{coins, from_slice, to_json_binary, Addr, Coin, Decimal, Empty, Uint128}; use cpm::query::ProposalResponse; use cw2::ContractVersion; use cw20::Cw20Coin; @@ -65,7 +65,7 @@ fn get_default_proposal_module_instantiate( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info, open_proposal_submission, extension: Empty::default(), @@ -122,7 +122,7 @@ fn setup_default_test( let core_addr = instantiate_with_cw4_groups_governance( app, cpm_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -1047,7 +1047,7 @@ fn test_instantiate_with_zero_native_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Native("ujuno".to_string()), @@ -1072,7 +1072,7 @@ fn test_instantiate_with_zero_native_deposit() { instantiate_with_cw4_groups_governance( &mut app, cpm_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -1109,7 +1109,7 @@ fn test_instantiate_with_zero_cw20_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Cw20(cw20_addr.into_string()), @@ -1134,7 +1134,7 @@ fn test_instantiate_with_zero_cw20_deposit() { instantiate_with_cw4_groups_governance( &mut app, cpm_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), diff --git a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs index fefc69fc3..5927603af 100644 --- a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coins, from_slice, to_binary, Addr, Coin, Empty, Uint128}; +use cosmwasm_std::{coins, from_slice, to_json_binary, Addr, Coin, Empty, Uint128}; use cw2::ContractVersion; use cw20::Cw20Coin; use cw_denom::UncheckedDenom; @@ -63,7 +63,7 @@ fn get_default_proposal_module_instantiate( pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info, open_proposal_submission, extension: Empty::default(), @@ -120,7 +120,7 @@ fn setup_default_test( let core_addr = instantiate_with_cw4_groups_governance( app, dps_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -983,7 +983,7 @@ fn test_instantiate_with_zero_native_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Native("ujuno".to_string()), @@ -1008,7 +1008,7 @@ fn test_instantiate_with_zero_native_deposit() { instantiate_with_cw4_groups_governance( &mut app, dps_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), @@ -1045,7 +1045,7 @@ fn test_instantiate_with_zero_cw20_deposit() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: DepositToken::Token { denom: UncheckedDenom::Cw20(cw20_addr.into_string()), @@ -1070,7 +1070,7 @@ fn test_instantiate_with_zero_cw20_deposit() { instantiate_with_cw4_groups_governance( &mut app, dps_id, - to_binary(&proposal_module_instantiate).unwrap(), + to_json_binary(&proposal_module_instantiate).unwrap(), Some(vec![ cw20::Cw20Coin { address: "ekez".to_string(), diff --git a/contracts/proposal/dao-proposal-condorcet/src/contract.rs b/contracts/proposal/dao-proposal-condorcet/src/contract.rs index a29603609..f6b5406f3 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/contract.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, }; use cw2::set_contract_version; @@ -252,12 +252,12 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { let mut proposal = PROPOSAL.load(deps.storage, id)?; let tally = TALLY.load(deps.storage, id)?; proposal.update_status(&env.block, &tally); - to_binary(&ProposalResponse { proposal, tally }) + to_json_binary(&ProposalResponse { proposal, tally }) } - QueryMsg::Config {} => to_binary(&CONFIG.load(deps.storage)?), - QueryMsg::NextProposalId {} => to_binary(&next_proposal_id(deps.storage)?), - QueryMsg::Dao {} => to_binary(&DAO.load(deps.storage)?), - QueryMsg::Info {} => to_binary(&dao_interface::voting::InfoResponse { + QueryMsg::Config {} => to_json_binary(&CONFIG.load(deps.storage)?), + QueryMsg::NextProposalId {} => to_json_binary(&next_proposal_id(deps.storage)?), + QueryMsg::Dao {} => to_json_binary(&DAO.load(deps.storage)?), + QueryMsg::Info {} => to_json_binary(&dao_interface::voting::InfoResponse { info: cw2::get_contract_version(deps.storage)?, }), } diff --git a/contracts/proposal/dao-proposal-condorcet/src/proposal.rs b/contracts/proposal/dao-proposal-condorcet/src/proposal.rs index 155b90cc2..bd2f82486 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/proposal.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/proposal.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, BlockInfo, StdResult, SubMsg, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, BlockInfo, StdResult, SubMsg, Uint128, WasmMsg}; use cw_utils::Expiration; use dao_voting::{ reply::mask_proposal_execution_proposal_id, threshold::PercentageThreshold, @@ -161,7 +161,7 @@ impl Proposal { let msgs = self.choices[winner as usize].msgs.clone(); let core_exec = WasmMsg::Execute { contract_addr: dao.into_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, funds: vec![], }; Ok(if self.close_on_execution_failure { diff --git a/contracts/proposal/dao-proposal-condorcet/src/testing/proposals.rs b/contracts/proposal/dao-proposal-condorcet/src/testing/proposals.rs index 151790ef8..6c39f4b6e 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/testing/proposals.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/testing/proposals.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, WasmMsg}; +use cosmwasm_std::{to_json_binary, WasmMsg}; use cw_utils::Duration; use crate::{ @@ -171,7 +171,7 @@ fn test_proposal_set_config() { suite.sender(), vec![vec![WasmMsg::Execute { contract_addr: suite.condorcet.to_string(), - msg: to_binary(&ExecuteMsg::SetConfig(UncheckedConfig { + msg: to_json_binary(&ExecuteMsg::SetConfig(UncheckedConfig { quorum: config.quorum, voting_period: config.voting_period, min_voting_period: None, @@ -194,7 +194,7 @@ fn test_proposal_set_config() { suite.sender(), vec![vec![WasmMsg::Execute { contract_addr: suite.condorcet.to_string(), - msg: to_binary(&ExecuteMsg::SetConfig(UncheckedConfig { + msg: to_json_binary(&ExecuteMsg::SetConfig(UncheckedConfig { quorum: config.quorum, voting_period: config.voting_period, min_voting_period: Some(Duration::Height(10)), diff --git a/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs b/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs index 9f9f945be..79d18154f 100644 --- a/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs +++ b/contracts/proposal/dao-proposal-condorcet/src/testing/suite.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coins, to_binary, Addr, BankMsg, CosmosMsg, Decimal}; +use cosmwasm_std::{coins, to_json_binary, Addr, BankMsg, CosmosMsg, Decimal}; use cw_multi_test::{next_block, App, Executor}; use cw_utils::Duration; use dao_interface::{ @@ -88,7 +88,7 @@ impl SuiteBuilder { automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw4_voting_id, - msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw4::msg::InstantiateMsg { group_contract: GroupContract::New { cw4_group_code_id: cw4_id, initial_members, @@ -101,7 +101,7 @@ impl SuiteBuilder { }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: condorcet_id, - msg: to_binary(&self.instantiate).unwrap(), + msg: to_json_binary(&self.instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "condorcet module".to_string(), diff --git a/contracts/proposal/dao-proposal-multiple/src/contract.rs b/contracts/proposal/dao-proposal-multiple/src/contract.rs index 2308858d3..96097ebc2 100644 --- a/contracts/proposal/dao-proposal-multiple/src/contract.rs +++ b/contracts/proposal/dao-proposal-multiple/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, + to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, Storage, SubMsg, WasmMsg, }; @@ -400,7 +400,7 @@ pub fn execute_execute( let response = if !winning_choice.msgs.is_empty() { let execute_message = WasmMsg::Execute { contract_addr: config.dao.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs: winning_choice.msgs, })?, funds: vec![], @@ -432,7 +432,7 @@ pub fn execute_execute( let hooks = match proposal_creation_policy { ProposalCreationPolicy::Anyone {} => hooks, ProposalCreationPolicy::Module { addr } => { - let msg = to_binary(&PreProposeMsg::ProposalCompletedHook { + let msg = to_json_binary(&PreProposeMsg::ProposalCompletedHook { proposal_id, new_status: prop.status, })?; @@ -491,7 +491,7 @@ pub fn execute_close( let hooks = match proposal_creation_policy { ProposalCreationPolicy::Anyone {} => hooks, ProposalCreationPolicy::Module { addr } => { - let msg = to_binary(&PreProposeMsg::ProposalCompletedHook { + let msg = to_json_binary(&PreProposeMsg::ProposalCompletedHook { proposal_id, new_status: prop.status, })?; @@ -746,30 +746,30 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { limit, } => query_reverse_proposals(deps, env, start_before, limit), QueryMsg::ProposalCreationPolicy {} => query_creation_policy(deps), - QueryMsg::ProposalHooks {} => to_binary(&PROPOSAL_HOOKS.query_hooks(deps)?), - QueryMsg::VoteHooks {} => to_binary(&VOTE_HOOKS.query_hooks(deps)?), + QueryMsg::ProposalHooks {} => to_json_binary(&PROPOSAL_HOOKS.query_hooks(deps)?), + QueryMsg::VoteHooks {} => to_json_binary(&VOTE_HOOKS.query_hooks(deps)?), QueryMsg::Dao {} => query_dao(deps), } } pub fn query_config(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config) + to_json_binary(&config) } pub fn query_dao(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config.dao) + to_json_binary(&config.dao) } pub fn query_proposal(deps: Deps, env: Env, id: u64) -> StdResult { let proposal = PROPOSALS.load(deps.storage, id)?; - to_binary(&proposal.into_response(&env.block, id)?) + to_json_binary(&proposal.into_response(&env.block, id)?) } pub fn query_creation_policy(deps: Deps) -> StdResult { let policy = CREATION_POLICY.load(deps.storage)?; - to_binary(&policy) + to_json_binary(&policy) } pub fn query_list_proposals( @@ -788,7 +788,7 @@ pub fn query_list_proposals( .map(|(id, proposal)| proposal.into_response(&env.block, id)) .collect::>>()?; - to_binary(&ProposalListResponse { proposals: props }) + to_json_binary(&ProposalListResponse { proposals: props }) } pub fn query_reverse_proposals( @@ -807,16 +807,16 @@ pub fn query_reverse_proposals( .map(|(id, proposal)| proposal.into_response(&env.block, id)) .collect::>>()?; - to_binary(&ProposalListResponse { proposals: props }) + to_json_binary(&ProposalListResponse { proposals: props }) } pub fn query_next_proposal_id(deps: Deps) -> StdResult { - to_binary(&next_proposal_id(deps.storage)?) + to_json_binary(&next_proposal_id(deps.storage)?) } pub fn query_proposal_count(deps: Deps) -> StdResult { let proposal_count = PROPOSAL_COUNT.load(deps.storage)?; - to_binary(&proposal_count) + to_json_binary(&proposal_count) } pub fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult { @@ -828,7 +828,7 @@ pub fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult>>()?; - to_binary(&VoteListResponse { votes }) + to_json_binary(&VoteListResponse { votes }) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/proposal/dao-proposal-multiple/src/testing/adversarial_tests.rs b/contracts/proposal/dao-proposal-multiple/src/testing/adversarial_tests.rs index fe09e69d1..11f052cd6 100644 --- a/contracts/proposal/dao-proposal-multiple/src/testing/adversarial_tests.rs +++ b/contracts/proposal/dao-proposal-multiple/src/testing/adversarial_tests.rs @@ -9,7 +9,7 @@ use crate::testing::queries::{ }; use crate::testing::tests::{get_pre_propose_info, ALTERNATIVE_ADDR, CREATOR_ADDR}; use crate::ContractError; -use cosmwasm_std::{to_binary, Addr, CosmosMsg, Decimal, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, Decimal, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, Executor}; use cw_utils::Duration; @@ -307,7 +307,7 @@ pub fn test_allow_voting_after_proposal_execution_pre_expiration_cw20() { recipient: CREATOR_ADDR.to_string(), amount: Uint128::new(100_000_000), }; - let binary_msg = to_binary(&msg).unwrap(); + let binary_msg = to_json_binary(&msg).unwrap(); let options = vec![ MultipleChoiceOption { diff --git a/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs b/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs index f6188a6f0..3a0dc89e2 100644 --- a/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs +++ b/contracts/proposal/dao-proposal-multiple/src/testing/instantiate.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Coin, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, Coin, Empty, Uint128}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, BankSudo, ContractWrapper, Executor, SudoMsg}; use cw_utils::Duration; @@ -32,7 +32,7 @@ fn get_pre_propose_info( PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_contract, - msg: to_binary(&cppm::InstantiateMsg { + msg: to_json_binary(&cppm::InstantiateMsg { deposit_info, open_proposal_submission, extension: Empty::default(), @@ -148,7 +148,7 @@ pub fn _instantiate_with_staked_cw721_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw721_stake_id, - msg: to_binary(&dao_voting_cw721_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw721_staked::msg::InstantiateMsg { unstaking_duration: None, nft_contract: dao_voting_cw721_staked::msg::NftContract::Existing { address: nft_address.to_string(), @@ -162,7 +162,7 @@ pub fn _instantiate_with_staked_cw721_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -211,7 +211,7 @@ pub fn _instantiate_with_staked_cw721_governance( &cw721_base::msg::ExecuteMsg::, Empty>::SendNft { contract: staking_addr.to_string(), token_id: format!("{address}_{i}"), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -267,7 +267,7 @@ pub fn _instantiate_with_native_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: native_stake_id, - msg: to_binary(&dao_voting_token_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_token_staked::msg::InstantiateMsg { token_info: dao_voting_token_staked::msg::TokenInfo::Existing { denom: "ujuno".to_string(), }, @@ -281,7 +281,7 @@ pub fn _instantiate_with_native_staked_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -379,7 +379,7 @@ pub fn instantiate_with_cw20_balances_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { token_info: dao_voting_cw20_balance::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -397,7 +397,7 @@ pub fn instantiate_with_cw20_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -461,7 +461,7 @@ pub fn instantiate_with_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: staked_balances_voting_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: None, token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, @@ -483,7 +483,7 @@ pub fn instantiate_with_staked_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -535,7 +535,7 @@ pub fn instantiate_with_staked_balances_governance( &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -598,7 +598,7 @@ pub fn instantiate_with_multiple_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: staked_balances_voting_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: Some(AbsoluteCount { count: Uint128::one(), }), @@ -622,7 +622,7 @@ pub fn instantiate_with_multiple_staked_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -674,7 +674,7 @@ pub fn instantiate_with_multiple_staked_balances_governance( &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -715,7 +715,7 @@ pub fn instantiate_with_staking_active_threshold( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -737,7 +737,7 @@ pub fn instantiate_with_staking_active_threshold( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module".to_string(), @@ -803,7 +803,7 @@ pub fn _instantiate_with_cw4_groups_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw4::msg::InstantiateMsg { group_contract: GroupContract::New { cw4_group_code_id: cw4_id, initial_members: initial_weights, @@ -816,7 +816,7 @@ pub fn _instantiate_with_cw4_groups_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module".to_string(), diff --git a/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs b/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs index 9f1749423..4f649beec 100644 --- a/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs +++ b/contracts/proposal/dao-proposal-multiple/src/testing/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Coin, CosmosMsg, Decimal, Empty, Timestamp, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Coin, CosmosMsg, Decimal, Empty, Timestamp, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_denom::{CheckedDenom, UncheckedDenom}; use cw_hooks::HooksResponse; @@ -89,7 +89,7 @@ pub fn get_pre_propose_info( PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_contract, - msg: to_binary(&cppm::InstantiateMsg { + msg: to_json_binary(&cppm::InstantiateMsg { deposit_info, open_proposal_submission, extension: Empty::default(), @@ -443,7 +443,7 @@ fn test_propose_with_messages() { let wasm_msg = WasmMsg::Execute { contract_addr: govmod.to_string(), - msg: to_binary(&config_msg).unwrap(), + msg: to_json_binary(&config_msg).unwrap(), funds: vec![], }; @@ -1728,7 +1728,7 @@ fn test_cant_execute_not_member_when_proposal_created() { &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(10), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -2682,7 +2682,7 @@ fn test_active_threshold_absolute() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(100), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(CREATOR_ADDR), token_contract, &msg, &[]) .unwrap(); @@ -2810,7 +2810,7 @@ fn test_active_threshold_percent() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(20000000), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(CREATOR_ADDR), token_contract, &msg, &[]) .unwrap(); @@ -2901,7 +2901,7 @@ fn test_active_threshold_none() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(2000), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(CREATOR_ADDR), token_contract, &msg, &[]) .unwrap(); @@ -3578,7 +3578,7 @@ fn test_close_failed_proposal() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(2000), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract( Addr::unchecked(CREATOR_ADDR), @@ -3592,7 +3592,7 @@ fn test_close_failed_proposal() { let msg = cw20::Cw20ExecuteMsg::Burn { amount: Uint128::new(2000), }; - let binary_msg = to_binary(&msg).unwrap(); + let binary_msg = to_json_binary(&msg).unwrap(); let options = vec![ MultipleChoiceOption { @@ -3674,7 +3674,7 @@ fn test_close_failed_proposal() { description: "Disable closing failed proposals".to_string(), msgs: vec![WasmMsg::Execute { contract_addr: govmod.to_string(), - msg: to_binary(&ExecuteMsg::UpdateConfig { + msg: to_json_binary(&ExecuteMsg::UpdateConfig { voting_strategy: VotingStrategy::SingleChoice { quorum }, max_voting_period: original.max_voting_period, min_voting_period: original.min_voting_period, @@ -3836,7 +3836,7 @@ fn test_no_double_refund_on_execute_fail_and_close() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(1), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract( Addr::unchecked(CREATOR_ADDR), @@ -3864,7 +3864,7 @@ fn test_no_double_refund_on_execute_fail_and_close() { let msg = cw20::Cw20ExecuteMsg::Burn { amount: Uint128::new(2000), }; - let binary_msg = to_binary(&msg).unwrap(); + let binary_msg = to_json_binary(&msg).unwrap(); // Increase allowance to pay the proposal deposit. app.execute_contract( diff --git a/contracts/proposal/dao-proposal-single/src/contract.rs b/contracts/proposal/dao-proposal-single/src/contract.rs index cf3ecf33d..dc255fbe8 100644 --- a/contracts/proposal/dao-proposal-single/src/contract.rs +++ b/contracts/proposal/dao-proposal-single/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Order, Reply, + to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Order, Reply, Response, StdResult, Storage, SubMsg, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -295,7 +295,7 @@ pub fn execute_execute( if !prop.msgs.is_empty() { let execute_message = WasmMsg::Execute { contract_addr: config.dao.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs: prop.msgs, })?, funds: vec![], @@ -326,7 +326,7 @@ pub fn execute_execute( let hooks = match proposal_creation_policy { ProposalCreationPolicy::Anyone {} => hooks, ProposalCreationPolicy::Module { addr } => { - let msg = to_binary(&PreProposeHookMsg::ProposalCompletedHook { + let msg = to_json_binary(&PreProposeHookMsg::ProposalCompletedHook { proposal_id, new_status: prop.status, })?; @@ -515,7 +515,7 @@ pub fn execute_close( let hooks = match proposal_creation_policy { ProposalCreationPolicy::Anyone {} => hooks, ProposalCreationPolicy::Module { addr } => { - let msg = to_binary(&PreProposeHookMsg::ProposalCompletedHook { + let msg = to_json_binary(&PreProposeHookMsg::ProposalCompletedHook { proposal_id, new_status: prop.status, })?; @@ -730,29 +730,29 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { limit, } => query_reverse_proposals(deps, env, start_before, limit), QueryMsg::ProposalCreationPolicy {} => query_creation_policy(deps), - QueryMsg::ProposalHooks {} => to_binary(&PROPOSAL_HOOKS.query_hooks(deps)?), - QueryMsg::VoteHooks {} => to_binary(&VOTE_HOOKS.query_hooks(deps)?), + QueryMsg::ProposalHooks {} => to_json_binary(&PROPOSAL_HOOKS.query_hooks(deps)?), + QueryMsg::VoteHooks {} => to_json_binary(&VOTE_HOOKS.query_hooks(deps)?), } } pub fn query_config(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config) + to_json_binary(&config) } pub fn query_dao(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config.dao) + to_json_binary(&config.dao) } pub fn query_proposal(deps: Deps, env: Env, id: u64) -> StdResult { let proposal = PROPOSALS.load(deps.storage, id)?; - to_binary(&proposal.into_response(&env.block, id)) + to_json_binary(&proposal.into_response(&env.block, id)) } pub fn query_creation_policy(deps: Deps) -> StdResult { let policy = CREATION_POLICY.load(deps.storage)?; - to_binary(&policy) + to_json_binary(&policy) } pub fn query_list_proposals( @@ -771,7 +771,7 @@ pub fn query_list_proposals( .map(|(id, proposal)| proposal.into_response(&env.block, id)) .collect(); - to_binary(&ProposalListResponse { proposals: props }) + to_json_binary(&ProposalListResponse { proposals: props }) } pub fn query_reverse_proposals( @@ -790,16 +790,16 @@ pub fn query_reverse_proposals( .map(|(id, proposal)| proposal.into_response(&env.block, id)) .collect(); - to_binary(&ProposalListResponse { proposals: props }) + to_json_binary(&ProposalListResponse { proposals: props }) } pub fn query_proposal_count(deps: Deps) -> StdResult { let proposal_count = PROPOSAL_COUNT.load(deps.storage)?; - to_binary(&proposal_count) + to_json_binary(&proposal_count) } pub fn query_next_proposal_id(deps: Deps) -> StdResult { - to_binary(&next_proposal_id(deps.storage)?) + to_json_binary(&next_proposal_id(deps.storage)?) } pub fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult { @@ -811,7 +811,7 @@ pub fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult>>()?; - to_binary(&VoteListResponse { votes }) + to_json_binary(&VoteListResponse { votes }) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/proposal/dao-proposal-single/src/testing/adversarial_tests.rs b/contracts/proposal/dao-proposal-single/src/testing/adversarial_tests.rs index 5d32804b9..19d3900e9 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/adversarial_tests.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/adversarial_tests.rs @@ -11,7 +11,7 @@ use crate::testing::{ }, queries::{query_balance_cw20, query_dao_token, query_proposal, query_single_proposal_module}, }; -use cosmwasm_std::{to_binary, Addr, CosmosMsg, Decimal, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, Decimal, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App}; use cw_utils::Duration; @@ -301,7 +301,7 @@ pub fn test_passed_prop_state_remains_after_vote_swing() { recipient: "threshold".to_string(), amount: Uint128::new(100_000_000), }; - let binary_msg = to_binary(&msg).unwrap(); + let binary_msg = to_json_binary(&msg).unwrap(); mint_cw20s(&mut app, &gov_token, &core_addr, CREATOR_ADDR, 10_000_000); let proposal_id = make_proposal( diff --git a/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs b/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs index b9e9d74de..3fd485f62 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/instantiate.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Coin, Decimal, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, Coin, Decimal, Empty, Uint128}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, BankSudo, Executor, SudoMsg}; @@ -34,7 +34,7 @@ pub(crate) fn get_pre_propose_info( PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_contract, - msg: to_binary(&cppbps::InstantiateMsg { + msg: to_json_binary(&cppbps::InstantiateMsg { deposit_info, open_proposal_submission, extension: Empty::default(), @@ -146,7 +146,7 @@ pub(crate) fn instantiate_with_staked_cw721_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: cw721_stake_id, - msg: to_binary(&dao_voting_cw721_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw721_staked::msg::InstantiateMsg { unstaking_duration: None, nft_contract: dao_voting_cw721_staked::msg::NftContract::Existing { address: nft_address.to_string(), @@ -160,7 +160,7 @@ pub(crate) fn instantiate_with_staked_cw721_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -208,7 +208,7 @@ pub(crate) fn instantiate_with_staked_cw721_governance( &cw721_base::msg::ExecuteMsg::SendNft::, Empty> { contract: staking_addr.to_string(), token_id: format!("{address}_{i}"), - msg: to_binary("").unwrap(), + msg: to_json_binary("").unwrap(), }, &[], ) @@ -265,7 +265,7 @@ pub(crate) fn instantiate_with_native_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: native_stake_id, - msg: to_binary(&dao_voting_token_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_token_staked::msg::InstantiateMsg { token_info: dao_voting_token_staked::msg::TokenInfo::Existing { denom: "ujuno".to_string(), }, @@ -279,7 +279,7 @@ pub(crate) fn instantiate_with_native_staked_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -378,7 +378,7 @@ pub(crate) fn instantiate_with_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: staked_balances_voting_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: None, token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, @@ -400,7 +400,7 @@ pub(crate) fn instantiate_with_staked_balances_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -451,7 +451,7 @@ pub(crate) fn instantiate_with_staked_balances_governance( &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -493,7 +493,7 @@ pub(crate) fn instantiate_with_staking_active_threshold( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -515,7 +515,7 @@ pub(crate) fn instantiate_with_staking_active_threshold( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module".to_string(), @@ -581,7 +581,7 @@ pub(crate) fn instantiate_with_cw4_groups_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw4::msg::InstantiateMsg { group_contract: GroupContract::New { cw4_group_code_id: cw4_id, initial_members: initial_weights, @@ -594,7 +594,7 @@ pub(crate) fn instantiate_with_cw4_groups_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_module_code_id, - msg: to_binary(&proposal_module_instantiate).unwrap(), + msg: to_json_binary(&proposal_module_instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module".to_string(), diff --git a/contracts/proposal/dao-proposal-single/src/testing/migration_tests.rs b/contracts/proposal/dao-proposal-single/src/testing/migration_tests.rs index 1e3aa7c0c..3d68ffb7a 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/migration_tests.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/migration_tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, Executor}; use dao_interface::query::{GetItemResponse, ProposalModuleCountResponse}; @@ -68,7 +68,7 @@ fn test_v1_v2_full_migration() { automatically_add_cw721s: true, voting_module_instantiate_info: cw_core_v1::msg::ModuleInstantiateInfo { code_id: voting_code, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: None, token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_code, @@ -89,7 +89,7 @@ fn test_v1_v2_full_migration() { }, proposal_modules_instantiate_info: vec![cw_core_v1::msg::ModuleInstantiateInfo { code_id: proposal_code, - msg: to_binary(&cw_proposal_single_v1::msg::InstantiateMsg { + msg: to_json_binary(&cw_proposal_single_v1::msg::InstantiateMsg { threshold: voting_v1::Threshold::AbsolutePercentage { percentage: voting_v1::PercentageThreshold::Majority {}, }, @@ -152,7 +152,7 @@ fn test_v1_v2_full_migration() { &cw20::Cw20ExecuteMsg::Send { contract: staking.into_string(), amount: Uint128::new(1), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -188,7 +188,7 @@ fn test_v1_v2_full_migration() { description: "d".to_string(), msgs: vec![WasmMsg::Execute { contract_addr: core.to_string(), - msg: to_binary(&cw_core_v1::msg::ExecuteMsg::UpdateCw20List { + msg: to_json_binary(&cw_core_v1::msg::ExecuteMsg::UpdateCw20List { to_add: vec![token.to_string()], to_remove: vec![], }) @@ -247,7 +247,7 @@ fn test_v1_v2_full_migration() { description: "d".to_string(), msgs: vec![WasmMsg::Execute { contract_addr: token.to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: sender.to_string(), // more tokens than the DAO posseses. amount: Uint128::new(101), @@ -316,7 +316,7 @@ fn test_v1_v2_full_migration() { WasmMsg::Migrate { contract_addr: core.to_string(), new_code_id: v2_core_code, - msg: to_binary(&dao_interface::msg::MigrateMsg::FromV1 { + msg: to_json_binary(&dao_interface::msg::MigrateMsg::FromV1 { dao_uri: Some("dao-uri".to_string()), params: None, }) @@ -326,7 +326,7 @@ fn test_v1_v2_full_migration() { WasmMsg::Migrate { contract_addr: proposal.to_string(), new_code_id: v2_proposal_code, - msg: to_binary(&crate::msg::MigrateMsg::FromV1 { + msg: to_json_binary(&crate::msg::MigrateMsg::FromV1 { close_proposal_on_execution_failure: true, pre_propose_info, }) @@ -413,7 +413,7 @@ fn test_v1_v2_full_migration() { sender.as_str(), vec![WasmMsg::Execute { contract_addr: core.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::UpdateCw20List { + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::UpdateCw20List { to_add: vec![], to_remove: vec![token.into_string()], }) diff --git a/contracts/proposal/dao-proposal-single/src/testing/tests.rs b/contracts/proposal/dao-proposal-single/src/testing/tests.rs index 8634243dd..f42464097 100644 --- a/contracts/proposal/dao-proposal-single/src/testing/tests.rs +++ b/contracts/proposal/dao-proposal-single/src/testing/tests.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{ coins, testing::{mock_dependencies, mock_env}, - to_binary, Addr, Attribute, BankMsg, Binary, ContractInfoResponse, CosmosMsg, Decimal, Empty, + to_json_binary, Addr, Attribute, BankMsg, Binary, ContractInfoResponse, CosmosMsg, Decimal, Empty, Reply, StdError, SubMsgResult, Uint128, WasmMsg, WasmQuery, }; use cw2::ContractVersion; @@ -321,7 +321,7 @@ fn test_proposal_message_execution() { vec![ WasmMsg::Execute { contract_addr: gov_token.to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Mint { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Mint { recipient: CREATOR_ADDR.to_string(), amount: Uint128::new(10_000_000), }) @@ -540,7 +540,7 @@ fn test_cant_execute_not_member_when_proposal_created() { &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(10_000_000), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -578,7 +578,7 @@ fn test_update_config() { CREATOR_ADDR, vec![WasmMsg::Execute { contract_addr: proposal_module.to_string(), - msg: to_binary(&ExecuteMsg::UpdateConfig { + msg: to_json_binary(&ExecuteMsg::UpdateConfig { threshold: Threshold::AbsoluteCount { threshold: Uint128::new(10_000), }, @@ -890,7 +890,7 @@ fn test_active_threshold_absolute() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(100), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(CREATOR_ADDR), gov_token, &msg, &[]) .unwrap(); @@ -971,7 +971,7 @@ fn test_active_threshold_percent() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount: Uint128::new(20_000_000), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(CREATOR_ADDR), gov_token, &msg, &[]) .unwrap(); @@ -1545,7 +1545,7 @@ fn test_migrate_from_compatible() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: proposal_module.to_string(), new_code_id, - msg: to_binary(&MigrateMsg::FromCompatible {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromCompatible {}).unwrap(), }), ) .unwrap(); @@ -1609,7 +1609,7 @@ fn test_migrate_from_v1() { automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: staked_balances_voting_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: None, token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, @@ -1631,7 +1631,7 @@ fn test_migrate_from_v1() { }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: v1_proposal_single_code, - msg: to_binary(&instantiate).unwrap(), + msg: to_json_binary(&instantiate).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module.".to_string(), @@ -1682,7 +1682,7 @@ fn test_migrate_from_v1() { &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -1730,7 +1730,7 @@ fn test_migrate_from_v1() { pre_propose_info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_single, - msg: to_binary(&dao_pre_propose_single::InstantiateMsg { + msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: dao_voting::deposit::DepositToken::VotingModuleToken {}, amount: Uint128::new(1), @@ -1752,7 +1752,7 @@ fn test_migrate_from_v1() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: proposal_module.to_string(), new_code_id: v2_proposal_single, - msg: to_binary(&migrate_msg).unwrap(), + msg: to_json_binary(&migrate_msg).unwrap(), }), ) .unwrap_err() @@ -1770,7 +1770,7 @@ fn test_migrate_from_v1() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: proposal_module.to_string(), new_code_id: v2_proposal_single, - msg: to_binary(&migrate_msg).unwrap(), + msg: to_json_binary(&migrate_msg).unwrap(), }), ) .unwrap(); @@ -1798,7 +1798,7 @@ fn test_migrate_from_v1() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: proposal_module.to_string(), new_code_id: v2_proposal_single, - msg: to_binary(&migrate_msg).unwrap(), + msg: to_json_binary(&migrate_msg).unwrap(), }), ) .unwrap_err() @@ -2397,11 +2397,11 @@ fn test_update_pre_propose_module() { CREATOR_ADDR, vec![WasmMsg::Execute { contract_addr: proposal_module.to_string(), - msg: to_binary(&ExecuteMsg::UpdatePreProposeInfo { + msg: to_json_binary(&ExecuteMsg::UpdatePreProposeInfo { info: PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: pre_propose_id, - msg: to_binary(&dao_pre_propose_single::InstantiateMsg { + msg: to_json_binary(&dao_pre_propose_single::InstantiateMsg { deposit_info: Some(UncheckedDepositInfo { denom: dao_voting::deposit::DepositToken::VotingModuleToken {}, amount: Uint128::new(1), @@ -2495,7 +2495,7 @@ fn test_update_pre_propose_module() { CREATOR_ADDR, vec![WasmMsg::Execute { contract_addr: pre_propose_start.into_string(), - msg: to_binary(&dao_pre_propose_single::ExecuteMsg::Withdraw { denom: None }).unwrap(), + msg: to_json_binary(&dao_pre_propose_single::ExecuteMsg::Withdraw { denom: None }).unwrap(), funds: vec![], } .into()], diff --git a/contracts/staking/cw20-stake-external-rewards/src/contract.rs b/contracts/staking/cw20-stake-external-rewards/src/contract.rs index b1774414f..63486915b 100644 --- a/contracts/staking/cw20-stake-external-rewards/src/contract.rs +++ b/contracts/staking/cw20-stake-external-rewards/src/contract.rs @@ -14,7 +14,7 @@ use crate::ContractError::{ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, + from_json_binary, to_json_binary, Addr, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, StdResult, Uint128, Uint256, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -143,7 +143,7 @@ pub fn execute_receive( info: MessageInfo, wrapper: Cw20ReceiveMsg, ) -> Result, ContractError> { - let msg: ReceiveMsg = from_binary(&wrapper.msg)?; + let msg: ReceiveMsg = from_json_binary(&wrapper.msg)?; let config = CONFIG.load(deps.storage)?; let sender = deps.api.addr_validate(&wrapper.sender)?; if config.reward_token != Denom::Cw20(info.sender) { @@ -280,7 +280,7 @@ pub fn get_transfer_msg(recipient: Addr, amount: Uint128, denom: Denom) -> StdRe } .into()), Denom::Cw20(addr) => { - let cw20_msg = to_binary(&cw20::Cw20ExecuteMsg::Transfer { + let cw20_msg = to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: recipient.into_string(), amount, })?; @@ -414,11 +414,11 @@ fn scale_factor() -> Uint256 { #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::Info {} => Ok(to_binary(&query_info(deps, env)?)?), + QueryMsg::Info {} => Ok(to_json_binary(&query_info(deps, env)?)?), QueryMsg::GetPendingRewards { address } => { - Ok(to_binary(&query_pending_rewards(deps, env, address)?)?) + Ok(to_json_binary(&query_pending_rewards(deps, env, address)?)?) } - QueryMsg::Ownership {} => to_binary(&cw_ownable::get_ownership(deps.storage)?), + QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), } } @@ -462,7 +462,7 @@ mod tests { use crate::{msg::MigrateMsg, ContractError}; - use cosmwasm_std::{coin, to_binary, Addr, Empty, Uint128, WasmMsg}; + use cosmwasm_std::{coin, to_json_binary, Addr, Empty, Uint128, WasmMsg}; use cw20::{Cw20Coin, Cw20ExecuteMsg, Denom}; use cw_ownable::{Action, Ownership, OwnershipError}; use cw_utils::Duration; @@ -566,7 +566,7 @@ mod tests { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_addr.to_string(), amount: Uint128::new(amount), - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(Addr::unchecked(sender), cw20_addr.clone(), &msg, &[]) .unwrap(); @@ -679,7 +679,7 @@ mod tests { reward_addr: &Addr, amount: u128, ) { - let fund_sub_msg = to_binary(&ReceiveMsg::Fund {}).unwrap(); + let fund_sub_msg = to_json_binary(&ReceiveMsg::Fund {}).unwrap(); let fund_msg = Cw20ExecuteMsg::Send { contract: reward_addr.clone().into_string(), amount: Uint128::new(amount), @@ -1680,7 +1680,7 @@ mod tests { amount: Uint128::new(500000000), }], ); - let fund_sub_msg = to_binary(&ReceiveMsg::Fund {}).unwrap(); + let fund_sub_msg = to_json_binary(&ReceiveMsg::Fund {}).unwrap(); let fund_msg = Cw20ExecuteMsg::Send { contract: reward_addr.into_string(), amount: Uint128::new(100), @@ -1733,7 +1733,7 @@ mod tests { app.borrow_mut().update_block(|b| b.height = 1000); // Test with invalid token - let fund_sub_msg = to_binary(&ReceiveMsg::Fund {}).unwrap(); + let fund_sub_msg = to_json_binary(&ReceiveMsg::Fund {}).unwrap(); let fund_msg = Cw20ExecuteMsg::Send { contract: reward_addr.clone().into_string(), amount: Uint128::new(100), @@ -2003,7 +2003,7 @@ mod tests { WasmMsg::Migrate { contract_addr: rewards_addr.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) @@ -2025,7 +2025,7 @@ mod tests { WasmMsg::Migrate { contract_addr: rewards_addr.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) diff --git a/contracts/staking/cw20-stake-reward-distributor/src/contract.rs b/contracts/staking/cw20-stake-reward-distributor/src/contract.rs index d4108d88c..66636add1 100644 --- a/contracts/staking/cw20-stake-reward-distributor/src/contract.rs +++ b/contracts/staking/cw20-stake-reward-distributor/src/contract.rs @@ -2,7 +2,7 @@ use std::cmp::min; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; -use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdError, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, StdError, Uint128, WasmMsg}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InfoResponse, InstantiateMsg, MigrateMsg, QueryMsg}; @@ -162,10 +162,10 @@ fn get_distribution_msg(deps: Deps, env: &Env) -> Result StdResult { match msg { - QueryMsg::Info {} => to_binary(&query_info(deps, env)?), - QueryMsg::Ownership {} => to_binary(&cw_ownable::get_ownership(deps.storage)?), + QueryMsg::Info {} => to_json_binary(&query_info(deps, env)?), + QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), } } diff --git a/contracts/staking/cw20-stake-reward-distributor/src/tests.rs b/contracts/staking/cw20-stake-reward-distributor/src/tests.rs index 829fafaf4..7b6bde529 100644 --- a/contracts/staking/cw20-stake-reward-distributor/src/tests.rs +++ b/contracts/staking/cw20-stake-reward-distributor/src/tests.rs @@ -6,7 +6,7 @@ use crate::{ use cw20_stake_reward_distributor_v1 as v1; -use cosmwasm_std::{to_binary, Addr, Empty, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Empty, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_multi_test::{next_block, App, Contract, ContractWrapper, Executor}; use cw_ownable::{Action, Expiration, Ownership, OwnershipError}; @@ -711,7 +711,7 @@ fn test_migrate_from_v1() { WasmMsg::Migrate { contract_addr: distributor.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) @@ -747,7 +747,7 @@ fn test_migrate_from_v1() { WasmMsg::Migrate { contract_addr: distributor.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) diff --git a/contracts/staking/cw20-stake/src/contract.rs b/contracts/staking/cw20-stake/src/contract.rs index f200b3737..24ee73d88 100644 --- a/contracts/staking/cw20-stake/src/contract.rs +++ b/contracts/staking/cw20-stake/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, + from_json_binary, to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, StdResult, Uint128, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -129,7 +129,7 @@ pub fn execute_receive( expected: config.token_address, }); } - let msg: ReceiveMsg = from_binary(&wrapper.msg)?; + let msg: ReceiveMsg = from_json_binary(&wrapper.msg)?; let sender = deps.api.addr_validate(&wrapper.sender)?; match msg { ReceiveMsg::Stake {} => execute_stake(deps, env, sender, wrapper.amount), @@ -221,7 +221,7 @@ pub fn execute_unstake( }; let wasm_msg = cosmwasm_std::WasmMsg::Execute { contract_addr: config.token_address.to_string(), - msg: to_binary(&cw_send_msg)?, + msg: to_json_binary(&cw_send_msg)?, funds: vec![], }; Ok(Response::new() @@ -270,7 +270,7 @@ pub fn execute_claim( }; let wasm_msg = cosmwasm_std::WasmMsg::Execute { contract_addr: config.token_address.to_string(), - msg: to_binary(&cw_send_msg)?, + msg: to_json_binary(&cw_send_msg)?, funds: vec![], }; Ok(Response::new() @@ -336,21 +336,21 @@ pub fn execute_update_owner( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::GetConfig {} => to_binary(&query_config(deps)?), + QueryMsg::GetConfig {} => to_json_binary(&query_config(deps)?), QueryMsg::StakedBalanceAtHeight { address, height } => { - to_binary(&query_staked_balance_at_height(deps, env, address, height)?) + to_json_binary(&query_staked_balance_at_height(deps, env, address, height)?) } QueryMsg::TotalStakedAtHeight { height } => { - to_binary(&query_total_staked_at_height(deps, env, height)?) + to_json_binary(&query_total_staked_at_height(deps, env, height)?) } - QueryMsg::StakedValue { address } => to_binary(&query_staked_value(deps, env, address)?), - QueryMsg::TotalValue {} => to_binary(&query_total_value(deps, env)?), - QueryMsg::Claims { address } => to_binary(&query_claims(deps, address)?), - QueryMsg::GetHooks {} => to_binary(&query_hooks(deps)?), + QueryMsg::StakedValue { address } => to_json_binary(&query_staked_value(deps, env, address)?), + QueryMsg::TotalValue {} => to_json_binary(&query_total_value(deps, env)?), + QueryMsg::Claims { address } => to_json_binary(&query_claims(deps, address)?), + QueryMsg::GetHooks {} => to_json_binary(&query_hooks(deps)?), QueryMsg::ListStakers { start_after, limit } => { query_list_stakers(deps, start_after, limit) } - QueryMsg::Ownership {} => to_binary(&cw_ownable::get_ownership(deps.storage)?), + QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), } } @@ -450,7 +450,7 @@ pub fn query_list_stakers( }) .collect(); - to_binary(&ListStakersResponse { stakers }) + to_json_binary(&ListStakersResponse { stakers }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/staking/cw20-stake/src/tests.rs b/contracts/staking/cw20-stake/src/tests.rs index 1838265a5..147bd806f 100644 --- a/contracts/staking/cw20-stake/src/tests.rs +++ b/contracts/staking/cw20-stake/src/tests.rs @@ -1,6 +1,6 @@ use anyhow::Result as AnyResult; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; -use cosmwasm_std::{to_binary, Addr, Empty, MessageInfo, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Empty, MessageInfo, Uint128, WasmMsg}; use cw20::Cw20Coin; use cw_controllers::{Claim, ClaimsResponse}; use cw_multi_test::{next_block, App, AppResponse, Contract, ContractWrapper, Executor}; @@ -190,7 +190,7 @@ fn stake_tokens( let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_addr.to_string(), amount, - msg: to_binary(&ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Stake {}).unwrap(), }; app.execute_contract(info.sender, cw20_addr.clone(), &msg, &[]) } @@ -653,7 +653,7 @@ fn test_auto_compounding_staking() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_addr.to_string(), amount: Uint128::from(100u128), - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }; let _res = app .borrow_mut() @@ -725,7 +725,7 @@ fn test_auto_compounding_staking() { let msg = cw20::Cw20ExecuteMsg::Send { contract: staking_addr.to_string(), amount: Uint128::from(90u128), - msg: to_binary(&ReceiveMsg::Fund {}).unwrap(), + msg: to_json_binary(&ReceiveMsg::Fund {}).unwrap(), }; let _res = app .borrow_mut() @@ -1151,7 +1151,7 @@ fn test_migrate_from_v1() { WasmMsg::Migrate { contract_addr: staking.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) @@ -1164,7 +1164,7 @@ fn test_migrate_from_v1() { WasmMsg::Migrate { contract_addr: staking.to_string(), new_code_id: v2_code, - msg: to_binary(&MigrateMsg::FromV1 {}).unwrap(), + msg: to_json_binary(&MigrateMsg::FromV1 {}).unwrap(), } .into(), ) diff --git a/contracts/test/dao-proposal-hook-counter/src/contract.rs b/contracts/test/dao-proposal-hook-counter/src/contract.rs index 0f2a36fd3..3aaefca3d 100644 --- a/contracts/test/dao-proposal-hook-counter/src/contract.rs +++ b/contracts/test/dao-proposal-hook-counter/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint128, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint128, }; use cw2::set_contract_version; use dao_hooks::stake::StakeChangedHookMsg; @@ -121,14 +121,14 @@ pub fn execute_vote_hook( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::ProposalCounter {} => to_binary(&CountResponse { + QueryMsg::ProposalCounter {} => to_json_binary(&CountResponse { count: PROPOSAL_COUNTER.load(deps.storage)?, }), - QueryMsg::StakeCounter {} => to_binary(&STAKE_COUNTER.load(deps.storage)?), - QueryMsg::StatusChangedCounter {} => to_binary(&CountResponse { + QueryMsg::StakeCounter {} => to_json_binary(&STAKE_COUNTER.load(deps.storage)?), + QueryMsg::StatusChangedCounter {} => to_json_binary(&CountResponse { count: STATUS_CHANGED_COUNTER.load(deps.storage)?, }), - QueryMsg::VoteCounter {} => to_binary(&CountResponse { + QueryMsg::VoteCounter {} => to_json_binary(&CountResponse { count: VOTE_COUNTER.load(deps.storage)?, }), } diff --git a/contracts/test/dao-proposal-hook-counter/src/tests.rs b/contracts/test/dao-proposal-hook-counter/src/tests.rs index 728baba65..fddc0f104 100644 --- a/contracts/test/dao-proposal-hook-counter/src/tests.rs +++ b/contracts/test/dao-proposal-hook-counter/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Empty, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, Empty, Uint128}; use cw20::Cw20Coin; use cw_hooks::HooksResponse; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; @@ -108,7 +108,7 @@ fn instantiate_with_default_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { token_info: dao_voting_cw20_balance::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -126,7 +126,7 @@ fn instantiate_with_default_governance( }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id, - msg: to_binary(&msg).unwrap(), + msg: to_json_binary(&msg).unwrap(), admin: Some(Admin::CoreModule {}), funds: vec![], label: "DAO DAO governance module".to_string(), diff --git a/contracts/test/dao-proposal-sudo/src/contract.rs b/contracts/test/dao-proposal-sudo/src/contract.rs index 82df228e3..902a0ee34 100644 --- a/contracts/test/dao-proposal-sudo/src/contract.rs +++ b/contracts/test/dao-proposal-sudo/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdResult, + to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg, }; use cw2::set_contract_version; @@ -59,7 +59,7 @@ pub fn execute_execute( let msg = WasmMsg::Execute { contract_addr: dao.to_string(), - msg: to_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, + msg: to_json_binary(&dao_interface::msg::ExecuteMsg::ExecuteProposalHook { msgs })?, funds: vec![], }; @@ -78,14 +78,14 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } pub fn query_admin(deps: Deps) -> StdResult { - to_binary(&ROOT.load(deps.storage)?) + to_json_binary(&ROOT.load(deps.storage)?) } pub fn query_dao(deps: Deps) -> StdResult { - to_binary(&DAO.load(deps.storage)?) + to_json_binary(&DAO.load(deps.storage)?) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } diff --git a/contracts/test/dao-test-custom-factory/src/contract.rs b/contracts/test/dao-test-custom-factory/src/contract.rs index 7091c027a..b7f8159b8 100644 --- a/contracts/test/dao-test-custom-factory/src/contract.rs +++ b/contracts/test/dao-test-custom-factory/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, + to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, SubMsg, Uint128, WasmMsg, }; use cw2::set_contract_version; @@ -131,7 +131,7 @@ pub fn execute_nft_factory( INITIAL_NFTS.save(deps.storage, &initial_nfts)?; // Override minter to be the DAO address - let msg = to_binary(&Cw721InstantiateMsg { + let msg = to_json_binary(&Cw721InstantiateMsg { name: cw721_instantiate_msg.name, symbol: cw721_instantiate_msg.symbol, minter: dao.to_string(), @@ -190,7 +190,7 @@ pub fn execute_nft_factory_wrong_callback( _env: Env, _info: MessageInfo, ) -> Result { - Ok(Response::new().set_data(to_binary(&TokenFactoryCallback { + Ok(Response::new().set_data(to_json_binary(&TokenFactoryCallback { denom: "wrong".to_string(), token_contract: None, module_instantiate_callback: None, @@ -224,7 +224,7 @@ pub fn execute_token_factory_factory( WasmMsg::Instantiate { admin: Some(dao.to_string()), code_id: token.token_issuer_code_id, - msg: to_binary(&IssuerInstantiateMsg::NewToken { + msg: to_json_binary(&IssuerInstantiateMsg::NewToken { subdenom: token.subdenom, })?, funds: vec![], @@ -264,7 +264,7 @@ pub fn execute_token_factory_factory_wrong_callback( _env: Env, _info: MessageInfo, ) -> Result { - Ok(Response::new().set_data(to_binary(&NftFactoryCallback { + Ok(Response::new().set_data(to_json_binary(&NftFactoryCallback { nft_contract: "nope".to_string(), module_instantiate_callback: None, })?)) @@ -328,7 +328,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] @@ -377,7 +377,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result Result Result Result Result Result StdResult { pub fn query_dao(deps: Deps) -> StdResult { let dao = DAO.load(deps.storage)?; - to_binary(&dao) + to_json_binary(&dao) } pub fn query_token_contract(deps: Deps) -> StdResult { let token = TOKEN.load(deps.storage)?; - to_binary(&token) + to_json_binary(&token) } pub fn query_voting_power_at_height(deps: Deps, env: Env, address: String) -> StdResult { @@ -121,7 +121,7 @@ pub fn query_voting_power_at_height(deps: Deps, env: Env, address: String) -> St address: address.to_string(), }, )?; - to_binary(&dao_interface::voting::VotingPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power: balance.balance, height: env.block.height, }) @@ -132,7 +132,7 @@ pub fn query_total_power_at_height(deps: Deps, env: Env) -> StdResult { let info: cw20::TokenInfoResponse = deps .querier .query_wasm_smart(token, &cw20::Cw20QueryMsg::TokenInfo {})?; - to_binary(&dao_interface::voting::TotalPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power: info.total_supply, height: env.block.height, }) @@ -140,7 +140,7 @@ pub fn query_total_power_at_height(deps: Deps, env: Env) -> StdResult { pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/voting/dao-voting-cw20-staked/src/contract.rs b/contracts/voting/dao-voting-cw20-staked/src/contract.rs index 28ed26836..0ce06700c 100644 --- a/contracts/voting/dao-voting-cw20-staked/src/contract.rs +++ b/contracts/voting/dao-voting-cw20-staked/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Addr, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, + to_json_binary, Addr, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg, Uint128, Uint256, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -89,7 +89,7 @@ pub fn instantiate( funds: vec![], admin: Some(info.sender.to_string()), label: env.contract.address.to_string(), - msg: to_binary(&cw20_stake::msg::InstantiateMsg { + msg: to_json_binary(&cw20_stake::msg::InstantiateMsg { owner: Some(info.sender.to_string()), unstaking_duration, token_address: address.to_string(), @@ -141,7 +141,7 @@ pub fn instantiate( let msg = WasmMsg::Instantiate { admin: Some(info.sender.to_string()), code_id, - msg: to_binary(&cw20_base::msg::InstantiateMsg { + msg: to_json_binary(&cw20_base::msg::InstantiateMsg { name, symbol, decimals, @@ -245,12 +245,12 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { pub fn query_token_contract(deps: Deps) -> StdResult { let token = TOKEN.load(deps.storage)?; - to_binary(&token) + to_json_binary(&token) } pub fn query_staking_contract(deps: Deps) -> StdResult { let staking_contract = STAKING_CONTRACT.load(deps.storage)?; - to_binary(&staking_contract) + to_json_binary(&staking_contract) } pub fn query_voting_power_at_height( @@ -268,7 +268,7 @@ pub fn query_voting_power_at_height( height, }, )?; - to_binary(&dao_interface::voting::VotingPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power: res.balance, height: res.height, }) @@ -284,7 +284,7 @@ pub fn query_total_power_at_height( staking_contract, &cw20_stake::msg::QueryMsg::TotalStakedAtHeight { height }, )?; - to_binary(&dao_interface::voting::TotalPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power: res.total, height: res.height, }) @@ -292,12 +292,12 @@ pub fn query_total_power_at_height( pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } pub fn query_dao(deps: Deps) -> StdResult { let dao = DAO.load(deps.storage)?; - to_binary(&dao) + to_json_binary(&dao) } pub fn query_is_active(deps: Deps) -> StdResult { @@ -311,7 +311,7 @@ pub fn query_is_active(deps: Deps) -> StdResult { &cw20_stake::msg::QueryMsg::TotalStakedAtHeight { height: None }, )?; match threshold { - ActiveThreshold::AbsoluteCount { count } => to_binary(&IsActiveResponse { + ActiveThreshold::AbsoluteCount { count } => to_json_binary(&IsActiveResponse { active: actual_power.total >= count, }), ActiveThreshold::Percentage { percent } => { @@ -354,18 +354,18 @@ pub fn query_is_active(deps: Deps) -> StdResult { let rounded = (applied + Uint256::from(PRECISION_FACTOR) - Uint256::from(1u128)) / Uint256::from(PRECISION_FACTOR); let count: Uint128 = rounded.try_into().unwrap(); - to_binary(&IsActiveResponse { + to_json_binary(&IsActiveResponse { active: actual_power.total >= count, }) } } } else { - to_binary(&IsActiveResponse { active: true }) + to_json_binary(&IsActiveResponse { active: true }) } } pub fn query_active_threshold(deps: Deps) -> StdResult { - to_binary(&ActiveThresholdResponse { + to_json_binary(&ActiveThresholdResponse { active_threshold: ACTIVE_THRESHOLD.may_load(deps.storage)?, }) } @@ -413,7 +413,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result StdResult { } QueryMsg::TotalPowerAtHeight { height } => query_total_power_at_height(deps, env, height), QueryMsg::Info {} => query_info(deps), - QueryMsg::GroupContract {} => to_binary(&GROUP_CONTRACT.load(deps.storage)?), - QueryMsg::Dao {} => to_binary(&DAO.load(deps.storage)?), + QueryMsg::GroupContract {} => to_json_binary(&GROUP_CONTRACT.load(deps.storage)?), + QueryMsg::Dao {} => to_json_binary(&DAO.load(deps.storage)?), } } @@ -145,7 +145,7 @@ pub fn query_voting_power_at_height( }, )?; - to_binary(&dao_interface::voting::VotingPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power: res.weight.unwrap_or(0).into(), height: height.unwrap_or(env.block.height), }) @@ -157,7 +157,7 @@ pub fn query_total_power_at_height(deps: Deps, env: Env, height: Option) -> group_contract, &cw4_group::msg::QueryMsg::TotalWeight { at_height: height }, )?; - to_binary(&dao_interface::voting::TotalPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power: res.weight.into(), height: height.unwrap_or(env.block.height), }) @@ -165,7 +165,7 @@ pub fn query_total_power_at_height(deps: Deps, env: Env, height: Option) -> pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/voting/dao-voting-cw4/src/tests.rs b/contracts/voting/dao-voting-cw4/src/tests.rs index 69ca443ef..769c53c4c 100644 --- a/contracts/voting/dao-voting-cw4/src/tests.rs +++ b/contracts/voting/dao-voting-cw4/src/tests.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ testing::{mock_dependencies, mock_env}, - to_binary, Addr, CosmosMsg, Empty, Uint128, WasmMsg, + to_json_binary, Addr, CosmosMsg, Empty, Uint128, WasmMsg, }; use cw2::ContractVersion; use cw_multi_test::{next_block, App, Contract, ContractWrapper, Executor}; @@ -608,7 +608,7 @@ fn test_migrate() { CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: voting_addr.to_string(), new_code_id: voting_id, - msg: to_binary(&MigrateMsg {}).unwrap(), + msg: to_json_binary(&MigrateMsg {}).unwrap(), }), ) .unwrap(); diff --git a/contracts/voting/dao-voting-cw721-roles/src/contract.rs b/contracts/voting/dao-voting-cw721-roles/src/contract.rs index 9d0f8852d..e2a696d2d 100644 --- a/contracts/voting/dao-voting-cw721-roles/src/contract.rs +++ b/contracts/voting/dao-voting-cw721-roles/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, SubMsg, + to_json_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdResult, SubMsg, WasmMsg, }; use cw2::set_contract_version; @@ -66,7 +66,7 @@ pub fn instantiate( funds: vec![], admin: Some(info.sender.to_string()), label, - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name, symbol, // Admin must be set to contract to mint initial NFTs @@ -121,7 +121,7 @@ pub fn query_voting_power_at_height( }, )?; - to_binary(&dao_interface::voting::VotingPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power: member.weight.unwrap_or(0).into(), height: at_height.unwrap_or(env.block.height), }) @@ -140,7 +140,7 @@ pub fn query_total_power_at_height( }, )?; - to_binary(&dao_interface::voting::TotalPowerAtHeightResponse { + to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power: total.weight.into(), height: at_height.unwrap_or(env.block.height), }) @@ -148,17 +148,17 @@ pub fn query_total_power_at_height( pub fn query_config(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config) + to_json_binary(&config) } pub fn query_dao(deps: Deps) -> StdResult { let dao = DAO.load(deps.storage)?; - to_binary(&dao) + to_json_binary(&dao) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } #[cfg_attr(not(feature = "library"), entry_point)] @@ -186,7 +186,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result::Mint { token_id: nft.token_id.clone(), owner: nft.owner.clone(), @@ -207,7 +207,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result::UpdateOwnership( Action::TransferOwnership { new_owner: dao.to_string(), diff --git a/contracts/voting/dao-voting-cw721-staked/src/contract.rs b/contracts/voting/dao-voting-cw721-staked/src/contract.rs index 982d40e78..29e48b896 100644 --- a/contracts/voting/dao-voting-cw721-staked/src/contract.rs +++ b/contracts/voting/dao-voting-cw721-staked/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, + from_json_binary, to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg, Uint128, Uint256, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -48,9 +48,9 @@ impl NftInstantiateMsg { } } - fn to_binary(&self) -> Result { + fn to_json_binary(&self) -> Result { match self { - NftInstantiateMsg::Cw721(msg) => to_binary(&msg), + NftInstantiateMsg::Cw721(msg) => to_json_binary(&msg), } } } @@ -58,7 +58,7 @@ impl NftInstantiateMsg { pub fn try_deserialize_nft_instantiate_msg( instantiate_msg: Binary, ) -> Result { - if let Ok(cw721_msg) = from_binary::(&instantiate_msg) { + if let Ok(cw721_msg) = from_json_binary::(&instantiate_msg) { return Ok(NftInstantiateMsg::Cw721(cw721_msg)); } @@ -153,7 +153,7 @@ pub fn instantiate( funds: vec![], admin: Some(info.sender.to_string()), label, - msg: instantiate_msg.to_binary()?, + msg: instantiate_msg.to_json_binary()?, }, INSTANTIATE_NFT_CONTRACT_REPLY_ID, ); @@ -162,7 +162,7 @@ pub fn instantiate( .add_attribute("method", "instantiate") .add_submessage(instantiate_msg)) } - NftContract::Factory(binary) => match from_binary(&binary)? { + NftContract::Factory(binary) => match from_json_binary(&binary)? { WasmMsg::Execute { msg: wasm_msg, contract_addr, @@ -296,7 +296,7 @@ pub fn execute_unstake( .map(|token_id| -> StdResult { Ok(cosmwasm_std::WasmMsg::Execute { contract_addr: config.nft_address.to_string(), - msg: to_binary(&cw721::Cw721ExecuteMsg::TransferNft { + msg: to_json_binary(&cw721::Cw721ExecuteMsg::TransferNft { recipient: info.sender.to_string(), token_id, })?, @@ -356,7 +356,7 @@ pub fn execute_claim_nfts( .map(|nft| -> StdResult { Ok(WasmMsg::Execute { contract_addr: config.nft_address.to_string(), - msg: to_binary(&cw721::Cw721ExecuteMsg::TransferNft { + msg: to_json_binary(&cw721::Cw721ExecuteMsg::TransferNft { recipient: info.sender.to_string(), token_id: nft, })?, @@ -500,7 +500,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { } pub fn query_active_threshold(deps: Deps) -> StdResult { - to_binary(&ActiveThresholdResponse { + to_json_binary(&ActiveThresholdResponse { active_threshold: ACTIVE_THRESHOLD.may_load(deps.storage)?, }) } @@ -518,13 +518,13 @@ pub fn query_is_active(deps: Deps, env: Env) -> StdResult { )?; match threshold { - ActiveThreshold::AbsoluteCount { count } => to_binary(&IsActiveResponse { + ActiveThreshold::AbsoluteCount { count } => to_json_binary(&IsActiveResponse { active: staked_nfts >= count, }), ActiveThreshold::Percentage { percent } => { // Check if there are any staked NFTs if staked_nfts.is_zero() { - return to_binary(&IsActiveResponse { active: false }); + return to_json_binary(&IsActiveResponse { active: false }); } // percent is bounded between [0, 100]. decimal @@ -564,13 +564,13 @@ pub fn query_is_active(deps: Deps, env: Env) -> StdResult { let count: Uint128 = rounded.try_into().unwrap(); // staked_nfts >= total_nfts * percent - to_binary(&IsActiveResponse { + to_json_binary(&IsActiveResponse { active: staked_nfts >= count, }) } } } else { - to_binary(&IsActiveResponse { active: true }) + to_json_binary(&IsActiveResponse { active: true }) } } @@ -585,7 +585,7 @@ pub fn query_voting_power_at_height( let power = NFT_BALANCES .may_load_at_height(deps.storage, &address, height)? .unwrap_or_default(); - to_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power, height }) + to_json_binary(&dao_interface::voting::VotingPowerAtHeightResponse { power, height }) } pub fn query_total_power_at_height(deps: Deps, env: Env, height: Option) -> StdResult { @@ -593,30 +593,30 @@ pub fn query_total_power_at_height(deps: Deps, env: Env, height: Option) -> let power = TOTAL_STAKED_NFTS .may_load_at_height(deps.storage, height)? .unwrap_or_default(); - to_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power, height }) + to_json_binary(&dao_interface::voting::TotalPowerAtHeightResponse { power, height }) } pub fn query_config(deps: Deps) -> StdResult { let config = CONFIG.load(deps.storage)?; - to_binary(&config) + to_json_binary(&config) } pub fn query_dao(deps: Deps) -> StdResult { let dao = DAO.load(deps.storage)?; - to_binary(&dao) + to_json_binary(&dao) } pub fn query_nft_claims(deps: Deps, address: String) -> StdResult { - to_binary(&NFT_CLAIMS.query_claims(deps, &deps.api.addr_validate(&address)?)?) + to_json_binary(&NFT_CLAIMS.query_claims(deps, &deps.api.addr_validate(&address)?)?) } pub fn query_hooks(deps: Deps) -> StdResult { - to_binary(&HOOKS.query_hooks(deps)?) + to_json_binary(&HOOKS.query_hooks(deps)?) } pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } pub fn query_staked_nfts( @@ -639,7 +639,7 @@ pub fn query_staked_nfts( Some(l) => range.take(l as usize).collect(), None => range.collect(), }; - to_binary(&range?) + to_json_binary(&range?) } #[cfg_attr(not(feature = "library"), entry_point)] @@ -692,7 +692,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result::UpdateOwnership( cw721_base::Action::TransferOwnership { new_owner: dao.to_string(), @@ -744,10 +744,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result::UpdateOwnership( cw721_base::Action::AcceptOwnership {}, ), @@ -767,7 +767,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Result::Mint { owner: accounts[0].address(), token_uri: Some("https://example.com".to_string()), @@ -100,7 +100,7 @@ fn test_full_integration_with_factory() { }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_single.code_id, - msg: to_binary(&dao_proposal_single::msg::InstantiateMsg { + msg: to_json_binary(&dao_proposal_single::msg::InstantiateMsg { min_voting_period: None, threshold: Threshold::ThresholdQuorum { threshold: PercentageThreshold::Majority {}, diff --git a/contracts/voting/dao-voting-cw721-staked/src/testing/test_tube_env.rs b/contracts/voting/dao-voting-cw721-staked/src/testing/test_tube_env.rs index cea9d24a1..26d5c4abc 100644 --- a/contracts/voting/dao-voting-cw721-staked/src/testing/test_tube_env.rs +++ b/contracts/voting/dao-voting-cw721-staked/src/testing/test_tube_env.rs @@ -7,7 +7,7 @@ use crate::{ state::Config, }; -use cosmwasm_std::{to_binary, Addr, Coin, Decimal, Empty, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Coin, Decimal, Empty, WasmMsg}; use cw_utils::Duration; use dao_interface::{ msg::QueryMsg as DaoQueryMsg, @@ -86,18 +86,18 @@ impl TestEnvBuilder { automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: vp_contract_id, - msg: to_binary(&InstantiateMsg { + msg: to_json_binary(&InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: custom_factory.contract_addr.clone(), - msg: to_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { + msg: to_json_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { code_id: cw721_id, cw721_instantiate_msg: Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: accounts[0].address(), }, - initial_nfts: vec![to_binary( + initial_nfts: vec![to_json_binary( &Cw721ExecuteMsg::::Mint { owner: accounts[0].address(), token_uri: Some("https://example.com".to_string()), @@ -124,7 +124,7 @@ impl TestEnvBuilder { }, proposal_modules_instantiate_info: vec![ModuleInstantiateInfo { code_id: proposal_single_id, - msg: to_binary(&dao_proposal_single::msg::InstantiateMsg { + msg: to_json_binary(&dao_proposal_single::msg::InstantiateMsg { min_voting_period: None, threshold: Threshold::ThresholdQuorum { threshold: PercentageThreshold::Majority {}, diff --git a/contracts/voting/dao-voting-cw721-staked/src/testing/tests.rs b/contracts/voting/dao-voting-cw721-staked/src/testing/tests.rs index 2f2ada85d..adb68ff04 100644 --- a/contracts/voting/dao-voting-cw721-staked/src/testing/tests.rs +++ b/contracts/voting/dao-voting-cw721-staked/src/testing/tests.rs @@ -1,5 +1,5 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env}; -use cosmwasm_std::{to_binary, Addr, Coin, Decimal, Empty, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Coin, Decimal, Empty, Uint128, WasmMsg}; use cw721_base::msg::{ExecuteMsg as Cw721ExecuteMsg, InstantiateMsg as Cw721InstantiateMsg}; use cw721_controllers::{NftClaim, NftClaimsResponse}; use cw_multi_test::{next_block, App, BankSudo, Executor, SudoMsg}; @@ -45,12 +45,12 @@ fn test_instantiate_with_new_cw721_collection() -> anyhow::Result<()> { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), })?, - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -432,13 +432,13 @@ fn test_instantiate_with_invalid_duration_fails() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Extension { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Extension { msg: Empty {}, }) .unwrap()], @@ -471,13 +471,13 @@ fn test_instantiate_zero_active_threshold_count() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -511,13 +511,13 @@ fn test_instantiate_invalid_active_threshold_count_new_nft() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -577,28 +577,28 @@ fn test_active_threshold_absolute_count() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), initial_nfts: vec![ - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "2".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "3".to_string(), @@ -657,13 +657,13 @@ fn test_active_threshold_percent() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -718,42 +718,42 @@ fn test_active_threshold_percent_rounds_up() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), initial_nfts: vec![ - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "2".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "3".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "4".to_string(), extension: Empty {}, }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "5".to_string(), @@ -820,13 +820,13 @@ fn test_update_active_threshold() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -896,13 +896,13 @@ fn test_active_threshold_percentage_gt_100() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -938,13 +938,13 @@ fn test_active_threshold_percentage_lte_0() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -978,8 +978,8 @@ fn test_invalid_instantiate_msg() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Empty {}).unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + msg: to_json_binary(&Empty {}).unwrap(), + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -1017,13 +1017,13 @@ fn test_invalid_initial_nft_msg() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Extension { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Extension { msg: Empty {}, }) .unwrap()], @@ -1056,16 +1056,16 @@ fn test_invalid_initial_nft_msg_wrong_absolute_count() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }) .unwrap(), initial_nfts: vec![ - to_binary(&Cw721ExecuteMsg::::Extension { msg: Empty {} }) + to_json_binary(&Cw721ExecuteMsg::::Extension { msg: Empty {} }) .unwrap(), - to_binary(&Cw721ExecuteMsg::::Mint { + to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -1104,7 +1104,7 @@ fn test_no_initial_nfts_fails() { nft_contract: NftContract::New { code_id: cw721_id, label: "Test NFT".to_string(), - msg: to_binary(&Cw721InstantiateMsg { + msg: to_json_binary(&Cw721InstantiateMsg { name: "Test NFT".to_string(), symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), @@ -1153,9 +1153,9 @@ fn test_factory() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: factory_addr.to_string(), - msg: to_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { + msg: to_json_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { code_id: cw721_id, cw721_instantiate_msg: Cw721InstantiateMsg { name: "Test NFT".to_string(), @@ -1216,9 +1216,9 @@ fn test_factory_with_funds_pass_through() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: factory_addr.to_string(), - msg: to_binary( + msg: to_json_binary( &dao_test_custom_factory::msg::ExecuteMsg::NftFactoryWithFunds { code_id: cw721_id, cw721_instantiate_msg: Cw721InstantiateMsg { @@ -1226,7 +1226,7 @@ fn test_factory_with_funds_pass_through() { symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }, - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -1261,9 +1261,9 @@ fn test_factory_with_funds_pass_through() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: factory_addr.to_string(), - msg: to_binary( + msg: to_json_binary( &dao_test_custom_factory::msg::ExecuteMsg::NftFactoryWithFunds { code_id: cw721_id, cw721_instantiate_msg: Cw721InstantiateMsg { @@ -1271,7 +1271,7 @@ fn test_factory_with_funds_pass_through() { symbol: "TEST".to_string(), minter: CREATOR_ADDR.to_string(), }, - initial_nfts: vec![to_binary(&Cw721ExecuteMsg::::Mint { + initial_nfts: vec![to_json_binary(&Cw721ExecuteMsg::::Mint { owner: CREATOR_ADDR.to_string(), token_uri: Some("https://example.com".to_string()), token_id: "1".to_string(), @@ -1310,9 +1310,9 @@ fn test_unsupported_factory_msg() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Instantiate { + to_json_binary(&WasmMsg::Instantiate { code_id: cw721_id, - msg: to_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { + msg: to_json_binary(&dao_test_custom_factory::msg::ExecuteMsg::NftFactory { code_id: cw721_id, cw721_instantiate_msg: Cw721InstantiateMsg { name: "Test NFT".to_string(), @@ -1368,9 +1368,9 @@ fn test_factory_wrong_callback() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: factory_addr.to_string(), - msg: to_binary( + msg: to_json_binary( &dao_test_custom_factory::msg::ExecuteMsg::NftFactoryWrongCallback {}, ) .unwrap(), @@ -1416,9 +1416,9 @@ fn test_factory_no_callback() { Addr::unchecked(CREATOR_ADDR), &InstantiateMsg { nft_contract: NftContract::Factory( - to_binary(&WasmMsg::Execute { + to_json_binary(&WasmMsg::Execute { contract_addr: factory_addr.to_string(), - msg: to_binary( + msg: to_json_binary( &dao_test_custom_factory::msg::ExecuteMsg::NftFactoryNoCallback {}, ) .unwrap(), diff --git a/contracts/voting/dao-voting-token-staked/src/contract.rs b/contracts/voting/dao-voting-token-staked/src/contract.rs index 93bb5c8e3..979dafcb8 100644 --- a/contracts/voting/dao-voting-token-staked/src/contract.rs +++ b/contracts/voting/dao-voting-token-staked/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - coins, from_binary, to_binary, BankMsg, BankQuery, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, + coins, from_json_binary, to_json_binary, BankMsg, BankQuery, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Order, Reply, Response, StdResult, SubMsg, Uint128, Uint256, WasmMsg, }; use cw2::{get_contract_version, set_contract_version, ContractVersion}; @@ -112,7 +112,7 @@ pub fn instantiate( WasmMsg::Instantiate { admin: Some(info.sender.to_string()), code_id: *token_issuer_code_id, - msg: to_binary(&IssuerInstantiateMsg::NewToken { + msg: to_json_binary(&IssuerInstantiateMsg::NewToken { subdenom: subdenom.to_string(), })?, funds: info.funds, @@ -126,7 +126,7 @@ pub fn instantiate( .add_attribute("token", "new_token") .add_submessage(issuer_instantiate_msg)) } - TokenInfo::Factory(binary) => match from_binary(&binary)? { + TokenInfo::Factory(binary) => match from_json_binary(&binary)? { WasmMsg::Execute { msg, contract_addr, @@ -389,16 +389,16 @@ pub fn execute_remove_hook( pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::VotingPowerAtHeight { address, height } => { - to_binary(&query_voting_power_at_height(deps, env, address, height)?) + to_json_binary(&query_voting_power_at_height(deps, env, address, height)?) } QueryMsg::TotalPowerAtHeight { height } => { - to_binary(&query_total_power_at_height(deps, env, height)?) + to_json_binary(&query_total_power_at_height(deps, env, height)?) } QueryMsg::Info {} => query_info(deps), QueryMsg::Dao {} => query_dao(deps), - QueryMsg::Claims { address } => to_binary(&query_claims(deps, address)?), - QueryMsg::GetConfig {} => to_binary(&CONFIG.load(deps.storage)?), - QueryMsg::Denom {} => to_binary(&DenomResponse { + QueryMsg::Claims { address } => to_json_binary(&query_claims(deps, address)?), + QueryMsg::GetConfig {} => to_json_binary(&CONFIG.load(deps.storage)?), + QueryMsg::Denom {} => to_json_binary(&DenomResponse { denom: DENOM.load(deps.storage)?, }), QueryMsg::ListStakers { start_after, limit } => { @@ -406,8 +406,8 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { } QueryMsg::IsActive {} => query_is_active(deps), QueryMsg::ActiveThreshold {} => query_active_threshold(deps), - QueryMsg::GetHooks {} => to_binary(&query_hooks(deps)?), - QueryMsg::TokenContract {} => to_binary(&TOKEN_ISSUER_CONTRACT.may_load(deps.storage)?), + QueryMsg::GetHooks {} => to_json_binary(&query_hooks(deps)?), + QueryMsg::TokenContract {} => to_json_binary(&TOKEN_ISSUER_CONTRACT.may_load(deps.storage)?), } } @@ -439,12 +439,12 @@ pub fn query_total_power_at_height( pub fn query_info(deps: Deps) -> StdResult { let info = cw2::get_contract_version(deps.storage)?; - to_binary(&dao_interface::voting::InfoResponse { info }) + to_json_binary(&dao_interface::voting::InfoResponse { info }) } pub fn query_dao(deps: Deps) -> StdResult { let dao = DAO.load(deps.storage)?; - to_binary(&dao) + to_json_binary(&dao) } pub fn query_claims(deps: Deps, address: String) -> StdResult { @@ -471,7 +471,7 @@ pub fn query_list_stakers( }) .collect::>()?; - to_binary(&ListStakersResponse { stakers }) + to_json_binary(&ListStakersResponse { stakers }) } pub fn query_is_active(deps: Deps) -> StdResult { @@ -480,7 +480,7 @@ pub fn query_is_active(deps: Deps) -> StdResult { let denom = DENOM.load(deps.storage)?; let actual_power = STAKED_TOTAL.may_load(deps.storage)?.unwrap_or_default(); match threshold { - ActiveThreshold::AbsoluteCount { count } => to_binary(&IsActiveResponse { + ActiveThreshold::AbsoluteCount { count } => to_json_binary(&IsActiveResponse { active: actual_power >= count, }), ActiveThreshold::Percentage { percent } => { @@ -526,18 +526,18 @@ pub fn query_is_active(deps: Deps) -> StdResult { let rounded = (applied + Uint256::from(PRECISION_FACTOR) - Uint256::from(1u128)) / Uint256::from(PRECISION_FACTOR); let count: Uint128 = rounded.try_into().unwrap(); - to_binary(&IsActiveResponse { + to_json_binary(&IsActiveResponse { active: actual_power >= count, }) } } } else { - to_binary(&IsActiveResponse { active: true }) + to_json_binary(&IsActiveResponse { active: true }) } } pub fn query_active_threshold(deps: Deps) -> StdResult { - to_binary(&ActiveThresholdResponse { + to_json_binary(&ActiveThresholdResponse { active_threshold: ACTIVE_THRESHOLD.may_load(deps.storage)?, }) } @@ -615,7 +615,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result Result Result Result Result Result { // Parse info from the callback, this will fail // if incorrectly formatted. - let info: TokenFactoryCallback = from_binary(&data)?; + let info: TokenFactoryCallback = from_json_binary(&data)?; // Save Denom DENOM.save(deps.storage, &info.denom)?; @@ -748,7 +748,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result WasmMsg::Execute { contract_addr: address.to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: who.to_string(), amount, })?, @@ -203,7 +203,7 @@ impl fmt::Display for CheckedDenom { mod tests { use cosmwasm_std::{ testing::{mock_dependencies, MockQuerier}, - to_binary, Addr, ContractResult, QuerierResult, StdError, SystemError, Uint128, WasmQuery, + to_json_binary, Addr, ContractResult, QuerierResult, StdError, SystemError, Uint128, WasmQuery, }; use super::*; @@ -217,7 +217,7 @@ mod tests { if *contract_addr == CW20_ADDR { if works { QuerierResult::Ok(ContractResult::Ok( - to_binary(&cw20::TokenInfoResponse { + to_json_binary(&cw20::TokenInfoResponse { name: "coin".to_string(), symbol: "symbol".to_string(), decimals: 6, diff --git a/packages/cw-paginate-storage/README.md b/packages/cw-paginate-storage/README.md index 03a9d03eb..8ab92c658 100644 --- a/packages/cw-paginate-storage/README.md +++ b/packages/cw-paginate-storage/README.md @@ -18,7 +18,7 @@ pub const ITEMS: Map = Map::new("items"); You can use this package to write a query to list it's contents like: ```rust -use cosmwasm_std::{Deps, Binary, to_binary, StdResult}; +use cosmwasm_std::{Deps, Binary, to_json_binary, StdResult}; use cw_storage_plus::Map; use cw_paginate_storage::paginate_map; @@ -29,7 +29,7 @@ pub fn query_list_items( start_after: Option, limit: Option, ) -> StdResult { - to_binary(&paginate_map( + to_json_binary(&paginate_map( deps, &ITEMS, start_after, diff --git a/packages/cw-stake-tracker/src/lib.rs b/packages/cw-stake-tracker/src/lib.rs index fc9a774cf..b9c633966 100644 --- a/packages/cw-stake-tracker/src/lib.rs +++ b/packages/cw-stake-tracker/src/lib.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{to_binary, Binary, StdResult, Storage, Timestamp, Uint128}; +use cosmwasm_std::{to_json_binary, Binary, StdResult, Storage, Timestamp, Uint128}; use cw_wormhole::Wormhole; #[cfg(test)] @@ -261,12 +261,12 @@ impl<'a> StakeTracker<'a> { /// API. pub fn query(&self, storage: &dyn Storage, msg: StakeTrackerQuery) -> StdResult { match msg { - StakeTrackerQuery::Cardinality { t } => to_binary(&Uint128::new( + StakeTrackerQuery::Cardinality { t } => to_json_binary(&Uint128::new( self.validator_cardinality(storage, t)?.into(), )), - StakeTrackerQuery::TotalStaked { t } => to_binary(&self.total_staked(storage, t)?), + StakeTrackerQuery::TotalStaked { t } => to_json_binary(&self.total_staked(storage, t)?), StakeTrackerQuery::ValidatorStaked { validator, t } => { - to_binary(&self.validator_staked(storage, t, validator)?) + to_json_binary(&self.validator_staked(storage, t, validator)?) } } } diff --git a/packages/cw-stake-tracker/src/tests.rs b/packages/cw-stake-tracker/src/tests.rs index 3d0c46b37..417b64375 100644 --- a/packages/cw-stake-tracker/src/tests.rs +++ b/packages/cw-stake-tracker/src/tests.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{from_binary, testing::mock_dependencies, Timestamp, Uint128}; +use cosmwasm_std::{from_json_binary, testing::mock_dependencies, Timestamp, Uint128}; use crate::{StakeTracker, StakeTrackerQuery}; @@ -431,7 +431,7 @@ fn test_queries() { ) .unwrap(); - let cardinality: Uint128 = from_binary( + let cardinality: Uint128 = from_json_binary( &st.query( storage, StakeTrackerQuery::Cardinality { @@ -443,7 +443,7 @@ fn test_queries() { .unwrap(); assert_eq!(cardinality, Uint128::one()); - let total_staked: Uint128 = from_binary( + let total_staked: Uint128 = from_json_binary( &st.query( storage, StakeTrackerQuery::TotalStaked { @@ -455,7 +455,7 @@ fn test_queries() { .unwrap(); assert_eq!(total_staked, Uint128::new(42)); - let val_staked: Uint128 = from_binary( + let val_staked: Uint128 = from_json_binary( &st.query( storage, StakeTrackerQuery::ValidatorStaked { @@ -468,7 +468,7 @@ fn test_queries() { .unwrap(); assert_eq!(val_staked, Uint128::new(42)); - let val_staked_before_staking: Uint128 = from_binary( + let val_staked_before_staking: Uint128 = from_json_binary( &st.query( storage, StakeTrackerQuery::ValidatorStaked { diff --git a/packages/dao-hooks/src/nft_stake.rs b/packages/dao-hooks/src/nft_stake.rs index 9cebad29b..adae78ca7 100644 --- a/packages/dao-hooks/src/nft_stake.rs +++ b/packages/dao-hooks/src/nft_stake.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, StdResult, Storage, SubMsg, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, StdResult, Storage, SubMsg, WasmMsg}; use cw_hooks::Hooks; /// An enum representing NFT staking hooks. @@ -17,7 +17,7 @@ pub fn stake_nft_hook_msgs( addr: Addr, token_id: String, ) -> StdResult> { - let msg = to_binary(&NftStakeChangedExecuteMsg::NftStakeChangeHook( + let msg = to_json_binary(&NftStakeChangedExecuteMsg::NftStakeChangeHook( NftStakeChangedHookMsg::Stake { addr, token_id }, ))?; hooks.prepare_hooks(storage, |a| { @@ -38,7 +38,7 @@ pub fn unstake_nft_hook_msgs( addr: Addr, token_ids: Vec, ) -> StdResult> { - let msg = to_binary(&NftStakeChangedExecuteMsg::NftStakeChangeHook( + let msg = to_json_binary(&NftStakeChangedExecuteMsg::NftStakeChangeHook( NftStakeChangedHookMsg::Unstake { addr, token_ids }, ))?; diff --git a/packages/dao-hooks/src/proposal.rs b/packages/dao-hooks/src/proposal.rs index 0b95758ad..6ccc7bd34 100644 --- a/packages/dao-hooks/src/proposal.rs +++ b/packages/dao-hooks/src/proposal.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, StdResult, Storage, SubMsg, WasmMsg}; +use cosmwasm_std::{to_json_binary, StdResult, Storage, SubMsg, WasmMsg}; use cw_hooks::Hooks; use dao_voting::reply::mask_proposal_hook_index; @@ -28,7 +28,7 @@ pub fn new_proposal_hooks( id: u64, proposer: &str, ) -> StdResult> { - let msg = to_binary(&ProposalHookExecuteMsg::ProposalHook( + let msg = to_json_binary(&ProposalHookExecuteMsg::ProposalHook( ProposalHookMsg::NewProposal { id, proposer: proposer.to_string(), @@ -65,7 +65,7 @@ pub fn proposal_status_changed_hooks( return Ok(vec![]); } - let msg = to_binary(&ProposalHookExecuteMsg::ProposalHook( + let msg = to_json_binary(&ProposalHookExecuteMsg::ProposalHook( ProposalHookMsg::ProposalStatusChanged { id, old_status, diff --git a/packages/dao-hooks/src/stake.rs b/packages/dao-hooks/src/stake.rs index 6161bf2c9..f74203173 100644 --- a/packages/dao-hooks/src/stake.rs +++ b/packages/dao-hooks/src/stake.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, StdResult, Storage, SubMsg, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, StdResult, Storage, SubMsg, Uint128, WasmMsg}; use cw_hooks::Hooks; /// An enum representing staking hooks. @@ -17,7 +17,7 @@ pub fn stake_hook_msgs( addr: Addr, amount: Uint128, ) -> StdResult> { - let msg = to_binary(&StakeChangedExecuteMsg::StakeChangeHook( + let msg = to_json_binary(&StakeChangedExecuteMsg::StakeChangeHook( StakeChangedHookMsg::Stake { addr, amount }, ))?; hooks.prepare_hooks(storage, |a| { @@ -38,7 +38,7 @@ pub fn unstake_hook_msgs( addr: Addr, amount: Uint128, ) -> StdResult> { - let msg = to_binary(&StakeChangedExecuteMsg::StakeChangeHook( + let msg = to_json_binary(&StakeChangedExecuteMsg::StakeChangeHook( StakeChangedHookMsg::Unstake { addr, amount }, ))?; hooks.prepare_hooks(storage, |a| { diff --git a/packages/dao-hooks/src/vote.rs b/packages/dao-hooks/src/vote.rs index b8a0dd772..9d5dedf3e 100644 --- a/packages/dao-hooks/src/vote.rs +++ b/packages/dao-hooks/src/vote.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, StdResult, Storage, SubMsg, WasmMsg}; +use cosmwasm_std::{to_json_binary, StdResult, Storage, SubMsg, WasmMsg}; use cw_hooks::Hooks; use dao_voting::reply::mask_vote_hook_index; @@ -23,7 +23,7 @@ pub fn new_vote_hooks( voter: String, vote: String, ) -> StdResult> { - let msg = to_binary(&VoteHookExecuteMsg::VoteHook(VoteHookMsg::NewVote { + let msg = to_json_binary(&VoteHookExecuteMsg::VoteHook(VoteHookMsg::NewVote { proposal_id, voter, vote, diff --git a/packages/dao-interface/src/state.rs b/packages/dao-interface/src/state.rs index 0bd445de3..2022640eb 100644 --- a/packages/dao-interface/src/state.rs +++ b/packages/dao-interface/src/state.rs @@ -91,13 +91,13 @@ pub struct ModuleInstantiateCallback { mod tests { use super::*; - use cosmwasm_std::{to_binary, Addr, WasmMsg}; + use cosmwasm_std::{to_json_binary, Addr, WasmMsg}; #[test] fn test_module_instantiate_admin_none() { let no_admin = ModuleInstantiateInfo { code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), admin: None, label: "bar".to_string(), funds: vec![], @@ -107,7 +107,7 @@ mod tests { WasmMsg::Instantiate { admin: None, code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), funds: vec![], label: "bar".to_string() } @@ -118,7 +118,7 @@ mod tests { fn test_module_instantiate_admin_addr() { let no_admin = ModuleInstantiateInfo { code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), admin: Some(Admin::Address { addr: "core".to_string(), }), @@ -130,7 +130,7 @@ mod tests { WasmMsg::Instantiate { admin: Some("core".to_string()), code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), funds: vec![], label: "bar".to_string() } @@ -141,7 +141,7 @@ mod tests { fn test_module_instantiate_instantiator_addr() { let no_admin = ModuleInstantiateInfo { code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), admin: Some(Admin::CoreModule {}), label: "bar".to_string(), funds: vec![], @@ -151,7 +151,7 @@ mod tests { WasmMsg::Instantiate { admin: Some("ekez".to_string()), code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), funds: vec![], label: "bar".to_string() } diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index 225a465fe..50949d476 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::schemars::JsonSchema; use cosmwasm_std::{ - to_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, WasmMsg, + to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, WasmMsg, }; use cw2::set_contract_version; @@ -138,7 +138,7 @@ where let propose_messsage = WasmMsg::Execute { contract_addr: proposal_module.into_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; @@ -147,7 +147,7 @@ where .prepare_hooks(deps.storage, |a| { let execute = WasmMsg::Execute { contract_addr: a.into_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(SubMsg::new(execute)) @@ -314,7 +314,7 @@ where Ok(Response::default() .add_attribute("method", "execute_proposal_completed_hook") .add_attribute("proposal", id.to_string()) - .add_attribute("deposit_info", to_binary(&deposit_info)?.to_string()) + .add_attribute("deposit_info", to_json_binary(&deposit_info)?.to_string()) .add_messages(messages)) } @@ -349,18 +349,18 @@ where pub fn query(&self, deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::ProposalModule {} => to_binary(&self.proposal_module.load(deps.storage)?), - QueryMsg::Dao {} => to_binary(&self.dao.load(deps.storage)?), - QueryMsg::Config {} => to_binary(&self.config.load(deps.storage)?), + QueryMsg::ProposalModule {} => to_json_binary(&self.proposal_module.load(deps.storage)?), + QueryMsg::Dao {} => to_json_binary(&self.dao.load(deps.storage)?), + QueryMsg::Config {} => to_json_binary(&self.config.load(deps.storage)?), QueryMsg::DepositInfo { proposal_id } => { let (deposit_info, proposer) = self.deposits.load(deps.storage, proposal_id)?; - to_binary(&DepositInfoResponse { + to_json_binary(&DepositInfoResponse { deposit_info, proposer, }) } QueryMsg::ProposalSubmittedHooks {} => { - to_binary(&self.proposal_submitted_hooks.query_hooks(deps)?) + to_json_binary(&self.proposal_submitted_hooks.query_hooks(deps)?) } QueryMsg::QueryExtension { .. } => Ok(Binary::default()), } diff --git a/packages/dao-pre-propose-base/src/tests.rs b/packages/dao-pre-propose-base/src/tests.rs index f04c6ed5a..7c868a74f 100644 --- a/packages/dao-pre-propose-base/src/tests.rs +++ b/packages/dao-pre-propose-base/src/tests.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{ - from_binary, + from_json_binary, testing::{mock_dependencies, mock_env, mock_info}, - to_binary, Addr, Binary, ContractResult, Empty, Response, SubMsg, WasmMsg, + to_json_binary, Addr, Binary, ContractResult, Empty, Response, SubMsg, WasmMsg, }; use cw_hooks::HooksResponse; use dao_voting::status::Status; @@ -97,7 +97,7 @@ fn test_proposal_submitted_hooks() { module .execute_add_proposal_submitted_hook(deps.as_mut(), info, "one".to_string()) .unwrap(); - let hooks: HooksResponse = from_binary( + let hooks: HooksResponse = from_json_binary( &module .query( deps.as_ref(), @@ -118,7 +118,7 @@ fn test_proposal_submitted_hooks() { deps.querier.update_wasm(|_| { // for responding to the next proposal ID query that gets fired by propose. - cosmwasm_std::SystemResult::Ok(ContractResult::Ok(to_binary(&1u64).unwrap())) + cosmwasm_std::SystemResult::Ok(ContractResult::Ok(to_json_binary(&1u64).unwrap())) }); // The hooks fire when a proposal is created. @@ -136,7 +136,7 @@ fn test_proposal_submitted_hooks() { res.messages[1], SubMsg::new(WasmMsg::Execute { contract_addr: "one".to_string(), - msg: to_binary(&Empty::default()).unwrap(), + msg: to_json_binary(&Empty::default()).unwrap(), funds: vec![], }) ); @@ -153,7 +153,7 @@ fn test_proposal_submitted_hooks() { module .execute_remove_proposal_submitted_hook(deps.as_mut(), info, "one".to_string()) .unwrap(); - let hooks: HooksResponse = from_binary( + let hooks: HooksResponse = from_json_binary( &module .query( deps.as_ref(), diff --git a/packages/dao-testing/src/helpers.rs b/packages/dao-testing/src/helpers.rs index 9bccd53c7..b629e7ba0 100644 --- a/packages/dao-testing/src/helpers.rs +++ b/packages/dao-testing/src/helpers.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Binary, Uint128}; +use cosmwasm_std::{to_json_binary, Addr, Binary, Uint128}; use cw20::Cw20Coin; use cw_multi_test::{App, Executor}; use cw_utils::Duration; @@ -57,7 +57,7 @@ pub fn instantiate_with_cw20_balances_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_balance::msg::InstantiateMsg { token_info: dao_voting_cw20_balance::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -138,7 +138,7 @@ pub fn instantiate_with_staked_balances_governance( automatically_add_cw721s: false, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: staked_balances_voting_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { active_threshold: None, token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, @@ -211,7 +211,7 @@ pub fn instantiate_with_staked_balances_governance( &cw20::Cw20ExecuteMsg::Send { contract: staking_contract.to_string(), amount, - msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), + msg: to_json_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(), }, &[], ) @@ -259,7 +259,7 @@ pub fn instantiate_with_staking_active_threshold( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw20_staked::msg::InstantiateMsg { token_info: dao_voting_cw20_staked::msg::TokenInfo::New { code_id: cw20_id, label: "DAO DAO governance token".to_string(), @@ -342,7 +342,7 @@ pub fn instantiate_with_cw4_groups_governance( automatically_add_cw721s: true, voting_module_instantiate_info: ModuleInstantiateInfo { code_id: votemod_id, - msg: to_binary(&dao_voting_cw4::msg::InstantiateMsg { + msg: to_json_binary(&dao_voting_cw4::msg::InstantiateMsg { group_contract: GroupContract::New { cw4_group_code_id: cw4_id, initial_members: initial_weights, diff --git a/packages/dao-voting/src/deposit.rs b/packages/dao-voting/src/deposit.rs index bf0852ea8..33fbb832c 100644 --- a/packages/dao-voting/src/deposit.rs +++ b/packages/dao-voting/src/deposit.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{ - to_binary, Addr, CosmosMsg, Deps, MessageInfo, StdError, StdResult, Uint128, WasmMsg, + to_json_binary, Addr, CosmosMsg, Deps, MessageInfo, StdError, StdResult, Uint128, WasmMsg, }; use cw_utils::{must_pay, PaymentError}; @@ -170,7 +170,7 @@ impl CheckedDepositInfo { vec![WasmMsg::Execute { contract_addr: address.to_string(), funds: vec![], - msg: to_binary(&cw20::Cw20ExecuteMsg::TransferFrom { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::TransferFrom { owner: depositor.to_string(), recipient: contract.to_string(), amount: *amount, @@ -312,7 +312,7 @@ pub mod tests { messages, vec![CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: CW20.to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::TransferFrom { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::TransferFrom { owner: "ekez".to_string(), recipient: "contract".to_string(), amount: Uint128::new(10) @@ -371,7 +371,7 @@ pub mod tests { messages, vec![CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: CW20.to_string(), - msg: to_binary(&cw20::Cw20ExecuteMsg::Transfer { + msg: to_json_binary(&cw20::Cw20ExecuteMsg::Transfer { recipient: "ekez".to_string(), amount: Uint128::new(10) }) diff --git a/packages/dao-voting/src/pre_propose.rs b/packages/dao-voting/src/pre_propose.rs index 7671425a3..482bf9260 100644 --- a/packages/dao-voting/src/pre_propose.rs +++ b/packages/dao-voting/src/pre_propose.rs @@ -60,7 +60,7 @@ impl PreProposeInfo { #[cfg(test)] mod tests { - use cosmwasm_std::{to_binary, WasmMsg}; + use cosmwasm_std::{to_json_binary, WasmMsg}; use super::*; @@ -114,7 +114,7 @@ mod tests { let info = PreProposeInfo::ModuleMayPropose { info: ModuleInstantiateInfo { code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), admin: None, funds: vec![], label: "pre-propose-9000".to_string(), @@ -136,7 +136,7 @@ mod tests { WasmMsg::Instantiate { admin: None, code_id: 42, - msg: to_binary("foo").unwrap(), + msg: to_json_binary("foo").unwrap(), funds: vec![], label: "pre-propose-9000".to_string() },