From f0dbc0b2f2ad252a281dc0742c15e68b49725654 Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@trentesaux.fr> Date: Fri, 23 Sep 2022 00:43:24 +0200 Subject: [PATCH] wip rename check traits --- pallets/certification/src/lib.rs | 4 ++-- pallets/certification/src/mock.rs | 2 +- pallets/certification/src/traits.rs | 4 ++-- pallets/duniter-wot/src/lib.rs | 4 ++-- pallets/duniter-wot/src/mock.rs | 6 +++--- pallets/identity/src/lib.rs | 12 ++++++------ pallets/identity/src/mock.rs | 2 +- pallets/identity/src/traits.rs | 4 ++-- runtime/common/src/pallets_config.rs | 6 +++--- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index d1e02a7b3..658785ef8 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -71,7 +71,7 @@ pub mod pallet { /// Something that give the owner key of an identity type OwnerKeyOf: Convert<Self::IdtyIndex, Option<Self::AccountId>>; /// - type IsCertAllowed: IsCertAllowed<Self::IdtyIndex>; + type CheckCertAllowed: CheckCertAllowed<Self::IdtyIndex>; #[pallet::constant] /// Maximum number of active certifications by issuer type MaxByIssuer: Get<u32>; @@ -323,7 +323,7 @@ pub mod pallet { ensure!(issuer_owner_key == who, DispatchError::BadOrigin); // Verify compatibility with other pallets state - T::IsCertAllowed::check_cert_allowed(issuer, receiver)?; + T::CheckCertAllowed::check_cert_allowed(issuer, receiver)?; // Verify rule MinReceivedCertToBeAbleToIssueCert let issuer_idty_cert_meta = <StorageIdtyCertMeta<T, I>>::get(issuer); diff --git a/pallets/certification/src/mock.rs b/pallets/certification/src/mock.rs index 066d3ebb0..68de7a87e 100644 --- a/pallets/certification/src/mock.rs +++ b/pallets/certification/src/mock.rs @@ -103,7 +103,7 @@ impl pallet_certification::Config for Test { type Event = Event; type IdtyIndex = IdtyIndex; type OwnerKeyOf = sp_runtime::traits::ConvertInto; - type IsCertAllowed = (); + type CheckCertAllowed = (); type MaxByIssuer = MaxByIssuer; type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = (); diff --git a/pallets/certification/src/traits.rs b/pallets/certification/src/traits.rs index 410ea643f..9a81bb3d0 100644 --- a/pallets/certification/src/traits.rs +++ b/pallets/certification/src/traits.rs @@ -16,11 +16,11 @@ use frame_support::pallet_prelude::*; -pub trait IsCertAllowed<IdtyIndex> { +pub trait CheckCertAllowed<IdtyIndex> { fn check_cert_allowed(issuer: IdtyIndex, receiver: IdtyIndex) -> Result<(), DispatchError>; } -impl<IdtyIndex> IsCertAllowed<IdtyIndex> for () { +impl<IdtyIndex> CheckCertAllowed<IdtyIndex> for () { fn check_cert_allowed(_issuer: IdtyIndex, _receiver: IdtyIndex) -> Result<(), DispatchError> { Ok(()) } diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 0b5e1a0be..e84484e7b 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -114,7 +114,7 @@ pub mod pallet { } } -impl<AccountId, T: Config<I>, I: 'static> pallet_identity::traits::EnsureIdtyCallAllowed<T> +impl<AccountId, T: Config<I>, I: 'static> pallet_identity::traits::CheckIdtyCallAllowed<T> for Pallet<T, I> where T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config<I>, @@ -196,7 +196,7 @@ where } } -impl<T: Config<I>, I: 'static> pallet_certification::traits::IsCertAllowed<IdtyIndex> +impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<IdtyIndex> for Pallet<T, I> { fn check_cert_allowed(issuer: IdtyIndex, receiver: IdtyIndex) -> Result<(), DispatchError> { diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index d6872196f..d26889790 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -122,7 +122,7 @@ impl pallet_identity::Config for Test { type ChangeOwnerKeyPeriod = ChangeOwnerKeyPeriod; type ConfirmPeriod = ConfirmPeriod; type Event = Event; - type EnsureIdtyCallAllowed = (DuniterWot, SmithsSubWot); + type CheckIdtyCallAllowed = (DuniterWot, SmithsSubWot); type IdtyCreationPeriod = IdtyCreationPeriod; type IdtyData = (); type IdtyNameValidator = IdtyNameValidatorTestImpl; @@ -167,7 +167,7 @@ impl pallet_certification::Config<Instance1> for Test { type Event = Event; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; - type IsCertAllowed = DuniterWot; + type CheckCertAllowed = DuniterWot; type MaxByIssuer = MaxByIssuer; type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = DuniterWot; @@ -221,7 +221,7 @@ impl pallet_certification::Config<Instance2> for Test { type Event = Event; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; - type IsCertAllowed = SmithsSubWot; + type CheckCertAllowed = SmithsSubWot; type MaxByIssuer = SmithsMaxByIssuer; type MinReceivedCertToBeAbleToIssueCert = SmithsMinReceivedCertToBeAbleToIssueCert; type OnNewcert = SmithsSubWot; diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 0c91a9546..961b8e2f8 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -72,7 +72,7 @@ pub mod pallet { type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>; /// Management of the authorizations of the different calls. /// The default implementation allows everything. - type EnsureIdtyCallAllowed: EnsureIdtyCallAllowed<Self>; + type CheckIdtyCallAllowed: CheckIdtyCallAllowed<Self>; #[pallet::constant] /// Minimum duration between the creation of 2 identities by the same creator type IdtyCreationPeriod: Get<Self::BlockNumber>; @@ -272,7 +272,7 @@ pub mod pallet { } // run checks for identity creation - T::EnsureIdtyCallAllowed::check_create_identity(creator)?; + T::CheckIdtyCallAllowed::check_create_identity(creator)?; let block_number = frame_system::pallet::Pallet::<T>::block_number(); @@ -340,7 +340,7 @@ pub mod pallet { if <IdentitiesNames<T>>::contains_key(&idty_name) { return Err(Error::<T>::IdtyNameAlreadyExist.into()); } - T::EnsureIdtyCallAllowed::check_confirm_identity(idty_index)?; + T::CheckIdtyCallAllowed::check_confirm_identity(idty_index)?; // Apply phase // idty_value.status = IdtyStatus::ConfirmedByOwner; @@ -369,7 +369,7 @@ pub mod pallet { match idty_value.status { IdtyStatus::Created => return Err(Error::<T>::IdtyNotConfirmedByOwner.into()), IdtyStatus::ConfirmedByOwner => { - T::EnsureIdtyCallAllowed::check_validate_identity(idty_index)?; + T::CheckIdtyCallAllowed::check_validate_identity(idty_index)?; } IdtyStatus::Validated => return Err(Error::<T>::IdtyAlreadyValidated.into()), } @@ -411,7 +411,7 @@ pub mod pallet { Error::<T>::OwnerKeyAlreadyUsed ); - T::EnsureIdtyCallAllowed::check_change_identity_address(idty_index)?; + T::CheckIdtyCallAllowed::check_change_identity_address(idty_index)?; let block_number = frame_system::Pallet::<T>::block_number(); let maybe_old_old_owner_key = @@ -498,7 +498,7 @@ pub mod pallet { Error::<T>::InvalidRevocationKey ); - T::EnsureIdtyCallAllowed::check_remove_identity(idty_index)?; + T::CheckIdtyCallAllowed::check_remove_identity(idty_index)?; let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); let revocation_payload = RevocationPayload { diff --git a/pallets/identity/src/mock.rs b/pallets/identity/src/mock.rs index 535e06726..6825ebf66 100644 --- a/pallets/identity/src/mock.rs +++ b/pallets/identity/src/mock.rs @@ -94,7 +94,7 @@ impl pallet_identity::Config for Test { type ChangeOwnerKeyPeriod = ChangeOwnerKeyPeriod; type ConfirmPeriod = ConfirmPeriod; type Event = Event; - type EnsureIdtyCallAllowed = (); + type CheckIdtyCallAllowed = (); type IdtyCreationPeriod = IdtyCreationPeriod; type IdtyData = (); type IdtyNameValidator = IdtyNameValidatorTestImpl; diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs index 181dec6cc..012d2a4a6 100644 --- a/pallets/identity/src/traits.rs +++ b/pallets/identity/src/traits.rs @@ -19,7 +19,7 @@ use frame_support::pallet_prelude::*; use impl_trait_for_tuples::impl_for_tuples; use sp_runtime::traits::Saturating; -pub trait EnsureIdtyCallAllowed<T: Config> { +pub trait CheckIdtyCallAllowed<T: Config> { fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>; fn check_confirm_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; @@ -29,7 +29,7 @@ pub trait EnsureIdtyCallAllowed<T: Config> { #[impl_for_tuples(5)] #[allow(clippy::let_and_return)] -impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple { +impl<T: Config> CheckIdtyCallAllowed<T> for Tuple { fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError> { for_tuples!( #( Tuple::check_create_identity(creator)?; )* ); Ok(()) diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index cdcaa4944..c5c6418fe 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -430,7 +430,7 @@ macro_rules! pallets_config { type ChangeOwnerKeyPeriod = ChangeOwnerKeyPeriod; type ConfirmPeriod = ConfirmPeriod; type Event = Event; - type EnsureIdtyCallAllowed = (Wot, SmithsSubWot); + type CheckIdtyCallAllowed = (Wot, SmithsSubWot); type IdtyCreationPeriod = IdtyCreationPeriod; type IdtyData = IdtyData; type IdtyIndex = IdtyIndex; @@ -461,7 +461,7 @@ macro_rules! pallets_config { type Event = Event; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; - type IsCertAllowed = Wot; + type CheckCertAllowed = Wot; type MaxByIssuer = MaxByIssuer; type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert; type OnNewcert = Wot; @@ -497,7 +497,7 @@ macro_rules! pallets_config { type Event = Event; type IdtyIndex = IdtyIndex; type OwnerKeyOf = Identity; - type IsCertAllowed = SmithsSubWot; + type CheckCertAllowed = SmithsSubWot; type MaxByIssuer = SmithMaxByIssuer; type MinReceivedCertToBeAbleToIssueCert = SmithMinReceivedCertToBeAbleToIssueCert; type OnNewcert = SmithsSubWot; -- GitLab