Skip to content

Commit

Permalink
change(pallet-assets): call died hook for Holder whenever necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed Jun 17, 2024
1 parent 029e887 commit bf376a5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions substrate/frame/assets/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
Asset::<T, I>::insert(&id, details);
// Executing a hook here is safe, since it is not in a `mutate`.
T::Freezer::died(id, &who);
T::Freezer::died(id.clone(), &who);
T::Holder::died(id, &who);
Ok(())
}

Expand Down Expand Up @@ -401,7 +402,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
Asset::<T, I>::insert(&id, details);
// Executing a hook here is safe, since it is not in a `mutate`.
T::Freezer::died(id, &who);
T::Freezer::died(id.clone(), &who);
T::Holder::died(id, &who);
return Ok(())
}

Expand Down Expand Up @@ -569,7 +571,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

// Execute hook outside of `mutate`.
if let Some(Remove) = target_died {
T::Freezer::died(id, target);
T::Freezer::died(id.clone(), target);
T::Holder::died(id, target);
}
Ok(actual)
}
Expand All @@ -593,7 +596,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let (balance, died) =
Self::transfer_and_die(id.clone(), source, dest, amount, maybe_need_admin, f)?;
if let Some(Remove) = died {
T::Freezer::died(id, source);
T::Freezer::died(id.clone(), source);
T::Holder::died(id, source);
}
Ok(balance)
}
Expand Down Expand Up @@ -791,6 +795,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

for who in &dead_accounts {
T::Freezer::died(id.clone(), &who);
T::Holder::died(id.clone(), &who);
}

Self::deposit_event(Event::AccountsDestroyed {
Expand Down Expand Up @@ -951,7 +956,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

// Execute hook outside of `mutate`.
if let Some(Remove) = owner_died {
T::Freezer::died(id, owner);
T::Freezer::died(id.clone(), owner);
T::Holder::died(id, owner);
}
Ok(())
}
Expand Down

0 comments on commit bf376a5

Please sign in to comment.