diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 7cf49c3a71314371e913665ea8d54773db7de618..400a3d06ce1196ae032ce81d187772d7cde3d905 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -66,8 +66,6 @@ pub mod pallet { #[pallet::constant] type FirstIssuableOn: Get<Self::BlockNumber>; #[pallet::constant] - type IsSubWot: Get<bool>; - #[pallet::constant] type MinCertForMembership: Get<u32>; #[pallet::constant] type MinCertForCreateIdtyRight: Get<u32>; @@ -132,30 +130,25 @@ where { // identity creation checks fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> { - // main WoT constraints - if !T::IsSubWot::get() { - let cert_meta = pallet_certification::Pallet::<T, I>::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 - ); - // 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 - ); - // 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 - ); - } - // TODO (#136) make these trait implementation work on instances rather than static to avoid checking IsSubWot - // smith subwot can never prevent from creating identity + let cert_meta = pallet_certification::Pallet::<T, I>::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 + ); + // 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 + ); + // 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 + ); Ok(()) } } @@ -238,17 +231,13 @@ where fn on_event(membership_event: &sp_membership::Event<IdtyIndex>) { match membership_event { sp_membership::Event::<IdtyIndex>::MembershipAdded(idty_index) => { - if !T::IsSubWot::get() { - // when main membership is acquired, tell identity - // (only used on first membership acquiry) - pallet_identity::Pallet::<T>::membership_added(*idty_index); - } + // when main membership is acquired, tell identity + // (only used on first membership acquiry) + pallet_identity::Pallet::<T>::membership_added(*idty_index); } sp_membership::Event::<IdtyIndex>::MembershipRemoved(idty_index) => { - if !T::IsSubWot::get() { - // when main membership is lost, tell identity - pallet_identity::Pallet::<T>::membership_removed(*idty_index); - } + // when main membership is lost, tell identity + pallet_identity::Pallet::<T>::membership_removed(*idty_index); } sp_membership::Event::<IdtyIndex>::MembershipRenewed(_) => {} } diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 33034b24c40893d999e42a2e0020b1cdc51aa600..1b501b409b1c50f76f5659b93e9a406c38b666fb 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -94,7 +94,6 @@ parameter_types! { } impl pallet_duniter_wot::Config<Instance1> for Test { - type IsSubWot = frame_support::traits::ConstBool<false>; type MinCertForMembership = MinCertForMembership; type MinCertForCreateIdtyRight = MinCertForCreateIdtyRight; type FirstIssuableOn = FirstIssuableOn; diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 1c64d6bb8da1bcac1824f3afed3dc053e09559df..6e1c717ba01ff879ccf61b344435dde8831f389f 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -458,7 +458,6 @@ macro_rules! pallets_config { impl pallet_duniter_wot::Config<Instance1> for Runtime { type FirstIssuableOn = WotFirstCertIssuableOn; type IsDistanceOk = common_runtime::providers::MainWotIsDistanceOk<Runtime>; - type IsSubWot = frame_support::traits::ConstBool<false>; type MinCertForMembership = WotMinCertForMembership; type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight; }