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