Skip to content

Commit

Permalink
terra: s/to_binary/to_json_binary/ (deprecation)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcsongor committed Dec 6, 2023
1 parent 015bdb9 commit 8d196f2
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 106 deletions.
12 changes: 6 additions & 6 deletions terra/contracts/cw20-wrapped/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{
to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult,
Uint128, WasmMsg,
to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError,
StdResult, Uint128, WasmMsg,
};

#[cfg(not(feature = "library"))]
Expand Down Expand Up @@ -167,12 +167,12 @@ fn execute_update_metadata(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::WrappedAssetInfo {} => to_binary(&query_wrapped_asset_info(deps)?),
QueryMsg::WrappedAssetInfo {} => to_json_binary(&query_wrapped_asset_info(deps)?),
// inherited from cw20-base
QueryMsg::TokenInfo {} => to_binary(&query_token_info(deps)?),
QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?),
QueryMsg::TokenInfo {} => to_json_binary(&query_token_info(deps)?),
QueryMsg::Balance { address } => to_json_binary(&query_balance(deps, address)?),
QueryMsg::Allowance { owner, spender } => {
to_binary(&query_allowance(deps, owner, spender)?)
to_json_binary(&query_allowance(deps, owner, spender)?)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions terra/contracts/cw721-base/src/contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use cosmwasm_std::{
from_binary,
testing::{mock_dependencies, mock_env, mock_info},
to_binary, CosmosMsg, DepsMut, Empty, Response, WasmMsg,
to_json_binary, CosmosMsg, DepsMut, Empty, Response, WasmMsg,
};

use cw721::{
Expand Down Expand Up @@ -272,7 +272,7 @@ fn sending_nft() {
.execute(deps.as_mut(), mock_env(), minter, mint_msg)
.unwrap();

let msg = to_binary("You now have the melting power").unwrap();
let msg = to_json_binary("You now have the melting power").unwrap();
let target = String::from("another_contract");
let send_msg = ExecuteMsg::SendNft {
contract: target.clone(),
Expand Down Expand Up @@ -516,15 +516,15 @@ fn approving_all_revoking_all() {
// random can now send
let inner_msg = WasmMsg::Execute {
contract_addr: "another_contract".into(),
msg: to_binary("You now also have the growing power").unwrap(),
msg: to_json_binary("You now also have the growing power").unwrap(),
funds: vec![],
};
let msg: CosmosMsg = CosmosMsg::Wasm(inner_msg);

let send_msg = ExecuteMsg::SendNft {
contract: String::from("another_contract"),
token_id: token_id2,
msg: to_binary(&msg).unwrap(),
msg: to_json_binary(&msg).unwrap(),
};
contract
.execute(deps.as_mut(), mock_env(), random, send_msg)
Expand Down
6 changes: 3 additions & 3 deletions terra/contracts/cw721-base/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{ExecuteMsg, QueryMsg};
use cosmwasm_std::{to_binary, Addr, CosmosMsg, QuerierWrapper, StdResult, WasmMsg, WasmQuery};
use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, QuerierWrapper, StdResult, WasmMsg, WasmQuery};
use cw721::{
AllNftInfoResponse, Approval, ApprovalResponse, ApprovalsResponse, ContractInfoResponse,
NftInfoResponse, NumTokensResponse, OperatorsResponse, OwnerOfResponse, TokensResponse,
Expand All @@ -17,7 +17,7 @@ impl Cw721Contract {
}

pub fn call<T: Serialize>(&self, msg: ExecuteMsg<T>) -> StdResult<CosmosMsg> {
let msg = to_binary(&msg)?;
let msg = to_json_binary(&msg)?;
Ok(WasmMsg::Execute {
contract_addr: self.addr().into(),
msg,
Expand All @@ -33,7 +33,7 @@ impl Cw721Contract {
) -> StdResult<T> {
let query = WasmQuery::Smart {
contract_addr: self.addr().into(),
msg: to_binary(&req)?,
msg: to_json_binary(&req)?,
}
.into();
querier.query(&query)
Expand Down
24 changes: 12 additions & 12 deletions terra/contracts/cw721-base/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::de::DeserializeOwned;
use serde::Serialize;

use cosmwasm_std::{to_binary, Binary, BlockInfo, Deps, Env, Order, StdError, StdResult};
use cosmwasm_std::{to_json_binary, Binary, BlockInfo, Deps, Env, Order, StdError, StdResult};

use cw0::maybe_addr;
use cw721::{
Expand Down Expand Up @@ -210,19 +210,19 @@ where

pub fn query(&self, deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Minter {} => to_binary(&self.minter(deps)?),
QueryMsg::ContractInfo {} => to_binary(&self.contract_info(deps)?),
QueryMsg::NftInfo { token_id } => to_binary(&self.nft_info(deps, token_id)?),
QueryMsg::Minter {} => to_json_binary(&self.minter(deps)?),
QueryMsg::ContractInfo {} => to_json_binary(&self.contract_info(deps)?),
QueryMsg::NftInfo { token_id } => to_json_binary(&self.nft_info(deps, token_id)?),
QueryMsg::OwnerOf {
token_id,
include_expired,
} => {
to_binary(&self.owner_of(deps, env, token_id, include_expired.unwrap_or(false))?)
to_json_binary(&self.owner_of(deps, env, token_id, include_expired.unwrap_or(false))?)
}
QueryMsg::AllNftInfo {
token_id,
include_expired,
} => to_binary(&self.all_nft_info(
} => to_json_binary(&self.all_nft_info(
deps,
env,
token_id,
Expand All @@ -233,28 +233,28 @@ where
include_expired,
start_after,
limit,
} => to_binary(&self.operators(
} => to_json_binary(&self.operators(
deps,
env,
owner,
include_expired.unwrap_or(false),
start_after,
limit,
)?),
QueryMsg::NumTokens {} => to_binary(&self.num_tokens(deps)?),
QueryMsg::NumTokens {} => to_json_binary(&self.num_tokens(deps)?),
QueryMsg::Tokens {
owner,
start_after,
limit,
} => to_binary(&self.tokens(deps, owner, start_after, limit)?),
} => to_json_binary(&self.tokens(deps, owner, start_after, limit)?),
QueryMsg::AllTokens { start_after, limit } => {
to_binary(&self.all_tokens(deps, start_after, limit)?)
to_json_binary(&self.all_tokens(deps, start_after, limit)?)
}
QueryMsg::Approval {
token_id,
spender,
include_expired,
} => to_binary(&self.approval(
} => to_json_binary(&self.approval(
deps,
env,
token_id,
Expand All @@ -265,7 +265,7 @@ where
token_id,
include_expired,
} => {
to_binary(&self.approvals(deps, env, token_id, include_expired.unwrap_or(false))?)
to_json_binary(&self.approvals(deps, env, token_id, include_expired.unwrap_or(false))?)
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions terra/contracts/cw721-wrapped/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod state;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

pub use cosmwasm_std::to_binary;
pub use cosmwasm_std::to_json_binary;
use cosmwasm_std::Empty;

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)]
Expand Down Expand Up @@ -33,7 +33,7 @@ pub mod entry {
use super::*;

use cosmwasm_std::{
entry_point, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response,
entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response,
StdError, StdResult, WasmMsg,
};
use cw721::Cw721Query;
Expand Down Expand Up @@ -111,18 +111,18 @@ pub mod entry {
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
let base = Cw721MetadataContract::default();
match msg {
QueryMsg::WrappedAssetInfo {} => to_binary(&query_wrapped_asset_info(deps)?),
QueryMsg::WrappedAssetInfo {} => to_json_binary(&query_wrapped_asset_info(deps)?),
QueryMsg::OwnerOf {
token_id,
include_expired,
} => {
to_binary(&base.owner_of(deps, env, token_id, include_expired.unwrap_or(false))?)
to_json_binary(&base.owner_of(deps, env, token_id, include_expired.unwrap_or(false))?)
}
QueryMsg::Approval {
token_id,
spender,
include_expired,
} => to_binary(&base.approval(
} => to_json_binary(&base.approval(
deps,
env,
token_id,
Expand All @@ -133,37 +133,37 @@ pub mod entry {
token_id,
include_expired,
} => {
to_binary(&base.approvals(deps, env, token_id, include_expired.unwrap_or(false))?)
to_json_binary(&base.approvals(deps, env, token_id, include_expired.unwrap_or(false))?)
}
QueryMsg::AllOperators {
owner,
include_expired,
start_after,
limit,
} => to_binary(&base.operators(
} => to_json_binary(&base.operators(
deps,
env,
owner,
include_expired.unwrap_or(false),
start_after,
limit,
)?),
QueryMsg::NumTokens {} => to_binary(&base.num_tokens(deps)?),
QueryMsg::NumTokens {} => to_json_binary(&base.num_tokens(deps)?),
QueryMsg::Tokens {
owner,
start_after,
limit,
} => to_binary(&base.tokens(deps, owner, start_after, limit)?),
} => to_json_binary(&base.tokens(deps, owner, start_after, limit)?),
QueryMsg::AllTokens { start_after, limit } => {
to_binary(&base.all_tokens(deps, start_after, limit)?)
to_json_binary(&base.all_tokens(deps, start_after, limit)?)
}
QueryMsg::Minter {} => to_binary(&base.minter(deps)?),
QueryMsg::ContractInfo {} => to_binary(&base.contract_info(deps)?),
QueryMsg::NftInfo { token_id } => to_binary(&base.nft_info(deps, token_id)?),
QueryMsg::Minter {} => to_json_binary(&base.minter(deps)?),
QueryMsg::ContractInfo {} => to_json_binary(&base.contract_info(deps)?),
QueryMsg::NftInfo { token_id } => to_json_binary(&base.nft_info(deps, token_id)?),
QueryMsg::AllNftInfo {
token_id,
include_expired,
} => to_binary(&base.all_nft_info(
} => to_json_binary(&base.all_nft_info(
deps,
env,
token_id,
Expand Down
6 changes: 3 additions & 3 deletions terra/contracts/mock-bridge-integration/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{
entry_point, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest,
entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest,
Reply, Response, StdError, StdResult, SubMsg, WasmMsg, WasmQuery,
};

Expand Down Expand Up @@ -63,7 +63,7 @@ fn complete_transfer_with_payload(
let messages = vec![SubMsg::reply_on_success(
CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: cfg.token_bridge_contract,
msg: to_binary(&TokenBridgeExecuteMsg::CompleteTransferWithPayload {
msg: to_json_binary(&TokenBridgeExecuteMsg::CompleteTransferWithPayload {
data: data.clone(),
relayer: info.sender.to_string(),
})?,
Expand All @@ -88,7 +88,7 @@ fn parse_transfer_vaa(deps: Deps, data: &Binary) -> StdResult<TransferInfoRespon
let transfer_info: TransferInfoResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: cfg.token_bridge_contract,
msg: to_binary(&TokenBridgeQueryMessage::TransferInfo { vaa: data.clone() })?,
msg: to_json_binary(&TokenBridgeQueryMessage::TransferInfo { vaa: data.clone() })?,
}))?;
Ok(transfer_info)
}
Loading

0 comments on commit 8d196f2

Please sign in to comment.