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

difftreelog

Add extrinsic: delete collection property

Daniel Shiposha2022-05-04parent: #aa3d2ae.patch.diff
in: master

10 files changed

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
292292
293 CollectionPropertySet(CollectionId, Property),293 CollectionPropertySet(CollectionId, Property),
294
295 CollectionPropertyDeleted(CollectionId, PropertyKey),
294296
295 TokenPropertySet(CollectionId, TokenId, Property),297 TokenPropertySet(CollectionId, TokenId, Property),
296298
761 Ok(())763 Ok(())
762 }764 }
765
766 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)?;
772
773 CollectionProperties::<T>::mutate(collection.id, |properties| {
774 properties.remove_property(&property_key);
775 });
776
777 Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, property_key));
778
779 Ok(())
780 }
781
782 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 }
790
791 Ok(())
792 }
763793
764 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,
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
54 <SelfWeightOf<T>>::set_collection_properties(amount)54 <SelfWeightOf<T>>::set_collection_properties(amount)
55 }55 }
56
57 fn delete_collection_properties(amount: u32) -> Weight {
58 <SelfWeightOf<T>>::delete_collection_properties(amount)
59 }
5660
57 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 }
255
256 fn delete_collection_properties(
257 &self,
258 _sender: &T::CrossAccountId,
259 _property_keys: Vec<PropertyKey>,
260 ) -> DispatchResultWithPostInfo {
261 fail!(<Error<T>>::PropertiesNotAllowed)
262 }
251263
252 fn set_token_properties(264 fn set_token_properties(
253 &self,265 &self,
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
36 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 0
80 }81 }
82
83 fn delete_collection_properties(_amount: u32) -> Weight {
84 // Error
85 0
86 }
8187
82 fn set_token_properties(_amount: u32) -> Weight {88 fn set_token_properties(_amount: u32) -> Weight {
83 // Error89 // Error
157 0163 0
158 }164 }
165
166 fn delete_collection_properties(_amount: u32) -> Weight {
167 // Error
168 0
169 }
159170
160 fn set_token_properties(_amount: u32) -> Weight {171 fn set_token_properties(_amount: u32) -> Weight {
161 // Error172 // Error
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
55 <SelfWeightOf<T>>::set_collection_properties(amount)55 <SelfWeightOf<T>>::set_collection_properties(amount)
56 }56 }
57
58 fn delete_collection_properties(amount: u32) -> Weight {
59 <SelfWeightOf<T>>::delete_collection_properties(amount)
60 }
5761
58 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 }
177
178 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);
184
185 with_weight(
186 <Pallet<T>>::delete_collection_properties(self, &sender, property_keys),
187 weight
188 )
189 }
173190
174 fn set_token_properties(191 fn set_token_properties(
175 &self,192 &self,
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
366 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)366 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)
367 }367 }
368
369 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 }
368376
369 pub fn set_property_permissions(377 pub fn set_property_permissions(
370 collection: &CollectionHandle<T>,378 collection: &CollectionHandle<T>,
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
37 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 }
103
104 fn delete_collection_properties(amount: u32) -> Weight {
105 // TODO calculate appropriate weight
106 (50_000_000 as Weight).saturating_mul(amount as Weight)
107 }
102108
103 fn set_token_properties(amount: u32) -> Weight {109 fn set_token_properties(amount: u32) -> Weight {
104 // TODO calculate appropriate weight110 // TODO calculate appropriate weight
210 (50_000_000 as Weight).saturating_mul(amount as Weight)216 (50_000_000 as Weight).saturating_mul(amount as Weight)
211 }217 }
218
219 fn delete_collection_properties(amount: u32) -> Weight {
220 // TODO calculate appropriate weight
221 (50_000_000 as Weight).saturating_mul(amount as Weight)
222 }
212223
213 fn set_token_properties(amount: u32) -> Weight {224 fn set_token_properties(amount: u32) -> Weight {
214 // TODO calculate appropriate weight225 // TODO calculate appropriate weight
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
70 <SelfWeightOf<T>>::set_collection_properties(amount)70 <SelfWeightOf<T>>::set_collection_properties(amount)
71 }71 }
72
73 fn delete_collection_properties(amount: u32) -> Weight {
74 <SelfWeightOf<T>>::delete_collection_properties(amount)
75 }
7276
73 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 }
274
275 fn delete_collection_properties(
276 &self,
277 _sender: &T::CrossAccountId,
278 _property_keys: Vec<PropertyKey>,
279 ) -> DispatchResultWithPostInfo {
280 fail!(<Error<T>>::PropertiesNotAllowed)
281 }
270282
271 fn set_token_properties(283 fn set_token_properties(
272 &self,284 &self,
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
39 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 0
140 }141 }
142
143 fn delete_collection_properties(_amount: u32) -> Weight {
144 // Error
145 0
146 }
141147
142 fn set_token_properties(_amount: u32) -> Weight {148 fn set_token_properties(_amount: u32) -> Weight {
143 // Error149 // Error
328 0334 0
329 }335 }
336
337 fn delete_collection_properties(_amount: u32) -> Weight {
338 // Error
339 0
340 }
330341
331 fn set_token_properties(_amount: u32) -> Weight {342 fn set_token_properties(_amount: u32) -> Weight {
332 // Error343 // Error
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
708 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 }
710
711 #[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);
719
720 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
721
722 dispatch_call::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))
723 }
710724
711 #[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 }
725739
726 #[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);
735749
736 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);750 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
737751
738 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 }
740754
741 #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]755 #[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]
modifiedruntime/common/src/weights.rsdiffbeforeafterboth
58 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))58 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
59 }59 }
60
61 fn delete_collection_properties(amount: u32) -> Weight {
62 dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
63 }
6064
61 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))