Skip to content

Commit

Permalink
chore: fixing cosmwasm-std to v1.3.4 (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgorenflo authored Apr 11, 2024
1 parent af22fee commit 5b33bfd
Show file tree
Hide file tree
Showing 33 changed files with 141 additions and 152 deletions.
16 changes: 7 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rust-version = "1.75.0" # be sure there is an optimizer release supporting this
[workspace.dependencies]
connection-router = { version = "^0.1.0", path = "contracts/connection-router" }
cosmwasm-std = "1.3.4"
cosmwasm-schema = "1.3.3"
cosmwasm-schema = "1.3.4"
cw-storage-plus = "1.1.0"
error-stack = { version = "0.4.0", features = ["eyre"] }
events = { version = "^0.1.0", path = "packages/events" }
Expand Down
8 changes: 4 additions & 4 deletions contracts/aggregate-verifier/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axelar_wasm_std::utils::TryMapExt;
use axelar_wasm_std::{FnExt, VerificationStatus};
use connection_router_api::{CrossChainId, Message};
use cosmwasm_std::{to_json_binary, Addr, QuerierWrapper, QueryRequest, WasmMsg, WasmQuery};
use cosmwasm_std::{to_binary, Addr, QuerierWrapper, QueryRequest, WasmMsg, WasmQuery};
use error_stack::{Result, ResultExt};
use serde::de::DeserializeOwned;
use std::collections::HashMap;
Expand All @@ -15,7 +15,7 @@ impl Verifier<'_> {
fn execute(&self, msg: &crate::msg::ExecuteMsg) -> WasmMsg {
WasmMsg::Execute {
contract_addr: self.address.to_string(),
msg: to_json_binary(msg).expect("msg should always be serializable"),
msg: to_binary(msg).expect("msg should always be serializable"),
funds: vec![],
}
}
Expand All @@ -24,7 +24,7 @@ impl Verifier<'_> {
self.querier
.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: self.address.to_string(),
msg: to_json_binary(&msg).expect("msg should always be serializable"),
msg: to_binary(&msg).expect("msg should always be serializable"),
}))
.change_context(Error::QueryVerifier)
}
Expand Down Expand Up @@ -120,7 +120,7 @@ mod tests {
fn verifier_returns_error_on_return_type_mismatch() {
let mut querier = MockQuerier::default();
querier.update_wasm(|_| {
Ok(to_json_binary(
Ok(to_binary(
&CrossChainId::from_str(format!("eth{}0x1234", CHAIN_NAME_DELIMITER).as_str())
.unwrap(),
)
Expand Down
12 changes: 6 additions & 6 deletions contracts/aggregate-verifier/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use connection_router_api::CrossChainId;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
from_json, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, QueryRequest, Reply,
Response, StdResult, WasmQuery,
from_binary, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, QueryRequest, Reply, Response,
StdResult, WasmQuery,
};
use cw_utils::{parse_reply_execute_data, MsgExecuteContractResponse};

Expand Down Expand Up @@ -45,7 +45,7 @@ pub fn execute(
}

pub mod execute {
use cosmwasm_std::{to_json_binary, SubMsg, WasmMsg};
use cosmwasm_std::{to_binary, SubMsg, WasmMsg};

use connection_router_api::Message;

Expand All @@ -59,7 +59,7 @@ pub mod execute {
Ok(Response::new().add_submessage(SubMsg::reply_on_success(
WasmMsg::Execute {
contract_addr: verifier.to_string(),
msg: to_json_binary(&voting_msg::ExecuteMsg::VerifyMessages { messages: msgs })?,
msg: to_binary(&voting_msg::ExecuteMsg::VerifyMessages { messages: msgs })?,
funds: vec![],
},
VERIFY_REPLY,
Expand All @@ -79,7 +79,7 @@ pub fn reply(
match parse_reply_execute_data(reply) {
Ok(MsgExecuteContractResponse { data: Some(data) }) => {
// check format of data
let _: Vec<(CrossChainId, VerificationStatus)> = from_json(&data)?;
let _: Vec<(CrossChainId, VerificationStatus)> = from_binary(&data)?;

// only one verifier, so just return the response as is
Ok(Response::new().set_data(data))
Expand All @@ -102,7 +102,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
let verifier = CONFIG.load(deps.storage)?.verifier;
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: verifier.to_string(),
msg: to_json_binary(&voting_msg::QueryMsg::GetMessagesStatus { messages })?,
msg: to_binary(&voting_msg::QueryMsg::GetMessagesStatus { messages })?,
}))
}
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/aggregate-verifier/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use aggregate_verifier::error::ContractError;
use axelar_wasm_std::VerificationStatus;
use connection_router_api::{CrossChainId, Message};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{to_json_binary, Addr, DepsMut, Env, MessageInfo, Response};
use cosmwasm_std::{to_binary, Addr, DepsMut, Env, MessageInfo, Response};
use cw_multi_test::{App, ContractWrapper, Executor};
use cw_storage_plus::Map;

Expand Down Expand Up @@ -33,7 +33,7 @@ pub fn mock_verifier_execute(
None => res.push((m.cc_id, VerificationStatus::None)),
}
}
Ok(Response::new().set_data(to_json_binary(&res)?))
Ok(Response::new().set_data(to_binary(&res)?))
}
MockVotingVerifierExecuteMsg::MessagesVerified { messages } => {
for m in messages {
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn make_mock_voting_verifier(app: &mut App) -> Addr {
|_, _, _, _: MockVotingVerifierInstantiateMsg| {
Ok::<Response, ContractError>(Response::new())
},
|_, _, _: aggregate_verifier::msg::QueryMsg| to_json_binary(&()),
|_, _, _: aggregate_verifier::msg::QueryMsg| to_binary(&()),
);
let code_id = app.store_code(Box::new(code));

Expand Down
10 changes: 5 additions & 5 deletions contracts/aggregate-verifier/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aggregate_verifier::msg::ExecuteMsg;
use axelar_wasm_std::VerificationStatus;
use connection_router_api::{CrossChainId, Message};
use cosmwasm_std::from_json;
use cosmwasm_std::from_binary;
use cosmwasm_std::Addr;
use cw_multi_test::App;

Expand Down Expand Up @@ -48,7 +48,7 @@ fn verify_messages_empty() {
&ExecuteMsg::VerifyMessages { messages: vec![] },
)
.unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_binary(&res.data.unwrap()).unwrap();
assert_eq!(ret, vec![]);
}

Expand All @@ -72,7 +72,7 @@ fn verify_messages_not_verified() {
},
)
.unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_binary(&res.data.unwrap()).unwrap();
assert_eq!(
ret,
messages
Expand Down Expand Up @@ -104,7 +104,7 @@ fn verify_messages_verified() {
},
)
.unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_binary(&res.data.unwrap()).unwrap();
assert_eq!(
ret,
messages
Expand Down Expand Up @@ -137,7 +137,7 @@ fn verify_messages_mixed_status() {
},
)
.unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap();
let ret: Vec<(CrossChainId, VerificationStatus)> = from_binary(&res.data.unwrap()).unwrap();
assert_eq!(
ret,
messages
Expand Down
9 changes: 4 additions & 5 deletions contracts/connection-router/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_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};

use connection_router_api::msg::{ExecuteMsg, QueryMsg};

Expand Down Expand Up @@ -108,9 +108,9 @@ pub fn query(
msg: QueryMsg,
) -> Result<Binary, axelar_wasm_std::ContractError> {
match msg {
QueryMsg::GetChainInfo(chain) => to_json_binary(&query::get_chain_info(deps, chain)?),
QueryMsg::GetChainInfo(chain) => to_binary(&query::get_chain_info(deps, chain)?),
QueryMsg::Chains { start_after, limit } => {
to_json_binary(&query::chains(deps, start_after, limit)?)
to_binary(&query::chains(deps, start_after, limit)?)
}
}
.map_err(axelar_wasm_std::ContractError::from)
Expand Down Expand Up @@ -215,8 +215,7 @@ mod test {
assert_eq!(
CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr,
msg: to_json_binary(&gateway_api::msg::ExecuteMsg::RouteMessages(messages,))
.unwrap(),
msg: to_binary(&gateway_api::msg::ExecuteMsg::RouteMessages(messages,)).unwrap(),
funds: vec![],
}),
cosmos_msg
Expand Down
4 changes: 2 additions & 2 deletions contracts/connection-router/src/contract/execute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::vec;

use cosmwasm_std::{to_json_binary, Addr, DepsMut, MessageInfo, Response, StdResult, WasmMsg};
use cosmwasm_std::{to_binary, Addr, DepsMut, MessageInfo, Response, StdResult, WasmMsg};
use error_stack::report;
use itertools::Itertools;

Expand Down Expand Up @@ -190,7 +190,7 @@ where

Ok(WasmMsg::Execute {
contract_addr: gateway.to_string(),
msg: to_json_binary(&gateway_api::msg::ExecuteMsg::RouteMessages(
msg: to_binary(&gateway_api::msg::ExecuteMsg::RouteMessages(
msgs.cloned().collect(),
))
.expect("must serialize message"),
Expand Down
4 changes: 2 additions & 2 deletions contracts/gateway/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum Error {
mod internal {
use aggregate_verifier::client::Verifier;
use connection_router_api::client::Router;
use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response};
use error_stack::{Result, ResultExt};
use gateway_api::msg::{ExecuteMsg, QueryMsg};

Expand Down Expand Up @@ -125,7 +125,7 @@ mod internal {
match msg {
QueryMsg::GetOutgoingMessages { message_ids } => {
let msgs = contract::query::get_outgoing_messages(deps.storage, message_ids)?;
to_json_binary(&msgs).change_context(Error::SerializeResponse)
to_binary(&msgs).change_context(Error::SerializeResponse)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/gateway/tests/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info, MockQuerier}
#[cfg(not(feature = "generate_golden_files"))]
use cosmwasm_std::Response;
use cosmwasm_std::{
from_json, to_json_binary, Addr, ContractResult, DepsMut, QuerierResult, WasmQuery,
from_binary, to_binary, Addr, ContractResult, DepsMut, QuerierResult, WasmQuery,
};
use itertools::Itertools;
use serde::Serialize;
Expand Down Expand Up @@ -146,7 +146,7 @@ fn successful_route_outgoing() {
if msgs.is_empty() {
assert_eq!(
query_response.unwrap(),
to_json_binary::<Vec<CrossChainId>>(&vec![]).unwrap()
to_binary::<Vec<CrossChainId>>(&vec![]).unwrap()
)
} else {
assert!(query_response.is_err());
Expand All @@ -173,7 +173,7 @@ fn successful_route_outgoing() {
// check all outgoing messages are stored because the router (sender) is implicitly trusted
iter::repeat(query(deps.as_ref(), mock_env().clone(), query_msg).unwrap())
.take(2)
.for_each(|response| assert_eq!(response, to_json_binary(&msgs).unwrap()));
.for_each(|response| assert_eq!(response, to_binary(&msgs).unwrap()));
}

let golden_file = "tests/test_route_outgoing.json";
Expand Down Expand Up @@ -423,8 +423,8 @@ fn update_query_handler<U: Serialize>(
) {
let handler = move |msg: &WasmQuery| match msg {
WasmQuery::Smart { msg, .. } => {
let result = handler(from_json(msg).expect("should not fail to deserialize"))
.map(|response| to_json_binary(&response).expect("should not fail to serialize"));
let result = handler(from_binary(msg).expect("should not fail to deserialize"))
.map(|response| to_binary(&response).expect("should not fail to serialize"));

QuerierResult::Ok(ContractResult::from(result))
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/multisig-prover/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_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult,
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult,
};

use crate::{
Expand Down Expand Up @@ -94,8 +94,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetProof {
multisig_session_id,
} => to_json_binary(&query::get_proof(deps, multisig_session_id)?),
QueryMsg::GetWorkerSet {} => to_json_binary(&query::get_worker_set(deps)?),
} => to_binary(&query::get_proof(deps, multisig_session_id)?),
QueryMsg::GetWorkerSet {} => to_binary(&query::get_worker_set(deps)?),
}
}

Expand Down
10 changes: 5 additions & 5 deletions contracts/multisig-prover/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;

use cosmwasm_std::{
to_json_binary, wasm_execute, Addr, DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest,
to_binary, wasm_execute, Addr, DepsMut, Env, MessageInfo, QuerierWrapper, QueryRequest,
Response, Storage, SubMsg, WasmQuery,
};

Expand Down Expand Up @@ -89,7 +89,7 @@ fn get_messages(
let query = gateway_api::msg::QueryMsg::GetOutgoingMessages { message_ids };
let messages: Vec<Message> = querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: gateway.into(),
msg: to_json_binary(&query)?,
msg: to_binary(&query)?,
}))?;

assert!(
Expand All @@ -116,7 +116,7 @@ fn get_workers_info(deps: &DepsMut, config: &Config) -> Result<WorkersInfo, Cont
let workers: Vec<WeightedWorker> =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.service_registry.to_string(),
msg: to_json_binary(&active_workers_query)?,
msg: to_binary(&active_workers_query)?,
}))?;

let participants = workers
Expand All @@ -136,7 +136,7 @@ fn get_workers_info(deps: &DepsMut, config: &Config) -> Result<WorkersInfo, Cont
};
let pub_key: PublicKey = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.multisig.to_string(),
msg: to_json_binary(&pub_key_query)?,
msg: to_binary(&pub_key_query)?,
}))?;
pub_keys.push(pub_key);
}
Expand Down Expand Up @@ -254,7 +254,7 @@ fn ensure_worker_set_verification(

let status: VerificationStatus = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.voting_verifier.to_string(),
msg: to_json_binary(&query)?,
msg: to_binary(&query)?,
}))?;

if status != VerificationStatus::SucceededOnChain {
Expand Down
4 changes: 2 additions & 2 deletions contracts/multisig-prover/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{
to_json_binary, Deps, QueryRequest, StdError, StdResult, Uint256, Uint64, WasmQuery,
to_binary, Deps, QueryRequest, StdError, StdResult, Uint256, Uint64, WasmQuery,
};

use itertools::Itertools;
Expand Down Expand Up @@ -29,7 +29,7 @@ pub fn get_proof(deps: Deps, multisig_session_id: Uint64) -> StdResult<GetProofR

let multisig: Multisig = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.multisig.to_string(),
msg: to_json_binary(&query_msg)?,
msg: to_binary(&query_msg)?,
}))?;

let status = match multisig.state {
Expand Down
Loading

0 comments on commit 5b33bfd

Please sign in to comment.