From eb4445e07cd0da2859c7313de569b83a773cc407 Mon Sep 17 00:00:00 2001 From: mintthemoon <105956535+mintthemoon@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:32:27 -0400 Subject: [PATCH] add multi-owner `cw-ownable` with cosmwasm v2 (#1) * move all logic to `OwnershipStore`. This way `cw-ownable` is still a singleton. But can be re-use e.g. by defining `CREATOR: OwnershipStore = OwnershipStore::new("creator")` * cargo fmt * cargo clippy --tests * use api and storage (instead of DepsMut) for being less restrictive * fix ownable * remove unneccessary lifetime (clippy warning) --------- Co-authored-by: mr-t --- packages/optional-indexes/src/unique.rs | 2 +- packages/ownable/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/optional-indexes/src/unique.rs b/packages/optional-indexes/src/unique.rs index e29cd4f..691d962 100644 --- a/packages/optional-indexes/src/unique.rs +++ b/packages/optional-indexes/src/unique.rs @@ -22,7 +22,7 @@ pub struct OptionalUniqueIndex { phantom: PhantomData, } -impl<'a, IK, T, PK> OptionalUniqueIndex { +impl OptionalUniqueIndex { pub const fn new(idx_fn: fn(&T) -> Option, idx_namespace: &'static str) -> Self { Self { index: idx_fn, diff --git a/packages/ownable/src/lib.rs b/packages/ownable/src/lib.rs index a529a47..a7c424a 100644 --- a/packages/ownable/src/lib.rs +++ b/packages/ownable/src/lib.rs @@ -28,12 +28,12 @@ pub struct Ownership { pub pending_expiry: Option, } -pub struct OwnershipStore<'a> { - pub item: Item<'a, Ownership>, +pub struct OwnershipStore { + pub item: Item>, } -impl<'a> OwnershipStore<'a> { - pub const fn new(key: &'a str) -> Self { +impl OwnershipStore { + pub const fn new(key: &'static str) -> Self { Self { item: Item::new(key), }