Skip to content

Commit

Permalink
Update deprecated function names to_binary and from_binary #761
Browse files Browse the repository at this point in the history
  • Loading branch information
Massvdev committed Nov 9, 2023
1 parent db42d45 commit fc11260
Show file tree
Hide file tree
Showing 79 changed files with 697 additions and 697 deletions.
8 changes: 4 additions & 4 deletions ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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(),
Expand All @@ -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 {},
Expand All @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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 {},
Expand All @@ -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,
Expand Down Expand Up @@ -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![],
Expand Down
4 changes: 2 additions & 2 deletions ci/integration-tests/src/tests/cw20_stake_test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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![],
Expand Down
10 changes: 5 additions & 5 deletions ci/integration-tests/src/tests/cw_core_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
})
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions ci/integration-tests/src/tests/proposal_gas_test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +15,7 @@ fn mint_mint_mint_mint(cw721: &str, owner: &str, mints: u64) -> Vec<CosmosMsg> {
.map(|mint| {
WasmMsg::Execute {
contract_addr: cw721.to_string(),
msg: to_binary(&cw721_base::msg::ExecuteMsg::Mint::<Empty, Empty>{
msg: to_json_binary(&cw721_base::msg::ExecuteMsg::Mint::<Empty, Empty>{
token_id: mint.to_string(),
owner: owner.to_string(),
token_uri: Some("https://bafkreibufednctf2f2bpduiibgkvpqcw5rtdmhqh2htqx3qbdnji4h55hy.ipfs.nftstorage.link".to_string()),
Expand Down
48 changes: 24 additions & 24 deletions contracts/dao-dao-core/src/contract.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -579,22 +579,22 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {

pub fn query_admin(deps: Deps) -> StdResult<Binary> {
let admin = ADMIN.load(deps.storage)?;
to_binary(&admin)
to_json_binary(&admin)
}

pub fn query_admin_nomination(deps: Deps) -> StdResult<Binary> {
let nomination = NOMINATED_ADMIN.may_load(deps.storage)?;
to_binary(&AdminNominationResponse { nomination })
to_json_binary(&AdminNominationResponse { nomination })
}

pub fn query_config(deps: Deps) -> StdResult<Binary> {
let config = CONFIG.load(deps.storage)?;
to_binary(&config)
to_json_binary(&config)
}

pub fn query_voting_module(deps: Deps) -> StdResult<Binary> {
let voting_module = VOTING_MODULE.load(deps.storage)?;
to_binary(&voting_module)
to_json_binary(&voting_module)
}

pub fn query_proposal_modules(
Expand All @@ -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
Expand Down Expand Up @@ -645,7 +645,7 @@ pub fn query_active_proposal_modules(

let limit = limit.unwrap_or(values.len() as u32);

to_binary::<Vec<ProposalModule>>(
to_json_binary::<Vec<ProposalModule>>(
&values
.into_iter()
.filter(|module: &ProposalModule| module.status == ProposalModuleStatus::Enabled)
Expand All @@ -668,7 +668,7 @@ fn get_pause_info(deps: Deps, env: Env) -> StdResult<PauseInfoResponse> {
}

pub fn query_paused(deps: Deps, env: Env) -> StdResult<Binary> {
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<Binary> {
Expand All @@ -683,7 +683,7 @@ pub fn query_dump_state(deps: Deps, env: Env) -> StdResult<Binary> {
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,
Expand All @@ -705,33 +705,33 @@ 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<u64>) -> StdResult<Binary> {
let voting_module = VOTING_MODULE.load(deps.storage)?;
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<Binary> {
let item = ITEMS.may_load(deps.storage, item)?;
to_binary(&GetItemResponse { item })
to_json_binary(&GetItemResponse { item })
}

pub fn query_info(deps: Deps) -> StdResult<Binary> {
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(
deps: Deps,
start_after: Option<String>,
limit: Option<u32>,
) -> StdResult<Binary> {
to_binary(&paginate_map(
to_json_binary(&paginate_map(
deps,
&ITEMS,
start_after,
Expand All @@ -745,7 +745,7 @@ pub fn query_cw20_list(
start_after: Option<String>,
limit: Option<u32>,
) -> StdResult<Binary> {
to_binary(&paginate_map_keys(
to_json_binary(&paginate_map_keys(
deps,
&CW20_LIST,
start_after
Expand All @@ -761,7 +761,7 @@ pub fn query_cw721_list(
start_after: Option<String>,
limit: Option<u32>,
) -> StdResult<Binary> {
to_binary(&paginate_map_keys(
to_json_binary(&paginate_map_keys(
deps,
&CW721_LIST,
start_after
Expand Down Expand Up @@ -802,7 +802,7 @@ pub fn query_cw20_balances(
})
})
.collect::<StdResult<Vec<_>>>()?;
to_binary(&balances)
to_json_binary(&balances)
}

pub fn query_list_sub_daos(
Expand Down Expand Up @@ -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<Binary> {
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<Binary> {
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)?,
})
Expand Down Expand Up @@ -904,10 +904,10 @@ pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result<Response, Con
let response = if let Some(migrate_params) = params {
let msg = WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&ExecuteMsg::UpdateProposalModules {
msg: to_json_binary(&ExecuteMsg::UpdateProposalModules {
to_add: vec![ModuleInstantiateInfo {
code_id: migrate_params.migrator_code_id,
msg: to_binary(&migrate_params.params).unwrap(),
msg: to_json_binary(&migrate_params.params).unwrap(),
admin: Some(Admin::CoreModule {}),
label: "migrator".to_string(),
funds: vec![],
Expand Down Expand Up @@ -952,7 +952,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE

// Check for module instantiation callbacks
let callback_msgs = match res.data {
Some(data) => from_binary::<ModuleInstantiateCallback>(&data)
Some(data) => from_json_binary::<ModuleInstantiateCallback>(&data)
.map(|m| m.msgs)
.unwrap_or_else(|_| vec![]),
None => vec![],
Expand All @@ -978,7 +978,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE

// Check for module instantiation callbacks
let callback_msgs = match res.data {
Some(data) => from_binary::<ModuleInstantiateCallback>(&data)
Some(data) => from_json_binary::<ModuleInstantiateCallback>(&data)
.map(|m| m.msgs)
.unwrap_or_else(|_| vec![]),
None => vec![],
Expand Down
Loading

0 comments on commit fc11260

Please sign in to comment.