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

difftreelog

Merge pull request #250 from UniqueNetwork/feature/CORE-221

kozyrevdev2021-12-02parents: #adeca06 #e9340e5.patch.diff
in: master
CORE-221

3 files changed

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -187,6 +187,13 @@
 		/// * account_id: Collection owner.
 		CollectionCreated(CollectionId, u8, T::AccountId),
 
+		/// New collection was destroyed
+		///
+		/// # Arguments
+		///
+		/// * collection_id: Globally unique identifier of collection.
+		CollectionDestroyed(CollectionId),
+
 		/// New item was created.
 		///
 		/// # Arguments
@@ -467,6 +474,8 @@
 		<AdminAmount<T>>::remove(collection.id);
 		<IsAdmin<T>>::remove_prefix((collection.id,), None);
 		<Allowlist<T>>::remove_prefix((collection.id,), None);
+
+		<Pallet<T>>::deposit_event(Event::CollectionDestroyed(collection.id));
 		Ok(())
 	}
 
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
16pub use serde::{Serialize, Deserialize};16pub use serde::{Serialize, Deserialize};
1717
18pub use frame_support::{18pub use frame_support::{
19 construct_runtime, decl_module, decl_storage, decl_error,19 construct_runtime, decl_module, decl_storage, decl_error, decl_event,
20 dispatch::DispatchResult,20 dispatch::DispatchResult,
21 ensure, fail, parameter_types,21 ensure, fail, parameter_types,
22 traits::{22 traits::{
97 + Sized98 + Sized
98 + TypeInfo99 + TypeInfo
99{100{
101 type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
102
100 /// Weight information for extrinsics in this pallet.103 /// Weight information for extrinsics in this pallet.
101 type WeightInfo: WeightInfo;104 type WeightInfo: WeightInfo;
102}105}
106
107decl_event! {
108 pub enum Event<T>
109 where
110 <T as frame_system::Config>::AccountId,
111 <T as pallet_common::Config>::CrossAccountId,
112 {
113 /// Collection sponsor was removed
114 ///
115 /// # Arguments
116 ///
117 /// * collection_id: Globally unique collection identifier.
118 CollectionSponsorRemoved(CollectionId),
119
120 /// Collection admin was added
121 ///
122 /// # Arguments
123 ///
124 /// * collection_id: Globally unique collection identifier.
125 ///
126 /// * admin: Admin address.
127 CollectionAdminAdded(CollectionId, CrossAccountId),
128
129 /// Collection owned was change
130 ///
131 /// # Arguments
132 ///
133 /// * collection_id: Globally unique collection identifier.
134 ///
135 /// * owner: New owner address.
136 CollectionOwnedChanged(CollectionId, AccountId),
137
138 /// Collection sponsor was set
139 ///
140 /// # Arguments
141 ///
142 /// * collection_id: Globally unique collection identifier.
143 ///
144 /// * owner: New sponsor address.
145 CollectionSponsorSet(CollectionId, AccountId),
146
147 /// const on chain schema was set
148 ///
149 /// # Arguments
150 ///
151 /// * collection_id: Globally unique collection identifier.
152 ConstOnChainSchemaSet(CollectionId),
153
154 /// New sponsor was confirm
155 ///
156 /// # Arguments
157 ///
158 /// * collection_id: Globally unique collection identifier.
159 ///
160 /// * sponsor: New sponsor address.
161 SponsorshipConfirmed(CollectionId, AccountId),
162
163 /// Collection admin was removed
164 ///
165 /// # Arguments
166 ///
167 /// * collection_id: Globally unique collection identifier.
168 ///
169 /// * admin: Admin address.
170 CollectionAdminRemoved(CollectionId, CrossAccountId),
171
172 /// Address was remove from allow list
173 ///
174 /// # Arguments
175 ///
176 /// * collection_id: Globally unique collection identifier.
177 ///
178 /// * user: Address.
179 AllowListAddressRemoved(CollectionId, CrossAccountId),
180
181 /// Address was add to allow list
182 ///
183 /// # Arguments
184 ///
185 /// * collection_id: Globally unique collection identifier.
186 ///
187 /// * user: Address.
188 AllowListAddressAdded(CollectionId, CrossAccountId),
189
190 /// Collection limits was set
191 ///
192 /// # Arguments
193 ///
194 /// * collection_id: Globally unique collection identifier.
195 CollectionLimitSet(CollectionId),
196
197 /// Mint permission was set
198 ///
199 /// # Arguments
200 ///
201 /// * collection_id: Globally unique collection identifier.
202 MintPermissionSet(CollectionId),
203
204 /// Offchain schema was set
205 ///
206 /// # Arguments
207 ///
208 /// * collection_id: Globally unique collection identifier.
209 OffchainSchemaSet(CollectionId),
210
211 /// Public access mode was set
212 ///
213 /// # Arguments
214 ///
215 /// * collection_id: Globally unique collection identifier.
216 ///
217 /// * mode: New access state.
218 PublicAccessModeSet(CollectionId, AccessMode),
219
220 /// Schema version was set
221 ///
222 /// # Arguments
223 ///
224 /// * collection_id: Globally unique collection identifier.
225 SchemaVersionSet(CollectionId),
226
227 /// Variable on chain schema was set
228 ///
229 /// # Arguments
230 ///
231 /// * collection_id: Globally unique collection identifier.
232 VariableOnChainSchemaSet(CollectionId),
233 }
234}
103235
104type SelfWeightOf<T> = <T as Config>::WeightInfo;236type SelfWeightOf<T> = <T as Config>::WeightInfo;
105237
162 {294 {
163 type Error = Error<T>;295 type Error = Error<T>;
296
297 fn deposit_event() = default;
164298
165 fn on_initialize(_now: T::BlockNumber) -> Weight {299 fn on_initialize(_now: T::BlockNumber) -> Weight {
166 0300 0
289 true,423 true,
290 )?;424 )?;
425
426 Self::deposit_event(Event::<T>::AllowListAddressAdded(
427 collection_id,
428 address
429 ));
291430
292 Ok(())431 Ok(())
293 }432 }
318 false,457 false,
319 )?;458 )?;
459
460 <Pallet<T>>::deposit_event(Event::<T>::AllowListAddressRemoved(
461 collection_id,
462 address
463 ));
320464
321 Ok(())465 Ok(())
322 }466 }
341 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;485 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
342 target_collection.check_is_owner(&sender)?;486 target_collection.check_is_owner(&sender)?;
343487
344 target_collection.access = mode;488 target_collection.access = mode.clone();
489
490 <Pallet<T>>::deposit_event(Event::<T>::PublicAccessModeSet(
491 collection_id,
492 mode
493 ));
494
345 target_collection.save()495 target_collection.save()
346 }496 }
369519
370 target_collection.mint_mode = mint_permission;520 target_collection.mint_mode = mint_permission;
521
522 <Pallet<T>>::deposit_event(Event::<T>::MintPermissionSet(
523 collection_id
524 ));
525
371 target_collection.save()526 target_collection.save()
372 }527 }
391 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;546 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
392 target_collection.check_is_owner(&sender)?;547 target_collection.check_is_owner(&sender)?;
393548
394 target_collection.owner = new_owner;549 target_collection.owner = new_owner.clone();
550 <Pallet<T>>::deposit_event(Event::<T>::CollectionOwnedChanged(
551 collection_id,
552 new_owner
553 ));
554
395 target_collection.save()555 target_collection.save()
396 }556 }
414 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);574 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
415 let collection = <CollectionHandle<T>>::try_get(collection_id)?;575 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
576
577 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminAdded(
578 collection_id,
579 new_admin_id.clone()
580 ));
416581
417 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)582 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)
418 }583 }
435 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);600 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
436 let collection = <CollectionHandle<T>>::try_get(collection_id)?;601 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
602
603 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminRemoved(
604 collection_id,
605 account_id.clone()
606 ));
437607
438 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)608 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)
439 }609 }
455 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;625 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
456 target_collection.check_is_owner(&sender)?;626 target_collection.check_is_owner(&sender)?;
457627
458 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor);628 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor.clone());
629
630 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(
631 collection_id,
632 new_sponsor
633 ));
634
459 target_collection.save()635 target_collection.save()
460 }636 }
477 Error::<T>::ConfirmUnsetSponsorFail653 Error::<T>::ConfirmUnsetSponsorFail
478 );654 );
479655
480 target_collection.sponsorship = SponsorshipState::Confirmed(sender);656 target_collection.sponsorship = SponsorshipState::Confirmed(sender.clone());
657
658 <Pallet<T>>::deposit_event(Event::<T>::SponsorshipConfirmed(
659 collection_id,
660 sender
661 ));
662
481 target_collection.save()663 target_collection.save()
482 }664 }
500682
501 target_collection.sponsorship = SponsorshipState::Disabled;683 target_collection.sponsorship = SponsorshipState::Disabled;
684
685 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorRemoved(
686 collection_id
687 ));
502 target_collection.save()688 target_collection.save()
503 }689 }
504690
794 target_collection.check_is_owner_or_admin(&sender)?;980 target_collection.check_is_owner_or_admin(&sender)?;
795 target_collection.schema_version = version;981 target_collection.schema_version = version;
982
983 <Pallet<T>>::deposit_event(Event::<T>::SchemaVersionSet(
984 collection_id
985 ));
986
796 target_collection.save()987 target_collection.save()
797 }988 }
8241015
825 target_collection.offchain_schema = schema;1016 target_collection.offchain_schema = schema;
1017
1018 <Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(
1019 collection_id
1020 ));
1021
826 target_collection.save()1022 target_collection.save()
827 }1023 }
8541050
855 target_collection.const_on_chain_schema = schema;1051 target_collection.const_on_chain_schema = schema;
1052
1053 <Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(
1054 collection_id
1055 ));
1056
856 target_collection.save()1057 target_collection.save()
857 }1058 }
8841085
885 target_collection.variable_on_chain_schema = schema;1086 target_collection.variable_on_chain_schema = schema;
1087
1088 <Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(
1089 collection_id
1090 ));
1091
886 target_collection.save()1092 target_collection.save()
887 }1093 }
9491155
950 target_collection.limits = new_limit;1156 target_collection.limits = new_limit;
1157
1158 <Pallet<T>>::deposit_event(Event::<T>::CollectionLimitSet(
1159 collection_id
1160 ));
9511161
952 target_collection.save()1162 target_collection.save()
953 }1163 }
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -781,6 +781,7 @@
 }
 
 impl pallet_unique::Config for Runtime {
+	type Event = Event;
 	type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
 }
 
@@ -881,7 +882,7 @@
 
 		// Unique Pallets
 		Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
-		Unique: pallet_unique::{Pallet, Call, Storage} = 61,
+		Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
 		// Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
 		// free = 63
 		Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,