git.delta.rocks / unique-network / refs/commits / 274525a86afb

difftreelog

fix unable to destroy collection with nested tokens

Daniel Shiposha2022-05-27parent: #9d51561.patch.diff
in: master

1 file changed

modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
79 NonfungibleItemsHaveNoAmount,79 NonfungibleItemsHaveNoAmount,
80 /// Unable to burn NFT with children80 /// Unable to burn NFT with children
81 CantBurnNftWithChildren,81 CantBurnNftWithChildren,
82 /// Unable to burn a collection containing NFTs that have children
83 CantBurnCollectionWithNestedTokens
82 }84 }
8385
84 #[pallet::config]86 #[pallet::config]
293 ) -> DispatchResult {295 ) -> DispatchResult {
294 let id = collection.id;296 let id = collection.id;
297
298 if Self::collection_has_nested_tokens(id) {
299 return Err(<Error<T>>::CantBurnCollectionWithNestedTokens.into());
300 }
295301
296 // =========302 // =========
297303
966 );972 );
967 }973 }
974
975 fn collection_has_nested_tokens(collection_id: CollectionId) -> bool {
976 <TokenChildren<T>>::iter_prefix((collection_id,)).next().is_some()
977 }
968978
969 fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {979 fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {
970 <TokenChildren<T>>::iter_prefix((collection_id, token_id)).next().is_some()980 <TokenChildren<T>>::iter_prefix((collection_id, token_id)).next().is_some()