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

wip replace adress change check

parent 9e7720ce
No related branches found
No related tags found
No related merge requests found
......@@ -103,6 +103,8 @@ pub mod pallet {
NotEnoughReceivedCertsToCreateIdty,
/// Max number of emited certs reached
MaxEmitedCertsReached,
/// Not allowed to change identity address
NotAllowedToChangeIdtyAddress,
}
}
......@@ -166,11 +168,14 @@ where
Ok(())
}
}
fn can_change_identity_address(idty_index: IdtyIndex) -> bool {
fn check_change_identity_address(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>::NotAllowedToChangeIdtyAddress.into()),
false => Ok(()),
}
} else {
true
Ok(())
}
}
fn can_remove_identity(idty_index: IdtyIndex) -> bool {
......
......@@ -411,10 +411,7 @@ pub mod pallet {
Error::<T>::OwnerKeyAlreadyUsed
);
ensure!(
T::EnsureIdtyCallAllowed::can_change_identity_address(idty_index),
Error::<T>::NotAllowedToChangeIdtyAddress
);
T::EnsureIdtyCallAllowed::check_change_identity_address(idty_index)?;
let block_number = frame_system::Pallet::<T>::block_number();
let maybe_old_old_owner_key =
......@@ -604,8 +601,6 @@ pub mod pallet {
InvalidRevocationKey,
/// Revocation payload signature is invalid
InvalidRevocationSig,
/// Identity not allowed to change address
NotAllowedToChangeIdtyAddress,
/// Not allowed to remove identity
NotAllowedToRemoveIdty,
/// Identity creation period is not respected
......
......@@ -23,7 +23,7 @@ pub trait EnsureIdtyCallAllowed<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>;
fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool;
fn check_change_identity_address(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_remove_identity(idty_index: T::IdtyIndex) -> bool;
}
......@@ -42,9 +42,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple {
for_tuples!( #( Tuple::check_validate_identity(idty_index)?; )* );
Ok(())
}
fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool {
for_tuples!( #( if !Tuple::can_change_identity_address(idty_index) { return false; } )* );
true
fn check_change_identity_address(idty_index: T::IdtyIndex) -> Result<(), DispatchError> {
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; } )* );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment