mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
Improve NFT locking (#14510)
* Update docs * Prevent locking of the same NFT twice * Validate item is not locked on burn * Cover with tests * chore
This commit is contained in:
@@ -169,6 +169,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
with_details: impl FnOnce(&ItemDetailsFor<T, I>) -> DispatchResult,
|
||||
) -> DispatchResult {
|
||||
ensure!(!T::Locker::is_locked(collection, item), Error::<T, I>::ItemLocked);
|
||||
ensure!(
|
||||
!Self::has_system_attribute(&collection, &item, PalletAttributes::TransferDisabled)?,
|
||||
Error::<T, I>::ItemLocked
|
||||
);
|
||||
let item_config = Self::get_item_config(&collection, &item)?;
|
||||
// NOTE: if item's settings are not empty (e.g. item's metadata is locked)
|
||||
// then we keep the config record and don't remove it
|
||||
|
||||
@@ -341,6 +341,13 @@ impl<T: Config<I>, I: 'static> Transfer<T::AccountId> for Pallet<T, I> {
|
||||
}
|
||||
|
||||
fn disable_transfer(collection: &Self::CollectionId, item: &Self::ItemId) -> DispatchResult {
|
||||
let transfer_disabled =
|
||||
Self::has_system_attribute(&collection, &item, PalletAttributes::TransferDisabled)?;
|
||||
// Can't lock the item twice
|
||||
if transfer_disabled {
|
||||
return Err(Error::<T, I>::ItemLocked.into())
|
||||
}
|
||||
|
||||
<Self as Mutate<T::AccountId, ItemConfig>>::set_attribute(
|
||||
collection,
|
||||
item,
|
||||
|
||||
Reference in New Issue
Block a user