Skip to content
Snippets Groups Projects
Commit 0dc746b4 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

remove check_remove_identity

parent 056b85df
No related branches found
No related tags found
1 merge request!215refac membership
......@@ -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
......@@ -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
......
......@@ -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 {
......
......@@ -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(())
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment