From 50176c630c6dd7d0a423bfc25caee8404bf530cf Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 10 Jun 2022 09:47:05 +0000 Subject: [PATCH] feat(rmrk): move internal rmrk id to property --- --- a/pallets/proxy-rmrk-core/src/lib.rs +++ b/pallets/proxy-rmrk-core/src/lib.rs @@ -68,10 +68,6 @@ pub type UniqueCollectionId = StorageMap<_, Twox64Concat, RmrkCollectionId, CollectionId, ValueQuery>; - #[pallet::storage] - pub type RmrkInernalCollectionId = - StorageMap<_, Twox64Concat, CollectionId, RmrkCollectionId, ValueQuery>; - #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); @@ -225,8 +221,13 @@ let rmrk_collection_id = >::get(); >::insert(rmrk_collection_id, unique_collection_id); - >::insert(unique_collection_id, rmrk_collection_id); + >::set_scoped_collection_property( + unique_collection_id, + PropertyScope::Rmrk, + Self::rmrk_property(RmrkInternalCollectionId, &rmrk_collection_id)? + )?; + >::mutate(|n| *n += 1); Self::deposit_event(Event::CollectionCreated { @@ -1318,8 +1319,10 @@ pub fn rmrk_collection_id( unique_collection_id: CollectionId, ) -> Result { - >::try_get(unique_collection_id) - .map_err(|_| >::CollectionUnknown.into()) + Self::get_collection_property_decoded( + unique_collection_id, + RmrkInternalCollectionId + ) } pub fn get_nft_collection( --- a/pallets/proxy-rmrk-core/src/property.rs +++ b/pallets/proxy-rmrk-core/src/property.rs @@ -20,6 +20,7 @@ pub enum RmrkProperty<'r> { Metadata, CollectionType, + RmrkInternalCollectionId, TokenType, Transferable, RoyaltyInfo, @@ -66,6 +67,7 @@ match self { Self::Metadata => key!("metadata"), Self::CollectionType => key!("collection-type"), + Self::RmrkInternalCollectionId => key!("internal-id"), Self::TokenType => key!("token-type"), Self::Transferable => key!("transferable"), Self::RoyaltyInfo => key!("royalty-info"), -- gitstuff