diff --git a/contracts/consumer/converter/src/contract.rs b/contracts/consumer/converter/src/contract.rs index 95678efb..226bafd6 100644 --- a/contracts/consumer/converter/src/contract.rs +++ b/contracts/consumer/converter/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{ - ensure_eq, to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, Deps, DepsMut, Event, Fraction, - MessageInfo, Reply, Response, SubMsg, SubMsgResponse, Uint128, Validator, WasmMsg, + ensure_eq, to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, Deps, DepsMut, Event, + Fraction, MessageInfo, Reply, Response, SubMsg, SubMsgResponse, Uint128, Validator, WasmMsg, }; use cw2::set_contract_version; use cw_storage_plus::Item; @@ -203,7 +203,7 @@ impl ConverterContract<'_> { let msg = virtual_staking_api::ExecMsg::Bond { validator, amount }; let msg = WasmMsg::Execute { contract_addr: self.virtual_stake.load(deps.storage)?.into(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; @@ -227,7 +227,7 @@ impl ConverterContract<'_> { let msg = virtual_staking_api::ExecMsg::Unbond { validator, amount }; let msg = WasmMsg::Execute { contract_addr: self.virtual_stake.load(deps.storage)?.into(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; @@ -254,7 +254,7 @@ impl ConverterContract<'_> { }; let msg = WasmMsg::Execute { contract_addr: self.virtual_stake.load(deps.storage)?.into(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; diff --git a/contracts/consumer/converter/src/ibc.rs b/contracts/consumer/converter/src/ibc.rs index 4af04b93..e81006c5 100644 --- a/contracts/consumer/converter/src/ibc.rs +++ b/contracts/consumer/converter/src/ibc.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_slice, to_binary, DepsMut, Env, Event, Ibc3ChannelOpenResponse, IbcBasicResponse, + from_json, to_json_binary, DepsMut, Env, Event, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcMsg, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, Validator, @@ -73,7 +73,7 @@ pub fn ibc_channel_open( version: SUPPORTED_IBC_PROTOCOL_VERSION.to_string(), } } else { - let v: ProtocolVersion = from_slice(channel.version.as_bytes())?; + let v: ProtocolVersion = from_json(channel.version.as_bytes())?; // if we can build a response to this, then it is compatible. And we use the highest version there v.build_response(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)? }; @@ -108,7 +108,7 @@ pub fn ibc_channel_connect( // Ensure the counterparty responded with a version we support. // Note: here, we error if it is higher than what we proposed originally - let v: ProtocolVersion = from_slice(counterparty_version.as_bytes())?; + let v: ProtocolVersion = from_json(counterparty_version.as_bytes())?; v.verify_compatibility(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)?; // store the channel @@ -162,7 +162,7 @@ pub(crate) fn valset_update_msg( }; let msg = IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id.clone(), - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout_validator(env), }; Ok(msg) @@ -188,7 +188,7 @@ pub fn ibc_packet_receive( _env: Env, msg: IbcPacketReceiveMsg, ) -> Result { - let packet: ProviderPacket = from_slice(&msg.packet.data)?; + let packet: ProviderPacket = from_json(&msg.packet.data)?; let contract = ConverterContract::new(); let res = match packet { ProviderPacket::Stake { @@ -246,7 +246,7 @@ pub fn ibc_packet_ack( _env: Env, msg: IbcPacketAckMsg, ) -> Result { - let ack: AckWrapper = from_slice(&msg.acknowledgement.data)?; + let ack: AckWrapper = from_json(&msg.acknowledgement.data)?; let mut res = IbcBasicResponse::new(); match ack { AckWrapper::Result(_) => {} @@ -286,7 +286,7 @@ pub(crate) fn make_ibc_packet( let channel = IBC_CHANNEL.load(ctx.deps.storage)?; Ok(IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout_rewards(&ctx.env), }) } diff --git a/contracts/consumer/remote-price-feed/src/ibc.rs b/contracts/consumer/remote-price-feed/src/ibc.rs index 3bd960fc..8124079c 100644 --- a/contracts/consumer/remote-price-feed/src/ibc.rs +++ b/contracts/consumer/remote-price-feed/src/ibc.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_slice, to_binary, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, + from_json, to_json_binary, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcMsg, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, Timestamp, @@ -65,7 +65,7 @@ pub fn ibc_channel_open( } // we handshake with the counterparty version, it must not be empty - let v: ProtocolVersion = from_slice(counterparty_version.as_bytes())?; + let v: ProtocolVersion = from_json(counterparty_version.as_bytes())?; // if we can build a response to this, then it is compatible. And we use the highest version there let version = v.build_response(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)?; @@ -125,7 +125,7 @@ pub fn ibc_packet_ack( _env: Env, msg: IbcPacketAckMsg, ) -> Result { - let ack: PriceFeedProviderAck = from_slice(&msg.acknowledgement.data)?; + let ack: PriceFeedProviderAck = from_json(&msg.acknowledgement.data)?; let PriceFeedProviderAck::Update { time, twap } = ack; let contract = RemotePriceFeedContract::new(); contract.update_twap(deps, time, twap)?; @@ -149,7 +149,7 @@ pub(crate) fn make_ibc_packet( ) -> Result { Ok(IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout(now), }) } diff --git a/contracts/consumer/virtual-staking/src/contract.rs b/contracts/consumer/virtual-staking/src/contract.rs index 3fe73893..7d4b029b 100644 --- a/contracts/consumer/virtual-staking/src/contract.rs +++ b/contracts/consumer/virtual-staking/src/contract.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, HashMap, HashSet}; use cosmwasm_std::{ - coin, ensure_eq, entry_point, to_binary, Coin, CosmosMsg, CustomQuery, DepsMut, + coin, ensure_eq, entry_point, to_json_binary, Coin, CosmosMsg, CustomQuery, DepsMut, DistributionMsg, Env, Event, Reply, Response, StdResult, Storage, SubMsg, Uint128, Validator, WasmMsg, }; @@ -262,7 +262,7 @@ impl VirtualStakingContract<'_> { }; let msg = WasmMsg::Execute { contract_addr: cfg.converter.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; let resp = Response::new().add_message(msg); @@ -338,7 +338,7 @@ impl VirtualStakingContract<'_> { }; let msg = WasmMsg::Execute { contract_addr: cfg.converter.into_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![coin(total.into(), cfg.denom)], }; Ok(Response::new().add_message(msg)) @@ -644,7 +644,7 @@ mod tests { }; use cosmwasm_std::{ - coins, from_binary, + coins, from_json, testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage}, Decimal, }; @@ -1221,12 +1221,12 @@ mod tests { match msg { mesh_bindings::VirtualStakeQuery::BondStatus { .. } => { cosmwasm_std::SystemResult::Ok(cosmwasm_std::ContractResult::Ok( - to_binary(&*bs_copy.borrow()).unwrap(), + to_json_binary(&*bs_copy.borrow()).unwrap(), )) } mesh_bindings::VirtualStakeQuery::SlashRatio {} => { cosmwasm_std::SystemResult::Ok(cosmwasm_std::ContractResult::Ok( - to_binary(&*slash_ratio.borrow()).unwrap(), + to_json_binary(&*slash_ratio.borrow()).unwrap(), )) } } @@ -1515,7 +1515,7 @@ mod tests { .. }] => { if let converter_api::ExecMsg::DistributeRewards { mut payments } = - from_binary(bin_msg).unwrap() + from_json(bin_msg).unwrap() { payments.sort(); Self::Batch(payments) diff --git a/contracts/osmosis-price-provider/src/ibc.rs b/contracts/osmosis-price-provider/src/ibc.rs index ee4646cc..94116910 100644 --- a/contracts/osmosis-price-provider/src/ibc.rs +++ b/contracts/osmosis-price-provider/src/ibc.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_slice, to_binary, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, + from_json, to_json_binary, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, StdError, Timestamp, @@ -46,7 +46,7 @@ pub fn ibc_channel_open( version: SUPPORTED_IBC_PROTOCOL_VERSION.to_string(), } } else { - let v: ProtocolVersion = from_slice(channel.version.as_bytes())?; + let v: ProtocolVersion = from_json(channel.version.as_bytes())?; // if we can build a response to this, then it is compatible. And we use the highest version there v.build_response(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)? }; @@ -77,7 +77,7 @@ pub fn ibc_channel_connect( // Ensure the counterparty responded with a version we support. // Note: here, we error if it is higher than what we proposed originally - let v: ProtocolVersion = from_slice(counterparty_version.as_bytes())?; + let v: ProtocolVersion = from_json(counterparty_version.as_bytes())?; v.verify_compatibility(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)?; let contract = OsmosisPriceProvider::new(); @@ -124,12 +124,17 @@ pub fn ibc_packet_receive( pool_id, base_asset, quote_asset, - } = from_slice(&msg.packet.data)?; + } = from_json(&msg.packet.data)?; let contract = OsmosisPriceProvider::new(); let time = env.block.time; let twap = contract.query_twap(deps, pool_id, base_asset, quote_asset)?; - Ok(IbcReceiveResponse::new().set_ack(to_binary(&PriceFeedProviderAck::Update { time, twap })?)) + Ok( + IbcReceiveResponse::new().set_ack(to_json_binary(&PriceFeedProviderAck::Update { + time, + twap, + })?), + ) } #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/provider/external-staking/src/contract.rs b/contracts/provider/external-staking/src/contract.rs index 02a773b7..50d8e7e2 100644 --- a/contracts/provider/external-staking/src/contract.rs +++ b/contracts/provider/external-staking/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - coin, ensure, ensure_eq, to_binary, Coin, Decimal, DepsMut, Env, Event, IbcMsg, Order, + coin, ensure, ensure_eq, to_json_binary, Coin, Decimal, DepsMut, Env, Event, IbcMsg, Order, Response, StdResult, Storage, Uint128, Uint256, WasmMsg, }; use cw2::set_contract_version; @@ -306,7 +306,7 @@ impl ExternalStakingContract<'_> { }; let msg = IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout(&env), }; // send packet if we are ibc enabled @@ -783,7 +783,7 @@ impl ExternalStakingContract<'_> { let channel_id = IBC_CHANNEL.load(ctx.deps.storage)?.endpoint.channel_id; let send_msg = IbcMsg::SendPacket { channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout(&ctx.env), }; @@ -1206,7 +1206,7 @@ pub mod cross_staking { use crate::msg::ReceiveVirtualStake; use super::*; - use cosmwasm_std::{from_binary, Binary}; + use cosmwasm_std::{from_json, Binary}; use mesh_apis::{cross_staking_api::CrossStakingApi, local_staking_api::SlashRatioResponse}; #[contract(module=crate::contract)] @@ -1236,7 +1236,7 @@ pub mod cross_staking { let owner = ctx.deps.api.addr_validate(&owner)?; // parse and validate message - let msg: ReceiveVirtualStake = from_binary(&msg)?; + let msg: ReceiveVirtualStake = from_json(&msg)?; if !self .val_set .is_active_validator(ctx.deps.storage, &msg.validator)? @@ -1276,7 +1276,7 @@ pub mod cross_staking { }; let msg = IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout(&ctx.env), }; // add ibc packet if we are ibc enabled (skip in tests) @@ -1402,7 +1402,7 @@ pub mod cross_staking { }; let msg = IbcMsg::SendPacket { channel_id: channel.endpoint.channel_id, - data: to_binary(&packet)?, + data: to_json_binary(&packet)?, timeout: packet_timeout(&ctx.env), }; let mut resp = Response::new(); @@ -1620,7 +1620,7 @@ mod tests { OWNER.to_string(), coin(100, "uosmo"), 1, - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: "bob".to_string(), }) .unwrap(), @@ -1670,7 +1670,7 @@ mod tests { msgs[0], WasmMsg::Execute { contract_addr: "vault_addr".to_string(), - msg: to_binary(&CrossSlash { + msg: to_json_binary(&CrossSlash { slashes: vec![SlashInfo { user: OWNER.to_string(), slash: Uint128::new(10), @@ -1751,7 +1751,7 @@ mod tests { OWNER.to_string(), coin(100, "uosmo"), 1, - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: "bob".to_string(), }) .unwrap(), @@ -1800,7 +1800,7 @@ mod tests { msgs[0], WasmMsg::Execute { contract_addr: "vault_addr".to_string(), - msg: to_binary(&CrossSlash { + msg: to_json_binary(&CrossSlash { slashes: vec![SlashInfo { user: OWNER.to_string(), slash: Uint128::new(10), @@ -1881,7 +1881,7 @@ mod tests { OWNER.to_string(), coin(100, "uosmo"), 1, - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: "bob".to_string(), }) .unwrap(), @@ -1944,7 +1944,7 @@ mod tests { msgs[0], WasmMsg::Execute { contract_addr: "vault_addr".to_string(), - msg: to_binary(&CrossSlash { + msg: to_json_binary(&CrossSlash { slashes: vec![SlashInfo { user: OWNER.to_string(), slash: Uint128::new(10), // Owner is slashed over the full stake, including pending @@ -2295,7 +2295,7 @@ mod tests { OWNER.to_string(), coin(100, "uosmo"), 1, - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: "bob".to_string(), }) .unwrap(), @@ -2345,7 +2345,7 @@ mod tests { msgs[0], WasmMsg::Execute { contract_addr: "vault_addr".to_string(), - msg: to_binary(&CrossSlash { + msg: to_json_binary(&CrossSlash { slashes: vec![SlashInfo { user: OWNER.to_string(), slash: Uint128::new(10), diff --git a/contracts/provider/external-staking/src/ibc.rs b/contracts/provider/external-staking/src/ibc.rs index 6e3795fe..2672b90d 100644 --- a/contracts/provider/external-staking/src/ibc.rs +++ b/contracts/provider/external-staking/src/ibc.rs @@ -2,7 +2,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_slice, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, + from_json, DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, }; @@ -69,7 +69,7 @@ pub fn ibc_channel_open( } // we handshake with the counterparty version, it must not be empty - let v: ProtocolVersion = from_slice(counterparty_version.as_bytes())?; + let v: ProtocolVersion = from_json(counterparty_version.as_bytes())?; // if we can build a response to this, then it is compatible. And we use the highest version there let version = v.build_response(SUPPORTED_IBC_PROTOCOL_VERSION, MIN_IBC_PROTOCOL_VERSION)?; @@ -123,7 +123,7 @@ pub fn ibc_packet_receive( // If a validator is in more than one of the events, the end result will depend on the // processing order below. let contract = ExternalStakingContract::new(); - let packet: ConsumerPacket = from_slice(&msg.packet.data)?; + let packet: ConsumerPacket = from_json(&msg.packet.data)?; let resp = match packet { ConsumerPacket::ValsetUpdate { height, @@ -178,9 +178,9 @@ pub fn ibc_packet_ack( env: Env, msg: IbcPacketAckMsg, ) -> Result { - let packet: ProviderPacket = from_slice(&msg.original_packet.data)?; + let packet: ProviderPacket = from_json(&msg.original_packet.data)?; let contract = ExternalStakingContract::new(); - let ack: AckWrapper = from_slice(&msg.acknowledgement.data)?; + let ack: AckWrapper = from_json(&msg.acknowledgement.data)?; let mut resp = IbcBasicResponse::new(); match (packet, ack) { @@ -251,7 +251,7 @@ pub fn ibc_packet_timeout( _env: Env, msg: IbcPacketTimeoutMsg, ) -> Result { - let packet: ProviderPacket = from_slice(&msg.packet.data)?; + let packet: ProviderPacket = from_json(&msg.packet.data)?; let contract = ExternalStakingContract::new(); let mut resp = IbcBasicResponse::new().add_attribute("action", "ibc_packet_timeout"); match packet { diff --git a/contracts/provider/external-staking/src/multitest.rs b/contracts/provider/external-staking/src/multitest.rs index 2d8041a3..da895300 100644 --- a/contracts/provider/external-staking/src/multitest.rs +++ b/contracts/provider/external-staking/src/multitest.rs @@ -2,7 +2,7 @@ mod utils; use anyhow::Result as AnyResult; -use cosmwasm_std::{coin, coins, to_binary, Decimal, Uint128}; +use cosmwasm_std::{coin, coins, to_json_binary, Decimal, Uint128}; use mesh_native_staking::contract::multitest_utils::CodeId as NativeStakingCodeId; use mesh_native_staking::contract::InstantiateMsg as NativeStakingInstantiateMsg; use mesh_native_staking_proxy::contract::multitest_utils::CodeId as NativeStakingProxyCodeId; @@ -60,7 +60,7 @@ fn setup<'app>( let staking_init = StakingInitInfo { admin: None, code_id: native_staking_code.code_id(), - msg: to_binary(&native_staking_instantiate)?, + msg: to_json_binary(&native_staking_instantiate)?, label: Some("Native staking".to_owned()), }; @@ -133,7 +133,7 @@ fn staking() { /* // Fail to stake on non-registered validator - let msg = to_binary(&ReceiveVirtualStake { + let msg = to_json_binary(&ReceiveVirtualStake { validator: "unknown".to_string(), }) .unwrap(); @@ -836,7 +836,7 @@ fn distribution() { .stake_remote( contract.contract_addr.to_string(), coin(300, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validators[1].to_string(), }) .unwrap(), @@ -1683,7 +1683,7 @@ fn slashing_pending_tx_bond() { .stake_remote( contract.contract_addr.to_string(), coin(50, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validators[0].into(), }) .unwrap(), @@ -1770,7 +1770,7 @@ fn slashing_pending_tx_bond_rolled_back() { .stake_remote( contract.contract_addr.to_string(), coin(50, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validators[0].into(), }) .unwrap(), diff --git a/contracts/provider/external-staking/src/multitest/utils.rs b/contracts/provider/external-staking/src/multitest/utils.rs index e7e7694e..e7cc773d 100644 --- a/contracts/provider/external-staking/src/multitest/utils.rs +++ b/contracts/provider/external-staking/src/multitest/utils.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{to_binary, Addr, Coin}; +use cosmwasm_std::{to_json_binary, Addr, Coin}; use cw_multi_test::{App as MtApp, AppResponse}; use mesh_apis::{converter_api::RewardInfo, ibc::AddValidator}; use mesh_sync::Tx; @@ -136,7 +136,7 @@ impl VaultExt for Vault<'_> { self.stake_remote( contract.contract_addr.to_string(), coin, - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.into(), }) .unwrap(), diff --git a/contracts/provider/native-staking-proxy/src/contract.rs b/contracts/provider/native-staking-proxy/src/contract.rs index fc7d83ef..f19fa45a 100644 --- a/contracts/provider/native-staking-proxy/src/contract.rs +++ b/contracts/provider/native-staking-proxy/src/contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::WasmMsg::Execute; use cosmwasm_std::{ - coin, ensure_eq, to_binary, Coin, DistributionMsg, GovMsg, Response, StakingMsg, VoteOption, - WeightedVoteOption, + coin, ensure_eq, to_json_binary, Coin, DistributionMsg, GovMsg, Response, StakingMsg, + VoteOption, WeightedVoteOption, }; use cw2::set_contract_version; use cw_storage_plus::Item; @@ -69,7 +69,7 @@ impl NativeStakingProxyContract<'_> { }; // Pass owner to caller's reply handler - let owner_msg = to_binary(&OwnerMsg { owner })?; + let owner_msg = to_json_binary(&OwnerMsg { owner })?; Ok(res.add_message(set_withdrawal).set_data(owner_msg)) } @@ -318,7 +318,7 @@ impl NativeStakingProxyContract<'_> { } // Send them to the parent contract via `release_proxy_stake` - let msg = to_binary(&native_staking_callback::ExecMsg::ReleaseProxyStake {})?; + let msg = to_json_binary(&native_staking_callback::ExecMsg::ReleaseProxyStake {})?; let wasm_msg = Execute { contract_addr: cfg.parent.to_string(), @@ -411,7 +411,7 @@ mod tests { // Assert data payload assert_eq!( res.data.unwrap(), - to_binary(&OwnerMsg { + to_json_binary(&OwnerMsg { owner: OWNER.to_owned(), }) .unwrap() diff --git a/contracts/provider/native-staking-proxy/src/multitest.rs b/contracts/provider/native-staking-proxy/src/multitest.rs index be3d9d27..a89fc034 100644 --- a/contracts/provider/native-staking-proxy/src/multitest.rs +++ b/contracts/provider/native-staking-proxy/src/multitest.rs @@ -1,7 +1,7 @@ use anyhow::Result as AnyResult; use cosmwasm_std::testing::mock_env; -use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, Validator}; +use cosmwasm_std::{coin, coins, to_json_binary, Addr, Decimal, Validator}; use cw_multi_test::{App as MtApp, StakingInfo, StakingSudo, SudoMsg}; @@ -65,7 +65,7 @@ fn setup<'app>( let staking_init_info = mesh_vault::msg::StakingInitInfo { admin: None, code_id: staking_code.code_id(), - msg: to_binary(&mesh_native_staking::contract::InstantiateMsg { + msg: to_json_binary(&mesh_native_staking::contract::InstantiateMsg { denom: OSMO.to_owned(), proxy_code_id: staking_proxy_code.code_id(), slash_ratio_dsign: Decimal::percent(5), @@ -94,7 +94,7 @@ fn setup<'app>( vault .stake_local( coin(100, OSMO), - to_binary(&mesh_native_staking::msg::StakeMsg { + to_json_binary(&mesh_native_staking::msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(), @@ -175,7 +175,7 @@ fn staking() { vault .stake_local( coin(20, OSMO), - to_binary(&mesh_native_staking::msg::StakeMsg { + to_json_binary(&mesh_native_staking::msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(), diff --git a/contracts/provider/native-staking/src/contract.rs b/contracts/provider/native-staking/src/contract.rs index 513f32d6..3aa562a7 100644 --- a/contracts/provider/native-staking/src/contract.rs +++ b/contracts/provider/native-staking/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::Order::Ascending; use cosmwasm_std::{ - from_slice, Addr, Decimal, DepsMut, Env, Event, Reply, Response, StdResult, SubMsgResponse, + from_json, Addr, Decimal, DepsMut, Env, Event, Reply, Response, StdResult, SubMsgResponse, WasmMsg, }; use cw2::set_contract_version; @@ -200,7 +200,7 @@ impl NativeStakingContract<'_> { // Associate staking proxy with owner address let proxy_addr = Addr::unchecked(init_data.contract_address); let owner_data: OwnerMsg = - from_slice(&init_data.data.ok_or(ContractError::NoInstantiateData {})?)?; + from_json(&init_data.data.ok_or(ContractError::NoInstantiateData {})?)?; let owner_addr = deps.api.addr_validate(&owner_data.owner)?; self.proxy_by_owner .save(deps.storage, &owner_addr, &proxy_addr)?; diff --git a/contracts/provider/native-staking/src/local_staking_api.rs b/contracts/provider/native-staking/src/local_staking_api.rs index 97a33eb5..3d9d5a27 100644 --- a/contracts/provider/native-staking/src/local_staking_api.rs +++ b/contracts/provider/native-staking/src/local_staking_api.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{ensure_eq, from_slice, to_binary, Binary, Coin, Response, SubMsg, WasmMsg}; +use cosmwasm_std::{ensure_eq, from_json, to_json_binary, Binary, Coin, Response, SubMsg, WasmMsg}; use cw_utils::{must_pay, nonpayable}; use sylvia::types::QueryCtx; use sylvia::{contract, types::ExecCtx}; @@ -37,7 +37,7 @@ impl LocalStakingApi for NativeStakingContract<'_> { let _paid = must_pay(&ctx.info, &cfg.denom)?; // Parse message to find validator to stake on - let StakeMsg { validator } = from_slice(&msg)?; + let StakeMsg { validator } = from_json(&msg)?; let owner_addr = ctx.deps.api.addr_validate(&owner)?; @@ -52,7 +52,7 @@ impl LocalStakingApi for NativeStakingContract<'_> { { None => { // Instantiate proxy contract and send funds to stake, with reply handling on success - let msg = to_binary(&mesh_native_staking_proxy::contract::InstantiateMsg { + let msg = to_json_binary(&mesh_native_staking_proxy::contract::InstantiateMsg { denom: cfg.denom, owner: owner.clone(), validator, @@ -69,8 +69,9 @@ impl LocalStakingApi for NativeStakingContract<'_> { } Some(proxy_addr) => { // Send stake message with funds to the proxy contract - let msg = - to_binary(&mesh_native_staking_proxy::contract::ExecMsg::Stake { validator })?; + let msg = to_json_binary(&mesh_native_staking_proxy::contract::ExecMsg::Stake { + validator, + })?; let wasm_msg = WasmMsg::Execute { contract_addr: proxy_addr.into(), msg, @@ -109,7 +110,7 @@ impl LocalStakingApi for NativeStakingContract<'_> { None => Err(ContractError::NoProxy(owner)), Some(proxy_addr) => { // Send burn message to the proxy contract - let msg = to_binary(&mesh_native_staking_proxy::contract::ExecMsg::Burn { + let msg = to_json_binary(&mesh_native_staking_proxy::contract::ExecMsg::Burn { validator, amount, })?; diff --git a/contracts/provider/native-staking/src/multitest.rs b/contracts/provider/native-staking/src/multitest.rs index 0ebc4ca9..ff2781bb 100644 --- a/contracts/provider/native-staking/src/multitest.rs +++ b/contracts/provider/native-staking/src/multitest.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - coin, coins, to_binary, Addr, Decimal, Delegation, StdError, Uint128, Validator, + coin, coins, to_json_binary, Addr, Decimal, Delegation, StdError, Uint128, Validator, }; use cw_multi_test::{App as MtApp, StakingInfo}; @@ -162,7 +162,7 @@ fn receiving_stake() { )); // Receive some stake on behalf of user1 for validator - let stake_msg = to_binary(&msg::StakeMsg { + let stake_msg = to_json_binary(&msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(); @@ -186,7 +186,7 @@ fn receiving_stake() { assert_delegations(&app, &proxy1, &[(validator, 100)]); // Stake some more - let stake_msg = to_binary(&msg::StakeMsg { + let stake_msg = to_json_binary(&msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(); @@ -217,7 +217,7 @@ fn receiving_stake() { assert_delegations(&app, &proxy1, &[(validator, 150)]); // Receive some stake on behalf of user2 for validator - let stake_msg = to_binary(&msg::StakeMsg { + let stake_msg = to_json_binary(&msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(); @@ -264,7 +264,7 @@ fn releasing_proxy_stake() { let staking_init_info = mesh_vault::msg::StakingInitInfo { admin: None, code_id: staking_code.code_id(), - msg: to_binary(&crate::contract::InstantiateMsg { + msg: to_json_binary(&crate::contract::InstantiateMsg { denom: OSMO.to_owned(), proxy_code_id: staking_proxy_code.code_id(), slash_ratio_dsign: slashing_rate_dsign(), @@ -308,7 +308,7 @@ fn releasing_proxy_stake() { vault .stake_local( coin(100, OSMO), - to_binary(&msg::StakeMsg { + to_json_binary(&msg::StakeMsg { validator: validator.to_owned(), }) .unwrap(), diff --git a/contracts/provider/vault/src/multitest.rs b/contracts/provider/vault/src/multitest.rs index 9d8c35ec..12a44466 100644 --- a/contracts/provider/vault/src/multitest.rs +++ b/contracts/provider/vault/src/multitest.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{coin, coins, to_binary, Addr, Decimal, Uint128, Validator}; +use cosmwasm_std::{coin, coins, to_json_binary, Addr, Decimal, Uint128, Validator}; use cw_multi_test::{App as MtApp, StakingInfo}; use mesh_apis::ibc::AddValidator; use mesh_external_staking::contract::multitest_utils::ExternalStakingContractProxy; @@ -135,7 +135,7 @@ fn setup_inner<'app>( Some(StakingInitInfo { admin: None, code_id: native_staking_code.code_id(), - msg: to_binary(&native_staking_inst_msg).unwrap(), + msg: to_json_binary(&native_staking_inst_msg).unwrap(), label: None, }) } else { @@ -223,7 +223,7 @@ fn stake_locally( }; vault - .stake_local(coin(stake, OSMO), to_binary(&msg).unwrap()) + .stake_local(coin(stake, OSMO), to_json_binary(&msg).unwrap()) .call(user) } @@ -239,7 +239,7 @@ fn stake_remotely( .stake_remote( cross_staking.contract_addr.to_string(), coin(*amount, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -470,7 +470,7 @@ fn local_staking_disabled() { .stake_remote( cross_staking.contract_addr.to_string(), coin(100, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: remote_val.to_string(), }) .unwrap(), @@ -723,7 +723,7 @@ fn stake_cross() { .stake_remote( cross_staking.contract_addr.to_string(), coin(100, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -796,7 +796,7 @@ fn stake_cross() { .stake_remote( cross_staking.contract_addr.to_string(), coin(150, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -862,7 +862,7 @@ fn stake_cross() { .stake_remote( cross_staking.contract_addr.to_string(), coin(150, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -1118,7 +1118,7 @@ fn stake_cross_txs() { .stake_remote( cross_staking.contract_addr.to_string(), coin(100, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -1136,7 +1136,7 @@ fn stake_cross_txs() { .stake_remote( cross_staking.contract_addr.to_string(), coin(50, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -1151,7 +1151,7 @@ fn stake_cross_txs() { .stake_remote( cross_staking.contract_addr.to_string(), coin(100, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -1327,7 +1327,7 @@ fn stake_cross_rollback_tx() { .stake_remote( cross_staking.contract_addr.to_string(), coin(100, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), @@ -1484,7 +1484,7 @@ fn multiple_stakes() { .stake_remote( cross_staking2.contract_addr.to_string(), coin(400, OSMO), - to_binary(&ReceiveVirtualStake { + to_json_binary(&ReceiveVirtualStake { validator: validator.to_string(), }) .unwrap(), diff --git a/packages/apis/src/cross_staking_api.rs b/packages/apis/src/cross_staking_api.rs index 2bd4df96..c02fbbc1 100644 --- a/packages/apis/src/cross_staking_api.rs +++ b/packages/apis/src/cross_staking_api.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, Binary, Coin, Deps, Response, StdError, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Binary, Coin, Deps, Response, StdError, WasmMsg}; use sylvia::types::{ExecCtx, QueryCtx}; use sylvia::{interface, schemars}; @@ -72,7 +72,7 @@ impl CrossStakingApiHelper { }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds, }; Ok(wasm) @@ -91,7 +91,7 @@ impl CrossStakingApiHelper { }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) diff --git a/packages/apis/src/ibc/packet.rs b/packages/apis/src/ibc/packet.rs index 400dd79f..0978b9e8 100644 --- a/packages/apis/src/ibc/packet.rs +++ b/packages/apis/src/ibc/packet.rs @@ -1,7 +1,7 @@ use std::error::Error; use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Binary, Coin, Decimal, StdResult, Timestamp}; +use cosmwasm_std::{to_json_binary, Binary, Coin, Decimal, StdResult, Timestamp}; use crate::converter_api::{RewardInfo, ValidatorSlashInfo}; @@ -166,14 +166,14 @@ pub enum AckWrapper { // create a serialized success message pub fn ack_success(data: &T) -> StdResult { - let res = AckWrapper::Result(to_binary(data)?); - to_binary(&res) + let res = AckWrapper::Result(to_json_binary(data)?); + to_json_binary(&res) } // create a serialized error message pub fn ack_fail(err: E) -> StdResult { let res = AckWrapper::Error(err.to_string()); - to_binary(&res) + to_json_binary(&res) } #[cw_serde] diff --git a/packages/apis/src/local_staking_api.rs b/packages/apis/src/local_staking_api.rs index 00ec9a2b..f2be8dd9 100644 --- a/packages/apis/src/local_staking_api.rs +++ b/packages/apis/src/local_staking_api.rs @@ -1,5 +1,7 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, Binary, Coin, Decimal, Deps, Response, StdError, WasmMsg}; +use cosmwasm_std::{ + to_json_binary, Addr, Binary, Coin, Decimal, Deps, Response, StdError, WasmMsg, +}; use sylvia::types::{ExecCtx, QueryCtx}; use sylvia::{interface, schemars}; @@ -69,7 +71,7 @@ impl LocalStakingApiHelper { let msg = LocalStakingApiExecMsg::ReceiveStake { owner, msg }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds, }; Ok(wasm) @@ -88,7 +90,7 @@ impl LocalStakingApiHelper { }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) diff --git a/packages/apis/src/vault_api.rs b/packages/apis/src/vault_api.rs index b3470e78..56d25686 100644 --- a/packages/apis/src/vault_api.rs +++ b/packages/apis/src/vault_api.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, Coin, Response, StdError, Uint128, WasmMsg}; +use cosmwasm_std::{to_json_binary, Addr, Coin, Response, StdError, Uint128, WasmMsg}; use sylvia::types::ExecCtx; use sylvia::{interface, schemars}; @@ -90,7 +90,7 @@ impl VaultApiHelper { let msg = VaultApiExecMsg::ReleaseCrossStake { owner, amount }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds, }; Ok(wasm) @@ -106,7 +106,7 @@ impl VaultApiHelper { let msg = VaultApiExecMsg::ReleaseLocalStake { owner }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds, }; Ok(wasm) @@ -123,7 +123,7 @@ impl VaultApiHelper { }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) @@ -140,7 +140,7 @@ impl VaultApiHelper { }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) @@ -150,7 +150,7 @@ impl VaultApiHelper { let msg = VaultApiExecMsg::CommitTx { tx_id }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) @@ -160,7 +160,7 @@ impl VaultApiHelper { let msg = VaultApiExecMsg::RollbackTx { tx_id }; let wasm = WasmMsg::Execute { contract_addr: self.0.to_string(), - msg: to_binary(&msg)?, + msg: to_json_binary(&msg)?, funds: vec![], }; Ok(wasm) diff --git a/packages/virtual-staking-mock/src/lib.rs b/packages/virtual-staking-mock/src/lib.rs index 49cb0390..09abfeb6 100644 --- a/packages/virtual-staking-mock/src/lib.rs +++ b/packages/virtual-staking-mock/src/lib.rs @@ -2,8 +2,8 @@ use anyhow::Result as AnyResult; use cosmwasm_std::{ coin, testing::{MockApi, MockStorage}, - to_binary, Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, QuerierWrapper, Storage, - Uint128, + to_json_binary, Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, QuerierWrapper, + Storage, Uint128, }; use cw_multi_test::{AppResponse, BankKeeper, Module, WasmKeeper}; use cw_storage_plus::{Item, Map}; @@ -173,16 +173,16 @@ impl Module for VirtualStakingModule { let cap = self.caps.load(storage, Addr::unchecked(&contract))?; let bonded = self.bonded_for_contract(storage, Addr::unchecked(contract))?; - to_binary(&BondStatusResponse { + to_json_binary(&BondStatusResponse { cap: coin(cap.u128(), &denom), delegated: coin(bonded.u128(), denom), })? } mesh_bindings::VirtualStakeQuery::SlashRatio {} => { - to_binary(&self.slash_ratio.load(storage)?)? + to_json_binary(&self.slash_ratio.load(storage)?)? } }; - Ok(to_binary(&result)?) + Ok(to_json_binary(&result)?) } }