Skip to content

Commit

Permalink
update cosmwasm-std to v1.5.4 and fix deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed May 24, 2024
1 parent 4919653 commit 12254d3
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 65 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ polytone-proxy = { path = "contracts/main/proxy", version = "1.0.0" }
polytone-note = { path = "contracts/main/note", version = "1.0.0" }
polytone-voice = { path = "contracts/main/voice", version = "1.0.0" }

cosmwasm-schema = "1.2.1"
cosmwasm-std = { version = "1.5.0", features = ["ibc3"] }
cosmwasm-schema = "1.5.4"
cosmwasm-std = { version = "1.5.4", features = ["ibc3"] }
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "1.0.1"
Expand Down
6 changes: 3 additions & 3 deletions contracts/accessories/listener/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::set_contract_version;

use crate::error::ContractError;
Expand Down Expand Up @@ -60,11 +60,11 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Note {} => to_binary(&NOTE.load(deps.storage)?),
QueryMsg::Note {} => to_json_binary(&NOTE.load(deps.storage)?),
QueryMsg::Result {
initiator,
initiator_msg,
} => to_binary(&ResultResponse {
} => to_json_binary(&ResultResponse {
callback: RESULTS.load(deps.storage, (initiator, initiator_msg))?,
}),
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/accessories/listener/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, Empty, Uint64};
use cosmwasm_std::{to_json_binary, Addr, Empty, Uint64};

