difftreelog
Add extrinsic: delete collection property
in: master
10 files changed
pallets/common/src/lib.rsdiffbeforeafterboth292292293 CollectionPropertySet(CollectionId, Property),293 CollectionPropertySet(CollectionId, Property),294295 CollectionPropertyDeleted(CollectionId, PropertyKey),294296295 TokenPropertySet(CollectionId, TokenId, Property),297 TokenPropertySet(CollectionId, TokenId, Property),296298761 Ok(())763 Ok(())762 }764 }765766 pub fn delete_collection_property(767 collection: &CollectionHandle<T>,768 sender: &T::CrossAccountId,769 property_key: PropertyKey,770 ) -> DispatchResult {771 collection.check_is_owner_or_admin(sender)?;772773 CollectionProperties::<T>::mutate(collection.id, |properties| {774 properties.remove_property(&property_key);775 });776777 Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, property_key));778779 Ok(())780 }781782 pub fn delete_collection_properties(783 collection: &CollectionHandle<T>,784 sender: &T::CrossAccountId,785 property_keys: Vec<PropertyKey>,786 ) -> DispatchResult {787 for key in property_keys {788 Self::delete_collection_property(collection, sender, key)?;789 }790791 Ok(())792 }763793764 pub fn set_property_permission(794 pub fn set_property_permission(765 collection: &CollectionHandle<T>,795 collection: &CollectionHandle<T>,956 fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;986 fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;957 fn burn_item() -> Weight;987 fn burn_item() -> Weight;958 fn set_collection_properties(amount: u32) -> Weight;988 fn set_collection_properties(amount: u32) -> Weight;989 fn delete_collection_properties(amount: u32) -> Weight;959 fn set_token_properties(amount: u32) -> Weight;990 fn set_token_properties(amount: u32) -> Weight;960 fn delete_token_properties(amount: u32) -> Weight;991 fn delete_token_properties(amount: u32) -> Weight;961 fn set_property_permissions(amount: u32) -> Weight;992 fn set_property_permissions(amount: u32) -> Weight;998 sender: T::CrossAccountId,1029 sender: T::CrossAccountId,999 properties: Vec<Property>,1030 properties: Vec<Property>,1000 ) -> DispatchResultWithPostInfo;1031 ) -> DispatchResultWithPostInfo;1032 fn delete_collection_properties(1033 &self,1034 sender: &T::CrossAccountId,1035 property_keys: Vec<PropertyKey>,1036 ) -> DispatchResultWithPostInfo;1001 fn set_token_properties(1037 fn set_token_properties(1002 &self,1038 &self,1003 sender: T::CrossAccountId,1039 sender: T::CrossAccountId,pallets/fungible/src/common.rsdiffbeforeafterboth54 <SelfWeightOf<T>>::set_collection_properties(amount)54 <SelfWeightOf<T>>::set_collection_properties(amount)55 }55 }5657 fn delete_collection_properties(amount: u32) -> Weight {58 <SelfWeightOf<T>>::delete_collection_properties(amount)59 }566057 fn set_token_properties(amount: u32) -> Weight {61 fn set_token_properties(amount: u32) -> Weight {58 <SelfWeightOf<T>>::set_token_properties(amount)62 <SelfWeightOf<T>>::set_token_properties(amount)249 fail!(<Error<T>>::PropertiesNotAllowed)253 fail!(<Error<T>>::PropertiesNotAllowed)250 }254 }255256 fn delete_collection_properties(257 &self,258 _sender: &T::CrossAccountId,259 _property_keys: Vec<PropertyKey>,260 ) -> DispatchResultWithPostInfo {261 fail!(<Error<T>>::PropertiesNotAllowed)262 }251263252 fn set_token_properties(264 fn set_token_properties(253 &self,265 &self,pallets/fungible/src/weights.rsdiffbeforeafterboth36 fn create_multiple_items_ex(b: u32, ) -> Weight;36 fn create_multiple_items_ex(b: u32, ) -> Weight;37 fn burn_item() -> Weight;37 fn burn_item() -> Weight;38 fn set_collection_properties(amount: u32) -> Weight;38 fn set_collection_properties(amount: u32) -> Weight;39 fn delete_collection_properties(amount: u32) -> Weight;39 fn set_token_properties(amount: u32) -> Weight;40 fn set_token_properties(amount: u32) -> Weight;40 fn delete_token_properties(amount: u32) -> Weight;41 fn delete_token_properties(amount: u32) -> Weight;41 fn set_property_permissions(amount: u32) -> Weight;42 fn set_property_permissions(amount: u32) -> Weight;79 080 080 }81 }8283 fn delete_collection_properties(_amount: u32) -> Weight {84 // Error85 086 }818782 fn set_token_properties(_amount: u32) -> Weight {88 fn set_token_properties(_amount: u32) -> Weight {83 // Error89 // Error157 0163 0158 }164 }165166 fn delete_collection_properties(_amount: u32) -> Weight {167 // Error168 0169 }159170160 fn set_token_properties(_amount: u32) -> Weight {171 fn set_token_properties(_amount: u32) -> Weight {161 // Error172 // Errorpallets/nonfungible/src/common.rsdiffbeforeafterboth55 <SelfWeightOf<T>>::set_collection_properties(amount)55 <SelfWeightOf<T>>::set_collection_properties(amount)56 }56 }5758 fn delete_collection_properties(amount: u32) -> Weight {59 <SelfWeightOf<T>>::delete_collection_properties(amount)60 }576158 fn set_token_properties(amount: u32) -> Weight {62 fn set_token_properties(amount: u32) -> Weight {59 <SelfWeightOf<T>>::set_token_properties(amount)63 <SelfWeightOf<T>>::set_token_properties(amount)171 )175 )172 }176 }177178 fn delete_collection_properties(179 &self,180 sender: &T::CrossAccountId,181 property_keys: Vec<PropertyKey>,182 ) -> DispatchResultWithPostInfo {183 let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);184185 with_weight(186 <Pallet<T>>::delete_collection_properties(self, &sender, property_keys),187 weight188 )189 }173190174 fn set_token_properties(191 fn set_token_properties(175 &self,192 &self,pallets/nonfungible/src/lib.rsdiffbeforeafterboth366 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)366 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)367 }367 }368369 pub fn delete_collection_properties(370 collection: &CollectionHandle<T>,371 sender: &T::CrossAccountId,372 property_keys: Vec<PropertyKey>,373 ) -> DispatchResult {374 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)375 }368376369 pub fn set_property_permissions(377 pub fn set_property_permissions(370 collection: &CollectionHandle<T>,378 collection: &CollectionHandle<T>,pallets/nonfungible/src/weights.rsdiffbeforeafterboth37 fn create_multiple_items_ex(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;38 fn burn_item() -> Weight;39 fn set_collection_properties(amount: u32) -> Weight;39 fn set_collection_properties(amount: u32) -> Weight;40 fn delete_collection_properties(amount: u32) -> Weight;40 fn set_token_properties(amount: u32) -> Weight;41 fn set_token_properties(amount: u32) -> Weight;41 fn delete_token_properties(amount: u32) -> Weight;42 fn delete_token_properties(amount: u32) -> Weight;42 fn set_property_permissions(amount: u32) -> Weight;43 fn set_property_permissions(amount: u32) -> Weight;100 (50_000_000 as Weight).saturating_mul(amount as Weight)101 (50_000_000 as Weight).saturating_mul(amount as Weight)101 }102 }103104 fn delete_collection_properties(amount: u32) -> Weight {105 // TODO calculate appropriate weight106 (50_000_000 as Weight).saturating_mul(amount as Weight)107 }102108103 fn set_token_properties(amount: u32) -> Weight {109 fn set_token_properties(amount: u32) -> Weight {104 // TODO calculate appropriate weight110 // TODO calculate appropriate weight210 (50_000_000 as Weight).saturating_mul(amount as Weight)216 (50_000_000 as Weight).saturating_mul(amount as Weight)211 }217 }218219 fn delete_collection_properties(amount: u32) -> Weight {220 // TODO calculate appropriate weight221 (50_000_000 as Weight).saturating_mul(amount as Weight)222 }212223213 fn set_token_properties(amount: u32) -> Weight {224 fn set_token_properties(amount: u32) -> Weight {214 // TODO calculate appropriate weight225 // TODO calculate appropriate weightpallets/refungible/src/common.rsdiffbeforeafterboth70 <SelfWeightOf<T>>::set_collection_properties(amount)70 <SelfWeightOf<T>>::set_collection_properties(amount)71 }71 }7273 fn delete_collection_properties(amount: u32) -> Weight {74 <SelfWeightOf<T>>::delete_collection_properties(amount)75 }727673 fn set_token_properties(amount: u32) -> Weight {77 fn set_token_properties(amount: u32) -> Weight {74 <SelfWeightOf<T>>::set_token_properties(amount)78 <SelfWeightOf<T>>::set_token_properties(amount)268 fail!(<Error<T>>::PropertiesNotAllowed)272 fail!(<Error<T>>::PropertiesNotAllowed)269 }273 }274275 fn delete_collection_properties(276 &self,277 _sender: &T::CrossAccountId,278 _property_keys: Vec<PropertyKey>,279 ) -> DispatchResultWithPostInfo {280 fail!(<Error<T>>::PropertiesNotAllowed)281 }270282271 fn set_token_properties(283 fn set_token_properties(272 &self,284 &self,pallets/refungible/src/weights.rsdiffbeforeafterboth39 fn burn_item_partial() -> Weight;39 fn burn_item_partial() -> Weight;40 fn burn_item_fully() -> Weight;40 fn burn_item_fully() -> Weight;41 fn set_collection_properties(amount: u32) -> Weight;41 fn set_collection_properties(amount: u32) -> Weight;42 fn delete_collection_properties(amount: u32) -> Weight;42 fn set_token_properties(amount: u32) -> Weight;43 fn set_token_properties(amount: u32) -> Weight;43 fn delete_token_properties(amount: u32) -> Weight;44 fn delete_token_properties(amount: u32) -> Weight;44 fn set_property_permissions(amount: u32) -> Weight;45 fn set_property_permissions(amount: u32) -> Weight;139 0140 0140 }141 }142143 fn delete_collection_properties(_amount: u32) -> Weight {144 // Error145 0146 }141147142 fn set_token_properties(_amount: u32) -> Weight {148 fn set_token_properties(_amount: u32) -> Weight {143 // Error149 // Error328 0334 0329 }335 }336337 fn delete_collection_properties(_amount: u32) -> Weight {338 // Error339 0340 }330341331 fn set_token_properties(_amount: u32) -> Weight {342 fn set_token_properties(_amount: u32) -> Weight {332 // Error343 // Errorpallets/unique/src/lib.rsdiffbeforeafterboth708 dispatch_call::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))708 dispatch_call::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))709 }709 }710711 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]712 #[transactional]713 pub fn delete_collection_properties(714 origin,715 collection_id: CollectionId,716 property_keys: Vec<PropertyKey>,717 ) -> DispatchResultWithPostInfo {718 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);719720 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);721722 dispatch_call::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))723 }710724711 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]725 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]712 #[transactional]726 #[transactional]723 dispatch_call::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties))737 dispatch_call::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties))724 }738 }725739726 #[weight = T::CommonWeightInfo::delete_token_properties(properties.len() as u32)]740 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]727 #[transactional]741 #[transactional]728 pub fn delete_token_properties(742 pub fn delete_token_properties(729 origin,743 origin,730 collection_id: CollectionId,744 collection_id: CollectionId,731 token_id: TokenId,745 token_id: TokenId,732 properties: Vec<PropertyKey>746 property_keys: Vec<PropertyKey>733 ) -> DispatchResultWithPostInfo {747 ) -> DispatchResultWithPostInfo {734 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);748 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);735749736 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);750 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);737751738 dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, properties))752 dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys))739 }753 }740754741 #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]755 #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]runtime/common/src/weights.rsdiffbeforeafterboth58 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))58 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))59 }59 }6061 fn delete_collection_properties(amount: u32) -> Weight {62 dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))63 }606461 fn set_token_properties(amount: u32) -> Weight {65 fn set_token_properties(amount: u32) -> Weight {62 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))66 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))