From f42d2466b9230001f52d6f8bafceaab2d2ea205c Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Mon, 23 May 2022 13:14:13 +0000 Subject: [PATCH] feat:make rmrk_property! use enum values --- --- a/pallets/proxy-rmrk-core/src/lib.rs +++ b/pallets/proxy-rmrk-core/src/lib.rs @@ -238,7 +238,7 @@ fn get_collection_type(collection_id: CollectionId) -> Result { let collection_type: CollectionType = >::collection_properties(collection_id) - .get(&rmrk_property!(Config=T, CollectionType)?) + .get(&rmrk_property!(Config=T, key: CollectionType)?) .ok_or(>::CollectionUnknown)? .try_into() .map_err(>::from)?; --- a/pallets/proxy-rmrk-core/src/property.rs +++ b/pallets/proxy-rmrk-core/src/property.rs @@ -75,8 +75,12 @@ #[macro_export] macro_rules! rmrk_property { + (Config=$cfg:ty, key: $key:ident $(($key_ext:expr))?) => { + rmrk_property!(Config=$cfg, $crate::RmrkProperty::$key $(($key_ext))?) + }; + (Config=$cfg:ty, $key:ident $(($key_ext:expr))?: $value:expr) => {{ - let key = rmrk_property!(@$cfg, $key $(($key_ext))?)?; + let key = rmrk_property!(@$cfg, $crate::RmrkProperty::$key $(($key_ext))?)?; let value = $value.into_property_value() .map_err(<$crate::Error<$cfg>>::from)?; @@ -87,12 +91,12 @@ }) }}; - (@$cfg:ty, $key:ident $(($key_ext:expr))?) => { - $crate::RmrkProperty::$key $(($key_ext))?.to_key::<$cfg>() + (@$cfg:ty, $key_enum:expr) => { + $key_enum.to_key::<$cfg>() }; - (Config=$cfg:ty, $key:ident $(($key_ext:expr))?) => { - PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key $(($key_ext))?)?) + (Config=$cfg:ty, $key_enum:expr) => { + PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key_enum)?) .map_err(|_| <$crate::Error<$cfg>>::RmrkPropertyKeyIsTooLong) }; } -- gitstuff