Skip to content

Commit

Permalink
bump CW-std to v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joldie777 committed Jul 29, 2024
1 parent 19fe454 commit 744a544
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ incremental = false
overflow-checks = true

[workspace.dependencies]
cosmwasm-std = "~2.0.4"
cosmwasm-std = "2.1.0"
cosmwasm-schema = { version = "2.1.0", default-features = false }
cw2 = "2.0.0"
cw-storage-plus = "2.0.0"
schemars = "0.8.15"
serde = { version = "1.0.188", default-features = false }
serde-json-wasm = "1.0.0"
cw-storage-plus = "2.0.0"
cosmwasm-schema = { version = "2.0.4", default-features = false }
base64 = "0.21.7"
prost = "0.12.3"
prost-types = "0.12.1"
Expand Down
31 changes: 5 additions & 26 deletions packages/neutron-std-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
pub fn query(self, querier: &cosmwasm_std::QuerierWrapper<impl cosmwasm_std::CustomQuery>) -> cosmwasm_std::StdResult<#res> {
use prost::Message;
let resp = #res::decode(
// Should be replaced with querier.query_grpc() after updating cosmwasm-std to v2.1.0
self.query_grpc(
querier,
&self.into(),
querier.query_grpc(
#path.to_string(),
self.to_proto_bytes().into(),
)
.unwrap()
.as_slice(),
Expand All @@ -70,26 +69,6 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
Ok(data) => Ok(data),
}
}

// Should be removed after updating cosmwasm-std to v2.1.0
fn query_grpc<Q: cosmwasm_std::CustomQuery>(
&self,
querier: &cosmwasm_std::QuerierWrapper<impl cosmwasm_std::CustomQuery>,
request: &cosmwasm_std::QueryRequest<Q>,
) -> cosmwasm_std::StdResult<cosmwasm_std::Binary> {
let raw = cosmwasm_std::to_json_vec(request).map_err(|serialize_err| {
cosmwasm_std::StdError::generic_err(format!("Serializing QueryRequest: {serialize_err}"))
})?;
match querier.raw_query(&raw) {
cosmwasm_std::SystemResult::Err(system_err) => Err(cosmwasm_std::StdError::generic_err(
format!("Querier system error: {system_err}"),
)),
cosmwasm_std::SystemResult::Ok(cosmwasm_std::ContractResult::Err(contract_err)) => Err(
cosmwasm_std::StdError::generic_err(format!("Querier contract error: {contract_err}")),
),
cosmwasm_std::SystemResult::Ok(cosmwasm_std::ContractResult::Ok(value)) => Ok(value),
}
}
};

(query_request_conversion, cosmwasm_query)
Expand All @@ -98,8 +77,6 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
};

(quote! {
#query_request_conversion

impl #ident {
pub const TYPE_URL: &'static str = #type_url;
#cosmwasm_query
Expand All @@ -118,6 +95,8 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
}
}

#query_request_conversion

impl From<#ident> for cosmwasm_std::Binary {
fn from(msg: #ident) -> Self {
cosmwasm_std::Binary::new(msg.to_proto_bytes())
Expand Down

0 comments on commit 744a544

Please sign in to comment.