Repository: CosmWasm/cw-multi-test
Pull request #94 (2023-10-31 13:43:43)

Upgrade to cosmwasm-std 1.5.0
Replaced deprecated functions.


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 4173819..54c1c8c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -135,11 +135,12 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f"
 
 [[package]]
 name = "cosmwasm-crypto"
-version = "1.4.1"
+version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6fb22494cf7d23d0c348740e06e5c742070b2991fd41db77bba0bcfbae1a723"
+checksum = "d8bb3c77c3b7ce472056968c745eb501c440fbc07be5004eba02782c35bfbbe3"
 dependencies = [
  "digest 0.10.7",
+ "ecdsa",
  "ed25519-zebra",
  "k256",
  "rand_core 0.6.4",
@@ -148,9 +149,9 @@ dependencies = [
 
 [[package]]
 name = "cosmwasm-derive"
-version = "1.4.1"
+version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e199424486ea97d6b211db6387fd72e26b4a439d40cc23140b2d8305728055b"
+checksum = "fea73e9162e6efde00018d55ed0061e93a108b5d6ec4548b4f8ce3c706249687"
 dependencies = [
  "syn 1.0.109",
 ]
@@ -181,11 +182,12 @@ dependencies = [
 
 [[package]]
 name = "cosmwasm-std"
-version = "1.4.1"
+version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d89d680fb60439b7c5947b15f9c84b961b88d1f8a3b20c4bd178a3f87db8bae"
+checksum = "04d6864742e3a7662d024b51a94ea81c9af21db6faea2f9a6d2232bb97c6e53e"
 dependencies = [
  "base64",
+ "bech32",
  "bnum",
  "cosmwasm-crypto",
  "cosmwasm-derive",
@@ -196,6 +198,7 @@ dependencies = [
  "serde",
  "serde-json-wasm",
  "sha2 0.10.8",
+ "static_assertions",
  "thiserror",
 ]
 
@@ -782,6 +785,12 @@ dependencies = [
  "der",
 ]
 
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
 [[package]]
 name = "subtle"
 version = "2.5.0"
diff --git a/Cargo.toml b/Cargo.toml
index b60962d..d671e26 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ cosmwasm_1_4 = ["cosmwasm_1_3", "cosmwasm-std/cosmwasm_1_4"]
 
 [dependencies]
 anyhow = "1.0.75"
-cosmwasm-std = { version = "1.4.1", features = ["staking", "stargate"] }
+cosmwasm-std = { version = "1.5.0", features = ["staking", "stargate"] }
 cw-storage-plus = "1.1.0"
 cw-utils = "1.0.2"
 derivative = "2.2.0"
diff --git a/README.md b/README.md
index b0d659b..dad3b07 100644
--- a/README.md
+++ b/README.md
@@ -15,5 +15,3 @@ in and out of bank.
 This only works with contracts and bank currently. We are working
 on refactoring to make it more extensible for more handlers,
 including custom messages/queries as well as IBC.
-
-
diff --git a/src/app.rs b/src/app.rs
index 4c3497a..9e3ed07 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -11,9 +11,9 @@ use crate::wasm::{ContractData, Wasm, WasmKeeper, WasmSudo};
 use crate::{AppBuilder, GovFailingModule, IbcFailingModule};
 use cosmwasm_std::testing::{MockApi, MockStorage};
 use cosmwasm_std::{
-    from_slice, to_binary, Addr, Api, Binary, BlockInfo, ContractResult, CosmosMsg, CustomQuery,
-    Empty, Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage, SystemError,
-    SystemResult,
+    from_json, to_json_binary, Addr, Api, Binary, BlockInfo, ContractResult, CosmosMsg,
+    CustomQuery, Empty, Querier, QuerierResult, QuerierWrapper, QueryRequest, Record, Storage,
+    SystemError, SystemResult,
 };
 use schemars::JsonSchema;
 use serde::{de::DeserializeOwned, Serialize};
@@ -387,7 +387,7 @@ where
         contract_addr: U,
         msg: &T,
     ) -> AnyResult<AppResponse> {
-        let msg = to_binary(msg)?;
+        let msg = to_json_binary(msg)?;
 
         let Self {
             block,
@@ -685,7 +685,7 @@ where
     QueryC: CustomQuery + DeserializeOwned + 'static,
 {
     fn raw_query(&self, bin_request: &[u8]) -> QuerierResult {
-        let request: QueryRequest<QueryC> = match from_slice(bin_request) {
+        let request: QueryRequest<QueryC> = match from_json(bin_request) {
             Ok(v) => v,
             Err(e) => {
                 return SystemResult::Err(SystemError::InvalidRequest {
diff --git a/src/bank.rs b/src/bank.rs
index 37190dd..b578bf9 100644
--- a/src/bank.rs
+++ b/src/bank.rs
@@ -4,8 +4,8 @@ use crate::executor::AppResponse;
 use crate::module::Module;
 use crate::prefixed_storage::{prefixed, prefixed_read};
 use cosmwasm_std::{
-    coin, to_binary, Addr, AllBalanceResponse, Api, BalanceResponse, BankMsg, BankQuery, Binary,
-    BlockInfo, Coin, Event, Order, Querier, StdResult, Storage, SupplyResponse, Uint128,
+    coin, to_json_binary, Addr, AllBalanceResponse, Api, BalanceResponse, BankMsg, BankQuery,
+    Binary, BlockInfo, Coin, Event, Order, Querier, StdResult, Storage, SupplyResponse, Uint128,
 };
 use cw_storage_plus::Map;
 use cw_utils::NativeBalance;
@@ -208,7 +208,7 @@ impl Module for BankKeeper {
                 let address = api.addr_validate(&address)?;
                 let amount = self.get_balance(&bank_storage, &address)?;
                 let res = AllBalanceResponse { amount };
-                Ok(to_binary(&res)?)
+                Ok(to_json_binary(&res)?)
             }
             BankQuery::Balance { address, denom } => {
                 let address = api.addr_validate(&address)?;
@@ -218,13 +218,13 @@ impl Module for BankKeeper {
                     .find(|c| c.denom == denom)
                     .unwrap_or_else(|| coin(0, denom));
                 let res = BalanceResponse { amount };
-                Ok(to_binary(&res)?)
+                Ok(to_json_binary(&res)?)
             }
             BankQuery::Supply { denom } => {
                 let amount = self.get_supply(&bank_storage, denom)?;
                 let mut res = SupplyResponse::default();
                 res.amount = amount;
-                Ok(to_binary(&res)?)
+                Ok(to_json_binary(&res)?)
             }
             q => bail!("Unsupported bank query: {:?}", q),
         }
@@ -237,7 +237,7 @@ mod test {
 
     use crate::app::MockRouter;
     use cosmwasm_std::testing::{mock_env, MockApi, MockQuerier, MockStorage};
-    use cosmwasm_std::{coins, from_slice, Empty, StdError};
+    use cosmwasm_std::{coins, from_json, Empty, StdError};
 
     fn query_balance(
         bank: &BankKeeper,
@@ -252,7 +252,7 @@ mod test {
         let querier: MockQuerier<Empty> = MockQuerier::new(&[]);
 
         let raw = bank.query(api, store, &querier, &block, req).unwrap();
-        let res: AllBalanceResponse = from_slice(&raw).unwrap();
+        let res: AllBalanceResponse = from_json(raw).unwrap();
         res.amount
     }
 
@@ -285,14 +285,14 @@ mod test {
             address: owner.clone().into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: AllBalanceResponse = from_slice(&raw).unwrap();
+        let res: AllBalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, norm);
 
         let req = BankQuery::AllBalances {
             address: rcpt.clone().into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: AllBalanceResponse = from_slice(&raw).unwrap();
+        let res: AllBalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, vec![]);
 
         let req = BankQuery::Balance {
@@ -300,7 +300,7 @@ mod test {
             denom: "eth".into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: BalanceResponse = from_slice(&raw).unwrap();
+        let res: BalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, coin(100, "eth"));
 
         let req = BankQuery::Balance {
@@ -308,7 +308,7 @@ mod test {
             denom: "foobar".into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: BalanceResponse = from_slice(&raw).unwrap();
+        let res: BalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, coin(0, "foobar"));
 
         let req = BankQuery::Balance {
@@ -316,7 +316,7 @@ mod test {
             denom: "eth".into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: BalanceResponse = from_slice(&raw).unwrap();
+        let res: BalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, coin(0, "eth"));
 
         // Query total supply of a denom
@@ -324,7 +324,7 @@ mod test {
             denom: "eth".into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: SupplyResponse = from_slice(&raw).unwrap();
+        let res: SupplyResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, coin(100, "eth"));
 
         // Mint tokens for recipient account
@@ -339,7 +339,7 @@ mod test {
             address: rcpt.into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: AllBalanceResponse = from_slice(&raw).unwrap();
+        let res: AllBalanceResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, norm);
 
         // Check that the total supply of a denom is updated
@@ -347,7 +347,7 @@ mod test {
             denom: "eth".into(),
         };
         let raw = bank.query(&api, &store, &querier, &block, req).unwrap();
-        let res: SupplyResponse = from_slice(&raw).unwrap();
+        let res: SupplyResponse = from_json(raw).unwrap();
         assert_eq!(res.amount, coin(200, "eth"));
     }
 
diff --git a/src/contracts.rs b/src/contracts.rs
index 908712a..52a189b 100644
--- a/src/contracts.rs
+++ b/src/contracts.rs
@@ -1,6 +1,6 @@
 use crate::error::{anyhow, bail, AnyError, AnyResult};
 use cosmwasm_std::{
-    from_slice, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo,
+    from_json, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Empty, Env, MessageInfo,
     QuerierWrapper, Reply, Response, SubMsg,
 };
 use schemars::JsonSchema;
@@ -387,7 +387,7 @@ where
         info: MessageInfo,
         msg: Vec<u8>,
     ) -> AnyResult<Response<C>> {
-        let msg: T1 = from_slice(&msg)?;
+        let msg: T1 = from_json(msg)?;
         (self.execute_fn)(deps, env, info, msg).map_err(|err| anyhow!(err))
     }
 
@@ -398,18 +398,18 @@ where
         info: MessageInfo,
         msg: Vec<u8>,
     ) -> AnyResult<Response<C>> {
-        let msg: T2 = from_slice(&msg)?;
+        let msg: T2 = from_json(msg)?;
         (self.instantiate_fn)(deps, env, info, msg).map_err(|err| anyhow!(err))
     }
 
     fn query(&self, deps: Deps<Q>, env: Env, msg: Vec<u8>) -> AnyResult<Binary> {
-        let msg: T3 = from_slice(&msg)?;
+        let msg: T3 = from_json(msg)?;
         (self.query_fn)(deps, env, msg).map_err(|err| anyhow!(err))
     }
 
     // this returns an error if the contract doesn't implement sudo
     fn sudo(&self, deps: DepsMut<Q>, env: Env, msg: Vec<u8>) -> AnyResult<Response<C>> {
-        let msg = from_slice(&msg)?;
+        let msg = from_json(msg)?;
         match &self.sudo_fn {
             Some(sudo) => sudo(deps, env, msg).map_err(|err| anyhow!(err)),
             None => bail!("sudo not implemented for contract"),
@@ -426,7 +426,7 @@ where
 
     // this returns an error if the contract doesn't implement migrate
     fn migrate(&self, deps: DepsMut<Q>, env: Env, msg: Vec<u8>) -> AnyResult<Response<C>> {
-        let msg = from_slice(&msg)?;
+        let msg = from_json(msg)?;
         match &self.migrate_fn {
             Some(migrate) => migrate(deps, env, msg).map_err(|err| anyhow!(err)),
             None => bail!("migrate not implemented for contract"),
diff --git a/src/executor.rs b/src/executor.rs
index 90233fd..694894a 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -1,6 +1,7 @@
 use crate::error::AnyResult;
 use cosmwasm_std::{
-    to_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgResponse, WasmMsg,
+    to_json_binary, Addr, Attribute, BankMsg, Binary, Coin, CosmosMsg, Event, SubMsgResponse,
+    WasmMsg,
 };
 use cw_utils::{parse_execute_response_data, parse_instantiate_response_data};
 use schemars::JsonSchema;
@@ -79,7 +80,7 @@ where
         admin: Option<String>,
     ) -> AnyResult<Addr> {
         // instantiate contract
-        let init_msg = to_binary(init_msg)?;
+        let init_msg = to_json_binary(init_msg)?;
         let msg = WasmMsg::Instantiate {
             admin,
             code_id,
@@ -115,7 +116,7 @@ where
         let msg = WasmMsg::Instantiate2 {
             admin: admin.into(),
             code_id,
-            msg: to_binary(init_msg)?,
+            msg: to_json_binary(init_msg)?,
             funds: funds.to_vec(),
             label: label.into(),
             salt: salt.into(),
@@ -136,7 +137,7 @@ where
         msg: &T,
         send_funds: &[Coin],
     ) -> AnyResult<AppResponse> {
-        let binary_msg = to_binary(msg)?;
+        let binary_msg = to_json_binary(msg)?;
         let wrapped_msg = WasmMsg::Execute {
             contract_addr: contract_addr.into_string(),
             msg: binary_msg,
@@ -158,7 +159,7 @@ where
         msg: &T,
         new_code_id: u64,
     ) -> AnyResult<AppResponse> {
-        let msg = to_binary(msg)?;
+        let msg = to_json_binary(msg)?;
         let msg = WasmMsg::Migrate {
             contract_addr: contract_addr.into(),
             msg,
diff --git a/src/staking.rs b/src/staking.rs
index 62034c3..8590657 100644
--- a/src/staking.rs
+++ b/src/staking.rs
@@ -4,8 +4,8 @@ use crate::executor::AppResponse;
 use crate::prefixed_storage::{prefixed, prefixed_read};
 use crate::{BankSudo, Module};
 use cosmwasm_std::{
-    coin, ensure, ensure_eq, to_binary, Addr, AllDelegationsResponse, AllValidatorsResponse, Api,
-    BankMsg, Binary, BlockInfo, BondedDenomResponse, Coin, CustomQuery, Decimal, Delegation,
+    coin, ensure, ensure_eq, to_json_binary, Addr, AllDelegationsResponse, AllValidatorsResponse,
+    Api, BankMsg, Binary, BlockInfo, BondedDenomResponse, Coin, CustomQuery, Decimal, Delegation,
     DelegationResponse, DistributionMsg, Empty, Event, FullDelegation, Querier, StakingMsg,
     StakingQuery, Storage, Timestamp, Uint128, Validator, ValidatorResponse,
 };
@@ -746,7 +746,7 @@ impl Module for StakeKeeper {
     ) -> AnyResult<Binary> {
         let staking_storage = prefixed_read(storage, NAMESPACE_STAKING);
         match request {
-            StakingQuery::BondedDenom {} => Ok(to_binary(&BondedDenomResponse {
+            StakingQuery::BondedDenom {} => Ok(to_json_binary(&BondedDenomResponse {
                 denom: Self::get_staking_info(&staking_storage)?.bonded_denom,
             })?),
             StakingQuery::AllDelegations { delegator } => {
@@ -773,7 +773,9 @@ impl Module for StakeKeeper {
                     })
                     .collect();
 
-                Ok(to_binary(&AllDelegationsResponse { delegations: res? })?)
+                Ok(to_json_binary(&AllDelegationsResponse {
+                    delegations: res?,
+                })?)
             }
             StakingQuery::Delegation {
                 delegator,
@@ -824,13 +826,13 @@ impl Module for StakeKeeper {
                     }
                 };
 
-                let res = to_binary(&full_delegation_response)?;
+                let res = to_json_binary(&full_delegation_response)?;
                 Ok(res)
             }
-            StakingQuery::AllValidators {} => Ok(to_binary(&AllValidatorsResponse {
+            StakingQuery::AllValidators {} => Ok(to_json_binary(&AllValidatorsResponse {
                 validators: self.get_validators(&staking_storage)?,
             })?),
-            StakingQuery::Validator { address } => Ok(to_binary(&ValidatorResponse {
+            StakingQuery::Validator { address } => Ok(to_json_binary(&ValidatorResponse {
                 validator: self.get_validator(&staking_storage, &Addr::unchecked(address))?,
             })?),
             q => bail!("Unsupported staking sudo message: {:?}", q),
@@ -993,7 +995,7 @@ mod test {
         WasmKeeper,
     };
     use cosmwasm_std::{
-        from_slice,
+        from_json,
         testing::{mock_env, MockApi, MockStorage},
         BalanceResponse, BankQuery,
     };
@@ -1363,19 +1365,18 @@ mod test {
             )
             .unwrap();
 
-        let balance: BalanceResponse = from_slice(
-            &bank
-                .query(
-                    &api,
-                    &store,
-                    &router.querier(&api, &store, &block),
-                    &block,
-                    BankQuery::Balance {
-                        address: delegator1.to_string(),
-                        denom: "TOKEN".to_string(),
-                    },
-                )
-                .unwrap(),
+        let balance: BalanceResponse = from_json(
+            bank.query(
+                &api,
+                &store,
+                &router.querier(&api, &store, &block),
+                &block,
+                BankQuery::Balance {
+                    address: delegator1.to_string(),
+                    denom: "TOKEN".to_string(),
+                },
+            )
+            .unwrap(),
         )
         .unwrap();
         assert_eq!(
@@ -1413,7 +1414,7 @@ mod test {
 
     mod msg {
         use cosmwasm_std::{
-            coins, from_slice, Addr, BondedDenomResponse, Decimal, QuerierWrapper, StakingQuery,
+            coins, Addr, BondedDenomResponse, Decimal, QuerierWrapper, StakingQuery,
         };
         use serde::de::DeserializeOwned;
 
@@ -1457,7 +1458,7 @@ mod test {
         }
 
         fn query_stake<T: DeserializeOwned>(env: &TestEnv, msg: StakingQuery) -> AnyResult<T> {
-            Ok(from_slice(&env.router.staking.query(
+            Ok(from_json(env.router.staking.query(
                 &env.api,
                 &env.store,
                 &env.router.querier(&env.api, &env.store, &env.block),
@@ -1482,7 +1483,7 @@ mod test {
         }
 
         fn query_bank<T: DeserializeOwned>(env: &TestEnv, msg: BankQuery) -> AnyResult<T> {
-            Ok(from_slice(&env.router.bank.query(
+            Ok(from_json(env.router.bank.query(
                 &env.api,
                 &env.store,
                 &env.router.querier(&env.api, &env.store, &env.block),
diff --git a/src/wasm.rs b/src/wasm.rs
index 00e93ea..9e62110 100644
--- a/src/wasm.rs
+++ b/src/wasm.rs
@@ -8,7 +8,7 @@ use crate::prefixed_storage::{prefixed, prefixed_read, PrefixedStorage, Readonly
 use crate::transactions::transactional;
 use cosmwasm_std::testing::mock_wasmd_attr;
 use cosmwasm_std::{
-    to_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo,
+    to_json_binary, Addr, Api, Attribute, BankMsg, Binary, BlockInfo, Coin, ContractInfo,
     ContractInfoResponse, CustomQuery, Deps, DepsMut, Env, Event, HexBinary, MessageInfo, Order,
     Querier, QuerierWrapper, Record, Reply, ReplyOn, Response, StdResult, Storage, SubMsg,
     SubMsgResponse, SubMsgResult, TransactionInfo, WasmMsg, WasmQuery,
@@ -40,7 +40,7 @@ impl WasmSudo {
     pub fn new<T: Serialize>(contract_addr: &Addr, msg: &T) -> StdResult<WasmSudo> {
         Ok(WasmSudo {
             contract_addr: contract_addr.clone(),
-            msg: to_binary(msg)?,
+            msg: to_json_binary(msg)?,
         })
     }
 }
@@ -174,7 +174,7 @@ where
                 res.code_id = contract.code_id;
                 res.creator = contract.creator.to_string();
                 res.admin = contract.admin.map(|x| x.into());
-                to_binary(&res).map_err(Into::into)
+                to_json_binary(&res).map_err(Into::into)
             }
             #[cfg(feature = "cosmwasm_1_2")]
             WasmQuery::CodeInfo { code_id } => {
@@ -183,7 +183,7 @@ where
                 res.code_id = code_id;
                 res.creator = code_data.creator.to_string();
                 res.checksum = code_data.checksum.clone();
-                to_binary(&res).map_err(Into::into)
+                to_json_binary(&res).map_err(Into::into)
             }
             other => bail!(Error::UnsupportedWasmQuery(other)),
         }
@@ -1122,7 +1122,7 @@ mod test {
     use crate::{GovFailingModule, IbcFailingModule};
     use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage};
     use cosmwasm_std::{
-        coin, from_slice, to_vec, BankMsg, CanonicalAddr, Coin, CosmosMsg, Empty, HexBinary,
+        coin, from_json, to_json_vec, BankMsg, CanonicalAddr, Coin, CosmosMsg, Empty, HexBinary,
         StdError,
     };
 
@@ -1284,7 +1284,7 @@ mod test {
             .query(&api, &wasm_storage, &querier, &block, query)
             .unwrap();
 
-        let actual: ContractInfoResponse = from_slice(&contract_info).unwrap();
+        let actual: ContractInfoResponse = from_json(contract_info).unwrap();
         let mut expected = ContractInfoResponse::default();
         expected.code_id = code_id;
         expected.creator = creator.into();
@@ -1305,7 +1305,7 @@ mod test {
         let code_info = wasm_keeper
             .query(&api, &wasm_storage, &querier, &block, query)
             .unwrap();
-        let actual: cosmwasm_std::CodeInfoResponse = from_slice(&code_info).unwrap();
+        let actual: cosmwasm_std::CodeInfoResponse = from_json(code_info).unwrap();
         assert_eq!(code_id, actual.code_id);
         assert_eq!("creator", actual.creator);
         assert!(!actual.checksum.is_empty());
@@ -1333,8 +1333,8 @@ mod test {
         let code_info_caller = wasm_keeper
             .query(&api, &wasm_storage, &querier, &block, query_caller)
             .unwrap();
-        let info_payout: cosmwasm_std::CodeInfoResponse = from_slice(&code_info_payout).unwrap();
-        let info_caller: cosmwasm_std::CodeInfoResponse = from_slice(&code_info_caller).unwrap();
+        let info_payout: cosmwasm_std::CodeInfoResponse = from_json(code_info_payout).unwrap();
+        let info_caller: cosmwasm_std::CodeInfoResponse = from_json(code_info_caller).unwrap();
         assert_eq!(code_id_payout, info_payout.code_id);
         assert_eq!(code_id_caller, info_caller.code_id);
         assert_ne!(info_caller.code_id, info_payout.code_id);
@@ -1393,7 +1393,7 @@ mod test {
                 &mock_router(),
                 &block,
                 mock_info("foobar", &[]),
-                to_vec(&msg).unwrap(),
+                to_json_vec(&msg).unwrap(),
             )
             .unwrap();
 
@@ -1403,11 +1403,11 @@ mod test {
         // check contents
         let (k, v) = &state[0];
         assert_eq!(k.as_slice(), b"count");
-        let count: u32 = from_slice(v).unwrap();
+        let count: u32 = from_json(v).unwrap();
         assert_eq!(count, 1);
         let (k, v) = &state[1];
         assert_eq!(k.as_slice(), b"payout");
-        let stored_pay: payout::InstantiateMessage = from_slice(v).unwrap();
+        let stored_pay: payout::InstantiateMessage = from_json(v).unwrap();
         assert_eq!(stored_pay.payout, payout);
     }
 
@@ -1438,7 +1438,7 @@ mod test {
 
         // init the contract
         let info = mock_info("foobar", &[]);
-        let init_msg = to_vec(&payout::InstantiateMessage {
+        let init_msg = to_json_vec(&payout::InstantiateMessage {
             payout: payout.clone(),
         })
         .unwrap();
@@ -1481,12 +1481,12 @@ mod test {
         cache.prepare().commit(&mut wasm_storage);
 
         // query the contract
-        let query = to_vec(&payout::QueryMsg::Payout {}).unwrap();
+        let query = to_json_vec(&payout::QueryMsg::Payout {}).unwrap();
         let querier: MockQuerier<Empty> = MockQuerier::new(&[]);
         let data = wasm_keeper
             .query_smart(contract_addr, &api, &wasm_storage, &querier, &block, query)
             .unwrap();
-        let res: payout::InstantiateMessage = from_slice(&data).unwrap();
+        let res: payout::InstantiateMessage = from_json(data).unwrap();
         assert_eq!(res.payout, payout);
     }
 
@@ -1550,7 +1550,7 @@ mod test {
                 )
                 .unwrap();
             let info = mock_info("foobar", &[]);
-            let init_msg = to_vec(&payout::InstantiateMessage {
+            let init_msg = to_json_vec(&payout::InstantiateMessage {
                 payout: payout1.clone(),
             })
             .unwrap();
@@ -1591,7 +1591,7 @@ mod test {
                 )
                 .unwrap();
             let info = mock_info("foobar", &[]);
-            let init_msg = to_vec(&payout::InstantiateMessage {
+            let init_msg = to_json_vec(&payout::InstantiateMessage {
                 payout: payout2.clone(),
             })
             .unwrap();
@@ -1627,7 +1627,7 @@ mod test {
                     )
                     .unwrap();
                 let info = mock_info("johnny", &[]);
-                let init_msg = to_vec(&payout::InstantiateMessage {
+                let init_msg = to_json_vec(&payout::InstantiateMessage {
                     payout: payout3.clone(),
                 })
                 .unwrap();
@@ -1690,7 +1690,7 @@ mod test {
                 },
             )
             .unwrap();
-        let res: ContractInfoResponse = from_slice(&data).unwrap();
+        let res: ContractInfoResponse = from_json(data).unwrap();
         assert_eq!(res.admin, admin.as_ref().map(Addr::to_string));
     }
 
@@ -1722,7 +1722,7 @@ mod test {
 
         // init the contract
         let info = mock_info("admin", &[]);
-        let init_msg = to_vec(&Empty {}).unwrap();
+        let init_msg = to_json_vec(&Empty {}).unwrap();
         let res = wasm_keeper
             .call_instantiate(
                 contract_addr.clone(),


Test patch:
diff --git a/src/test_helpers/echo.rs b/src/test_helpers/echo.rs
index aa8984c..02ab269 100644
--- a/src/test_helpers/echo.rs
+++ b/src/test_helpers/echo.rs
@@ -5,8 +5,8 @@
 
 use crate::{Contract, ContractWrapper};
 use cosmwasm_std::{
-    to_binary, Attribute, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response,
-    StdError, SubMsg, SubMsgResponse, SubMsgResult,
+    to_json_binary, Attribute, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply,
+    Response, StdError, SubMsg, SubMsgResponse, SubMsgResult,
 };
 use cw_utils::{parse_execute_response_data, parse_instantiate_response_data};
 use derivative::Derivative;
@@ -84,7 +84,7 @@ where
 }
 
 fn query(_deps: Deps, _env: Env, msg: Empty) -> Result<Binary, StdError> {
-    to_binary(&msg)
+    to_json_binary(&msg)
 }
 
 #[allow(clippy::unnecessary_wraps)]
diff --git a/src/test_helpers/hackatom.rs b/src/test_helpers/hackatom.rs
index e968ccd..394c735 100644
--- a/src/test_helpers/hackatom.rs
+++ b/src/test_helpers/hackatom.rs
@@ -2,7 +2,7 @@
 
 use crate::{Contract, ContractWrapper};
 use cosmwasm_std::{
-    to_binary, BankMsg, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError,
+    to_json_binary, BankMsg, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError,
 };
 use cw_storage_plus::Item;
 use schemars::JsonSchema;
@@ -55,7 +55,7 @@ fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, StdError> {
     match msg {
         QueryMsg::Beneficiary {} => {
             let res = HACKATOM.load(deps.storage)?;
-            to_binary(&res)
+            to_json_binary(&res)
         }
     }
 }
diff --git a/src/test_helpers/payout.rs b/src/test_helpers/payout.rs
index 8198afb..a1d13ea 100644
--- a/src/test_helpers/payout.rs
+++ b/src/test_helpers/payout.rs
@@ -1,7 +1,8 @@
 use crate::test_helpers::COUNT;
 use crate::{Contract, ContractWrapper};
 use cosmwasm_std::{
-    to_binary, BankMsg, Binary, Coin, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError,
+    to_json_binary, BankMsg, Binary, Coin, Deps, DepsMut, Empty, Env, MessageInfo, Response,
+    StdError,
 };
 use cw_storage_plus::Item;
 use schemars::JsonSchema;
@@ -64,11 +65,11 @@ fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, StdError> {
         QueryMsg::Count {} => {
             let count = COUNT.load(deps.storage)?;
             let res = CountResponse { count };
-            to_binary(&res)
+            to_json_binary(&res)
         }
         QueryMsg::Payout {} => {
             let payout = PAYOUT.load(deps.storage)?;
-            to_binary(&payout)
+            to_json_binary(&payout)
         }
     }
 }
diff --git a/src/test_helpers/reflect.rs b/src/test_helpers/reflect.rs
index de8a465..c7b3740 100644
--- a/src/test_helpers/reflect.rs
+++ b/src/test_helpers/reflect.rs
@@ -1,8 +1,8 @@
 use crate::test_helpers::{payout, CustomMsg, COUNT};
 use crate::{Contract, ContractWrapper};
 use cosmwasm_std::{
-    to_binary, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response, StdError,
-    SubMsg,
+    to_json_binary, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Reply, Response,
+    StdError, SubMsg,
 };
 use cw_storage_plus::Map;
 use serde::{Deserialize, Serialize};
@@ -46,11 +46,11 @@ fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, StdError> {
         QueryMsg::Count {} => {
             let count = COUNT.load(deps.storage)?;
             let res = payout::CountResponse { count };
-            to_binary(&res)
+            to_json_binary(&res)
         }
         QueryMsg::Reply { id } => {
             let reply = REFLECT.load(deps.storage, id)?;
-            to_binary(&reply)
+            to_json_binary(&reply)
         }
     }
 }
diff --git a/src/tests/test_app.rs b/src/tests/test_app.rs
index 51f7e7d..6d9817a 100644
--- a/src/tests/test_app.rs
+++ b/src/tests/test_app.rs
@@ -12,7 +12,7 @@ use crate::{
 };
 use cosmwasm_std::testing::{mock_env, MockQuerier};
 use cosmwasm_std::{
-    coin, coins, from_slice, to_binary, Addr, AllBalanceResponse, Api, Attribute, BankMsg,
+    coin, coins, from_json, to_json_binary, Addr, AllBalanceResponse, Api, Attribute, BankMsg,
     BankQuery, Binary, BlockInfo, Coin, CosmosMsg, CustomQuery, Empty, Event, OverflowError,
     OverflowOperation, Querier, Reply, StdError, StdResult, Storage, SubMsg, WasmMsg,
 };
@@ -64,7 +64,7 @@ where
         .bank
         .query(api, storage, &querier, &block, query)
         .unwrap();
-    let val: AllBalanceResponse = from_slice(&res).unwrap();
+    let val: AllBalanceResponse = from_json(res).unwrap();
     val.amount
 }
 
@@ -564,7 +564,7 @@ fn sudo_works() {
     let msg = payout::SudoMsg { set_count: 49 };
     let sudo_msg = WasmSudo {
         contract_addr: payout_addr.clone(),
-        msg: to_binary(&msg).unwrap(),
+        msg: to_json_binary(&msg).unwrap(),
     };
     app.sudo(sudo_msg.into()).unwrap();
 
@@ -986,6 +986,7 @@ mod custom_handler {
 
 mod reply_data_overwrite {
     use super::*;
+    use cosmwasm_std::to_json_binary;
 
     use echo::EXECUTE_REPLY_BASE_ID;
 
@@ -999,7 +1000,7 @@ mod reply_data_overwrite {
         SubMsg::reply_always(
             CosmosMsg::Wasm(WasmMsg::Execute {
                 contract_addr: contract.into(),
-                msg: to_binary(&echo::Message {
+                msg: to_json_binary(&echo::Message {
                     data,
                     sub_msg,
                     ..echo::Message::default()
@@ -1019,7 +1020,7 @@ mod reply_data_overwrite {
         let data = data.into().map(|s| s.to_owned());
         SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute {
             contract_addr: contract.into(),
-            msg: to_binary(&echo::Message {
+            msg: to_json_binary(&echo::Message {
                 data,
                 sub_msg,
                 ..echo::Message::default()
@@ -1215,7 +1216,7 @@ mod reply_data_overwrite {
         let reflect_msg = reflect::Message {
             messages: vec![SubMsg::new(WasmMsg::Execute {
                 contract_addr: echo_addr.to_string(),
-                msg: to_binary(&echo_msg).unwrap(),
+                msg: to_json_binary(&echo_msg).unwrap(),
                 funds: vec![],
             })],
         };
@@ -1552,7 +1553,6 @@ mod response_validation {
 }
 
 mod contract_instantiation {
-
     #[test]
     #[cfg(feature = "cosmwasm_1_2")]
     fn instantiate2_works() {
@@ -1566,7 +1566,7 @@ mod contract_instantiation {
         let code_id = app.store_code_with_creator(Addr::unchecked("creator"), echo::contract());
 
         // initialize the contract
-        let init_msg = to_binary(&Empty {}).unwrap();
+        let init_msg = to_json_binary(&Empty {}).unwrap();
         let msg = WasmMsg::Instantiate2 {
             admin: None,
             code_id,
@@ -1680,7 +1680,7 @@ mod protobuf_wrapped_data {
         // set up reflect contract
         let code_id = app.store_code(reflect::contract());
 
-        let init_msg = to_binary(&Empty {}).unwrap();
+        let init_msg = to_json_binary(&Empty {}).unwrap();
         let msg = WasmMsg::Instantiate {
             admin: None,
             code_id,
@@ -1714,7 +1714,7 @@ mod protobuf_wrapped_data {
             data: Some("food".into()),
             sub_msg: None,
         };
-        let init_msg = to_binary(&msg).unwrap();
+        let init_msg = to_json_binary(&msg).unwrap();
         let msg = WasmMsg::Instantiate {
             admin: None,
             code_id,
@@ -1755,7 +1755,7 @@ mod protobuf_wrapped_data {
         let sub_msg = SubMsg::reply_on_success(
             WasmMsg::Execute {
                 contract_addr: addr1.to_string(),
-                msg: to_binary(&msg).unwrap(),
+                msg: to_json_binary(&msg).unwrap(),
                 funds: vec![],
             },
             EXECUTE_REPLY_BASE_ID,
@@ -1764,7 +1764,7 @@ mod protobuf_wrapped_data {
             data: Some("Overwrite me".into()),
             sub_msg: Some(vec![sub_msg]),
         };
-        let init_msg = to_binary(&init_msg).unwrap();
+        let init_msg = to_json_binary(&init_msg).unwrap();
         let msg = WasmMsg::Instantiate {
             admin: None,
             code_id,
@@ -1808,6 +1808,7 @@ mod protobuf_wrapped_data {
 
 mod errors {
     use super::*;
+    use cosmwasm_std::to_json_binary;
 
     #[test]
     fn simple_instantiation() {
@@ -1886,7 +1887,7 @@ mod errors {
         // execute should error
         let msg = WasmMsg::Execute {
             contract_addr: error_addr.into(),
-            msg: to_binary(&Empty {}).unwrap(),
+            msg: to_json_binary(&Empty {}).unwrap(),
             funds: vec![],
         };
         let err = app
@@ -1929,9 +1930,9 @@ mod errors {
         // caller1 calls caller2, caller2 calls error
         let msg = WasmMsg::Execute {
             contract_addr: caller_addr2.into(),
-            msg: to_binary(&WasmMsg::Execute {
+            msg: to_json_binary(&WasmMsg::Execute {
                 contract_addr: error_addr.into(),
-                msg: to_binary(&Empty {}).unwrap(),
+                msg: to_json_binary(&Empty {}).unwrap(),
                 funds: vec![],
             })
             .unwrap(),
diff --git a/tests/mod.rs b/tests/mod.rs
index cd39353..e794b49 100644
--- a/tests/mod.rs
+++ b/tests/mod.rs
@@ -35,7 +35,8 @@ mod test_contracts {
     pub mod counter {
         use super::*;
         use cosmwasm_std::{
-            to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, WasmMsg,
+            to_json_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError,
+            WasmMsg,
         };
         use cw_multi_test::{Contract, ContractWrapper};
 
@@ -64,7 +65,7 @@ mod test_contracts {
 
         fn query(deps: Deps, _env: Env, msg: CounterQueryMsg) -> Result<Binary, StdError> {
             match msg {
-                CounterQueryMsg::Counter { .. } => Ok(to_binary(&CounterResponseMsg {
+                CounterQueryMsg::Counter { .. } => Ok(to_json_binary(&CounterResponseMsg {
                     value: COUNTER.may_load(deps.storage).unwrap().unwrap(),
                 })?),
             }
diff --git a/tests/test_app_builder/test_with_storage.rs b/tests/test_app_builder/test_with_storage.rs
index 32a1944..378b321 100644
--- a/tests/test_app_builder/test_with_storage.rs
+++ b/tests/test_app_builder/test_with_storage.rs
@@ -1,5 +1,5 @@
 use crate::{test_contracts, CounterQueryMsg, CounterResponseMsg};
-use cosmwasm_std::{to_binary, Addr, Empty, Order, Record, Storage, WasmMsg};
+use cosmwasm_std::{to_json_binary, Addr, Empty, Order, Record, Storage, WasmMsg};
 use cw_multi_test::{AppBuilder, Executor};
 use std::collections::BTreeMap;
 use std::iter;
@@ -35,7 +35,7 @@ impl Storage for MyStorage {
 fn building_app_with_custom_storage_should_work() {
     // prepare additional test input data
     let owner = Addr::unchecked("owner");
-    let msg = to_binary(&Empty {}).unwrap();
+    let msg = to_json_binary(&Empty {}).unwrap();
     let admin = None;
     let funds = vec![];
     let label = "my-counter";