diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index fd60d814e7e8cef3591f1e174c434637267ec90e..aab81a26417bc6e1c7a4e4459537e121c840e140 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -53,10 +53,10 @@ pub mod pallet { #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] - pub struct Pallet<T, I = ()>(PhantomData<(T, I)>); + pub struct Pallet<T>(PhantomData<T>); #[pallet::config] - pub trait Config<I: 'static = ()>: frame_system::Config { + pub trait Config: frame_system::Config { #[pallet::constant] /// Minimum duration between two certifications issued by the same issuer type CertPeriod: Get<Self::BlockNumber>; @@ -86,8 +86,7 @@ pub mod pallet { /// Handler for Removed event type OnRemovedCert: OnRemovedCert<Self::IdtyIndex>; /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From<Event<Self, I>> - + IsType<<Self as frame_system::Config>::RuntimeEvent>; + type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; #[pallet::constant] @@ -99,14 +98,14 @@ pub mod pallet { #[pallet::genesis_config] #[allow(clippy::type_complexity)] - pub struct GenesisConfig<T: Config<I>, I: 'static = ()> { + pub struct GenesisConfig<T: Config> { pub apply_cert_period_at_genesis: bool, pub certs_by_receiver: BTreeMap<T::IdtyIndex, BTreeMap<T::IdtyIndex, Option<T::BlockNumber>>>, } #[cfg(feature = "std")] - impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> { + impl<T: Config> Default for GenesisConfig<T> { fn default() -> Self { Self { apply_cert_period_at_genesis: false, @@ -116,7 +115,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> { + impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { fn build(&self) { let mut cert_meta_by_issuer = BTreeMap::<T::IdtyIndex, IdtyCertMeta<T::BlockNumber>>::new(); @@ -175,7 +174,7 @@ pub mod pallet { // Write CertsByReceiver issuers_.sort(); - CertsByReceiver::<T, I>::insert(receiver, issuers_); + CertsByReceiver::<T>::insert(receiver, issuers_); } // Write StorageIdtyCertMeta @@ -190,11 +189,11 @@ pub mod pallet { "Identity n°{:?} not respect MinReceivedCertToBeAbleToIssueCert.", issuer ); - StorageIdtyCertMeta::<T, I>::insert(issuer, cert_meta); + StorageIdtyCertMeta::<T>::insert(issuer, cert_meta); } // Write storage StorageCertsRemovableOn for (removable_on, certs) in certs_removable_on { - StorageCertsRemovableOn::<T, I>::insert(removable_on, certs); + StorageCertsRemovableOn::<T>::insert(removable_on, certs); } } } @@ -204,26 +203,26 @@ pub mod pallet { /// Certifications metada by issuer #[pallet::storage] #[pallet::getter(fn idty_cert_meta)] - pub type StorageIdtyCertMeta<T: Config<I>, I: 'static = ()> = + pub type StorageIdtyCertMeta<T: Config> = StorageMap<_, Twox64Concat, T::IdtyIndex, IdtyCertMeta<T::BlockNumber>, ValueQuery>; /// Certifications by receiver #[pallet::storage] #[pallet::getter(fn certs_by_receiver)] - pub type CertsByReceiver<T: Config<I>, I: 'static = ()> = + pub type CertsByReceiver<T: Config> = StorageMap<_, Twox64Concat, T::IdtyIndex, Vec<(T::IdtyIndex, T::BlockNumber)>, ValueQuery>; /// Certifications removable on #[pallet::storage] #[pallet::getter(fn certs_removable_on)] - pub type StorageCertsRemovableOn<T: Config<I>, I: 'static = ()> = + pub type StorageCertsRemovableOn<T: Config> = StorageMap<_, Twox64Concat, T::BlockNumber, Vec<(T::IdtyIndex, T::IdtyIndex)>, OptionQuery>; // EVENTS // #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event<T: Config<I>, I: 'static = ()> { + pub enum Event<T: Config> { /// A new certification was added. CertAdded { issuer: T::IdtyIndex, @@ -245,7 +244,7 @@ pub mod pallet { // ERRORS // #[pallet::error] - pub enum Error<T, I = ()> { + pub enum Error<T> { /// Identity cannot certify itself CannotCertifySelf, /// Identity has already issued the maximum number of certifications @@ -259,7 +258,7 @@ pub mod pallet { } #[pallet::hooks] - impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> { + impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { fn on_initialize(n: T::BlockNumber) -> Weight { Self::prune_certifications(n).saturating_add(T::WeightInfo::on_initialize()) } @@ -268,7 +267,7 @@ pub mod pallet { // CALLS // #[pallet::call] - impl<T: Config<I>, I: 'static> Pallet<T, I> { + impl<T: Config> Pallet<T> { /// Add a new certification or renew an existing one /// /// - `receiver`: the account receiving the certification from the origin @@ -303,13 +302,13 @@ pub mod pallet { /// remove all certifications received by an identity (only root) #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::remove_all_certs_received_by(CertsByReceiver::<T, I>::get(idty_index).len() as u32))] + #[pallet::weight(T::WeightInfo::remove_all_certs_received_by(CertsByReceiver::<T>::get(idty_index).len() as u32))] pub fn remove_all_certs_received_by( origin: OriginFor<T>, idty_index: T::IdtyIndex, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - for (issuer, _) in CertsByReceiver::<T, I>::get(idty_index) { + for (issuer, _) in CertsByReceiver::<T>::get(idty_index) { Self::do_remove_cert(issuer, idty_index, None); } Ok(().into()) @@ -318,7 +317,7 @@ pub mod pallet { // INTERNAL FUNCTIONS // - impl<T: Config<I>, I: 'static> Pallet<T, I> { + impl<T: Config> Pallet<T> { /// add a certification without checks pub fn do_add_cert_checked( issuer: T::IdtyIndex, @@ -326,29 +325,29 @@ pub mod pallet { verify_rules: bool, ) -> DispatchResultWithPostInfo { // Forbid self cert - ensure!(issuer != receiver, Error::<T, I>::CannotCertifySelf); + ensure!(issuer != receiver, Error::<T>::CannotCertifySelf); let block_number = frame_system::pallet::Pallet::<T>::block_number(); if verify_rules { // Verify rule MinReceivedCertToBeAbleToIssueCert - let issuer_idty_cert_meta = StorageIdtyCertMeta::<T, I>::get(issuer); + let issuer_idty_cert_meta = StorageIdtyCertMeta::<T>::get(issuer); ensure!( issuer_idty_cert_meta.received_count >= T::MinReceivedCertToBeAbleToIssueCert::get(), - Error::<T, I>::NotEnoughCertReceived + Error::<T>::NotEnoughCertReceived ); // Verify rule MaxByIssuer ensure!( issuer_idty_cert_meta.issued_count < T::MaxByIssuer::get(), - Error::<T, I>::IssuedTooManyCert + Error::<T>::IssuedTooManyCert ); // Verify rule CertPeriod ensure!( block_number >= issuer_idty_cert_meta.next_issuable_on, - Error::<T, I>::NotRespectCertPeriod + Error::<T>::NotRespectCertPeriod ); }; @@ -362,11 +361,11 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { // Write StorageCertsRemovableOn let removable_on = block_number + T::ValidityPeriod::get(); - <StorageCertsRemovableOn<T, I>>::append(removable_on, (issuer, receiver)); + <StorageCertsRemovableOn<T>>::append(removable_on, (issuer, receiver)); // Write CertsByReceiver let mut created = false; - CertsByReceiver::<T, I>::mutate_exists(receiver, |maybe_issuers| { + CertsByReceiver::<T>::mutate_exists(receiver, |maybe_issuers| { let issuers = maybe_issuers.get_or_insert(Vec::with_capacity(0)); match issuers.binary_search_by(|(issuer_, _)| issuer_.cmp(&issuer)) { // cert exists, must be renewed @@ -384,7 +383,7 @@ pub mod pallet { if created { // Write StorageIdtyCertMeta for issuer let issuer_issued_count = - StorageIdtyCertMeta::<T, I>::mutate(issuer, |issuer_idty_cert_meta| { + StorageIdtyCertMeta::<T>::mutate(issuer, |issuer_idty_cert_meta| { issuer_idty_cert_meta.issued_count = issuer_idty_cert_meta.issued_count.saturating_add(1); issuer_idty_cert_meta.next_issuable_on = @@ -394,7 +393,7 @@ pub mod pallet { // Write StorageIdtyCertMeta for receiver let receiver_received_count = - <StorageIdtyCertMeta<T, I>>::mutate_exists(receiver, |cert_meta_opt| { + <StorageIdtyCertMeta<T>>::mutate_exists(receiver, |cert_meta_opt| { let cert_meta = cert_meta_opt.get_or_insert(IdtyCertMeta::default()); cert_meta.received_count = cert_meta.received_count.saturating_add(1); cert_meta.received_count @@ -410,7 +409,7 @@ pub mod pallet { ); } else { // Update next_issuable_on in StorageIdtyCertMeta for issuer - StorageIdtyCertMeta::<T, I>::mutate(issuer, |issuer_idty_cert_meta| { + StorageIdtyCertMeta::<T>::mutate(issuer, |issuer_idty_cert_meta| { issuer_idty_cert_meta.next_issuable_on = block_number + T::CertPeriod::get(); }); // emit CertRenewed event @@ -425,7 +424,7 @@ pub mod pallet { // See on initialize for the overhead weight accounting let mut total_weight = Weight::zero(); - if let Some(certs) = StorageCertsRemovableOn::<T, I>::take(block_number) { + if let Some(certs) = StorageCertsRemovableOn::<T>::take(block_number) { for (issuer, receiver) in certs { total_weight += Self::do_remove_cert(issuer, receiver, Some(block_number)); } @@ -442,7 +441,7 @@ pub mod pallet { ) -> Weight { let mut total_weight = Weight::zero(); let mut removed = false; - CertsByReceiver::<T, I>::mutate_exists(receiver, |issuers_opt| { + CertsByReceiver::<T>::mutate_exists(receiver, |issuers_opt| { let issuers = issuers_opt.get_or_insert(Vec::with_capacity(0)); if let Ok(index) = issuers.binary_search_by(|(issuer_, _)| issuer_.cmp(&issuer)) { if let Some(block_number) = block_number_opt { @@ -463,13 +462,13 @@ pub mod pallet { }); if removed { let issuer_issued_count = - <StorageIdtyCertMeta<T, I>>::mutate_exists(issuer, |cert_meta_opt| { + <StorageIdtyCertMeta<T>>::mutate_exists(issuer, |cert_meta_opt| { let cert_meta = cert_meta_opt.get_or_insert(IdtyCertMeta::default()); cert_meta.issued_count = cert_meta.issued_count.saturating_sub(1); cert_meta.issued_count }); let receiver_received_count = - <StorageIdtyCertMeta<T, I>>::mutate_exists(receiver, |cert_meta_opt| { + <StorageIdtyCertMeta<T>>::mutate_exists(receiver, |cert_meta_opt| { let cert_meta = cert_meta_opt.get_or_insert(IdtyCertMeta::default()); cert_meta.received_count = cert_meta.received_count.saturating_sub(1); cert_meta.received_count @@ -506,32 +505,32 @@ pub mod pallet { ) -> DispatchResult { // --- first internal checks // 1. Forbid self cert - ensure!(issuer != receiver, Error::<T, I>::CannotCertifySelf); + ensure!(issuer != receiver, Error::<T>::CannotCertifySelf); // 2. Verify caller ownership let issuer_owner_key = - T::OwnerKeyOf::convert(issuer).ok_or(Error::<T, I>::IssuerNotFound)?; + T::OwnerKeyOf::convert(issuer).ok_or(Error::<T>::IssuerNotFound)?; ensure!(issuer_owner_key == caller_key, DispatchError::BadOrigin); // 3. Verify rule MinReceivedCertToBeAbleToIssueCert // (this number can differ from the one necessary to be member) - let issuer_idty_cert_meta = <StorageIdtyCertMeta<T, I>>::get(issuer); + let issuer_idty_cert_meta = <StorageIdtyCertMeta<T>>::get(issuer); ensure!( issuer_idty_cert_meta.received_count >= T::MinReceivedCertToBeAbleToIssueCert::get(), - Error::<T, I>::NotEnoughCertReceived + Error::<T>::NotEnoughCertReceived ); // 4. Verify rule MaxByIssuer ensure!( issuer_idty_cert_meta.issued_count < T::MaxByIssuer::get(), - Error::<T, I>::IssuedTooManyCert + Error::<T>::IssuedTooManyCert ); // 5. Verify rule CertPeriod ensure!( block_number >= issuer_idty_cert_meta.next_issuable_on, - Error::<T, I>::NotRespectCertPeriod + Error::<T>::NotRespectCertPeriod ); // --- then external checks @@ -546,9 +545,9 @@ pub mod pallet { } // implement setting next_issuable_on for certification period -impl<T: Config<I>, I: 'static> SetNextIssuableOn<T::BlockNumber, T::IdtyIndex> for Pallet<T, I> { +impl<T: Config> SetNextIssuableOn<T::BlockNumber, T::IdtyIndex> for Pallet<T> { fn set_next_issuable_on(idty_index: T::IdtyIndex, next_issuable_on: T::BlockNumber) { - <StorageIdtyCertMeta<T, I>>::mutate_exists(idty_index, |cert_meta_opt| { + <StorageIdtyCertMeta<T>>::mutate_exists(idty_index, |cert_meta_opt| { let cert_meta = cert_meta_opt.get_or_insert(IdtyCertMeta::default()); cert_meta.next_issuable_on = next_issuable_on; }); diff --git a/pallets/certification/src/tests.rs b/pallets/certification/src/tests.rs index cf09fa72de745ddf9eafd3eaa9718866b196cfcd..c1abd06b9df5ea8d9c16ea9cdbdde820f02e776e 100644 --- a/pallets/certification/src/tests.rs +++ b/pallets/certification/src/tests.rs @@ -29,7 +29,7 @@ fn test_must_receive_cert_before_can_issue() { .execute_with(|| { assert_eq!( DefaultCertification::add_cert(RuntimeOrigin::signed(0), 0, 1), - Err(Error::<Test, _>::NotEnoughCertReceived.into()) + Err(Error::<Test>::NotEnoughCertReceived.into()) ); }); } @@ -50,7 +50,7 @@ fn test_cannot_certify_self() { assert_eq!( DefaultCertification::add_cert(RuntimeOrigin::signed(0), 0, 0), - Err(Error::<Test, _>::CannotCertifySelf.into()) + Err(Error::<Test>::CannotCertifySelf.into()) ); }); } @@ -152,7 +152,7 @@ fn test_cert_period() { ); assert_eq!( DefaultCertification::add_cert(RuntimeOrigin::signed(0), 0, 3), - Err(Error::<Test, _>::NotRespectCertPeriod.into()) + Err(Error::<Test>::NotRespectCertPeriod.into()) ); run_to_block(CertPeriod::get()); assert_ok!(DefaultCertification::add_cert( @@ -163,7 +163,7 @@ fn test_cert_period() { run_to_block(CertPeriod::get() + 1); assert_eq!( DefaultCertification::add_cert(RuntimeOrigin::signed(0), 0, 4), - Err(Error::<Test, _>::NotRespectCertPeriod.into()) + Err(Error::<Test>::NotRespectCertPeriod.into()) ); run_to_block((2 * CertPeriod::get()) + 1); assert_ok!(DefaultCertification::add_cert( @@ -290,7 +290,7 @@ fn test_cert_renewal_cert_delay() { // try to renew again assert_noop!( DefaultCertification::add_cert(RuntimeOrigin::signed(1), 1, 0), - Error::<Test, _>::NotRespectCertPeriod, + Error::<Test>::NotRespectCertPeriod, ); // no renewal event should be emitted assert_eq!(System::events().last(), None); diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 400a3d06ce1196ae032ce81d187772d7cde3d905..f6f0c331dd1c3cbcda735738f24cd3fa889ff44c 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -50,16 +50,16 @@ pub mod pallet { #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] - pub struct Pallet<T, I = ()>(_); + pub struct Pallet<T>(_); // CONFIG // #[pallet::config] - pub trait Config<I: 'static = ()>: + pub trait Config: frame_system::Config - + pallet_certification::Config<I, IdtyIndex = IdtyIndex> + + pallet_certification::Config<IdtyIndex = IdtyIndex> + pallet_identity::Config<IdtyIndex = IdtyIndex> - + pallet_membership::Config<I, IdtyId = IdtyIndex> + + pallet_membership::Config<IdtyId = IdtyIndex> { /// Distance evaluation provider type IsDistanceOk: IsDistanceOk<IdtyIndex>; @@ -73,10 +73,10 @@ pub mod pallet { // INTERNAL FUNCTIONS // - impl<T: Config<I>, I: 'static> Pallet<T, I> { + impl<T: Config> Pallet<T> { pub(super) fn do_apply_first_issuable_on(idty_index: IdtyIndex) { let block_number = frame_system::pallet::Pallet::<T>::block_number(); - pallet_certification::Pallet::<T, I>::set_next_issuable_on( + pallet_certification::Pallet::<T>::set_next_issuable_on( idty_index, block_number + T::FirstIssuableOn::get(), ); @@ -86,7 +86,7 @@ pub mod pallet { // ERRORS // #[pallet::error] - pub enum Error<T, I = ()> { + pub enum Error<T> { /// Insufficient certifications received to claim membership. NotEnoughCertsToClaimMembership, /// Distance is invalid. @@ -123,39 +123,37 @@ pub mod pallet { } // implement identity call checks -impl<AccountId, T: Config<I>, I: 'static> pallet_identity::traits::CheckIdtyCallAllowed<T> - for Pallet<T, I> +impl<AccountId, T: Config> pallet_identity::traits::CheckIdtyCallAllowed<T> for Pallet<T> where - T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config<I>, + T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config, { // identity creation checks fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> { - let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator); + let cert_meta = pallet_certification::Pallet::<T>::idty_cert_meta(creator); // perform all checks // 1. check that identity has the right to create an identity // identity can be member with 5 certifications and still not reach identity creation threshold which could be higher (6, 7...) ensure!( cert_meta.received_count >= T::MinCertForCreateIdtyRight::get(), - Error::<T, I>::NotEnoughReceivedCertsToCreateIdty + Error::<T>::NotEnoughReceivedCertsToCreateIdty ); // 2. check that issuer can emit one more certification // (this is only a partial check) ensure!( cert_meta.issued_count < T::MaxByIssuer::get(), - Error::<T, I>::MaxEmittedCertsReached + Error::<T>::MaxEmittedCertsReached ); // 3. check that issuer respects certification creation period ensure!( cert_meta.next_issuable_on <= frame_system::pallet::Pallet::<T>::block_number(), - Error::<T, I>::IdtyCreationPeriodNotRespected + Error::<T>::IdtyCreationPeriodNotRespected ); Ok(()) } } // implement cert call checks -impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<IdtyIndex> - for Pallet<T, I> +impl<T: Config> pallet_certification::traits::CheckCertAllowed<IdtyIndex> for Pallet<T> // TODO (#136) add the following where clause once checks can be done on pallet instance // where // T: pallet_membership::Config<I>, @@ -171,10 +169,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id if let Some(issuer_data) = pallet_identity::Pallet::<T>::identity(issuer) { ensure!( issuer_data.status == IdtyStatus::Member, - Error::<T, I>::IssuerNotMember + Error::<T>::IssuerNotMember ); } else { - return Err(Error::<T, I>::IdtyNotFound.into()); + return Err(Error::<T>::IdtyNotFound.into()); } // receiver checks @@ -183,26 +181,24 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id match receiver_data.status { // able to receive cert IdtyStatus::Unvalidated | IdtyStatus::Member | IdtyStatus::NotMember => {} - IdtyStatus::Unconfirmed => return Err(Error::<T, I>::CertToUnconfirmed.into()), - IdtyStatus::Revoked => return Err(Error::<T, I>::CertToRevoked.into()), + IdtyStatus::Unconfirmed => return Err(Error::<T>::CertToUnconfirmed.into()), + IdtyStatus::Revoked => return Err(Error::<T>::CertToRevoked.into()), }; } else { - return Err(Error::<T, I>::IdtyNotFound.into()); + return Err(Error::<T>::IdtyNotFound.into()); } Ok(()) } } // implement membership call checks -impl<T: Config<I>, I: 'static> sp_membership::traits::CheckMembershipCallAllowed<IdtyIndex> - for Pallet<T, I> -{ +impl<T: Config> sp_membership::traits::CheckMembershipCallAllowed<IdtyIndex> for Pallet<T> { // membership claim is only possible when enough certs are received (both wots) and distance is ok fn check_idty_allowed_to_claim_membership(idty_index: &IdtyIndex) -> Result<(), DispatchError> { - let idty_cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(idty_index); + let idty_cert_meta = pallet_certification::Pallet::<T>::idty_cert_meta(idty_index); ensure!( idty_cert_meta.received_count >= T::MinCertForMembership::get(), - Error::<T, I>::NotEnoughCertsToClaimMembership + Error::<T>::NotEnoughCertsToClaimMembership ); T::IsDistanceOk::is_distance_ok(idty_index)?; Ok(()) @@ -213,20 +209,20 @@ impl<T: Config<I>, I: 'static> sp_membership::traits::CheckMembershipCallAllowed if let Some(idty_value) = pallet_identity::Pallet::<T>::identity(idty_index) { ensure!( idty_value.status == IdtyStatus::Member, - Error::<T, I>::IdtyNotAllowedToRenewMembership + Error::<T>::IdtyNotAllowedToRenewMembership ); T::IsDistanceOk::is_distance_ok(idty_index)?; } else { - return Err(Error::<T, I>::IdtyNotFound.into()); + return Err(Error::<T>::IdtyNotFound.into()); } Ok(()) } } // implement membership event handler -impl<T: Config<I>, I: 'static> sp_membership::traits::OnEvent<IdtyIndex> for Pallet<T, I> +impl<T: Config> sp_membership::traits::OnEvent<IdtyIndex> for Pallet<T> where - T: pallet_membership::Config<I>, + T: pallet_membership::Config, { fn on_event(membership_event: &sp_membership::Event<IdtyIndex>) { match membership_event { @@ -245,12 +241,12 @@ where } // implement identity event handler -impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pallet<T, I> { +impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> { fn on_idty_change(idty_index: IdtyIndex, idty_event: &IdtyEvent<T>) { match idty_event { // identity just has been created, a cert must be added IdtyEvent::Created { creator, .. } => { - if let Err(e) = <pallet_certification::Pallet<T, I>>::do_add_cert_checked( + if let Err(e) = <pallet_certification::Pallet<T>>::do_add_cert_checked( *creator, idty_index, true, ) { sp_std::if_std! { @@ -263,7 +259,7 @@ impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pall // if identity is removed also remove certs IdtyEvent::Removed { status } => { // try remove membership in any case - <pallet_membership::Pallet<T, I>>::do_remove_membership( + <pallet_membership::Pallet<T>>::do_remove_membership( idty_index, MembershipRemovalReason::Revoked, ); @@ -272,7 +268,7 @@ impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pall match status { IdtyStatus::Unconfirmed | IdtyStatus::Unvalidated => { if let Err(e) = - <pallet_certification::Pallet<T, I>>::remove_all_certs_received_by( + <pallet_certification::Pallet<T>>::remove_all_certs_received_by( frame_system::Origin::<T>::Root.into(), idty_index, ) @@ -296,7 +292,7 @@ impl<T: Config<I>, I: 'static> pallet_identity::traits::OnIdtyChange<T> for Pall // implement certification event handlers // new cert handler -impl<T: Config<I>, I: 'static> pallet_certification::traits::OnNewcert<IdtyIndex> for Pallet<T, I> { +impl<T: Config> pallet_certification::traits::OnNewcert<IdtyIndex> for Pallet<T> { fn on_new_cert( _issuer: IdtyIndex, _issuer_issued_count: u32, @@ -310,9 +306,7 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnNewcert<IdtyIndex } // remove cert handler -impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyIndex> - for Pallet<T, I> -{ +impl<T: Config> pallet_certification::traits::OnRemovedCert<IdtyIndex> for Pallet<T> { fn on_removed_cert( _issuer: IdtyIndex, _issuer_issued_count: u32, @@ -321,10 +315,10 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::OnRemovedCert<IdtyI _expiration: bool, ) { if receiver_received_count < T::MinCertForMembership::get() - && pallet_membership::Pallet::<T, I>::is_member(&receiver) + && pallet_membership::Pallet::<T>::is_member(&receiver) { // expire receiver membership - <pallet_membership::Pallet<T, I>>::do_remove_membership( + <pallet_membership::Pallet<T>>::do_remove_membership( receiver, MembershipRemovalReason::NotEnoughCerts, ) diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 1b501b409b1c50f76f5659b93e9a406c38b666fb..543bde2bfe5d1bf2857eae805cbe4929662b6ed7 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -46,10 +46,10 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event<T>}, - DuniterWot: pallet_duniter_wot::<Instance1>::{Pallet}, + DuniterWot: pallet_duniter_wot::{Pallet}, Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>}, - Membership: pallet_membership::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>}, - Cert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>}, + Membership: pallet_membership::{Pallet, Call, Config<T>, Storage, Event<T>}, + Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>}, } ); @@ -93,7 +93,7 @@ parameter_types! { pub const FirstIssuableOn: u64 = 2; } -impl pallet_duniter_wot::Config<Instance1> for Test { +impl pallet_duniter_wot::Config for Test { type MinCertForMembership = MinCertForMembership; type MinCertForCreateIdtyRight = MinCertForCreateIdtyRight; type FirstIssuableOn = FirstIssuableOn; @@ -143,7 +143,7 @@ parameter_types! { pub const MembershipPeriod: u64 = 8; } -impl pallet_membership::Config<Instance1> for Test { +impl pallet_membership::Config for Test { type CheckMembershipCallAllowed = DuniterWot; type IdtyId = IdtyIndex; type IdtyIdOf = IdentityIndexOf<Self>; @@ -164,7 +164,7 @@ parameter_types! { pub const ValidityPeriod: u64 = 20; } -impl pallet_certification::Config<Instance1> for Test { +impl pallet_certification::Config for Test { type CertPeriod = CertPeriod; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; @@ -205,7 +205,7 @@ pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - pallet_membership::GenesisConfig::<Test, Instance1> { + pallet_membership::GenesisConfig::<Test> { memberships: (1..=initial_identities_len) .map(|i| { ( @@ -220,7 +220,7 @@ pub fn new_test_ext(initial_identities_len: usize) -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - pallet_certification::GenesisConfig::<Test, Instance1> { + pallet_certification::GenesisConfig::<Test> { apply_cert_period_at_genesis: true, certs_by_receiver: clique_wot(initial_identities_len, ValidityPeriod::get()), } diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 83806fc151f534d3e04b8e92d062a4ac6f7dadea..2b86ee97f6dd1258126a035a3ca166a95b13eb69 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -17,7 +17,6 @@ use crate::mock::*; use crate::pallet as pallet_duniter_wot; use codec::Encode; -use frame_support::instances::Instance1; use frame_support::{assert_noop, assert_ok}; use pallet_identity::{ IdtyName, IdtyStatus, RevocationPayload, RevocationReason, REVOCATION_PAYLOAD_PREFIX, @@ -35,7 +34,7 @@ fn test_genesis_build() { assert_eq!(Identity::identities_count(), 3); assert_eq!(Identity::identity(1).unwrap().next_creatable_identity_on, 0); assert_eq!( - pallet_certification::Pallet::<Test, Instance1>::idty_cert_meta(1).next_issuable_on, + pallet_certification::Pallet::<Test>::idty_cert_meta(1).next_issuable_on, 2 ); }); @@ -52,7 +51,7 @@ fn test_creator_not_allowed_to_create_idty() { // because Alice.next_issuable_on = 2) assert_noop!( Identity::create_identity(RuntimeOrigin::signed(1), 4), - pallet_duniter_wot::Error::<Test, Instance1>::NotEnoughReceivedCertsToCreateIdty + pallet_duniter_wot::Error::<Test>::NotEnoughReceivedCertsToCreateIdty ); }); } @@ -66,7 +65,7 @@ fn test_creator_allowed_to_create_idty() { // Alice should be able to create an identity assert_ok!( Identity::create_identity(RuntimeOrigin::signed(1), 6), - // pallet_duniter_wot::Error::<Test, Instance1>::NotEnoughReceivedCertsToCreateIdty + // pallet_duniter_wot::Error::<Test>::NotEnoughReceivedCertsToCreateIdty ); }); } @@ -128,8 +127,7 @@ fn test_new_idty_validation() { System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipAdded { member: 6, - expire_on: 5 - + <Test as pallet_membership::Config<Instance1>>::MembershipPeriod::get(), + expire_on: 5 + <Test as pallet_membership::Config>::MembershipPeriod::get(), }, )); System::assert_has_event(RuntimeEvent::Identity( @@ -300,7 +298,7 @@ fn test_idty_membership_expire() { // Alice can't certify revoked identity assert_noop!( Cert::add_cert(RuntimeOrigin::signed(1), 1, 3), - pallet_duniter_wot::Error::<Test, Instance1>::CertToRevoked + pallet_duniter_wot::Error::<Test>::CertToRevoked ); run_to_block(21); @@ -313,7 +311,7 @@ fn test_idty_membership_expire() { // Alice can't certify removed identity assert_noop!( Cert::add_cert(RuntimeOrigin::signed(1), 1, 3), - pallet_duniter_wot::Error::<Test, Instance1>::IdtyNotFound + pallet_duniter_wot::Error::<Test>::IdtyNotFound ); }); } @@ -395,13 +393,13 @@ fn test_certification_expire() { // Alice can not renew her membership which does not exist assert_noop!( Membership::renew_membership(RuntimeOrigin::signed(1)), - pallet_membership::Error::<Test, Instance1>::MembershipNotFound + pallet_membership::Error::<Test>::MembershipNotFound ); // Alice can not claim her membership because she does not have enough certifications assert_noop!( Membership::claim_membership(RuntimeOrigin::signed(1)), - pallet_duniter_wot::Error::<Test, Instance1>::NotEnoughCertsToClaimMembership + pallet_duniter_wot::Error::<Test>::NotEnoughCertsToClaimMembership ); // --- BLOCK 23 --- diff --git a/pallets/membership/src/lib.rs b/pallets/membership/src/lib.rs index 4b8fd399301241c3f27afd90104c93ae5aa88f34..3b84b30d5bfc67de592b2f4bf5cee390940d6140 100644 --- a/pallets/membership/src/lib.rs +++ b/pallets/membership/src/lib.rs @@ -79,12 +79,12 @@ pub mod pallet { #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] - pub struct Pallet<T, I = ()>(_); + pub struct Pallet<T>(_); // CONFIG // #[pallet::config] - pub trait Config<I: 'static = ()>: frame_system::Config { + pub trait Config: frame_system::Config { /// Ask the runtime whether the identity can perform membership operations type CheckMembershipCallAllowed: CheckMembershipCallAllowed<Self::IdtyId>; /// Something that identifies an identity @@ -99,8 +99,7 @@ pub mod pallet { /// On event handler type OnEvent: OnEvent<Self::IdtyId>; /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From<Event<Self, I>> - + IsType<<Self as frame_system::Config>::RuntimeEvent>; + type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type WeightInfo: WeightInfo; #[cfg(feature = "runtime-benchmarks")] type BenchmarkSetupHandler: SetupBenchmark<Self::IdtyId, Self::AccountId>; @@ -109,12 +108,12 @@ pub mod pallet { // GENESIS STUFF // #[pallet::genesis_config] - pub struct GenesisConfig<T: Config<I>, I: 'static = ()> { + pub struct GenesisConfig<T: Config> { pub memberships: BTreeMap<T::IdtyId, MembershipData<T::BlockNumber>>, } #[cfg(feature = "std")] - impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> { + impl<T: Config> Default for GenesisConfig<T> { fn default() -> Self { Self { memberships: Default::default(), @@ -123,11 +122,11 @@ pub mod pallet { } #[pallet::genesis_build] - impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> { + impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { fn build(&self) { for (idty_id, membership_data) in &self.memberships { - MembershipsExpireOn::<T, I>::append(membership_data.expire_on, idty_id); - Membership::<T, I>::insert(idty_id, membership_data); + MembershipsExpireOn::<T>::append(membership_data.expire_on, idty_id); + Membership::<T>::insert(idty_id, membership_data); } } } @@ -138,20 +137,20 @@ pub mod pallet { // (expiration block for instance) #[pallet::storage] #[pallet::getter(fn membership)] - pub type Membership<T: Config<I>, I: 'static = ()> = + pub type Membership<T: Config> = CountedStorageMap<_, Twox64Concat, T::IdtyId, MembershipData<T::BlockNumber>, OptionQuery>; /// maps block number to the list of identity id set to expire at this block #[pallet::storage] #[pallet::getter(fn memberships_expire_on)] - pub type MembershipsExpireOn<T: Config<I>, I: 'static = ()> = + pub type MembershipsExpireOn<T: Config> = StorageMap<_, Twox64Concat, T::BlockNumber, Vec<T::IdtyId>, ValueQuery>; // EVENTS // #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event<T: Config<I>, I: 'static = ()> { + pub enum Event<T: Config> { /// A membership was added. MembershipAdded { member: T::IdtyId, @@ -167,7 +166,7 @@ pub mod pallet { // ERRORS// #[pallet::error] - pub enum Error<T, I = ()> { + pub enum Error<T> { /// Identity ID not found. IdtyIdNotFound, /// Membership already acquired. @@ -179,7 +178,7 @@ pub mod pallet { // HOOKS // #[pallet::hooks] - impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> { + impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { fn on_initialize(n: T::BlockNumber) -> Weight { if n > T::BlockNumber::zero() { T::WeightInfo::on_initialize().saturating_add(Self::expire_memberships(n)) @@ -192,7 +191,7 @@ pub mod pallet { // CALLS // #[pallet::call] - impl<T: Config<I>, I: 'static> Pallet<T, I> { + impl<T: Config> Pallet<T> { /// claim membership /// it must fullfill the requirements (certs, distance) /// TODO #159 for main wot claim_membership is called automatically when distance is evaluated positively @@ -215,7 +214,7 @@ pub mod pallet { // Verify phase let idty_id = Self::get_idty_id(origin)?; let membership_data = - Membership::<T, I>::get(idty_id).ok_or(Error::<T, I>::MembershipNotFound)?; + Membership::<T>::get(idty_id).ok_or(Error::<T>::MembershipNotFound)?; T::CheckMembershipCallAllowed::check_idty_allowed_to_renew_membership(&idty_id)?; @@ -244,14 +243,14 @@ pub mod pallet { // INTERNAL FUNCTIONS // - impl<T: Config<I>, I: 'static> Pallet<T, I> { + impl<T: Config> Pallet<T> { /// unschedule membership expiry fn unschedule_membership_expiry(idty_id: T::IdtyId, block_number: T::BlockNumber) { - let mut scheduled = MembershipsExpireOn::<T, I>::get(block_number); + let mut scheduled = MembershipsExpireOn::<T>::get(block_number); if let Some(pos) = scheduled.iter().position(|x| *x == idty_id) { scheduled.swap_remove(pos); - MembershipsExpireOn::<T, I>::set(block_number, scheduled); + MembershipsExpireOn::<T>::set(block_number, scheduled); } } /// schedule membership expiry @@ -259,8 +258,8 @@ pub mod pallet { let block_number = frame_system::pallet::Pallet::<T>::block_number(); let expire_on = block_number + T::MembershipPeriod::get(); - Membership::<T, I>::insert(idty_id, MembershipData { expire_on }); - MembershipsExpireOn::<T, I>::append(expire_on, idty_id); + Membership::<T>::insert(idty_id, MembershipData { expire_on }); + MembershipsExpireOn::<T>::append(expire_on, idty_id); Self::deposit_event(Event::MembershipAdded { member: idty_id, expire_on, @@ -282,7 +281,7 @@ pub mod pallet { /// perform membership removal pub fn do_remove_membership(idty_id: T::IdtyId, reason: MembershipRemovalReason) { - if let Some(membership_data) = Membership::<T, I>::take(idty_id) { + if let Some(membership_data) = Membership::<T>::take(idty_id) { Self::unschedule_membership_expiry(idty_id, membership_data.expire_on); Self::deposit_event(Event::MembershipRemoved { member: idty_id, @@ -295,7 +294,7 @@ pub mod pallet { /// check the origin and get identity id if valid fn get_idty_id(origin: OriginFor<T>) -> Result<T::IdtyId, DispatchError> { if let Ok(RawOrigin::Signed(account_id)) = origin.into() { - T::IdtyIdOf::convert(account_id).ok_or_else(|| Error::<T, I>::IdtyIdNotFound.into()) + T::IdtyIdOf::convert(account_id).ok_or_else(|| Error::<T>::IdtyIdNotFound.into()) } else { Err(BadOrigin.into()) } @@ -305,7 +304,7 @@ pub mod pallet { pub fn expire_memberships(block_number: T::BlockNumber) -> Weight { let mut expired_idty_count = 0u32; - for idty_id in MembershipsExpireOn::<T, I>::take(block_number) { + for idty_id in MembershipsExpireOn::<T>::take(block_number) { // remove membership (take) Self::do_remove_membership(idty_id, MembershipRemovalReason::Expired); expired_idty_count = 0; @@ -315,21 +314,21 @@ pub mod pallet { /// check if identity is member pub fn is_member(idty_id: &T::IdtyId) -> bool { - Membership::<T, I>::contains_key(idty_id) + Membership::<T>::contains_key(idty_id) } } } // implement traits -impl<T: Config<I>, I: 'static> sp_runtime::traits::IsMember<T::IdtyId> for Pallet<T, I> { +impl<T: Config> sp_runtime::traits::IsMember<T::IdtyId> for Pallet<T> { fn is_member(idty_id: &T::IdtyId) -> bool { Self::is_member(idty_id) } } -impl<T: Config<I>, I: 'static> MembersCount for Pallet<T, I> { +impl<T: Config> MembersCount for Pallet<T> { fn members_count() -> u32 { - Membership::<T, I>::count() + Membership::<T>::count() } } diff --git a/pallets/membership/src/tests.rs b/pallets/membership/src/tests.rs index d3ea561676c7df75c9037da79ec8b5f2a47b232b..53da60336bb6cefa94a5897836a38871929f7503 100644 --- a/pallets/membership/src/tests.rs +++ b/pallets/membership/src/tests.rs @@ -106,7 +106,7 @@ fn test_membership_renewal_nope() { // Membership 1 can not be renewed assert_noop!( DefaultMembership::renew_membership(RuntimeOrigin::signed(1)), - Error::<Test, _>::MembershipNotFound, + Error::<Test>::MembershipNotFound, ); run_to_block(3); assert!(!DefaultMembership::is_member(&1)); diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index 57922ab7f56b02ab036312be9b757f3b10703645..5a5fc2ebda7c3e1f55840f4bfc68a63d32d2290d 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -17,7 +17,6 @@ use super::entities::*; use super::{AccountId, IdtyIndex}; use frame_support::dispatch::UnfilteredDispatchable; -use frame_support::instances::Instance1; use frame_support::pallet_prelude::Weight; use pallet_smith_members::SmithRemovalReason; @@ -39,7 +38,7 @@ impl< Inner: sp_membership::traits::OnEvent<IdtyIndex>, Runtime: frame_system::Config<AccountId = AccountId> + pallet_identity::Config<IdtyData = IdtyData, IdtyIndex = IdtyIndex> - + pallet_membership::Config<Instance1> + + pallet_membership::Config + pallet_universal_dividend::Config, > sp_membership::traits::OnEvent<IdtyIndex> for OnMembershipEventHandler<Inner, Runtime> { diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 6e1c717ba01ff879ccf61b344435dde8831f389f..8121de9653a4c327320219a40d7e2549301e84b9 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -454,8 +454,7 @@ macro_rules! pallets_config { // WEB OF TRUST // - use frame_support::instances::Instance1; - impl pallet_duniter_wot::Config<Instance1> for Runtime { + impl pallet_duniter_wot::Config for Runtime { type FirstIssuableOn = WotFirstCertIssuableOn; type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime>; type MinCertForMembership = WotMinCertForMembership; @@ -488,7 +487,7 @@ macro_rules! pallets_config { type BenchmarkSetupHandler = common_runtime::providers::BenchmarkSetupHandler<Runtime>; } - impl pallet_membership::Config<frame_support::instances::Instance1> for Runtime { + impl pallet_membership::Config for Runtime { type CheckMembershipCallAllowed = Wot; type IdtyId = IdtyIndex; type IdtyIdOf = common_runtime::providers::IdentityIndexOf<Self>; @@ -501,7 +500,7 @@ macro_rules! pallets_config { type BenchmarkSetupHandler = common_runtime::providers::BenchmarkSetupHandler<Runtime>; } - impl pallet_certification::Config<Instance1> for Runtime { + impl pallet_certification::Config for Runtime { type CertPeriod = CertPeriod; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; diff --git a/runtime/common/src/providers.rs b/runtime/common/src/providers.rs index 01da1ebe7519478c1c092e32b461bd80f86b7258..f67bd9cf0b827b9fa290270cd5211f11d5eb0596 100644 --- a/runtime/common/src/providers.rs +++ b/runtime/common/src/providers.rs @@ -16,7 +16,6 @@ use crate::{entities::IdtyData, AccountId, IdtyIndex}; use core::marker::PhantomData; -use frame_support::instances::Instance1; use pallet_universal_dividend::FirstEligibleUd; use sp_runtime::DispatchError; use sp_std::boxed::Box; @@ -114,7 +113,7 @@ pub struct MainWotIsDistanceOk<T>(PhantomData<T>); impl<T> pallet_duniter_wot::traits::IsDistanceOk<<T as pallet_identity::Config>::IdtyIndex> for MainWotIsDistanceOk<T> where - T: pallet_distance::Config + pallet_duniter_wot::Config<frame_support::instances::Instance1>, + T: pallet_distance::Config + pallet_duniter_wot::Config, { fn is_distance_ok( idty_id: &<T as pallet_identity::Config>::IdtyIndex, @@ -122,23 +121,27 @@ where match pallet_distance::Pallet::<T>::identity_distance_status(idty_id) { Some((_, status)) => match status { pallet_distance::DistanceStatus::Valid => Ok(()), - pallet_distance::DistanceStatus::Invalid => Err(pallet_duniter_wot::Error::<T, frame_support::instances::Instance1>::DistanceIsInvalid.into()), - pallet_distance::DistanceStatus::Pending => Err(pallet_duniter_wot::Error::<T, frame_support::instances::Instance1>::DistanceEvaluationPending.into()), + pallet_distance::DistanceStatus::Invalid => { + Err(pallet_duniter_wot::Error::<T>::DistanceIsInvalid.into()) + } + pallet_distance::DistanceStatus::Pending => { + Err(pallet_duniter_wot::Error::<T>::DistanceEvaluationPending.into()) + } }, - None => Err(pallet_duniter_wot::Error::<T, frame_support::instances::Instance1>::DistanceEvaluationNotRequested.into()), - } + None => Err(pallet_duniter_wot::Error::<T>::DistanceEvaluationNotRequested.into()), + } } } pub struct IsWoTMemberProvider<T>(PhantomData<T>); impl<T: pallet_smith_members::Config> - sp_runtime::traits::IsMember<<T as pallet_membership::Config<Instance1>>::IdtyId> + sp_runtime::traits::IsMember<<T as pallet_membership::Config>::IdtyId> for IsWoTMemberProvider<T> where - T: pallet_distance::Config + pallet_membership::Config<Instance1>, + T: pallet_distance::Config + pallet_membership::Config, { fn is_member(idty_id: &T::IdtyId) -> bool { - pallet_membership::Pallet::<T, Instance1>::is_member(idty_id) + pallet_membership::Pallet::<T>::is_member(idty_id) } } @@ -152,8 +155,8 @@ macro_rules! impl_benchmark_setup_handler { impl<T> $t for BenchmarkSetupHandler<T> where T: pallet_distance::Config, - T: pallet_certification::Config<frame_support::instances::Instance1>, - <T as pallet_certification::Config<frame_support::instances::Instance1>>::IdtyIndex: From<u32>, + T: pallet_certification::Config, + <T as pallet_certification::Config>::IdtyIndex: From<u32>, { fn force_status_ok( idty_id: &IdtyIndex, @@ -165,7 +168,11 @@ macro_rules! impl_benchmark_setup_handler { ); } fn add_cert(issuer: &IdtyIndex, receiver: &IdtyIndex) { - let _ = pallet_certification::Pallet::<T, frame_support::instances::Instance1>::do_add_cert_checked((*issuer).into(), (*receiver).into(), false); + let _ = pallet_certification::Pallet::<T>::do_add_cert_checked( + (*issuer).into(), + (*receiver).into(), + false, + ); } } }; diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index e86383d1a1d22fe6f5a1c68d5f4a969fb9306dba..e8ab75d92e610b507217f715f091d64ee120aa60 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -286,10 +286,10 @@ construct_runtime!( UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust - Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40, + Wot: pallet_duniter_wot::{Pallet} = 40, Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 41, - Membership: pallet_membership::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, - Cert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, + Membership: pallet_membership::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, + Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, Distance: pallet_distance::{Pallet, Call, Storage, Inherent, Event<T>} = 44, // Utilities diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 383b56927f73468cd18b57eb87a7b4fe6adb4494..1514f5f8746e932b1c6128daeba46430cc345006 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -329,10 +329,10 @@ construct_runtime!( UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust - Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40, + Wot: pallet_duniter_wot::{Pallet} = 40, Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 41, - Membership: pallet_membership::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, - Cert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, + Membership: pallet_membership::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, + Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, Distance: pallet_distance::{Pallet, Call, Storage, Inherent, Event<T>} = 44, // Utilities diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 037c13f3be32e1f8ac99e3f7b1897fa7a9d054b3..a74493b34a02f8f680be2c32712341314b1858fe 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -18,7 +18,6 @@ use common_runtime::constants::*; use common_runtime::*; -use frame_support::instances::Instance1; use frame_support::traits::{GenesisBuild, OnFinalize, OnInitialize}; use gdev_runtime::opaque::SessionKeys; use gdev_runtime::*; @@ -247,7 +246,7 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - pallet_membership::GenesisConfig::<Runtime, Instance1> { + pallet_membership::GenesisConfig::<Runtime> { memberships: (1..=initial_identities.len()) .map(|i| { ( @@ -262,7 +261,7 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - pallet_certification::GenesisConfig::<Runtime, Instance1> { + pallet_certification::GenesisConfig::<Runtime> { certs_by_receiver: clique_wot( initial_identities.len(), parameters.cert_validity_period, diff --git a/runtime/gdev/tests/fixme_tests.rs b/runtime/gdev/tests/fixme_tests.rs index 028f23600ccebc7d1258815fb514717706143eaf..1ab0bd7a7c799d9ed6b9c8be655bb38106d3c7ad 100644 --- a/runtime/gdev/tests/fixme_tests.rs +++ b/runtime/gdev/tests/fixme_tests.rs @@ -43,10 +43,7 @@ fn can_still_issue_cert_when_membership_lost() { run_to_block(1); // expire Bob membership - Membership::do_remove_membership( - 2, - MembershipRemovalReason::System - ); + Membership::do_remove_membership(2, MembershipRemovalReason::System); System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipRemoved { member: 2, @@ -55,12 +52,13 @@ fn can_still_issue_cert_when_membership_lost() { )); // fixed :) - assert_noop!(Cert::add_cert( - frame_system::RawOrigin::Signed(AccountKeyring::Bob.to_account_id()).into(), + assert_noop!( + Cert::add_cert( + frame_system::RawOrigin::Signed(AccountKeyring::Bob.to_account_id()).into(), 2, // Bob 3, // Charlie ), - pallet_duniter_wot::Error::<gdev_runtime::Runtime, pallet_certification::Instance1>::IssuerNotMember + pallet_duniter_wot::Error::<gdev_runtime::Runtime>::IssuerNotMember ); // // not anymore // System::assert_has_event(RuntimeEvent::Cert( diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index ef8539fe34beb74628777796a5df9e081ad55acd..240b1a58dbf59c10aab4eec5377b2ec1151474f7 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -17,7 +17,6 @@ mod common; use common::*; -use frame_support::instances::Instance1; use frame_support::traits::StoredMap; use frame_support::traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait}; use frame_support::{assert_err, assert_noop, assert_ok}; @@ -369,9 +368,7 @@ fn test_validate_identity_when_claim() { System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipAdded { member: 5, - expire_on: 76 - + <Runtime as pallet_membership::Config<Instance1>>::MembershipPeriod::get( - ), + expire_on: 76 + <Runtime as pallet_membership::Config>::MembershipPeriod::get(), }, )); // not possible anymore to validate identity of someone else @@ -448,9 +445,7 @@ fn test_membership_renewal() { System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipAdded { member: 1, - expire_on: 76 - + <Runtime as pallet_membership::Config<Instance1>>::MembershipPeriod::get( - ), + expire_on: 76 + <Runtime as pallet_membership::Config>::MembershipPeriod::get(), }, )); @@ -462,9 +457,7 @@ fn test_membership_renewal() { System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipAdded { member: 1, - expire_on: 77 - + <Runtime as pallet_membership::Config<Instance1>>::MembershipPeriod::get( - ), + expire_on: 77 + <Runtime as pallet_membership::Config>::MembershipPeriod::get(), }, )); @@ -605,8 +598,7 @@ fn test_ud_claimed_membership_on_and_off() { System::assert_has_event(RuntimeEvent::Membership( pallet_membership::Event::MembershipAdded { member: 1, - expire_on: 14 - + <Runtime as pallet_membership::Config<Instance1>>::MembershipPeriod::get(), + expire_on: 14 + <Runtime as pallet_membership::Config>::MembershipPeriod::get(), }, )); @@ -1359,10 +1351,7 @@ fn test_smith_member_can_revoke_its_idty() { pallet_authority_members::Event::IncomingAuthorities { members: vec![3] }, )); // Charlie is not going out - assert_eq!( - pallet_authority_members::OutgoingAuthorities::<Runtime>::get().contains(&3), - false - ); + assert!(!pallet_authority_members::OutgoingAuthorities::<Runtime>::get().contains(&3)); let revocation_payload = RevocationPayload { idty_index: 3u32, diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 9dc7d515947d6285e674e9b9b1c0f03c80966c4c..3613fe2f94241c3bb3f3a1eb76e2d7a082c1da04 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -291,10 +291,10 @@ construct_runtime!( UniversalDividend: pallet_universal_dividend::{Pallet, Call, Config<T>, Storage, Event<T>} = 30, // Web Of Trust - Wot: pallet_duniter_wot::<Instance1>::{Pallet} = 40, + Wot: pallet_duniter_wot::{Pallet} = 40, Identity: pallet_identity::{Pallet, Call, Config<T>, Storage, Event<T>} = 41, - Membership: pallet_membership::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, - Cert: pallet_certification::<Instance1>::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, + Membership: pallet_membership::{Pallet, Call, Config<T>, Storage, Event<T>} = 42, + Cert: pallet_certification::{Pallet, Call, Config<T>, Storage, Event<T>} = 43, Distance: pallet_distance::{Pallet, Call, Storage, Inherent, Event<T>} = 44, // Utilities