mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 05:11:02 +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:
@@ -40,9 +40,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
);
|
||||
|
||||
if let Some(check_origin) = maybe_check_origin {
|
||||
let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin);
|
||||
let permitted = is_admin || check_origin == details.owner;
|
||||
ensure!(permitted, Error::<T, I>::NoPermission);
|
||||
ensure!(check_origin == details.owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
|
||||
let now = frame_system::Pallet::<T>::block_number();
|
||||
@@ -85,9 +83,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
if !is_past_deadline {
|
||||
if let Some(check_origin) = maybe_check_origin {
|
||||
let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin);
|
||||
let permitted = is_admin || check_origin == details.owner;
|
||||
ensure!(permitted, Error::<T, I>::NoPermission);
|
||||
ensure!(check_origin == details.owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +109,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Item::<T, I>::get(&collection, &item).ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
|
||||
if let Some(check_origin) = maybe_check_origin {
|
||||
let is_admin = Self::has_role(&collection, &check_origin, CollectionRole::Admin);
|
||||
let permitted = is_admin || check_origin == details.owner;
|
||||
ensure!(permitted, Error::<T, I>::NoPermission);
|
||||
ensure!(check_origin == details.owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
|
||||
details.approvals.clear();
|
||||
|
||||
Reference in New Issue
Block a user