git.delta.rocks / unique-network / refs/commits / 00a765656f26

difftreelog

source

pallets/proxy-rmrk-core/src/property.rs2.9 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use super::*;18use core::convert::AsRef;1920pub enum RmrkProperty<'r> {21	Metadata,22	CollectionType,23	RmrkInternalCollectionId,24	TokenType,25	Transferable,26	RoyaltyInfo,27	Equipped,28	ResourceCollection,29	ResourcePriorities,30	ResourceType,31	PendingNftAccept,32	PendingResourceAccept,33	PendingResourceRemoval,34	Parts,35	Base,36	Src,37	Slot,38	License,39	Thumb,40	EquippedNft,41	BaseType,42	ExternalPartId,43	EquippableList,44	ZIndex,45	ThemeName,46	ThemeInherit,47	UserProperty(&'r [u8]),48}4950impl<'r> RmrkProperty<'r> {51	pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {52		fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {53			container.as_ref()54		}5556		macro_rules! key {57            ($($component:expr),+) => {58                PropertyKey::try_from([$(key!(@ &$component)),+].concat())59                    .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)60            };6162            (@ $key:expr) => {63                get_bytes($key)64            };65        }6667		match self {68			Self::Metadata => key!("metadata"),69			Self::CollectionType => key!("collection-type"),70			Self::RmrkInternalCollectionId => key!("internal-id"),71			Self::TokenType => key!("token-type"),72			Self::Transferable => key!("transferable"),73			Self::RoyaltyInfo => key!("royalty-info"),74			Self::Equipped => key!("equipped"),75			Self::ResourceCollection => key!("resource-collection"),76			Self::ResourcePriorities => key!("resource-priorities"),77			Self::ResourceType => key!("resource-type"),78			Self::PendingNftAccept => key!("pending-nft-accept"),79			Self::PendingResourceAccept => key!("pending-resource-accept"),80			Self::PendingResourceRemoval => key!("pending-resource-removal"),81			Self::Parts => key!("parts"),82			Self::Base => key!("base"),83			Self::Src => key!("src"),84			Self::Slot => key!("slot"),85			Self::License => key!("license"),86			Self::Thumb => key!("thumb"),87			Self::EquippedNft => key!("equipped-nft"),88			Self::BaseType => key!("base-type"),89			Self::ExternalPartId => key!("ext-part-id"),90			Self::EquippableList => key!("equippable-list"),91			Self::ZIndex => key!("z-index"),92			Self::ThemeName => key!("theme-name"),93			Self::ThemeInherit => key!("theme-inherit"),94			Self::UserProperty(name) => key!("userprop-", name),95		}96	}97}