difftreelog
Merge pull request #250 from UniqueNetwork/feature/CORE-221
in: master
CORE-221
3 files changed
pallets/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(())
}
pallets/unique/src/lib.rsdiffbeforeafterboth16pub use serde::{Serialize, Deserialize};16pub use serde::{Serialize, Deserialize};171718pub 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 + Sized98 + TypeInfo99 + TypeInfo99{100{101 type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;102100 /// 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}106107decl_event! {108 pub enum Event<T>109 where110 <T as frame_system::Config>::AccountId,111 <T as pallet_common::Config>::CrossAccountId,112 {113 /// Collection sponsor was removed114 ///115 /// # Arguments116 ///117 /// * collection_id: Globally unique collection identifier.118 CollectionSponsorRemoved(CollectionId),119120 /// Collection admin was added121 ///122 /// # Arguments123 ///124 /// * collection_id: Globally unique collection identifier.125 ///126 /// * admin: Admin address.127 CollectionAdminAdded(CollectionId, CrossAccountId),128129 /// Collection owned was change130 ///131 /// # Arguments132 ///133 /// * collection_id: Globally unique collection identifier.134 ///135 /// * owner: New owner address.136 CollectionOwnedChanged(CollectionId, AccountId),137138 /// Collection sponsor was set139 ///140 /// # Arguments141 ///142 /// * collection_id: Globally unique collection identifier.143 ///144 /// * owner: New sponsor address.145 CollectionSponsorSet(CollectionId, AccountId),146147 /// const on chain schema was set148 ///149 /// # Arguments150 ///151 /// * collection_id: Globally unique collection identifier.152 ConstOnChainSchemaSet(CollectionId),153154 /// New sponsor was confirm155 ///156 /// # Arguments157 ///158 /// * collection_id: Globally unique collection identifier.159 ///160 /// * sponsor: New sponsor address.161 SponsorshipConfirmed(CollectionId, AccountId),162163 /// Collection admin was removed164 ///165 /// # Arguments166 ///167 /// * collection_id: Globally unique collection identifier.168 ///169 /// * admin: Admin address.170 CollectionAdminRemoved(CollectionId, CrossAccountId),171172 /// Address was remove from allow list173 ///174 /// # Arguments175 ///176 /// * collection_id: Globally unique collection identifier.177 ///178 /// * user: Address.179 AllowListAddressRemoved(CollectionId, CrossAccountId),180181 /// Address was add to allow list182 ///183 /// # Arguments184 ///185 /// * collection_id: Globally unique collection identifier.186 ///187 /// * user: Address.188 AllowListAddressAdded(CollectionId, CrossAccountId),189190 /// Collection limits was set191 ///192 /// # Arguments193 ///194 /// * collection_id: Globally unique collection identifier.195 CollectionLimitSet(CollectionId),196197 /// Mint permission was set198 ///199 /// # Arguments200 ///201 /// * collection_id: Globally unique collection identifier.202 MintPermissionSet(CollectionId),203204 /// Offchain schema was set205 ///206 /// # Arguments207 ///208 /// * collection_id: Globally unique collection identifier.209 OffchainSchemaSet(CollectionId),210211 /// Public access mode was set212 ///213 /// # Arguments214 ///215 /// * collection_id: Globally unique collection identifier.216 ///217 /// * mode: New access state.218 PublicAccessModeSet(CollectionId, AccessMode),219220 /// Schema version was set221 ///222 /// # Arguments223 ///224 /// * collection_id: Globally unique collection identifier.225 SchemaVersionSet(CollectionId),226227 /// Variable on chain schema was set228 ///229 /// # Arguments230 ///231 /// * collection_id: Globally unique collection identifier.232 VariableOnChainSchemaSet(CollectionId),233 }234}103235104type SelfWeightOf<T> = <T as Config>::WeightInfo;236type SelfWeightOf<T> = <T as Config>::WeightInfo;105237162 {294 {163 type Error = Error<T>;295 type Error = Error<T>;296297 fn deposit_event() = default;164298165 fn on_initialize(_now: T::BlockNumber) -> Weight {299 fn on_initialize(_now: T::BlockNumber) -> Weight {166 0300 0289 true,423 true,290 )?;424 )?;425426 Self::deposit_event(Event::<T>::AllowListAddressAdded(427 collection_id,428 address429 ));291430292 Ok(())431 Ok(())293 }432 }318 false,457 false,319 )?;458 )?;459460 <Pallet<T>>::deposit_event(Event::<T>::AllowListAddressRemoved(461 collection_id,462 address463 ));320464321 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)?;343487344 target_collection.access = mode;488 target_collection.access = mode.clone();489490 <Pallet<T>>::deposit_event(Event::<T>::PublicAccessModeSet(491 collection_id,492 mode493 ));494345 target_collection.save()495 target_collection.save()346 }496 }369519370 target_collection.mint_mode = mint_permission;520 target_collection.mint_mode = mint_permission;521522 <Pallet<T>>::deposit_event(Event::<T>::MintPermissionSet(523 collection_id524 ));525371 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)?;393548394 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_owner553 ));554395 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)?;576577 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminAdded(578 collection_id,579 new_admin_id.clone()580 ));416581417 <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)?;602603 <Pallet<T>>::deposit_event(Event::<T>::CollectionAdminRemoved(604 collection_id,605 account_id.clone()606 ));437607438 <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)?;457627458 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor);628 target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor.clone());629630 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(631 collection_id,632 new_sponsor633 ));634459 target_collection.save()635 target_collection.save()460 }636 }477 Error::<T>::ConfirmUnsetSponsorFail653 Error::<T>::ConfirmUnsetSponsorFail478 );654 );479655480 target_collection.sponsorship = SponsorshipState::Confirmed(sender);656 target_collection.sponsorship = SponsorshipState::Confirmed(sender.clone());657658 <Pallet<T>>::deposit_event(Event::<T>::SponsorshipConfirmed(659 collection_id,660 sender661 ));662481 target_collection.save()663 target_collection.save()482 }664 }500682501 target_collection.sponsorship = SponsorshipState::Disabled;683 target_collection.sponsorship = SponsorshipState::Disabled;684685 <Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorRemoved(686 collection_id687 ));502 target_collection.save()688 target_collection.save()503 }689 }504690794 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;982983 <Pallet<T>>::deposit_event(Event::<T>::SchemaVersionSet(984 collection_id985 ));986796 target_collection.save()987 target_collection.save()797 }988 }8241015825 target_collection.offchain_schema = schema;1016 target_collection.offchain_schema = schema;10171018 <Pallet<T>>::deposit_event(Event::<T>::OffchainSchemaSet(1019 collection_id1020 ));1021826 target_collection.save()1022 target_collection.save()827 }1023 }8541050855 target_collection.const_on_chain_schema = schema;1051 target_collection.const_on_chain_schema = schema;10521053 <Pallet<T>>::deposit_event(Event::<T>::ConstOnChainSchemaSet(1054 collection_id1055 ));1056856 target_collection.save()1057 target_collection.save()857 }1058 }8841085885 target_collection.variable_on_chain_schema = schema;1086 target_collection.variable_on_chain_schema = schema;10871088 <Pallet<T>>::deposit_event(Event::<T>::VariableOnChainSchemaSet(1089 collection_id1090 ));1091886 target_collection.save()1092 target_collection.save()887 }1093 }9491155950 target_collection.limits = new_limit;1156 target_collection.limits = new_limit;11571158 <Pallet<T>>::deposit_event(Event::<T>::CollectionLimitSet(1159 collection_id1160 ));9511161952 target_collection.save()1162 target_collection.save()953 }1163 }runtime/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,