git.delta.rocks / unique-network / refs/commits / f42d2466b923

difftreelog

feat:make rmrk_property! use enum values

Daniel Shiposha2022-05-23parent: #7e71176.patch.diff
in: master

2 files changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- 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<CollectionType, DispatchError> {
         let collection_type: CollectionType = <PalletCommon<T>>::collection_properties(collection_id)
-            .get(&rmrk_property!(Config=T, CollectionType)?)
+            .get(&rmrk_property!(Config=T, key: CollectionType)?)
             .ok_or(<Error<T>>::CollectionUnknown)?
             .try_into()
             .map_err(<Error<T>>::from)?;
modifiedpallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth
7575
76#[macro_export]76#[macro_export]
77macro_rules! rmrk_property {77macro_rules! rmrk_property {
78 (Config=$cfg:ty, key: $key:ident $(($key_ext:expr))?) => {
79 rmrk_property!(Config=$cfg, $crate::RmrkProperty::$key $(($key_ext))?)
80 };
81
78 (Config=$cfg:ty, $key:ident $(($key_ext:expr))?: $value:expr) => {{82 (Config=$cfg:ty, $key:ident $(($key_ext:expr))?: $value:expr) => {{
79 let key = rmrk_property!(@$cfg, $key $(($key_ext))?)?;83 let key = rmrk_property!(@$cfg, $crate::RmrkProperty::$key $(($key_ext))?)?;
8084
81 let value = $value.into_property_value()85 let value = $value.into_property_value()
82 .map_err(<$crate::Error<$cfg>>::from)?;86 .map_err(<$crate::Error<$cfg>>::from)?;
87 })91 })
88 }};92 }};
8993
90 (@$cfg:ty, $key:ident $(($key_ext:expr))?) => {94 (@$cfg:ty, $key_enum:expr) => {
91 $crate::RmrkProperty::$key $(($key_ext))?.to_key::<$cfg>()95 $key_enum.to_key::<$cfg>()
92 };96 };
9397
94 (Config=$cfg:ty, $key:ident $(($key_ext:expr))?) => {98 (Config=$cfg:ty, $key_enum:expr) => {
95 PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key $(($key_ext))?)?)99 PropertyScope::Rmrk.apply(rmrk_property!(@$cfg, $key_enum)?)
96 .map_err(|_| <$crate::Error<$cfg>>::RmrkPropertyKeyIsTooLong)100 .map_err(|_| <$crate::Error<$cfg>>::RmrkPropertyKeyIsTooLong)
97 };101 };
98}102}