diff --git a/examples/interfaces/custom-and-generic/src/lib.rs b/examples/interfaces/custom-and-generic/src/lib.rs index fb209557..f80e16e4 100644 --- a/examples/interfaces/custom-and-generic/src/lib.rs +++ b/examples/interfaces/custom-and-generic/src/lib.rs @@ -105,18 +105,21 @@ mod tests { let querier = sylvia::types::BoundQuerier::< _, - std::marker::PhantomData<( - Empty, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - )>, + &dyn super::CustomAndGeneric< + RetT = SvCustomMsg, + Exec1T = SvCustomMsg, + Exec2T = SvCustomMsg, + Exec3T = SvCustomMsg, + Query1T = SvCustomMsg, + Query2T = SvCustomMsg, + Query3T = SvCustomMsg, + Sudo1T = SvCustomMsg, + Sudo2T = SvCustomMsg, + Sudo3T = SvCustomMsg, + Error = (), + ExecC = (), + QueryC = (), + >, >::borrowed(&contract, &querier_wrapper); let _: Result = diff --git a/examples/interfaces/generic/src/lib.rs b/examples/interfaces/generic/src/lib.rs index 95aeebd4..9624672d 100644 --- a/examples/interfaces/generic/src/lib.rs +++ b/examples/interfaces/generic/src/lib.rs @@ -102,18 +102,19 @@ mod tests { let querier = sylvia::types::BoundQuerier::< Empty, - std::marker::PhantomData<( - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - SvCustomMsg, - )>, + &dyn super::Generic< + Exec1T = SvCustomMsg, + Exec2T = SvCustomMsg, + Exec3T = SvCustomMsg, + Query1T = SvCustomMsg, + Query2T = SvCustomMsg, + Query3T = SvCustomMsg, + Sudo1T = SvCustomMsg, + Sudo2T = SvCustomMsg, + Sudo3T = SvCustomMsg, + RetT = SvCustomMsg, + Error = (), + >, >::borrowed(&contract, &querier_wrapper); let _: Result = super::sv::Querier::generic_query_one(&querier, SvCustomMsg {}, SvCustomMsg {}); diff --git a/sylvia-derive/src/associated_types.rs b/sylvia-derive/src/associated_types.rs index 7225fe7c..bcee8571 100644 --- a/sylvia-derive/src/associated_types.rs +++ b/sylvia-derive/src/associated_types.rs @@ -24,6 +24,10 @@ impl<'a> AssociatedTypes<'a> { Self(associated_types) } + pub fn all_names(&self) -> impl Iterator { + self.0.iter().map(|associated| &associated.ident) + } + pub fn without_error(&self) -> impl Iterator { self.0 .iter() @@ -62,7 +66,7 @@ impl<'a> AssociatedTypes<'a> { } } - pub fn as_names(&self) -> impl Iterator { + pub fn as_filtered_names(&self) -> impl Iterator { self.filtered().map(|associated| &associated.ident) } diff --git a/sylvia-derive/src/input.rs b/sylvia-derive/src/input.rs index 6488fb6c..8f66eb73 100644 --- a/sylvia-derive/src/input.rs +++ b/sylvia-derive/src/input.rs @@ -62,7 +62,7 @@ impl<'a> TraitInput<'a> { custom, } = self; let messages = self.emit_messages(); - let associated_names: Vec<_> = associated_types.as_names().collect(); + let associated_names: Vec<_> = associated_types.as_filtered_names().collect(); let query_variants = MsgVariants::new(item.as_variants(), MsgType::Query, &associated_names, &None); diff --git a/sylvia-derive/src/querier.rs b/sylvia-derive/src/querier.rs index 9920adec..3e1f61d3 100644 --- a/sylvia-derive/src/querier.rs +++ b/sylvia-derive/src/querier.rs @@ -44,6 +44,8 @@ where .map(ItemType::as_name) .collect(); + let all_generics: Vec<_> = associated_types.all_names().collect(); + let assoc_types: Vec<_> = associated_types .without_special() .map(ItemType::as_name) @@ -70,7 +72,7 @@ where #(#methods_declaration)* } - impl <'a, C: #sylvia ::cw_std::CustomQuery, #(#generics,)*> Querier for #sylvia ::types::BoundQuerier<'a, C, std::marker::PhantomData< (#(#generics,)*) > > #where_clause { + impl <'a, C: #sylvia ::cw_std::CustomQuery, #(#all_generics,)*> Querier for #sylvia ::types::BoundQuerier<'a, C, &dyn #interface_name <#( #all_generics = #all_generics,)*> > #where_clause { #(type #generics = #generics;)* #(#methods_trait_impl)* diff --git a/sylvia/tests/querier.rs b/sylvia/tests/querier.rs index 17d1dd56..3440a681 100644 --- a/sylvia/tests/querier.rs +++ b/sylvia/tests/querier.rs @@ -114,11 +114,11 @@ impl CounterContract<'_> { #[cfg(test)] mod tests { - use crate::counter::sv::test_utils::CounterProxy; use cosmwasm_std::testing::mock_dependencies; use cosmwasm_std::{Addr, Empty, QuerierWrapper}; use sylvia::multitest::App; + use crate::counter::sv::test_utils::CounterProxy; use crate::sv::multitest_utils::CodeId; #[test]