From a9dbbdd30da45dfacc38248d0ef692b5bf6653cd Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Wed, 4 Jan 2023 10:30:43 +0200 Subject: [PATCH] Disallow burning externally locked nfts (#13054) * Disallow burning externally locked nfts * Update docs --- frame/nfts/src/features/create_delete_item.rs | 1 + frame/nfts/src/lib.rs | 4 +++- frame/uniques/src/functions.rs | 1 + frame/uniques/src/lib.rs | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index 7fd745b2bfff8..8d6c8a280956c 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -91,6 +91,7 @@ impl, I: 'static> Pallet { item: T::ItemId, with_details: impl FnOnce(&ItemDetailsFor) -> DispatchResult, ) -> DispatchResult { + ensure!(!T::Locker::is_locked(collection, item), Error::::ItemLocked); let owner = Collection::::try_mutate( &collection, |maybe_collection_details| -> Result { diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index dbd2c2048155a..9a6242143aedb 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -856,7 +856,9 @@ pub mod pallet { /// Destroy a single item. /// - /// Origin must be Signed and the sender should be the Admin of the `collection`. + /// Origin must be Signed and the signing account must be either: + /// - the Admin of the `collection`; + /// - the Owner of the `item`; /// /// - `collection`: The collection of the item to be burned. /// - `item`: The item to be burned. diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index 4e68f1139420d..03dba16eaa12b 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -189,6 +189,7 @@ impl, I: 'static> Pallet { item: T::ItemId, with_details: impl FnOnce(&CollectionDetailsFor, &ItemDetailsFor) -> DispatchResult, ) -> DispatchResult { + ensure!(!T::Locker::is_locked(collection, item), Error::::Locked); let owner = Collection::::try_mutate( &collection, |maybe_collection_details| -> Result { diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 8157817d4166e..6b21477be4340 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -577,7 +577,9 @@ pub mod pallet { /// Destroy a single item. /// - /// Origin must be Signed and the sender should be the Admin of the `collection`. + /// Origin must be Signed and the signing account must be either: + /// - the Admin of the `collection`; + /// - the Owner of the `item`; /// /// - `collection`: The collection of the item to be burned. /// - `item`: The item of the item to be burned.