From 8d196f2fe47b20c860cc3ad538a013c6337cd253 Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Wed, 6 Dec 2023 14:06:38 +0000 Subject: [PATCH] terra: s/to_binary/to_json_binary/ (deprecation) --- terra/contracts/cw20-wrapped/src/contract.rs | 12 ++--- .../cw721-base/src/contract_tests.rs | 8 +-- terra/contracts/cw721-base/src/helpers.rs | 6 +-- terra/contracts/cw721-base/src/query.rs | 24 ++++----- terra/contracts/cw721-wrapped/src/lib.rs | 28 +++++----- .../mock-bridge-integration/src/contract.rs | 6 +-- terra/contracts/nft-bridge/src/contract.rs | 30 +++++------ terra/contracts/token-bridge/src/contract.rs | 54 +++++++++---------- terra/contracts/wormhole/src/contract.rs | 14 ++--- terra/packages/cw20-legacy/src/allowances.rs | 2 +- terra/packages/cw20-legacy/src/contract.rs | 16 +++--- terra/packages/cw20-legacy/src/enumerable.rs | 13 +++-- terra/packages/cw721/src/receiver.rs | 4 +- 13 files changed, 111 insertions(+), 106 deletions(-) diff --git a/terra/contracts/cw20-wrapped/src/contract.rs b/terra/contracts/cw20-wrapped/src/contract.rs index dcfc72bf45..90bea91ae3 100644 --- a/terra/contracts/cw20-wrapped/src/contract.rs +++ b/terra/contracts/cw20-wrapped/src/contract.rs @@ -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"))] @@ -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 { 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)?) } } } diff --git a/terra/contracts/cw721-base/src/contract_tests.rs b/terra/contracts/cw721-base/src/contract_tests.rs index 998036df19..40236a1542 100644 --- a/terra/contracts/cw721-base/src/contract_tests.rs +++ b/terra/contracts/cw721-base/src/contract_tests.rs @@ -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::{ @@ -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(), @@ -516,7 +516,7 @@ 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); @@ -524,7 +524,7 @@ fn approving_all_revoking_all() { 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) diff --git a/terra/contracts/cw721-base/src/helpers.rs b/terra/contracts/cw721-base/src/helpers.rs index abb59a21a3..a609b48c8a 100644 --- a/terra/contracts/cw721-base/src/helpers.rs +++ b/terra/contracts/cw721-base/src/helpers.rs @@ -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, @@ -17,7 +17,7 @@ impl Cw721Contract { } pub fn call(&self, msg: ExecuteMsg) -> StdResult { - let msg = to_binary(&msg)?; + let msg = to_json_binary(&msg)?; Ok(WasmMsg::Execute { contract_addr: self.addr().into(), msg, @@ -33,7 +33,7 @@ impl Cw721Contract { ) -> StdResult { let query = WasmQuery::Smart { contract_addr: self.addr().into(), - msg: to_binary(&req)?, + msg: to_json_binary(&req)?, } .into(); querier.query(&query) diff --git a/terra/contracts/cw721-base/src/query.rs b/terra/contracts/cw721-base/src/query.rs index 7318529e47..2c6672ee8c 100644 --- a/terra/contracts/cw721-base/src/query.rs +++ b/terra/contracts/cw721-base/src/query.rs @@ -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::{ @@ -210,19 +210,19 @@ where pub fn query(&self, deps: Deps, env: Env, msg: QueryMsg) -> StdResult { 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, @@ -233,7 +233,7 @@ where include_expired, start_after, limit, - } => to_binary(&self.operators( + } => to_json_binary(&self.operators( deps, env, owner, @@ -241,20 +241,20 @@ where 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, @@ -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))?) } } } diff --git a/terra/contracts/cw721-wrapped/src/lib.rs b/terra/contracts/cw721-wrapped/src/lib.rs index bc468583f8..b783528436 100644 --- a/terra/contracts/cw721-wrapped/src/lib.rs +++ b/terra/contracts/cw721-wrapped/src/lib.rs @@ -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)] @@ -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; @@ -111,18 +111,18 @@ pub mod entry { pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { 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, @@ -133,14 +133,14 @@ 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, @@ -148,22 +148,22 @@ pub mod entry { 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, diff --git a/terra/contracts/mock-bridge-integration/src/contract.rs b/terra/contracts/mock-bridge-integration/src/contract.rs index c9ce9794eb..6204ff74ba 100644 --- a/terra/contracts/mock-bridge-integration/src/contract.rs +++ b/terra/contracts/mock-bridge-integration/src/contract.rs @@ -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, }; @@ -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(), })?, @@ -88,7 +88,7 @@ fn parse_transfer_vaa(deps: Deps, data: &Binary) -> StdResult StdResult::Wasm(WasmMsg::Execute { contract_addr: contract_addr.clone(), - msg: to_binary(&cw721_base::msg::ExecuteMsg::>::TransferNft { + msg: to_json_binary(&cw721_base::msg::ExecuteMsg::>::TransferNft { recipient: recipient.to_string(), token_id, })?, @@ -364,7 +364,7 @@ fn handle_initiate_transfer( // This is a deployed wrapped asset, burn it messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: asset.clone(), - msg: to_binary(&cw721_wrapped::msg::ExecuteMsg::Burn::> { + msg: to_json_binary(&cw721_wrapped::msg::ExecuteMsg::Burn::> { token_id: token_id.clone(), })?, funds: vec![], @@ -374,7 +374,7 @@ fn handle_initiate_transfer( .querier .custom_query(&QueryRequest::::Wasm(WasmQuery::Smart { contract_addr: asset.clone(), - msg: to_binary(&cw721_wrapped::msg::QueryMsg::WrappedAssetInfo {})?, + msg: to_json_binary(&cw721_wrapped::msg::QueryMsg::WrappedAssetInfo {})?, }))?; asset_address = wrapped_token_info.asset_address.to_array()?; @@ -383,7 +383,7 @@ fn handle_initiate_transfer( // Native NFT, lock it up messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: asset.clone(), - msg: to_binary(&cw721_base::msg::ExecuteMsg::>::TransferNft { + msg: to_json_binary(&cw721_base::msg::ExecuteMsg::>::TransferNft { recipient: env.contract.address.to_string(), token_id: token_id.clone(), })?, @@ -412,7 +412,7 @@ fn handle_initiate_transfer( deps.querier .custom_query(&QueryRequest::::Wasm(WasmQuery::Smart { contract_addr: asset.clone(), - msg: to_binary(&cw721_base::msg::QueryMsg::ContractInfo {})?, + msg: to_json_binary(&cw721_base::msg::QueryMsg::ContractInfo {})?, }))?; name = string_to_array(&response.name); symbol = string_to_array(&response.symbol); @@ -422,7 +422,7 @@ fn handle_initiate_transfer( deps.querier .custom_query(&QueryRequest::::Wasm(WasmQuery::Smart { contract_addr: asset, - msg: to_binary(&cw721_base::msg::QueryMsg::NftInfo { + msg: to_json_binary(&cw721_base::msg::QueryMsg::NftInfo { token_id: token_id.clone(), })?, }))?; @@ -445,7 +445,7 @@ fn handle_initiate_transfer( messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce, })?, @@ -474,9 +474,9 @@ fn handle_initiate_transfer( pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::WrappedRegistry { chain, address } => { - to_binary(&query_wrapped_registry(deps, chain, address.as_slice())?) + to_json_binary(&query_wrapped_registry(deps, chain, address.as_slice())?) } - QueryMsg::AllWrappedAssets {} => to_binary(&query_all_wrapped_assets(deps)?), + QueryMsg::AllWrappedAssets {} => to_json_binary(&query_all_wrapped_assets(deps)?), } } diff --git a/terra/contracts/token-bridge/src/contract.rs b/terra/contracts/token-bridge/src/contract.rs index 327dbba0eb..78bd96251f 100644 --- a/terra/contracts/token-bridge/src/contract.rs +++ b/terra/contracts/token-bridge/src/contract.rs @@ -26,9 +26,9 @@ use wormhole::{ use cosmwasm_std::entry_point; use cosmwasm_std::{ - coin, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, CustomQuery, Decimal, Deps, - DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest, Reply, Response, StdError, StdResult, - SubMsg, Uint128, WasmMsg, WasmQuery, + coin, to_json_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, CustomQuery, Decimal, + Deps, DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest, Reply, Response, StdError, + StdResult, SubMsg, Uint128, WasmMsg, WasmQuery, }; use crate::{ @@ -123,7 +123,7 @@ pub fn reply(deps: DepsMut, env: Env, _msg: Reply) -> StdResult { let new_balance: BalanceResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: state.token_address.clone(), - msg: to_binary(&TokenQuery::Balance { + msg: to_json_binary(&TokenQuery::Balance { address: env.contract.address.to_string(), })?, }))?; @@ -166,7 +166,7 @@ pub fn reply(deps: DepsMut, env: Env, _msg: Reply) -> StdResult { let message = CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, funds: vec![], - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce: state.nonce, })?, @@ -200,7 +200,7 @@ fn parse_vaa( let cfg = config_read(deps.storage).load()?; let vaa: ParsedVAA = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeQueryMsg::VerifyVAA { + msg: to_json_binary(&WormholeQueryMsg::VerifyVAA { vaa: data.clone(), block_time, })?, @@ -380,7 +380,7 @@ fn handle_attest_meta( } CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract, - msg: to_binary(&WrappedMsg::UpdateMetadata { + msg: to_json_binary(&WrappedMsg::UpdateMetadata { name: get_string_from_32(&meta.name), symbol: get_string_from_32(&meta.symbol), })?, @@ -391,7 +391,7 @@ fn handle_attest_meta( CosmosMsg::Wasm(WasmMsg::Instantiate { admin: Some(env.contract.address.clone().into_string()), code_id: cfg.wrapped_asset_code_id, - msg: to_binary(&WrappedInit { + msg: to_json_binary(&WrappedInit { name: get_string_from_32(&meta.name), symbol: get_string_from_32(&meta.symbol), asset_chain: meta.token_chain, @@ -400,7 +400,7 @@ fn handle_attest_meta( mint: None, init_hook: Some(InitHook { contract_addr: env.contract.address.to_string(), - msg: to_binary(&ExecuteMsg::RegisterAssetHook { + msg: to_json_binary(&ExecuteMsg::RegisterAssetHook { asset_id: asset_id.to_vec().into(), })?, }), @@ -441,7 +441,7 @@ fn handle_create_asset_meta_token( let request = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: asset_address.clone(), - msg: to_binary(&TokenQuery::TokenInfo {})?, + msg: to_json_binary(&TokenQuery::TokenInfo {})?, }); let asset_canonical = deps.api.addr_canonicalize(&asset_address)?; @@ -463,7 +463,7 @@ fn handle_create_asset_meta_token( Ok(Response::new() .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce, })?, @@ -501,7 +501,7 @@ fn handle_create_asset_meta_native_token( Ok(Response::new() .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce, })?, @@ -639,7 +639,7 @@ fn handle_upgrade_contract( .add_message(CosmosMsg::Wasm(WasmMsg::Migrate { contract_addr: env.contract.address.to_string(), new_code_id: new_contract, - msg: to_binary(&MigrateMsg {})?, + msg: to_json_binary(&MigrateMsg {})?, })) .add_attribute("action", "contract_upgrade")) } @@ -786,7 +786,7 @@ fn handle_complete_transfer_token( let mut messages = vec![CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.clone(), - msg: to_binary(&WrappedMsg::Mint { + msg: to_json_binary(&WrappedMsg::Mint { recipient: recipient.to_string(), amount: Uint128::from(amount), })?, @@ -795,7 +795,7 @@ fn handle_complete_transfer_token( if fee != 0 { messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.clone(), - msg: to_binary(&WrappedMsg::Mint { + msg: to_json_binary(&WrappedMsg::Mint { recipient: relayer_address.to_string(), amount: Uint128::from(fee), })?, @@ -827,7 +827,7 @@ fn handle_complete_transfer_token( let token_info: TokenInfoResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: contract_addr.to_string(), - msg: to_binary(&TokenQuery::TokenInfo {})?, + msg: to_json_binary(&TokenQuery::TokenInfo {})?, }))?; let decimals = token_info.decimals; @@ -837,7 +837,7 @@ fn handle_complete_transfer_token( let mut messages = vec![CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.to_string(), - msg: to_binary(&TokenMsg::Transfer { + msg: to_json_binary(&TokenMsg::Transfer { recipient: recipient.to_string(), amount: Uint128::from(amount), })?, @@ -847,7 +847,7 @@ fn handle_complete_transfer_token( if fee != 0 { messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.to_string(), - msg: to_binary(&TokenMsg::Transfer { + msg: to_json_binary(&TokenMsg::Transfer { recipient: relayer_address.to_string(), amount: Uint128::from(fee), })?, @@ -1038,7 +1038,7 @@ fn handle_initiate_transfer_token( // This is a deployed wrapped asset, burn it messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: asset.clone(), - msg: to_binary(&WrappedMsg::Burn { + msg: to_json_binary(&WrappedMsg::Burn { account: info.sender.to_string(), amount, })?, @@ -1046,7 +1046,7 @@ fn handle_initiate_transfer_token( })); let request = QueryRequest::Wasm(WasmQuery::Smart { contract_addr: asset, - msg: to_binary(&WrappedQuery::WrappedAssetInfo {})?, + msg: to_json_binary(&WrappedQuery::WrappedAssetInfo {})?, }); let wrapped_token_info: WrappedAssetInfoResponse = deps.querier.query(&request)?; asset_chain = wrapped_token_info.asset_chain; @@ -1086,7 +1086,7 @@ fn handle_initiate_transfer_token( messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce, })?, @@ -1099,7 +1099,7 @@ fn handle_initiate_transfer_token( let token_info: TokenInfoResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: asset.clone(), - msg: to_binary(&TokenQuery::TokenInfo {})?, + msg: to_json_binary(&TokenQuery::TokenInfo {})?, }))?; let decimals = token_info.decimals; @@ -1123,7 +1123,7 @@ fn handle_initiate_transfer_token( submessages.push(SubMsg::reply_on_success( CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: asset.clone(), - msg: to_binary(&TokenMsg::TransferFrom { + msg: to_json_binary(&TokenMsg::TransferFrom { owner: info.sender.to_string(), recipient: env.contract.address.to_string(), amount, @@ -1144,7 +1144,7 @@ fn handle_initiate_transfer_token( let balance: BalanceResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: asset.to_string(), - msg: to_binary(&TokenQuery::Balance { + msg: to_json_binary(&TokenQuery::Balance { address: env.contract.address.to_string(), })?, }))?; @@ -1312,7 +1312,7 @@ fn handle_initiate_transfer_native_token( let sender = deps.api.addr_canonicalize(info.sender.as_str())?; messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: cfg.wormhole_contract, - msg: to_binary(&WormholeExecuteMsg::PostMessage { + msg: to_json_binary(&WormholeExecuteMsg::PostMessage { message: Binary::from(token_bridge_message.serialize()), nonce, })?, @@ -1338,9 +1338,9 @@ fn handle_initiate_transfer_native_token( pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::WrappedRegistry { chain, address } => { - to_binary(&query_wrapped_registry(deps, chain, address.as_slice())?) + to_json_binary(&query_wrapped_registry(deps, chain, address.as_slice())?) } - QueryMsg::TransferInfo { vaa } => to_binary(&query_transfer_info(deps, env, &vaa)?), + QueryMsg::TransferInfo { vaa } => to_json_binary(&query_transfer_info(deps, env, &vaa)?), } } diff --git a/terra/contracts/wormhole/src/contract.rs b/terra/contracts/wormhole/src/contract.rs index ddc7beb496..332843aa8b 100644 --- a/terra/contracts/wormhole/src/contract.rs +++ b/terra/contracts/wormhole/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - has_coins, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, + has_coins, to_json_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Storage, WasmMsg, }; @@ -250,7 +250,7 @@ fn vaa_update_contract(_deps: DepsMut, env: Env, data: &[u8]) -> StdResult StdResult { match msg { - QueryMsg::GuardianSetInfo {} => to_binary(&query_guardian_set_info(deps)?), - QueryMsg::VerifyVAA { vaa, block_time } => to_binary(&query_parse_and_verify_vaa( + QueryMsg::GuardianSetInfo {} => to_json_binary(&query_guardian_set_info(deps)?), + QueryMsg::VerifyVAA { vaa, block_time } => to_json_binary(&query_parse_and_verify_vaa( deps, vaa.as_slice(), block_time, )?), - QueryMsg::GetState {} => to_binary(&query_state(deps)?), - QueryMsg::QueryAddressHex { address } => to_binary(&query_address_hex(deps, &address)?), + QueryMsg::GetState {} => to_json_binary(&query_state(deps)?), + QueryMsg::QueryAddressHex { address } => { + to_json_binary(&query_address_hex(deps, &address)?) + } } } diff --git a/terra/packages/cw20-legacy/src/allowances.rs b/terra/packages/cw20-legacy/src/allowances.rs index 23b8070743..944b444111 100644 --- a/terra/packages/cw20-legacy/src/allowances.rs +++ b/terra/packages/cw20-legacy/src/allowances.rs @@ -296,7 +296,7 @@ mod tests { use super::*; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coins, CosmosMsg, Timestamp, WasmMsg, SubMsg}; + use cosmwasm_std::{coins, CosmosMsg, SubMsg, Timestamp, WasmMsg}; use cw20::{Cw20Coin, TokenInfoResponse}; use crate::contract::{execute, instantiate, query_balance, query_token_info}; diff --git a/terra/packages/cw20-legacy/src/contract.rs b/terra/packages/cw20-legacy/src/contract.rs index 603afcad52..0fdfc0bb77 100644 --- a/terra/packages/cw20-legacy/src/contract.rs +++ b/terra/packages/cw20-legacy/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - attr, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, + attr, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint128, }; @@ -281,19 +281,19 @@ pub fn execute_send( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::Balance { address } => to_binary(&query_balance(deps, address)?), - QueryMsg::TokenInfo {} => to_binary(&query_token_info(deps)?), - QueryMsg::Minter {} => to_binary(&query_minter(deps)?), + QueryMsg::Balance { address } => to_json_binary(&query_balance(deps, address)?), + QueryMsg::TokenInfo {} => to_json_binary(&query_token_info(deps)?), + QueryMsg::Minter {} => to_json_binary(&query_minter(deps)?), QueryMsg::Allowance { owner, spender } => { - to_binary(&query_allowance(deps, owner, spender)?) + to_json_binary(&query_allowance(deps, owner, spender)?) } QueryMsg::AllAllowances { owner, start_after, limit, - } => to_binary(&query_all_allowances(deps, owner, start_after, limit)?), + } => to_json_binary(&query_all_allowances(deps, owner, start_after, limit)?), QueryMsg::AllAccounts { start_after, limit } => { - to_binary(&query_all_accounts(deps, start_after, limit)?) + to_json_binary(&query_all_accounts(deps, start_after, limit)?) } } } @@ -332,7 +332,7 @@ pub fn query_minter(deps: Deps) -> StdResult> { #[cfg(test)] mod tests { use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coins, from_binary, CosmosMsg, StdError, WasmMsg, SubMsg}; + use cosmwasm_std::{coins, from_binary, CosmosMsg, StdError, SubMsg, WasmMsg}; use super::*; diff --git a/terra/packages/cw20-legacy/src/enumerable.rs b/terra/packages/cw20-legacy/src/enumerable.rs index f827ef1be7..a0b80e1db9 100644 --- a/terra/packages/cw20-legacy/src/enumerable.rs +++ b/terra/packages/cw20-legacy/src/enumerable.rs @@ -30,8 +30,9 @@ pub fn query_all_allowances( ) -> StdResult { let owner_addr = deps.api.addr_canonicalize(&owner)?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start: Option> = - calc_range_start_human(deps.api, start_after.map(Addr::unchecked))?.map(Bound::ExclusiveRaw); + let start: Option> = + calc_range_start_human(deps.api, start_after.map(Addr::unchecked))? + .map(Bound::ExclusiveRaw); let allowances: StdResult> = ALLOWANCES .prefix(owner_addr.as_slice()) @@ -57,8 +58,8 @@ pub fn query_all_accounts( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - let start = - calc_range_start_human(deps.api, start_after.map(Addr::unchecked))?.map(Bound::ExclusiveRaw); + let start = calc_range_start_human(deps.api, start_after.map(Addr::unchecked))? + .map(Bound::ExclusiveRaw); let accounts: Result, _> = BALANCES .keys(deps.storage, start, None, Order::Ascending) @@ -79,7 +80,9 @@ pub fn query_all_accounts( mod tests { use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info, mock_dependencies_with_balance}; + use cosmwasm_std::testing::{ + mock_dependencies, mock_dependencies_with_balance, mock_env, mock_info, + }; use cosmwasm_std::Api; use cosmwasm_std::{coins, DepsMut, Uint128}; use cw20::{Cw20Coin, Expiration, TokenInfoResponse}; diff --git a/terra/packages/cw721/src/receiver.rs b/terra/packages/cw721/src/receiver.rs index 4287760c11..48e7f25147 100644 --- a/terra/packages/cw721/src/receiver.rs +++ b/terra/packages/cw721/src/receiver.rs @@ -1,7 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, WasmMsg}; +use cosmwasm_std::{to_json_binary, Binary, CosmosMsg, StdResult, WasmMsg}; /// Cw721ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)] @@ -16,7 +16,7 @@ impl Cw721ReceiveMsg { /// serializes the message pub fn into_binary(self) -> StdResult { let msg = ReceiverExecuteMsg::ReceiveNft(self); - to_binary(&msg) + to_json_binary(&msg) } /// creates a cosmos_msg sending this struct to the named contract