use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use polytone::callbacks::{Callback, CallbackMessage};
Expand Down Expand Up @@ -87,7 +87,7 @@ fn test() {
// Allows note to execute callback.
let callback = CallbackMessage {
initiator: Addr::unchecked(INITIATOR_ADDR),
initiator_msg: to_binary(INITIATOR_MSG).unwrap(),
initiator_msg: to_json_binary(INITIATOR_MSG).unwrap(),
result: Callback::Execute(Result::Err("ERROR".to_string())),
};
app.execute_contract(
Expand Down Expand Up @@ -118,7 +118,7 @@ fn test() {
listener,
&QueryMsg::Result {
initiator: INITIATOR_ADDR.to_string(),
initiator_msg: to_binary(INITIATOR_MSG).unwrap().to_string(),
initiator_msg: to_json_binary(INITIATOR_MSG).unwrap().to_string(),
},
)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions contracts/accessories/polytone-tester/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg,
};
use cw2::set_contract_version;

Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn execute(
}
ExecuteMsg::RunOutOfGas {} => Ok(Response::default().add_message(WasmMsg::Execute {
contract_addr: env.contract.address.into_string(),
msg: to_binary(&ExecuteMsg::RunOutOfGas {}).unwrap(),
msg: to_json_binary(&ExecuteMsg::RunOutOfGas {}).unwrap(),
funds: vec![],
})),
}
Expand All @@ -67,10 +67,10 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::History {} => to_binary(&CallbackHistoryResponse {
QueryMsg::History {} => to_json_binary(&CallbackHistoryResponse {
history: CALLBACK_HISTORY.load(deps.storage)?,
}),
QueryMsg::HelloHistory {} => to_binary(&HelloHistoryResponse {
QueryMsg::HelloHistory {} => to_json_binary(&HelloHistoryResponse {
history: HELLO_CALL_HISTORY.load(deps.storage)?,
}),
}
Expand Down
13 changes: 7 additions & 6 deletions contracts/main/note/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, IbcMsg, IbcTimeout, MessageInfo, Response, StdResult,
to_json_binary, Binary, Deps, DepsMut, Env, IbcMsg, IbcTimeout, MessageInfo, Response,
StdResult,
};
use cw2::set_contract_version;
use polytone::callbacks::CallbackRequestType;
Expand Down Expand Up @@ -106,7 +107,7 @@ pub fn execute(
.add_attribute("method", "execute")
.add_message(IbcMsg::SendPacket {
channel_id,
data: to_binary(&ibc::Packet {
data: to_json_binary(&ibc::Packet {
sender: info.sender.into_string(),
msg,
})
Expand All @@ -118,18 +119,18 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::ActiveChannel => to_binary(&CHANNEL.may_load(deps.storage)?),
QueryMsg::Pair => to_binary(&CONNECTION_REMOTE_PORT.may_load(deps.storage)?.map(
QueryMsg::ActiveChannel => to_json_binary(&CHANNEL.may_load(deps.storage)?),
QueryMsg::Pair => to_json_binary(&CONNECTION_REMOTE_PORT.may_load(deps.storage)?.map(
|(connection_id, remote_port)| Pair {
connection_id,
remote_port,
},
)),
QueryMsg::RemoteAddress { local_address } => to_binary(&accounts::query_account(
QueryMsg::RemoteAddress { local_address } => to_json_binary(&accounts::query_account(
deps.storage,
deps.api.addr_validate(&local_address)?,
)?),
QueryMsg::BlockMaxGas => to_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
QueryMsg::BlockMaxGas => to_json_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
}
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/main/note/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{
testing::{mock_dependencies, mock_env, mock_info},
to_binary, Uint64, WasmMsg,
to_json_binary, Uint64, WasmMsg,
};

use crate::{
Expand Down Expand Up @@ -35,7 +35,7 @@ fn simple_note() {
on_behalf_of: None,
msgs: vec![WasmMsg::Execute {
contract_addr: "some_addr".to_string(),
msg: to_binary("some_msg").unwrap(),
msg: to_json_binary("some_msg").unwrap(),
funds: vec![],
}
.into()],
Expand Down
4 changes: 2 additions & 2 deletions contracts/main/proxy/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, SubMsg,
SubMsgResponse, SubMsgResult,
};
use cw2::set_contract_version;
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Instantiator {} => to_binary(&INSTANTIATOR.load(deps.storage)?),
QueryMsg::Instantiator {} => to_json_binary(&INSTANTIATOR.load(deps.storage)?),
}
}

Expand Down
17 changes: 9 additions & 8 deletions contracts/main/voice/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
from_binary, instantiate2_address, to_binary, to_vec, Binary, CodeInfoResponse, ContractResult,
Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, SystemResult, Uint64, WasmMsg,
from_json, instantiate2_address, to_json_binary, to_json_vec, Binary, CodeInfoResponse,
ContractResult, Deps, DepsMut, Env, MessageInfo, Response, StdResult, SubMsg, SystemResult,
Uint64, WasmMsg,
};
use cw2::set_contract_version;

Expand Down Expand Up @@ -59,12 +60,12 @@ pub fn execute(
if info.sender != env.contract.address {
Err(ContractError::NotSelf)
} else {
let Packet { sender, msg } = from_binary(&data)?;
let Packet { sender, msg } = from_json(data)?;
match msg {
Msg::Query { msgs } => {
let mut results = Vec::with_capacity(msgs.len());
for msg in msgs {
let query_result = deps.querier.raw_query(&to_vec(&msg)?);
let query_result = deps.querier.raw_query(&to_json_vec(&msg)?);
let error = match query_result {
SystemResult::Ok(ContractResult::Err(error)) => {
format!("contract: {error}")
Expand Down Expand Up @@ -119,7 +120,7 @@ pub fn execute(
admin: None,
code_id,
label: format!("polytone-proxy {sender}"),
msg: to_binary(&polytone_proxy::msg::InstantiateMsg {})?,
msg: to_json_binary(&polytone_proxy::msg::InstantiateMsg {})?,
funds: vec![],
salt,
}),
Expand All @@ -132,7 +133,7 @@ pub fn execute(
.add_submessage(SubMsg::reply_always(
WasmMsg::Execute {
contract_addr: proxy.into_string(),
msg: to_binary(&polytone_proxy::msg::ExecuteMsg::Proxy {
msg: to_json_binary(&polytone_proxy::msg::ExecuteMsg::Proxy {
msgs,
})?,
funds: vec![],
Expand Down Expand Up @@ -168,8 +169,8 @@ fn salt(local_connection: &str, counterparty_port: &str, remote_sender: &str) ->
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::BlockMaxGas => to_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
QueryMsg::ProxyCodeId => to_binary(&PROXY_CODE_ID.load(deps.storage)?),
QueryMsg::BlockMaxGas => to_json_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
QueryMsg::ProxyCodeId => to_json_binary(&PROXY_CODE_ID.load(deps.storage)?),
}
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/main/voice/src/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
from_binary, to_binary, DepsMut, Env, IbcBasicResponse, IbcChannelCloseMsg,
from_json, to_json_binary, DepsMut, Env, IbcBasicResponse, IbcChannelCloseMsg,
IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcPacketAckMsg,
IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, Never, Reply, Response, SubMsg,
SubMsgResult, WasmMsg,
Expand Down Expand Up @@ -94,7 +94,7 @@ pub fn ibc_packet_receive(
id: REPLY_ACK,
msg: WasmMsg::Execute {
contract_addr: env.contract.address.into_string(),
msg: to_binary(&ExecuteMsg::Rx {
msg: to_json_binary(&ExecuteMsg::Rx {
connection_id,
counterparty_port: msg.packet.src.port_id,
data: msg.packet.data,
Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, Contract
.expect("execution succeeded")
.data
.expect("reply_forward_data sets data");
match from_binary::<Callback>(&data) {
match from_json::<Callback>(&data) {
Ok(_) => Response::default().set_data(data),
Err(e) => Response::default()
.set_data(ack_fail(format!("unmarshalling callback data: ({e})"))),
Expand Down
Loading

0 comments on commit 12254d3

Please sign in to comment.