Skip to content

Commit

Permalink
feat: No ref needed for 'dyn Interface' type in Remote and BoundQueri…
Browse files Browse the repository at this point in the history
…er (#382)
  • Loading branch information
kulikthebird authored May 22, 2024
1 parent 1e555ae commit e145ddc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/interfaces/custom-and-generic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mod tests {

let querier = sylvia::types::BoundQuerier::<
_,
&dyn super::CustomAndGeneric<
dyn super::CustomAndGeneric<
RetT = SvCustomMsg,
Exec1T = SvCustomMsg,
Exec2T = SvCustomMsg,
Expand Down
2 changes: 1 addition & 1 deletion examples/interfaces/generic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {

let querier = sylvia::types::BoundQuerier::<
Empty,
&dyn super::Generic<
dyn super::Generic<
Exec1T = SvCustomMsg,
Exec2T = SvCustomMsg,
Exec3T = SvCustomMsg,
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*
Expand Down
10 changes: 5 additions & 5 deletions sylvia/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Contract>,
}

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
Expand Down Expand Up @@ -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<Contract>,
}

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 {
Expand Down Expand Up @@ -246,7 +246,7 @@ impl<'a, Contract> Remote<'a, Contract> {
}
}

impl<'a, Contract> AsRef<cosmwasm_std::Addr> for Remote<'a, Contract> {
impl<'a, Contract: ?Sized> AsRef<cosmwasm_std::Addr> for Remote<'a, Contract> {
/// Returns reference to the underlying contract address.
fn as_ref(&self) -> &cosmwasm_std::Addr {
&self.addr
Expand Down

0 comments on commit e145ddc

Please sign in to comment.