From e145ddc5f01dd6fbb2ef7738063109aa6794f971 Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Wed, 22 May 2024 13:14:28 +0200 Subject: [PATCH] feat: No ref needed for 'dyn Interface' type in Remote and BoundQuerier (#382) --- examples/interfaces/custom-and-generic/src/lib.rs | 2 +- examples/interfaces/generic/src/lib.rs | 2 +- sylvia-derive/src/querier.rs | 2 +- sylvia/src/types.rs | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/interfaces/custom-and-generic/src/lib.rs b/examples/interfaces/custom-and-generic/src/lib.rs index e1f94dfd..f860b301 100644 --- a/examples/interfaces/custom-and-generic/src/lib.rs +++ b/examples/interfaces/custom-and-generic/src/lib.rs @@ -109,7 +109,7 @@ mod tests { let querier = sylvia::types::BoundQuerier::< _, - &dyn super::CustomAndGeneric< + dyn super::CustomAndGeneric< RetT = SvCustomMsg, Exec1T = SvCustomMsg, Exec2T = SvCustomMsg, diff --git a/examples/interfaces/generic/src/lib.rs b/examples/interfaces/generic/src/lib.rs index 782818fc..0624268a 100644 --- a/examples/interfaces/generic/src/lib.rs +++ b/examples/interfaces/generic/src/lib.rs @@ -107,7 +107,7 @@ mod tests { let querier = sylvia::types::BoundQuerier::< Empty, - &dyn super::Generic< + dyn super::Generic< Exec1T = SvCustomMsg, Exec2T = SvCustomMsg, Exec3T = SvCustomMsg, diff --git a/sylvia-derive/src/querier.rs b/sylvia-derive/src/querier.rs index 61d24c5a..9d301213 100644 --- a/sylvia-derive/src/querier.rs +++ b/sylvia-derive/src/querier.rs @@ -74,7 +74,7 @@ where #(#methods_declaration)* } - 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 { + 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/src/types.rs b/sylvia/src/types.rs index b028a7a4..edbf3ac4 100644 --- a/sylvia/src/types.rs +++ b/sylvia/src/types.rs @@ -121,13 +121,13 @@ use serde::{Deserialize, Serialize}; /// /// fn main() {} /// ``` -pub struct BoundQuerier<'a, C: cosmwasm_std::CustomQuery, Contract> { +pub struct BoundQuerier<'a, C: cosmwasm_std::CustomQuery, Contract: ?Sized> { contract: &'a cosmwasm_std::Addr, querier: &'a cosmwasm_std::QuerierWrapper<'a, C>, _phantom: std::marker::PhantomData, } -impl<'a, C: cosmwasm_std::CustomQuery, Contract> BoundQuerier<'a, C, Contract> { +impl<'a, C: cosmwasm_std::CustomQuery, Contract: ?Sized> BoundQuerier<'a, C, Contract> { /// Returns reference to the underlying [QuerierWrapper](cosmwasm_std::QuerierWrapper). pub fn querier(&self) -> &'a cosmwasm_std::QuerierWrapper<'a, C> { self.querier @@ -210,13 +210,13 @@ impl<'a, C: cosmwasm_std::CustomQuery, Contract> From<&'a BoundQuerier<'a, C, Co /// fn main() {} /// ``` #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub struct Remote<'a, Contract> { +pub struct Remote<'a, Contract: ?Sized> { addr: std::borrow::Cow<'a, cosmwasm_std::Addr>, #[serde(skip)] _phantom: std::marker::PhantomData, } -impl<'a, Contract> Remote<'a, Contract> { +impl<'a, Contract: ?Sized> Remote<'a, Contract> { /// Creates a new instance of [Remote] from owned contract address. pub fn new(addr: cosmwasm_std::Addr) -> Self { Self { @@ -246,7 +246,7 @@ impl<'a, Contract> Remote<'a, Contract> { } } -impl<'a, Contract> AsRef for Remote<'a, Contract> { +impl<'a, Contract: ?Sized> AsRef for Remote<'a, Contract> { /// Returns reference to the underlying contract address. fn as_ref(&self) -> &cosmwasm_std::Addr { &self.addr