Skip to content
Snippets Groups Projects
Commit 012d096f authored by Éloïs's avatar Éloïs
Browse files

fix(wot): Identity should be removed after the consumers of the identity

parent 0062278f
No related branches found
No related tags found
1 merge request!61fix(wot): Identity should be removed after the consumers of the identity & membership revocation should not trigger identity removal
This commit is part of merge request !61. Comments created here will be created in the context of that merge request.
...@@ -379,7 +379,7 @@ pub mod pallet { ...@@ -379,7 +379,7 @@ pub mod pallet {
Error::<T>::InvalidRevocationProof Error::<T>::InvalidRevocationProof
); );
if let Some(idty_index) = <IdentityIndexOf<T>>::take(&payload.owner_key) { if let Some(idty_index) = <IdentityIndexOf<T>>::take(&payload.owner_key) {
Self::do_remove_identity(idty_index, Some(&payload.owner_key)); Self::do_remove_identity(idty_index);
Ok(().into()) Ok(().into())
} else { } else {
Err(Error::<T>::IdtyNotFound.into()) Err(Error::<T>::IdtyNotFound.into())
...@@ -394,7 +394,7 @@ pub mod pallet { ...@@ -394,7 +394,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
ensure_root(origin)?; ensure_root(origin)?;
Self::do_remove_identity(idty_index, None); Self::do_remove_identity(idty_index);
if let Some(idty_name) = idty_name { if let Some(idty_name) = idty_name {
<IdentitiesNames<T>>::remove(idty_name); <IdentitiesNames<T>>::remove(idty_name);
} }
...@@ -499,15 +499,12 @@ pub mod pallet { ...@@ -499,15 +499,12 @@ pub mod pallet {
// INTERNAL FUNCTIONS // // INTERNAL FUNCTIONS //
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
pub(super) fn do_remove_identity( pub(super) fn do_remove_identity(idty_index: T::IdtyIndex) -> Weight {
idty_index: T::IdtyIndex, if let Some(idty_val) = Identities::<T>::get(idty_index) {
maybe_owner_key: Option<&T::AccountId>, let _ = T::RemoveIdentityConsumers::remove_idty_consumers(idty_index);
) -> Weight { IdentityIndexOf::<T>::remove(&idty_val.owner_key);
if let Some(idty_val) = Identities::<T>::take(idty_index) { // Identity should be removed after the consumers of the identity
T::RemoveIdentityConsumers::remove_idty_consumers(idty_index); Identities::<T>::remove(idty_index);
if let Some(owner_key) = maybe_owner_key {
IdentityIndexOf::<T>::remove(owner_key);
}
frame_system::Pallet::<T>::dec_sufficients(&idty_val.owner_key); frame_system::Pallet::<T>::dec_sufficients(&idty_val.owner_key);
Self::deposit_event(Event::IdtyRemoved { idty_index }); Self::deposit_event(Event::IdtyRemoved { idty_index });
T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Removed); T::OnIdtyChange::on_idty_change(idty_index, IdtyEvent::Removed);
...@@ -529,8 +526,7 @@ pub mod pallet { ...@@ -529,8 +526,7 @@ pub mod pallet {
for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) { for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) {
if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) { if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) {
if idty_val.removable_on == block_number && idty_val.status == idty_status { if idty_val.removable_on == block_number && idty_val.status == idty_status {
total_weight += total_weight += Self::do_remove_identity(idty_index)
Self::do_remove_identity(idty_index, Some(&idty_val.owner_key))
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment