diff --git a/notes.txt b/notes.txt index 7feeff064bcd94340f10b5846293e3fa3f705ba0..81859b2bf267901ca6ab661114819e7ee1443796 100644 --- a/notes.txt +++ b/notes.txt @@ -7,23 +7,18 @@ concept validate_identity dans la doc à prévoir -donner directement le statut dans GenesisIdentity au lieu de xxx -déplacer IdtyCreationPeriod vers le certification period (?) trouver un meilleur nom pour "next_scheduled" (anciennement removable_on) qui correspond à la prochaine action programmée - -à remplacer - -T::OnEvent::on_event(&sp_membership::Event::PendingMembershipExpired(idty_id)); -PendingMembershipPeriod - - - optionnellement +donner directement le statut dans GenesisIdentity au lieu du booléen "active" ce qui permettrait + - d'inclure des identité révoquées pour protéger leur pseudo / clés + - d'inclure des identités non membres en conservant le délai de réactivation + séparer OnEvent(membership_event) en OnMembershipAdded OnMembershipRenewed -OnMembershipRemoved \ No newline at end of file +OnMembershipRemoved + diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index 4ecdc454c49719a2471800c628ead97f905aaff7..d9214f14fcc5a2bf445329ed257ad2536232b528 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -130,6 +130,7 @@ impl<AccountId, T: Config<I>, I: 'static> pallet_identity::traits::CheckIdtyCall where T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config<I>, { + // identity creation checks fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> { // main WoT constraints if !T::IsSubWot::get() { @@ -153,12 +154,13 @@ where Error::<T, I>::IdtyCreationPeriodNotRespected ); } - // TODO make these trait implementation work on instances rather than static to avoid checking IsSubWot + // TODO (#136) make these trait implementation work on instances rather than static to avoid checking IsSubWot // smith subwot can never prevent from creating identity Ok(()) } - // TODO uniformize naming between changing "identity owner key" and "identity address" - fn check_change_identity_address(idty_index: IdtyIndex) -> Result<(), DispatchError> { + + // identity change owner key cheks + fn change_owner_key(idty_index: IdtyIndex) -> Result<(), DispatchError> { // sub WoT prevents from changing identity if T::IsSubWot::get() { ensure!( @@ -169,16 +171,6 @@ where // no constraints for main wot Ok(()) } - fn check_remove_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> { - // identity can not be removed when member of a subwot (smith in this case) - if T::IsSubWot::get() { - ensure!( - !pallet_membership::Pallet::<T, I>::is_member(&idty_index), - Error::<T, I>::NotAllowedToRemoveIdty - ); - } - Ok(()) - } } // implement cert call checks diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 99adb60916c8531eb0450c139f47a7d08ea87f05..0de04edab3e642fc90605826c895f016d0cff937 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -415,7 +415,7 @@ pub mod pallet { Error::<T>::OwnerKeyAlreadyUsed ); - T::CheckIdtyCallAllowed::check_change_identity_address(idty_index)?; + T::CheckIdtyCallAllowed::change_owner_key(idty_index)?; let block_number = frame_system::Pallet::<T>::block_number(); let maybe_old_old_owner_key = @@ -506,9 +506,6 @@ pub mod pallet { Error::<T>::InvalidRevocationKey ); - // make sure that no wot prevents identity removal - T::CheckIdtyCallAllowed::check_remove_identity(idty_index)?; - // then check payload signature let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero()); let revocation_payload = RevocationPayload { diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs index 762b4b97ff6eb795b0cc8d8a697642d8df31d782..0ecf15a0c1b5375226fe6f3590a928ce31c2be5a 100644 --- a/pallets/identity/src/traits.rs +++ b/pallets/identity/src/traits.rs @@ -20,8 +20,7 @@ use impl_trait_for_tuples::impl_for_tuples; pub trait CheckIdtyCallAllowed<T: Config> { fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>; - fn check_change_identity_address(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; - fn check_remove_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; + fn change_owner_key(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; } #[impl_for_tuples(5)] @@ -30,12 +29,8 @@ impl<T: Config> CheckIdtyCallAllowed<T> for Tuple { for_tuples!( #( Tuple::check_create_identity(creator)?; )* ); Ok(()) } - fn check_change_identity_address(idty_index: T::IdtyIndex) -> Result<(), DispatchError> { - for_tuples!( #( Tuple::check_change_identity_address(idty_index)?; )* ); - Ok(()) - } - fn check_remove_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError> { - for_tuples!( #( Tuple::check_remove_identity(idty_index)?; )* ); + fn change_owner_key(idty_index: T::IdtyIndex) -> Result<(), DispatchError> { + for_tuples!( #( Tuple::change_owner_key(idty_index)?; )* ); Ok(()) } }