Skip to content
Snippets Groups Projects

refac membership renewal

Merged Hugo Trentesaux requested to merge hugo-fix-nonmember-identities into master
Files
8
@@ -128,6 +128,7 @@ where
@@ -128,6 +128,7 @@ where
T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config<I>,
T: frame_system::Config<AccountId = AccountId> + pallet_membership::Config<I>,
{
{
fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> {
fn check_create_identity(creator: IdtyIndex) -> Result<(), DispatchError> {
 
// main WoT constraints
if !T::IsSubWot::get() {
if !T::IsSubWot::get() {
let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator);
let cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(creator);
// perform all checks
// perform all checks
@@ -144,9 +145,11 @@ where
@@ -144,9 +145,11 @@ where
Error::<T, I>::IdtyCreationPeriodNotRespected
Error::<T, I>::IdtyCreationPeriodNotRespected
);
);
}
}
 
// no constraints for subwot
Ok(())
Ok(())
}
}
fn check_confirm_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
fn check_confirm_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
 
// main WoT constraints
if !T::IsSubWot::get() {
if !T::IsSubWot::get() {
pallet_membership::Pallet::<T, I>::force_request_membership(
pallet_membership::Pallet::<T, I>::force_request_membership(
RawOrigin::Root.into(),
RawOrigin::Root.into(),
@@ -155,9 +158,11 @@ where
@@ -155,9 +158,11 @@ where
)
)
.map_err(|e| e.error)?;
.map_err(|e| e.error)?;
}
}
 
// no constraints for subwot
Ok(())
Ok(())
}
}
fn check_validate_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
fn check_validate_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
 
// main WoT constraints
if !T::IsSubWot::get() {
if !T::IsSubWot::get() {
// TODO replace this code by the commented one for distance feature
// 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);
/*let idty_cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(idty_index);
@@ -169,18 +174,22 @@ where
@@ -169,18 +174,22 @@ where
)
)
.map_err(|e| e.error)?;
.map_err(|e| e.error)?;
}
}
 
// no constraints for subwot
Ok(())
Ok(())
}
}
fn check_change_identity_address(idty_index: IdtyIndex) -> Result<(), DispatchError> {
fn check_change_identity_address(idty_index: IdtyIndex) -> Result<(), DispatchError> {
 
// sub WoT constraints
if T::IsSubWot::get() {
if T::IsSubWot::get() {
ensure!(
ensure!(
!pallet_membership::Pallet::<T, I>::is_member(&idty_index),
!pallet_membership::Pallet::<T, I>::is_member(&idty_index),
Error::<T, I>::NotAllowedToChangeIdtyAddress
Error::<T, I>::NotAllowedToChangeIdtyAddress
);
);
}
}
 
// no constraints for main wot
Ok(())
Ok(())
}
}
fn check_remove_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
fn check_remove_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
 
// identities can not be remove when member of a subwot (smith in this case)
if T::IsSubWot::get() {
if T::IsSubWot::get() {
ensure!(
ensure!(
!pallet_membership::Pallet::<T, I>::is_member(&idty_index),
!pallet_membership::Pallet::<T, I>::is_member(&idty_index),
Loading