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

wip replace identity removal check

parent 69ad2193
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,8 @@ pub mod pallet {
MaxEmitedCertsReached,
/// Not allowed to change identity address
NotAllowedToChangeIdtyAddress,
/// Not allowed to remove identity
NotAllowedToRemoveIdty,
}
}
......@@ -178,11 +180,14 @@ where
Ok(())
}
}
fn can_remove_identity(idty_index: IdtyIndex) -> bool {
fn check_remove_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
if T::IsSubWot::get() {
!pallet_membership::Pallet::<T, I>::is_member(&idty_index)
match pallet_membership::Pallet::<T, I>::is_member(&idty_index) {
true => Err(Error::<T, I>::NotAllowedToRemoveIdty.into()),
false => Ok(()),
}
} else {
true
Ok(())
}
}
}
......
......@@ -498,10 +498,7 @@ pub mod pallet {
Error::<T>::InvalidRevocationKey
);
ensure!(
T::EnsureIdtyCallAllowed::can_remove_identity(idty_index),
Error::<T>::NotAllowedToRemoveIdty
);
T::EnsureIdtyCallAllowed::check_remove_identity(idty_index)?;
let genesis_hash = frame_system::Pallet::<T>::block_hash(T::BlockNumber::zero());
let revocation_payload = RevocationPayload {
......@@ -601,8 +598,6 @@ pub mod pallet {
InvalidRevocationKey,
/// Revocation payload signature is invalid
InvalidRevocationSig,
/// Not allowed to remove identity
NotAllowedToRemoveIdty,
/// Identity creation period is not respected
NotRespectIdtyCreationPeriod,
/// Not the same identity name
......
......@@ -24,7 +24,7 @@ pub trait EnsureIdtyCallAllowed<T: Config> {
fn check_confirm_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn check_change_identity_address(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_remove_identity(idty_index: T::IdtyIndex) -> bool;
fn check_remove_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
}
#[impl_for_tuples(5)]
......@@ -46,9 +46,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple {
for_tuples!( #( Tuple::check_change_identity_address(idty_index)?; )* );
Ok(())
}
fn can_remove_identity(idty_index: T::IdtyIndex) -> bool {
for_tuples!( #( if !Tuple::can_remove_identity(idty_index) { return false; } )* );
true
fn check_remove_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError> {
for_tuples!( #( Tuple::check_remove_identity(idty_index)?; )* );
Ok(())
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment