pallet-uniques: decrement total_deposit when clearing collection metadata (#3976)

Decrements `total_deposit` when collection metadata is cleared in
`pallet-nfts` and `pallet-uniques`.
This commit is contained in:
Liam Aharon
2024-04-06 16:10:46 +11:00
committed by GitHub
parent 1c85bfe901
commit 9d62618928
5 changed files with 99 additions and 2 deletions
@@ -247,7 +247,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
);
}
let details =
let mut details =
Collection::<T, I>::get(&collection).ok_or(Error::<T, I>::UnknownCollection)?;
let collection_config = Self::get_collection_config(&collection)?;
@@ -260,6 +260,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
CollectionMetadataOf::<T, I>::try_mutate_exists(collection, |metadata| {
let deposit = metadata.take().ok_or(Error::<T, I>::UnknownCollection)?.deposit;
T::Currency::unreserve(&details.owner, deposit);
details.owner_deposit.saturating_reduce(deposit);
Collection::<T, I>::insert(&collection, details);
Self::deposit_event(Event::CollectionMetadataCleared { collection });
Ok(())
})