diff --git a/pallets/duniter-wot/src/lib.rs b/pallets/duniter-wot/src/lib.rs index a65ad91019c0d691be2603a1b250ecc595f5ebee..39505cabf4036271eaddc5a9f10cc2c101c5db51 100644 --- a/pallets/duniter-wot/src/lib.rs +++ b/pallets/duniter-wot/src/lib.rs @@ -150,18 +150,20 @@ where Ok(()) } } - fn can_validate_identity(idty_index: IdtyIndex) -> bool { + fn check_validate_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> { if !T::IsSubWot::get() { // TODO replace this code by the commented one for distance feature /*let idty_cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(idty_index); idty_cert_meta.received_count >= T::MinCertForMembership::get() as u32*/ - pallet_membership::Pallet::<T, I>::claim_membership( + match pallet_membership::Pallet::<T, I>::claim_membership( RawOrigin::Root.into(), Some(idty_index), - ) - .is_ok() + ) { + Ok(_) => Ok(()), + Err(e) => Err(e.error), + } } else { - true + Ok(()) } } fn can_change_identity_address(idty_index: IdtyIndex) -> bool { diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index c3b001e5735fad3594ddff1309f1a2d77f1cd358..91da35b60b4eae67079be8c8cec6a076dbee3d8e 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -369,9 +369,7 @@ pub mod pallet { match idty_value.status { IdtyStatus::Created => return Err(Error::<T>::IdtyNotConfirmedByOwner.into()), IdtyStatus::ConfirmedByOwner => { - if !T::EnsureIdtyCallAllowed::can_validate_identity(idty_index) { - return Err(Error::<T>::NotAllowedToValidateIdty.into()); - } + T::EnsureIdtyCallAllowed::check_validate_identity(idty_index)?; } IdtyStatus::Validated => return Err(Error::<T>::IdtyAlreadyValidated.into()), } @@ -610,8 +608,6 @@ pub mod pallet { NotAllowedToChangeIdtyAddress, /// Not allowed to remove identity NotAllowedToRemoveIdty, - /// Not allowed to validate identity - NotAllowedToValidateIdty, /// Identity creation period is not respected NotRespectIdtyCreationPeriod, /// Not the same identity name diff --git a/pallets/identity/src/traits.rs b/pallets/identity/src/traits.rs index 0beb7d59472c90e190b6bd193ce65b4f334a3c83..32a6e905accb8408da79e7f9fe78d62a7be5f439 100644 --- a/pallets/identity/src/traits.rs +++ b/pallets/identity/src/traits.rs @@ -22,7 +22,7 @@ use sp_runtime::traits::Saturating; 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 can_validate_identity(idty_index: T::IdtyIndex) -> bool; + fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>; fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool; fn can_remove_identity(idty_index: T::IdtyIndex) -> bool; } @@ -38,9 +38,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple { for_tuples!( #( Tuple::check_confirm_identity(idty_index)?; )* ); Ok(()) } - fn can_validate_identity(idty_index: T::IdtyIndex) -> bool { - for_tuples!( #( if !Tuple::can_validate_identity(idty_index) { return false; } )* ); - true + fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError> { + 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; } )* );