mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 19:47:59 +00:00
[NFTs] Rework permissions model (#13482)
* Disallow admin to transfer or burn items he doesn't own * lock_collection should be accessible by collection's owner only * Allow admin to access lock_item_properties() * Fix do_lock_item_properties * Move update_mint_settings() to Issuer * Rename check_owner to check_origin * Typo * Make admin to be in charge of managing the metadata * Make admin the main attributes manager * offchain mint should be signed by Issuer * Remove the special case when the Issuer calls the mint() function * Rework burn and destroy methods * Return back item_metadatas * Don't repatriate the deposit on transfer * A bit more tests * One more test * Add migration * Chore * Clippy * Rename to owned_item * Address comments * Replace .filter_map with .find_map * Improve version validation in pre_upgrade() * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_nfts --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -38,6 +38,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
owner_deposit: deposit,
|
||||
items: 0,
|
||||
item_metadatas: 0,
|
||||
item_configs: 0,
|
||||
attributes: 0,
|
||||
},
|
||||
);
|
||||
@@ -71,24 +72,23 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
if let Some(check_owner) = maybe_check_owner {
|
||||
ensure!(collection_details.owner == check_owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
ensure!(collection_details.items == witness.items, Error::<T, I>::BadWitness);
|
||||
ensure!(collection_details.items == 0, Error::<T, I>::CollectionNotEmpty);
|
||||
ensure!(collection_details.attributes == witness.attributes, Error::<T, I>::BadWitness);
|
||||
ensure!(
|
||||
collection_details.item_metadatas == witness.item_metadatas,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
ensure!(collection_details.attributes == witness.attributes, Error::<T, I>::BadWitness);
|
||||
ensure!(
|
||||
collection_details.item_configs == witness.item_configs,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
|
||||
for (item, details) in Item::<T, I>::drain_prefix(&collection) {
|
||||
Account::<T, I>::remove((&details.owner, &collection, &item));
|
||||
T::Currency::unreserve(&details.deposit.account, details.deposit.amount);
|
||||
}
|
||||
for (_, metadata) in ItemMetadataOf::<T, I>::drain_prefix(&collection) {
|
||||
if let Some(depositor) = metadata.deposit.account {
|
||||
T::Currency::unreserve(&depositor, metadata.deposit.amount);
|
||||
}
|
||||
}
|
||||
let _ = ItemPriceOf::<T, I>::clear_prefix(&collection, witness.items, None);
|
||||
let _ = PendingSwapOf::<T, I>::clear_prefix(&collection, witness.items, None);
|
||||
|
||||
CollectionMetadataOf::<T, I>::remove(&collection);
|
||||
Self::clear_roles(&collection)?;
|
||||
|
||||
@@ -103,15 +103,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
CollectionAccount::<T, I>::remove(&collection_details.owner, &collection);
|
||||
T::Currency::unreserve(&collection_details.owner, collection_details.owner_deposit);
|
||||
CollectionConfigOf::<T, I>::remove(&collection);
|
||||
let _ = ItemConfigOf::<T, I>::clear_prefix(&collection, witness.items, None);
|
||||
let _ =
|
||||
ItemAttributesApprovalsOf::<T, I>::clear_prefix(&collection, witness.items, None);
|
||||
let _ = ItemConfigOf::<T, I>::clear_prefix(&collection, witness.item_configs, None);
|
||||
|
||||
Self::deposit_event(Event::Destroyed { collection });
|
||||
|
||||
Ok(DestroyWitness {
|
||||
items: collection_details.items,
|
||||
item_metadatas: collection_details.item_metadatas,
|
||||
item_configs: collection_details.item_configs,
|
||||
attributes: collection_details.attributes,
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user