Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
437 changes: 295 additions & 142 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ exclude = ["examples/*"]
resolver = "2"

[workspace.package]
version = "2.0.0-rc.1"
version = "2.0.0"

[workspace.dependencies]
anyhow = "1.0.98"
cosmwasm-schema = "3.0.0-rc.0"
cosmwasm-std = "3.0.0-rc.0"
cw-multi-test = "3.0.0-rc.0"
cw-storage-plus = "3.0.0-rc.0"
cw-utils = "3.0.0-rc.0"
cosmwasm-schema = "3.0.1"
cosmwasm-std = "3.0.1"
cw-multi-test = "3.0.0"
cw-storage-plus = "3.0.0"
cw-utils = "3.0.0"
schemars = "0.8.22"
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
sylvia-derive = { version = "2.0.0-rc.1", path = "sylvia-derive" }
sylvia-derive = { version = "2.0.0", path = "sylvia-derive" }
thiserror = "2.0.12"

[workspace.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ proc-macro-crate = "3.3.0"
itertools = "0.14.0"

[dev-dependencies]
sylvia-runtime-macros = "0.7.0"
runtime-macros-derive = "0.8.0"
sylvia = { path = "../sylvia", features = [
"mt",
"stargate",
Expand Down
4 changes: 2 additions & 2 deletions sylvia-derive/src/contract/communication/wrapper_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ impl<'a> GlueMessage<'a> {

let mut response_schemas_calls = interfaces.emit_response_schemas_calls(msg_ty, contract);
response_schemas_calls
.push(quote! {<#contract as #sylvia ::types::ContractApi> :: #enum_accessor ::response_schemas_impl()});
.push(quote! {<#contract as #sylvia ::types::ContractApi> :: #enum_accessor ::response_schemas_cw()});

let response_schemas = match msg_ty {
MsgType::Query => {
quote! {
#[cfg(not(target_arch = "wasm32"))]
impl #bracketed_wrapper_generics #sylvia ::cw_schema::QueryResponses for #contract_enum_name #bracketed_wrapper_generics #full_where_clause {
fn response_schemas_impl() -> std::collections::BTreeMap<String, #sylvia ::schemars::schema::RootSchema> {
fn response_schemas_cw() -> std::collections::BTreeMap<String, #sylvia ::schemars::schema::RootSchema> {
let responses = [#(#response_schemas_calls),*];
responses.into_iter().flatten().collect()
}
Expand Down
6 changes: 3 additions & 3 deletions sylvia-derive/src/contract/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl<'a> MtHelpers<'a> {
label,
admin,
)
.map_err(|err| err.downcast().unwrap())
.map_err(|err| StdError::msg(err.to_string()).into())
.map(|addr| #sylvia ::multitest::Proxy {
contract_addr: addr,
app: code_id.app,
Expand Down Expand Up @@ -450,7 +450,7 @@ impl<'a> MtHelpers<'a> {
let app_response = (*code_id.app)
.app_mut()
.execute(sender.clone(), msg.into())
.map_err(|err| err.downcast::< #error_type >().unwrap())?;
.map_err(|err| StdError::msg(err.to_string()).into())?;

#sylvia:: cw_utils::parse_instantiate_response_data(app_response.data.unwrap().as_slice())
.map_err(|err| Into::into( #sylvia ::cw_std::StdError::generic_err(err.to_string())))
Expand Down Expand Up @@ -685,7 +685,7 @@ impl EmitMethods for MsgVariant<'_> {
(*self.app)
.app_mut()
.wasm_sudo(self.contract_addr.clone(), &msg)
.map_err(|err| err.downcast().unwrap())
.map_err(|err| StdError::msg(err.to_string()).into())
}
},
MsgType::Migrate => quote! {
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/interface/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl EmitMethods for MsgVariant<'_> {
(*self.app)
.app_mut()
.wasm_sudo(self.contract_addr.clone(), &msg)
.map_err(|err| err.downcast().unwrap())
.map_err(|err| StdError::msg(err.to_string()).into())
}
},
MsgType::Migrate => quote! {
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ fn entry_points_impl(attr: TokenStream2, item: TokenStream2) -> TokenStream2 {
mod test {
use std::{env, fs};

use sylvia_runtime_macros::emulate_attribute_expansion_fallible;
use runtime_macros_derive::emulate_attribute_expansion_fallible;

use crate::{contract_impl, interface_impl};

Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/types/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Interfaces {

let type_name = msg_ty.as_accessor_name();
quote! {
<#contract as #module ::sv::InterfaceMessagesApi> :: #type_name :: response_schemas_impl()
<#contract as #module ::sv::InterfaceMessagesApi> :: #type_name :: response_schemas_cw()
}
})
.collect()
Expand Down
11 changes: 3 additions & 8 deletions sylvia/src/into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ impl<C> IntoMsg<C> for SubMsg<Empty> {
CosmosMsg::Staking(staking) => CosmosMsg::Staking(staking),
#[cfg(feature = "staking")]
CosmosMsg::Distribution(distribution) => CosmosMsg::Distribution(distribution),
CosmosMsg::Custom(_) => Err(StdError::generic_err(
"Custom Empty message should not be sent",
))?,
CosmosMsg::Custom(_) => Err(StdError::msg("Custom Empty message should not be sent"))?,
#[cfg(feature = "stargate")]
CosmosMsg::Ibc(ibc) => CosmosMsg::Ibc(ibc),
#[cfg(feature = "cosmwasm_2_0")]
CosmosMsg::Any(any) => CosmosMsg::Any(any),
#[cfg(feature = "stargate")]
CosmosMsg::Gov(msg) => CosmosMsg::Gov(msg),
_ => return Err(StdError::generic_err(format!(
_ => return Err(StdError::msg(format!(
"Unknown message variant: {:?}. Please make sure you are using up-to-date Sylvia version, and if so please issue this bug on the Sylvia repository.",
self
))),
Expand Down Expand Up @@ -93,9 +91,6 @@ mod tests {
resp = resp.add_message(CosmosMsg::Custom(Empty {}));

let err = IntoResponse::<MyMsg>::into_response(resp).unwrap_err();
assert_eq!(
err,
StdError::generic_err("Custom Empty message should not be sent")
);
assert_eq!("Custom Empty message should not be sent", err.to_string());
}
}
18 changes: 5 additions & 13 deletions sylvia/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,12 @@ where
&self.msg,
self.funds,
)
.map_err(|err| {
if err.is::<Error>() {
err.downcast::<Error>().unwrap()
} else if err.is::<StdError>() {
err.downcast::<StdError>().unwrap().into()
} else {
StdError::generic_err(err.to_string()).into()
}
})
.map_err(|err| StdError::msg(err.to_string()).into())
}
}

/// Intermiediate proxy to set additional information
/// before sending an migrate message.
/// Intermediate proxy to set additional information
/// before sending a migrate message.
#[must_use]
pub struct MigrateProxy<'a, 'app, Error, Msg, MtApp, ExecC>
where
Expand All @@ -330,7 +322,7 @@ where
impl<'a, 'app, Error, Msg, MtApp, ExecC> MigrateProxy<'a, 'app, Error, Msg, MtApp, ExecC>
where
Msg: Serialize + Debug,
Error: Debug + Display + Send + Sync + 'static,
Error: From<StdError> + Debug + Display + Send + Sync + 'static,
ExecC: cosmwasm_std::CustomMsg + 'static,
MtApp: Executor<ExecC>,
{
Expand Down Expand Up @@ -358,7 +350,7 @@ where
&self.msg,
new_code_id,
)
.map_err(|err| err.downcast().unwrap())
.map_err(|err| StdError::msg(err.to_string()).into())
}
}

Expand Down
1 change: 1 addition & 0 deletions sylvia/tests/custom_msg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmwasm_schema::cw_schema::Schemaifier;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use sylvia::ctx::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx};
Expand Down
14 changes: 4 additions & 10 deletions sylvia/tests/reply_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ fn data_raw() {
.send_message_expecting_data(None, DATA_RAW_REPLY_ID)
.call(&owner)
.unwrap_err();
assert_eq!(
err,
StdError::generic_err("Missing reply data field.").into()
);
assert_eq!(err, StdError::msg("Missing reply data field.").into());

contract
.send_message_expecting_data(data.clone(), DATA_RAW_REPLY_ID)
Expand Down Expand Up @@ -336,7 +333,7 @@ fn data_opt() {
.unwrap_err();
assert_eq!(
err,
StdError::generic_err(
StdError::msg(
"Invalid reply data at block height: 12345, transaction id: 0.\nSerde error while deserializing Error parsing into type alloc::string::String: expected value at line 1 column 1"
).into()
);
Expand Down Expand Up @@ -369,18 +366,15 @@ fn data() {
.send_message_expecting_data(None, DATA_REPLY_ID)
.call(&owner)
.unwrap_err();
assert_eq!(
err,
StdError::generic_err("Missing reply data field.").into()
);
assert_eq!(err, StdError::msg("Missing reply data field.").into());

let err = contract
.send_message_expecting_data(invalid_data, DATA_REPLY_ID)
.call(&owner)
.unwrap_err();
assert_eq!(
err,
StdError::generic_err(
StdError::msg(
"Invalid reply data at block height: 12345, transaction id: 0.\nSerde error while deserializing Error parsing into type alloc::string::String: expected value at line 1 column 1"
).into()
);
Expand Down
11 changes: 5 additions & 6 deletions sylvia/tests/reply_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct InstantiatePayload {
pub sender: Addr,
}

#[derive(Error, Debug, PartialEq)]
#[derive(Error, Debug)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),
Expand Down Expand Up @@ -307,7 +307,7 @@ mod tests {

// Should not dispatch if expected success and execution failed
let err = contract.call_remote_success(true).call(&owner).unwrap_err();
assert_eq!(err, StdError::generic_err("Failed as requested").into());
assert!(err.to_string().contains("Failed as requested"));
let last_reply = contract.last_reply().unwrap();
assert_eq!(last_reply, REMOTE_INSTANTIATED_REPLY_ID);

Expand Down Expand Up @@ -357,9 +357,8 @@ mod tests {
.call_remote_unknown_id(false, unknown_reply_id)
.call(&owner)
.unwrap_err();
assert_eq!(
err,
StdError::generic_err(format!("Unknown reply id: {}.", unknown_reply_id)).into()
);
assert!(err
.to_string()
.contains(&format!("Unknown reply id: {}.", unknown_reply_id)));
}
}
Loading