CosmWasm / sylvia

CosmWasm smart contract framework
Apache License 2.0
88 stars 14 forks source link

Inspect possibility to remove lifetimes from `Remote` and `Querier` #372

Closed jawoznia closed 1 month ago

jawoznia commented 2 months ago
          Can we use `&'static dyn` here instead of adding a new lifetime to the structure? Let's consider removing the reference in the implementation of Querier for dyn Trait as well.

_Originally posted by @kulikthebird in https://github.com/CosmWasm/sylvia/pull/367#discussion_r1592406573_

#[derive(Serialize, Deserialize, Derivative)]
#[derivative(Clone, Debug, PartialEq)]
+ pub struct Remote<Contract> {
- pub struct Remote<'a, Contract> {
+   addr: std::borrow::Cow<'a, cosmwasm_std::Addr>,
-    addr: std::borrow::Cow<'static, cosmwasm_std::Addr>,
    #[serde(skip)]
    #[derivative(Debug = "ignore")]
    _phantom: std::marker::PhantomData<Contract>,
}
+ pub struct BoundQuerier<C: cosmwasm_std::CustomQuery, Contract> {
- pub struct BoundQuerier<'a, C: cosmwasm_std::CustomQuery, Contract> {
+    contract: &'static cosmwasm_std::Addr,
+    querier: &'static cosmwasm_std::QuerierWrapper<'static, C>,
-    contract: &'a cosmwasm_std::Addr,
-    querier: &'a cosmwasm_std::QuerierWrapper<'a, C>,
    _phantom: std::marker::PhantomData<Contract>,
}
kulikthebird commented 1 month ago

I think that we could port https://github.com/CosmWasm/sylvia/pull/367#discussion_r1595321827 to the main branch to solve this issue