From 274525a86afb8887623dad22507985a7d80c1163 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 27 May 2022 13:10:33 +0000 Subject: [PATCH] fix: unable to destroy collection with nested tokens --- --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -79,6 +79,8 @@ NonfungibleItemsHaveNoAmount, /// Unable to burn NFT with children CantBurnNftWithChildren, + /// Unable to burn a collection containing NFTs that have children + CantBurnCollectionWithNestedTokens } #[pallet::config] @@ -293,6 +295,10 @@ ) -> DispatchResult { let id = collection.id; + if Self::collection_has_nested_tokens(id) { + return Err(>::CantBurnCollectionWithNestedTokens.into()); + } + // ========= PalletCommon::destroy_collection(collection.0, sender)?; @@ -966,6 +972,10 @@ ); } + fn collection_has_nested_tokens(collection_id: CollectionId) -> bool { + >::iter_prefix((collection_id,)).next().is_some() + } + fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool { >::iter_prefix((collection_id, token_id)).next().is_some() } -- gitstuff