difftreelog
feat add scoped properties adding to pallet common
in: master
1 file changed
pallets/common/src/lib.rsdiffbeforeafterboth64 PropertyKeyPermission,64 PropertyKeyPermission,65 TokenData,65 TokenData,66 TrySetProperty,66 TrySetProperty,67 PropertyScope,67 // RMRK68 // RMRK68 RmrkCollectionInfo,69 RmrkCollectionInfo,69 RmrkInstanceInfo,70 RmrkInstanceInfo,689690690 let mut collection_properties = up_data_structs::CollectionProperties::get();691 let mut collection_properties = up_data_structs::CollectionProperties::get();691 collection_properties692 collection_properties692 .try_set_from_iter(data.properties.into_iter().map(|p| (p.key, p.value)))693 .try_set_from_iter(data.properties.into_iter())693 .map_err(<Error<T>>::from)?;694 .map_err(<Error<T>>::from)?;694695695 CollectionProperties::<T>::insert(id, collection_properties);696 CollectionProperties::<T>::insert(id, collection_properties);696697697 let mut token_props_permissions = PropertiesPermissionMap::new();698 let mut token_props_permissions = PropertiesPermissionMap::new();698 token_props_permissions699 token_props_permissions699 .try_set_from_iter(700 .try_set_from_iter(data.token_property_permissions.into_iter())700 data.token_property_permissions701 .into_iter()702 .map(|property| (property.key, property.permission)),703 )704 .map_err(<Error<T>>::from)?;701 .map_err(<Error<T>>::from)?;705702788 Ok(())785 Ok(())789 }786 }787788 pub fn set_scoped_collection_property(789 collection: &CollectionHandle<T>,790 scope: PropertyScope,791 property: Property,792 ) -> DispatchResult {793 CollectionProperties::<T>::try_mutate(collection.id, |properties| {794 properties.try_scoped_set(scope, property.key, property.value)795 })796 .map_err(<Error<T>>::from)?;797798 Ok(())799 }800801 #[transactional]802 pub fn set_scoped_collection_properties(803 collection: &CollectionHandle<T>,804 scope: PropertyScope,805 properties: impl Iterator<Item=Property>,806 ) -> DispatchResult {807 CollectionProperties::<T>::try_mutate(collection.id, |stored_properties| {808 stored_properties.try_scoped_set_from_iter(scope, properties)809 })810 .map_err(<Error<T>>::from)?;811812 Ok(())813 }790814791 #[transactional]815 #[transactional]792 pub fn set_collection_properties(816 pub fn set_collection_properties(