difftreelog
feat add all rmrk properties
in: master
4 files changed
pallets/rmrk-proxy/src/lib.rsdiffbeforeafterboth27pub use pallet::*;27pub use pallet::*;282829pub mod misc;29pub mod misc;30pub mod property;303131use misc::*;32use misc::*;33pub use property::*;323433#[frame_support::pallet]35#[frame_support::pallet]34pub mod pallet {36pub mod pallet {69 /* Unique-specific events */71 /* Unique-specific events */70 CorruptedCollectionType,72 CorruptedCollectionType,71 NotRmrkCollection,73 NotRmrkCollection,74 RmrkPropertyIsTooLong,727573 /* RMRK compatible events */76 /* RMRK compatible events */74 CollectionNotEmpty,77 CollectionNotEmpty,113 &collection,116 &collection,114 PropertyScope::Rmrk,117 PropertyScope::Rmrk,115 [118 [116 rmrk_property!(Metadata, metadata),119 rmrk_property!(Config=T, Metadata: metadata)?,117 rmrk_property!(CollectionType, CollectionType::Regular),120 rmrk_property!(Config=T, CollectionType: CollectionType::Regular)?,118 ].into_iter()121 ].into_iter()119 )?;122 )?;120123215218216 fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {219 fn get_collection_type(collection_id: CollectionId) -> Result<CollectionType, DispatchError> {217 let collection_type: CollectionType = <PalletCommon<T>>::collection_properties(collection_id)220 let collection_type: CollectionType = <PalletCommon<T>>::collection_properties(collection_id)218 .get(&rmrk_property!(CollectionType))221 .get(&rmrk_property!(Config=T, CollectionType)?)219 .ok_or(<Error<T>>::NotRmrkCollection)?222 .ok_or(<Error<T>>::NotRmrkCollection)?220 .try_into()223 .try_into()221 .map_err(<Error<T>>::from)?;224 .map_err(<Error<T>>::from)?;pallets/rmrk-proxy/src/misc.rsdiffbeforeafterboth1use super::*;1use super::*;2use codec::{Encode, Decode};2use codec::{Encode, Decode};3use frame_support::dispatch::Vec;4use pallet_nonfungible::NonfungibleHandle;3use pallet_nonfungible::NonfungibleHandle;56#[macro_export]7macro_rules! rmrk_property {8 ($key:ident, $value:expr) => {9 Property {10 key: rmrk_property!(@raw $key),11 value: $value.into()12 }13 };1415 (@raw $key:ident) => {16 RmrkProperty::$key.to_key()17 };1819 ($key:ident) => {20 PropertyScope::Rmrk.apply(rmrk_property!(@raw $key)).unwrap()21 };22}23424macro_rules! impl_rmrk_value {5macro_rules! impl_rmrk_value {25 ($enum_name:path, decode_error: $error:ident) => {6 ($enum_name:path, decode_error: $error:ident) => {26 impl Into<PropertyValue> for $enum_name {7 impl From<$enum_name> for PropertyValue {27 fn into(self) -> PropertyValue {8 fn from(e: $enum_name) -> Self {28 self.encode().try_into().unwrap()9 e.encode().try_into().unwrap()29 }10 }30 }11 }311268 }49 }69}50}7071pub enum RmrkProperty {72 Metadata,73 CollectionType,74}7576impl RmrkProperty {77 pub fn to_key(self) -> PropertyKey {78 let key = |str_key: &str| {79 PropertyKey::try_from(80 str_key.bytes().collect::<Vec<_>>()81 ).unwrap()82 };8384 match self {85 Self::Metadata => key("metadata"),86 Self::CollectionType => key("collection-type"),87 }88 }89}905191#[derive(Encode, Decode, PartialEq, Eq)]52#[derive(Encode, Decode, PartialEq, Eq)]92pub enum CollectionType {53pub enum CollectionType {pallets/rmrk-proxy/src/property.rsdiffbeforeafterbothno changes
primitives/data-structs/src/lib.rsdiffbeforeafterboth924pub type RmrkThemeName = RmrkRpcString;924pub type RmrkThemeName = RmrkRpcString;925pub type RmrkPropertyKey = RmrkRpcString;925pub type RmrkPropertyKey = RmrkRpcString;926926927type RmrkString = BoundedVec<u8, RmrkStringLimit>;927pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;928928