Skip to content

Commit

Permalink
update packages and fix deprecated functions (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored May 24, 2024
1 parent 4919653 commit adcbc3c
Show file tree
Hide file tree
Showing 19 changed files with 626 additions and 1,267 deletions.
1,784 changes: 570 additions & 1,214 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["packages/*", "contracts/accessories/*", "contracts/main/*"]
resolver = "2"

[workspace.package]
edition = "2021"
Expand All @@ -25,8 +26,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", "staking"] }
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "1.0.1"
Expand All @@ -43,4 +44,4 @@ sha2 = "0.10.6"
cw-multi-test = "0.16.2"
polytone-tester = { path = "tests/polytone-tester" }
anyhow = { version = "1.0.51" }
cw-orch = { version = "0.19.0" }
cw-orch = { version = "0.22.2" }
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
2 changes: 1 addition & 1 deletion packages/cw-orch-polytone/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::PathBuf;

use crate::{PolytoneNote, PolytoneProxy, PolytoneVoice};
use cw_orch::{
deploy::Deploy,
contract::Deploy,
prelude::{ContractInstance, CwEnv, CwOrchError, CwOrchInstantiate, CwOrchUpload},
};

Expand Down
4 changes: 2 additions & 2 deletions packages/cw-orch-polytone/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cw_orch::{interface, prelude::*};
pub struct PolytoneNote<Chain>;

impl<Chain: CwEnv> Uploadable for PolytoneNote<Chain> {
fn wrapper(&self) -> <Mock as TxHandler>::ContractSource {
fn wrapper() -> <Mock as TxHandler>::ContractSource {
Box::new(
ContractWrapper::new(
polytone_note::contract::execute,
Expand All @@ -27,7 +27,7 @@ impl<Chain: CwEnv> Uploadable for PolytoneNote<Chain> {
),
)
}
fn wasm(&self) -> WasmPath {
fn wasm(_chain_info: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("polytone_note")
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions packages/cw-orch-polytone/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cw_orch::{interface, prelude::*};
pub struct PolytoneProxy<Chain>;

impl<Chain: CwEnv> Uploadable for PolytoneProxy<Chain> {
fn wrapper(&self) -> <Mock as TxHandler>::ContractSource {
fn wrapper() -> <Mock as TxHandler>::ContractSource {
Box::new(
ContractWrapper::new(
polytone_proxy::contract::execute,
Expand All @@ -19,7 +19,7 @@ impl<Chain: CwEnv> Uploadable for PolytoneProxy<Chain> {
.with_reply(polytone_proxy::contract::reply),
)
}
fn wasm(&self) -> WasmPath {
fn wasm(_chain_info: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("polytone_proxy")
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions packages/cw-orch-polytone/src/voice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cw_orch::{interface, prelude::*};
pub struct PolytoneVoice<Chain>;

impl<Chain: CwEnv> Uploadable for PolytoneVoice<Chain> {
fn wrapper(&self) -> <Mock as TxHandler>::ContractSource {
fn wrapper() -> <Mock as TxHandler>::ContractSource {
Box::new(
ContractWrapper::new(
polytone_voice::contract::execute,
Expand All @@ -27,7 +27,7 @@ impl<Chain: CwEnv> Uploadable for PolytoneVoice<Chain> {
),
)
}
fn wasm(&self) -> WasmPath {
fn wasm(_chain_info: &ChainInfoOwned) -> WasmPath {
artifacts_dir_from_workspace!()
.find_wasm_path("polytone_voice")
.unwrap()
Expand Down
12 changes: 6 additions & 6 deletions packages/polytone/src/ack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{from_json, to_binary, Binary, IbcAcknowledgement, SubMsgResponse, Uint64};
use cosmwasm_std::{from_json, to_json_binary, Binary, IbcAcknowledgement, SubMsgResponse, Uint64};

pub use crate::callbacks::Callback;
use crate::callbacks::{ErrorResponse, ExecutionResponse};
Expand All @@ -12,12 +12,12 @@ pub type Ack = Callback;

/// Serializes an ACK-SUCCESS containing the provided data.
pub fn ack_query_success(result: Vec<Binary>) -> Binary {
to_binary(&Callback::Query(Ok(result))).unwrap()
to_json_binary(&Callback::Query(Ok(result))).unwrap()
}

/// Serializes an ACK-SUCCESS for a query that failed.
pub fn ack_query_fail(message_index: Uint64, error: String) -> Binary {
to_binary(&Callback::Query(Err(ErrorResponse {
to_json_binary(&Callback::Query(Err(ErrorResponse {
message_index,
error,
})))
Expand All @@ -26,7 +26,7 @@ pub fn ack_query_fail(message_index: Uint64, error: String) -> Binary {

/// Serializes an ACK-SUCCESS for execution that succeeded.
pub fn ack_execute_success(result: Vec<SubMsgResponse>, executed_by: String) -> Binary {
to_binary(&Callback::Execute(Ok(ExecutionResponse {
to_json_binary(&Callback::Execute(Ok(ExecutionResponse {
result,
executed_by,
})))
Expand All @@ -35,12 +35,12 @@ pub fn ack_execute_success(result: Vec<SubMsgResponse>, executed_by: String) ->

/// Serializes an ACK-SUCCESS for execution that failed.
pub fn ack_execute_fail(error: String) -> Binary {
to_binary(&Callback::Execute(Err(error))).unwrap()
to_json_binary(&Callback::Execute(Err(error))).unwrap()
}

/// Serializes an ACK-FAIL containing the provided error.
pub fn ack_fail(err: String) -> Binary {
to_binary(&Callback::FatalError(err)).unwrap()
to_json_binary(&Callback::FatalError(err)).unwrap()
}

/// Unmarshals an ACK from an acknowledgement returned by the SDK. If
Expand Down
4 changes: 2 additions & 2 deletions packages/polytone/src/callbacks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{
to_binary, Addr, Api, Binary, CosmosMsg, IbcPacketAckMsg, IbcPacketTimeoutMsg, StdResult,
to_json_binary, Addr, Api, Binary, CosmosMsg, IbcPacketAckMsg, IbcPacketTimeoutMsg, StdResult,
Storage, SubMsgResponse, Uint64, WasmMsg,
};
use cw_storage_plus::Map;
Expand Down Expand Up @@ -178,7 +178,7 @@ fn callback_message(request: PendingCallback, result: Callback) -> CosmosMsg {
}
WasmMsg::Execute {
contract_addr: request.receiver.into_string(),
msg: to_binary(&C::Callback(CallbackMessage {
msg: to_json_binary(&C::Callback(CallbackMessage {
initiator: request.initiator,
initiator_msg: request.initiator_msg,
result,
Expand Down
Loading

0 comments on commit adcbc3c

Please sign in to comment.