git.delta.rocks / unique-network / refs/commits / aa3d2ae73e39

difftreelog

Add extrinsic: delete token property

Daniel Shiposha2022-05-04parent: #d66bc31.patch.diff
in: master

12 files changed

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -294,6 +294,8 @@
 
 		TokenPropertySet(CollectionId, TokenId, Property),
 
+		TokenPropertyDeleted(CollectionId, TokenId, PropertyKey),
+
 		PropertyPermissionSet(CollectionId, PropertyKeyPermission),
 	}
 
@@ -738,10 +740,9 @@
 	) -> DispatchResult {
 		collection.check_is_owner_or_admin(sender)?;
 
-		CollectionProperties::<T>::try_mutate(
-			collection.id,
-			|properties| properties.try_set_property(property.clone())
-		)?;
+		CollectionProperties::<T>::try_mutate(collection.id, |properties| {
+			properties.try_set_property(property.clone())
+		})?;
 
 		Self::deposit_event(Event::CollectionPropertySet(collection.id, property));
 
@@ -763,13 +764,16 @@
 	pub fn set_property_permission(
 		collection: &CollectionHandle<T>,
 		sender: &T::CrossAccountId,
-		property_permission: PropertyKeyPermission
+		property_permission: PropertyKeyPermission,
 	) -> DispatchResult {
 		collection.check_is_owner_or_admin(sender)?;
 
 		let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);
 		let current_permission = all_permissions.get(&property_permission.key);
-		if matches![current_permission, Some(PropertyPermission::AdminConst | PropertyPermission::ItemOwnerConst)] {
+		if matches![
+			current_permission,
+			Some(PropertyPermission::AdminConst | PropertyPermission::ItemOwnerConst)
+		] {
 			return Err(<Error<T>>::NoPermission.into());
 		}
 
@@ -779,7 +783,10 @@
 		})
 		.map_err(|_| PropertiesError::PropertyLimitReached)?;
 
-		Self::deposit_event(Event::PropertyPermissionSet(collection.id, property_permission));
+		Self::deposit_event(Event::PropertyPermissionSet(
+			collection.id,
+			property_permission,
+		));
 
 		Ok(())
 	}
@@ -787,7 +794,7 @@
 	pub fn set_property_permissions(
 		collection: &CollectionHandle<T>,
 		sender: &T::CrossAccountId,
-		property_permissions: Vec<PropertyKeyPermission>
+		property_permissions: Vec<PropertyKeyPermission>,
 	) -> DispatchResult {
 		for prop_pemission in property_permissions {
 			Self::set_property_permission(collection, sender, prop_pemission)?;
@@ -950,6 +957,7 @@
 	fn burn_item() -> Weight;
 	fn set_collection_properties(amount: u32) -> Weight;
 	fn set_token_properties(amount: u32) -> Weight;
+	fn delete_token_properties(amount: u32) -> Weight;
 	fn set_property_permissions(amount: u32) -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
@@ -996,6 +1004,12 @@
 		token_id: TokenId,
 		property: Vec<Property>,
 	) -> DispatchResultWithPostInfo;
+	fn delete_token_properties(
+		&self,
+		sender: T::CrossAccountId,
+		token_id: TokenId,
+		property_keys: Vec<PropertyKey>,
+	) -> DispatchResultWithPostInfo;
 	fn set_property_permissions(
 		&self,
 		sender: &T::CrossAccountId,
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -21,7 +21,7 @@
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::ArithmeticError;
 use sp_std::{vec::Vec, vec};
-use up_data_structs::{CustomDataLimit, Property, PropertyKeyPermission,};
+use up_data_structs::{CustomDataLimit, Property, PropertyKey, PropertyKeyPermission};
 
 use crate::{
 	Allowance, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf, weights::WeightInfo,
@@ -58,6 +58,10 @@
 		<SelfWeightOf<T>>::set_token_properties(amount)
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		<SelfWeightOf<T>>::delete_token_properties(amount)
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		<SelfWeightOf<T>>::set_property_permissions(amount)
 	}
@@ -262,6 +266,15 @@
 		fail!(<Error<T>>::PropertiesNotAllowed)
 	}
 
+	fn delete_token_properties(
+		&self,
+		_sender: T::CrossAccountId,
+		_token_id: TokenId,
+		_property_keys: Vec<PropertyKey>,
+	) -> DispatchResultWithPostInfo {
+		fail!(<Error<T>>::PropertiesNotAllowed)
+	}
+
 	fn set_variable_metadata(
 		&self,
 		_sender: T::CrossAccountId,
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -37,6 +37,7 @@
 	fn burn_item() -> Weight;
 	fn set_collection_properties(amount: u32) -> Weight;
 	fn set_token_properties(amount: u32) -> Weight;
+	fn delete_token_properties(amount: u32) -> Weight;
 	fn set_property_permissions(amount: u32) -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
@@ -73,17 +74,22 @@
 			.saturating_add(T::DbWeight::get().writes(2 as Weight))
 	}
 
-	fn set_collection_properties(amount: u32) -> Weight {
+	fn set_collection_properties(_amount: u32) -> Weight {
+		// Error
+		0
+	}
+
+	fn set_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_token_properties(amount: u32) -> Weight {
+	fn delete_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_property_permissions(amount: u32) -> Weight {
+	fn set_property_permissions(_amount: u32) -> Weight {
 		// Error
 		0
 	}
@@ -146,17 +152,22 @@
 			.saturating_add(RocksDbWeight::get().writes(2 as Weight))
 	}
 
-	fn set_collection_properties(amount: u32) -> Weight {
+	fn set_collection_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_token_properties(amount: u32) -> Weight {
+	fn set_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_property_permissions(amount: u32) -> Weight {
+	fn delete_token_properties(_amount: u32) -> Weight {
+		// Error
+		0
+	}
+
+	fn set_property_permissions(_amount: u32) -> Weight {
 		// Error
 		0
 	}
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -18,7 +18,8 @@
 
 use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, BoundedVec};
 use up_data_structs::{
-	TokenId, CustomDataLimit, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKeyPermission,
+	TokenId, CustomDataLimit, CreateItemExData, CollectionId, budget::Budget, Property,
+	PropertyKey, PropertyKeyPermission,
 };
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::DispatchError;
@@ -58,6 +59,10 @@
 		<SelfWeightOf<T>>::set_token_properties(amount)
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		<SelfWeightOf<T>>::delete_token_properties(amount)
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		<SelfWeightOf<T>>::set_property_permissions(amount)
 	}
@@ -162,7 +167,7 @@
 
 		with_weight(
 			<Pallet<T>>::set_collection_properties(self, &sender, properties),
-			weight
+			weight,
 		)
 	}
 
@@ -176,7 +181,21 @@
 
 		with_weight(
 			<Pallet<T>>::set_token_properties(self, &sender, token_id, properties),
-			weight
+			weight,
+		)
+	}
+
+	fn delete_token_properties(
+		&self,
+		sender: T::CrossAccountId,
+		token_id: TokenId,
+		property_keys: Vec<PropertyKey>,
+	) -> DispatchResultWithPostInfo {
+		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);
+
+		with_weight(
+			<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),
+			weight,
 		)
 	}
 
@@ -185,11 +204,12 @@
 		sender: &T::CrossAccountId,
 		property_permissions: Vec<PropertyKeyPermission>,
 	) -> DispatchResultWithPostInfo {
-		let weight = <CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);
+		let weight =
+			<CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);
 
 		with_weight(
 			<Pallet<T>>::set_property_permissions(self, sender, property_permissions),
-			weight
+			weight,
 		)
 	}
 
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
before · pallets/nonfungible/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use erc::ERC721Events;20use frame_support::{BoundedVec, ensure, fail};21use up_data_structs::{22	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,23	mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,24	PropertyKeyPermission,25};26use pallet_evm::account::CrossAccountId;27use pallet_common::{28	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,29	dispatch::CollectionDispatch,30};31use pallet_structure::Pallet as PalletStructure;32use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};33use sp_core::H160;34use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};35use sp_std::{vec::Vec, vec};36use core::ops::Deref;37use sp_std::collections::btree_map::BTreeMap;38use codec::{Encode, Decode, MaxEncodedLen};39use scale_info::TypeInfo;4041pub use pallet::*;42#[cfg(feature = "runtime-benchmarks")]43pub mod benchmarking;44pub mod common;45pub mod erc;46pub mod weights;4748pub type CreateItemData<T> = CreateNftExData<<T as pallet_evm::account::Config>::CrossAccountId>;49pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;5051#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]52pub struct ItemData<CrossAccountId> {53	pub const_data: BoundedVec<u8, CustomDataLimit>,54	pub variable_data: BoundedVec<u8, CustomDataLimit>,55	pub owner: CrossAccountId,56}5758#[frame_support::pallet]59pub mod pallet {60	use super::*;61	use frame_support::{Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};62	use up_data_structs::{CollectionId, TokenId};63	use super::weights::WeightInfo;6465	#[pallet::error]66	pub enum Error<T> {67		/// Not Nonfungible item data used to mint in Nonfungible collection.68		NotNonfungibleDataUsedToMintFungibleCollectionToken,69		/// Used amount > 1 with NFT70		NonfungibleItemsHaveNoAmount,71	}7273	#[pallet::config]74	pub trait Config:75		frame_system::Config + pallet_common::Config + pallet_structure::Config76	{77		type WeightInfo: WeightInfo;78	}7980	#[pallet::pallet]81	#[pallet::generate_store(pub(super) trait Store)]82	pub struct Pallet<T>(_);8384	#[pallet::storage]85	pub type TokensMinted<T: Config> =86		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;87	#[pallet::storage]88	pub type TokensBurnt<T: Config> =89		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;9091	#[pallet::storage]92	pub type TokenData<T: Config> = StorageNMap<93		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),94		Value = ItemData<T::CrossAccountId>,95		QueryKind = OptionQuery,96	>;9798	#[pallet::storage]99	pub type TokenProperties<T: Config> = StorageNMap<100		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),101		Value = up_data_structs::Properties,102		QueryKind = ValueQuery,103		OnEmpty = up_data_structs::TokenProperties,104	>;105106	/// Used to enumerate tokens owned by account107	#[pallet::storage]108	pub type Owned<T: Config> = StorageNMap<109		Key = (110			Key<Twox64Concat, CollectionId>,111			Key<Blake2_128Concat, T::CrossAccountId>,112			Key<Twox64Concat, TokenId>,113		),114		Value = bool,115		QueryKind = ValueQuery,116	>;117118	#[pallet::storage]119	pub type AccountBalance<T: Config> = StorageNMap<120		Key = (121			Key<Twox64Concat, CollectionId>,122			Key<Blake2_128Concat, T::CrossAccountId>,123		),124		Value = u32,125		QueryKind = ValueQuery,126	>;127128	#[pallet::storage]129	pub type Allowance<T: Config> = StorageNMap<130		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),131		Value = T::CrossAccountId,132		QueryKind = OptionQuery,133	>;134}135136pub struct NonfungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);137impl<T: Config> NonfungibleHandle<T> {138	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {139		Self(inner)140	}141	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {142		self.0143	}144}145impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {146	fn recorder(&self) -> &SubstrateRecorder<T> {147		self.0.recorder()148	}149	fn into_recorder(self) -> SubstrateRecorder<T> {150		self.0.into_recorder()151	}152}153impl<T: Config> Deref for NonfungibleHandle<T> {154	type Target = pallet_common::CollectionHandle<T>;155156	fn deref(&self) -> &Self::Target {157		&self.0158	}159}160161impl<T: Config> Pallet<T> {162	pub fn total_supply(collection: &NonfungibleHandle<T>) -> u32 {163		<TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)164	}165	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {166		<TokenData<T>>::contains_key((collection.id, token))167	}168}169170// unchecked calls skips any permission checks171impl<T: Config> Pallet<T> {172	pub fn init_collection(173		owner: T::AccountId,174		data: CreateCollectionData<T::AccountId>,175	) -> Result<CollectionId, DispatchError> {176		<PalletCommon<T>>::init_collection(owner, data)177	}178	pub fn destroy_collection(179		collection: NonfungibleHandle<T>,180		sender: &T::CrossAccountId,181	) -> DispatchResult {182		let id = collection.id;183184		// =========185186		PalletCommon::destroy_collection(collection.0, sender)?;187188		<TokenData<T>>::remove_prefix((id,), None);189		<Owned<T>>::remove_prefix((id,), None);190		<TokensMinted<T>>::remove(id);191		<TokensBurnt<T>>::remove(id);192		<Allowance<T>>::remove_prefix((id,), None);193		<AccountBalance<T>>::remove_prefix((id,), None);194		Ok(())195	}196197	pub fn burn(198		collection: &NonfungibleHandle<T>,199		sender: &T::CrossAccountId,200		token: TokenId,201	) -> DispatchResult {202		let token_data =203			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;204		ensure!(205			&token_data.owner == sender206				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),207			<CommonError<T>>::NoPermission208		);209210		if collection.access == AccessMode::AllowList {211			collection.check_allowlist(sender)?;212		}213214		let burnt = <TokensBurnt<T>>::get(collection.id)215			.checked_add(1)216			.ok_or(ArithmeticError::Overflow)?;217218		let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))219			.checked_sub(1)220			.ok_or(ArithmeticError::Overflow)?;221222		if balance == 0 {223			<AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));224		} else {225			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);226		}227		// =========228229		<Owned<T>>::remove((collection.id, &token_data.owner, token));230		<TokensBurnt<T>>::insert(collection.id, burnt);231		<TokenData<T>>::remove((collection.id, token));232		let old_spender = <Allowance<T>>::take((collection.id, token));233234		if let Some(old_spender) = old_spender {235			<PalletCommon<T>>::deposit_event(CommonEvent::Approved(236				collection.id,237				token,238				sender.clone(),239				old_spender,240				0,241			));242		}243244		collection.log_mirrored(ERC721Events::Transfer {245			from: *token_data.owner.as_eth(),246			to: H160::default(),247			token_id: token.into(),248		});249		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(250			collection.id,251			token,252			token_data.owner,253			1,254		));255		Ok(())256	}257258	pub fn set_token_property(259		collection: &NonfungibleHandle<T>,260		sender: &T::CrossAccountId,261		token_id: TokenId,262		property: Property,263	) -> DispatchResult {264		let permission = <PalletCommon<T>>::property_permission(collection.id)265			.get(&property.key)266			.map(|p| p.clone())267			.unwrap_or(PropertyPermission::None);268269		let token_data = <TokenData<T>>::get((collection.id, token_id))270			.ok_or(<CommonError<T>>::TokenNotFound)?;271272		let check_token_owner = || -> DispatchResult {273			ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);274			Ok(())275		};276277		let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))278			.get_property(&property.key)279			.is_some();280281		match (permission, is_property_exists) {282			(PropertyPermission::AdminConst, false) => {283				collection.check_is_owner_or_admin(sender)?284			}285			(PropertyPermission::Admin, _) => collection.check_is_owner_or_admin(sender)?,286			(PropertyPermission::ItemOwnerConst, false) => check_token_owner()?,287			(PropertyPermission::ItemOwner, _) => check_token_owner()?,288			(PropertyPermission::ItemOwnerOrAdmin, _) => {289				check_token_owner().or(collection.check_is_owner_or_admin(sender))?;290			}291			_ => return Err(<CommonError<T>>::NoPermission.into()),292		}293294		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {295			properties.try_set_property(property.clone())296		})?;297298		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(299			collection.id,300			token_id,301			property,302		));303304		Ok(())305	}306307	pub fn set_token_properties(308		collection: &NonfungibleHandle<T>,309		sender: &T::CrossAccountId,310		token_id: TokenId,311		properties: Vec<Property>,312	) -> DispatchResult {313		for property in properties {314			Self::set_token_property(collection, sender, token_id, property)?;315		}316317		Ok(())318	}319320	pub fn set_collection_properties(321		collection: &NonfungibleHandle<T>,322		sender: &T::CrossAccountId,323		properties: Vec<Property>,324	) -> DispatchResult {325		<PalletCommon<T>>::set_collection_properties(collection, sender, properties)326	}327328	pub fn set_property_permissions(329		collection: &CollectionHandle<T>,330		sender: &T::CrossAccountId,331		property_permissions: Vec<PropertyKeyPermission>332	) -> DispatchResult {333		<PalletCommon<T>>::set_property_permissions(334			collection,335			sender,336			property_permissions,337		)338	}339340	pub fn transfer(341		collection: &NonfungibleHandle<T>,342		from: &T::CrossAccountId,343		to: &T::CrossAccountId,344		token: TokenId,345		nesting_budget: &dyn Budget,346	) -> DispatchResult {347		ensure!(348			collection.limits.transfers_enabled(),349			<CommonError<T>>::TransferNotAllowed350		);351352		let token_data =353			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;354		// TODO: require sender to be token, owner, require admins to go through transfer_from355		ensure!(356			&token_data.owner == from357				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),358			<CommonError<T>>::NoPermission359		);360361		if collection.access == AccessMode::AllowList {362			collection.check_allowlist(from)?;363			collection.check_allowlist(to)?;364		}365		<PalletCommon<T>>::ensure_correct_receiver(to)?;366367		let balance_from = <AccountBalance<T>>::get((collection.id, from))368			.checked_sub(1)369			.ok_or(<CommonError<T>>::TokenValueTooLow)?;370		let balance_to = if from != to {371			let balance_to = <AccountBalance<T>>::get((collection.id, to))372				.checked_add(1)373				.ok_or(ArithmeticError::Overflow)?;374375			ensure!(376				balance_to < collection.limits.account_token_ownership_limit(),377				<CommonError<T>>::AccountTokenLimitExceeded,378			);379380			Some(balance_to)381		} else {382			None383		};384385		if let Some(target) = T::CrossTokenAddressMapping::address_to_token(to) {386			let handle = <CollectionHandle<T>>::try_get(target.0)?;387			let dispatch = T::CollectionDispatch::dispatch(handle);388			let dispatch = dispatch.as_dyn();389390			dispatch.check_nesting(391				from.clone(),392				(collection.id, token),393				target.1,394				nesting_budget,395			)?;396		}397398		// =========399400		<TokenData<T>>::insert(401			(collection.id, token),402			ItemData {403				owner: to.clone(),404				..token_data405			},406		);407408		if let Some(balance_to) = balance_to {409			// from != to410			if balance_from == 0 {411				<AccountBalance<T>>::remove((collection.id, from));412			} else {413				<AccountBalance<T>>::insert((collection.id, from), balance_from);414			}415			<AccountBalance<T>>::insert((collection.id, to), balance_to);416			<Owned<T>>::remove((collection.id, from, token));417			<Owned<T>>::insert((collection.id, to, token), true);418		}419		Self::set_allowance_unchecked(collection, from, token, None, true);420421		collection.log_mirrored(ERC721Events::Transfer {422			from: *from.as_eth(),423			to: *to.as_eth(),424			token_id: token.into(),425		});426		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(427			collection.id,428			token,429			from.clone(),430			to.clone(),431			1,432		));433		Ok(())434	}435436	pub fn create_multiple_items(437		collection: &NonfungibleHandle<T>,438		sender: &T::CrossAccountId,439		data: Vec<CreateItemData<T>>,440		nesting_budget: &dyn Budget,441	) -> DispatchResult {442		if !collection.is_owner_or_admin(sender) {443			ensure!(444				collection.mint_mode,445				<CommonError<T>>::PublicMintingNotAllowed446			);447			collection.check_allowlist(sender)?;448449			for item in data.iter() {450				collection.check_allowlist(&item.owner)?;451			}452		}453454		for data in data.iter() {455			<PalletCommon<T>>::ensure_correct_receiver(&data.owner)?;456		}457458		let first_token = <TokensMinted<T>>::get(collection.id);459		let tokens_minted = first_token460			.checked_add(data.len() as u32)461			.ok_or(ArithmeticError::Overflow)?;462		ensure!(463			tokens_minted <= collection.limits.token_limit(),464			<CommonError<T>>::CollectionTokenLimitExceeded465		);466467		let mut balances = BTreeMap::new();468		for data in &data {469			let balance = balances470				.entry(&data.owner)471				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));472			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;473474			ensure!(475				*balance <= collection.limits.account_token_ownership_limit(),476				<CommonError<T>>::AccountTokenLimitExceeded,477			);478		}479480		for (i, data) in data.iter().enumerate() {481			let token = TokenId(first_token + i as u32 + 1);482			if let Some(target) = T::CrossTokenAddressMapping::address_to_token(&data.owner) {483				let handle = <CollectionHandle<T>>::try_get(target.0)?;484				let dispatch = T::CollectionDispatch::dispatch(handle);485				let dispatch = dispatch.as_dyn();486				dispatch.check_nesting(487					sender.clone(),488					(collection.id, token),489					target.1,490					nesting_budget,491				)?;492			}493		}494495		// =========496497		<TokensMinted<T>>::insert(collection.id, tokens_minted);498		for (account, balance) in balances {499			<AccountBalance<T>>::insert((collection.id, account), balance);500		}501		for (i, data) in data.into_iter().enumerate() {502			let token = first_token + i as u32 + 1;503504			<TokenData<T>>::insert(505				(collection.id, token),506				ItemData {507					const_data: data.const_data,508					variable_data: data.variable_data,509					owner: data.owner.clone(),510				},511			);512			<Owned<T>>::insert((collection.id, &data.owner, token), true);513514			collection.log_mirrored(ERC721Events::Transfer {515				from: H160::default(),516				to: *data.owner.as_eth(),517				token_id: token.into(),518			});519			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(520				collection.id,521				TokenId(token),522				data.owner.clone(),523				1,524			));525		}526		Ok(())527	}528529	pub fn set_allowance_unchecked(530		collection: &NonfungibleHandle<T>,531		sender: &T::CrossAccountId,532		token: TokenId,533		spender: Option<&T::CrossAccountId>,534		assume_implicit_eth: bool,535	) {536		if let Some(spender) = spender {537			let old_spender = <Allowance<T>>::get((collection.id, token));538			<Allowance<T>>::insert((collection.id, token), spender);539			// In ERC721 there is only one possible approved user of token, so we set540			// approved user to spender541			collection.log_mirrored(ERC721Events::Approval {542				owner: *sender.as_eth(),543				approved: *spender.as_eth(),544				token_id: token.into(),545			});546			// In Unique chain, any token can have any amount of approved users, so we need to547			// set allowance of old owner to 0, and allowance of new owner to 1548			if old_spender.as_ref() != Some(spender) {549				if let Some(old_owner) = old_spender {550					<PalletCommon<T>>::deposit_event(CommonEvent::Approved(551						collection.id,552						token,553						sender.clone(),554						old_owner,555						0,556					));557				}558				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(559					collection.id,560					token,561					sender.clone(),562					spender.clone(),563					1,564				));565			}566		} else {567			let old_spender = <Allowance<T>>::take((collection.id, token));568			if !assume_implicit_eth {569				// In ERC721 there is only one possible approved user of token, so we set570				// approved user to zero address571				collection.log_mirrored(ERC721Events::Approval {572					owner: *sender.as_eth(),573					approved: H160::default(),574					token_id: token.into(),575				});576			}577			// In Unique chain, any token can have any amount of approved users, so we need to578			// set allowance of old owner to 0579			if let Some(old_spender) = old_spender {580				<PalletCommon<T>>::deposit_event(CommonEvent::Approved(581					collection.id,582					token,583					sender.clone(),584					old_spender,585					0,586				));587			}588		}589	}590591	pub fn set_allowance(592		collection: &NonfungibleHandle<T>,593		sender: &T::CrossAccountId,594		token: TokenId,595		spender: Option<&T::CrossAccountId>,596	) -> DispatchResult {597		if collection.access == AccessMode::AllowList {598			collection.check_allowlist(sender)?;599			if let Some(spender) = spender {600				collection.check_allowlist(spender)?;601			}602		}603604		if let Some(spender) = spender {605			<PalletCommon<T>>::ensure_correct_receiver(spender)?;606		}607		let token_data =608			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;609		if &token_data.owner != sender {610			ensure!(611				collection.ignores_owned_amount(sender),612				<CommonError<T>>::CantApproveMoreThanOwned613			);614		}615616		// =========617618		Self::set_allowance_unchecked(collection, sender, token, spender, false);619		Ok(())620	}621622	fn check_allowed(623		collection: &NonfungibleHandle<T>,624		spender: &T::CrossAccountId,625		from: &T::CrossAccountId,626		token: TokenId,627		nesting_budget: &dyn Budget,628	) -> DispatchResult {629		if spender.conv_eq(from) {630			return Ok(());631		}632		if collection.access == AccessMode::AllowList {633			// `from`, `to` checked in [`transfer`]634			collection.check_allowlist(spender)?;635		}636		if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {637			// TODO: should collection owner be allowed to perform this transfer?638			ensure!(639				<PalletStructure<T>>::check_indirectly_owned(640					spender.clone(),641					source.0,642					source.1,643					None,644					nesting_budget645				)?,646				<CommonError<T>>::ApprovedValueTooLow,647			);648			return Ok(());649		}650		if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {651			return Ok(());652		}653		ensure!(654			collection.ignores_allowance(spender),655			<CommonError<T>>::ApprovedValueTooLow656		);657		Ok(())658	}659660	pub fn transfer_from(661		collection: &NonfungibleHandle<T>,662		spender: &T::CrossAccountId,663		from: &T::CrossAccountId,664		to: &T::CrossAccountId,665		token: TokenId,666		nesting_budget: &dyn Budget,667	) -> DispatchResult {668		Self::check_allowed(collection, spender, from, token, nesting_budget)?;669670		// =========671672		// Allowance is reset in [`transfer`]673		Self::transfer(collection, from, to, token, nesting_budget)674	}675676	pub fn burn_from(677		collection: &NonfungibleHandle<T>,678		spender: &T::CrossAccountId,679		from: &T::CrossAccountId,680		token: TokenId,681		nesting_budget: &dyn Budget,682	) -> DispatchResult {683		Self::check_allowed(collection, spender, from, token, nesting_budget)?;684685		// =========686687		Self::burn(collection, from, token)688	}689690	pub fn set_variable_metadata(691		collection: &NonfungibleHandle<T>,692		sender: &T::CrossAccountId,693		token: TokenId,694		data: BoundedVec<u8, CustomDataLimit>,695	) -> DispatchResult {696		let token_data =697			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;698		collection.check_can_update_meta(sender, &token_data.owner)?;699700		// =========701702		<TokenData<T>>::insert(703			(collection.id, token),704			ItemData {705				variable_data: data,706				..token_data707			},708		);709		Ok(())710	}711712	pub fn check_nesting(713		handle: &NonfungibleHandle<T>,714		sender: T::CrossAccountId,715		from: (CollectionId, TokenId),716		under: TokenId,717		nesting_budget: &dyn Budget,718	) -> DispatchResult {719		fn ensure_sender_allowed<T: Config>(720			collection: CollectionId,721			token: TokenId,722			for_nest: (CollectionId, TokenId),723			sender: T::CrossAccountId,724			budget: &dyn Budget,725		) -> DispatchResult {726			ensure!(727				<PalletStructure<T>>::check_indirectly_owned(728					sender,729					collection,730					token,731					Some(for_nest),732					budget733				)?,734				<CommonError<T>>::OnlyOwnerAllowedToNest,735			);736			Ok(())737		}738		match handle.limits.nesting_rule() {739			NestingRule::Disabled => fail!(<CommonError<T>>::NestingIsDisabled),740			NestingRule::Owner => {741				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?742			}743			NestingRule::OwnerRestricted(whitelist) => {744				ensure!(745					whitelist.contains(&from.0),746					<CommonError<T>>::SourceCollectionIsNotAllowedToNest747				);748				ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?749			}750		}751		Ok(())752	}753754	/// Delegated to `create_multiple_items`755	pub fn create_item(756		collection: &NonfungibleHandle<T>,757		sender: &T::CrossAccountId,758		data: CreateItemData<T>,759		nesting_budget: &dyn Budget,760	) -> DispatchResult {761		Self::create_multiple_items(collection, sender, vec![data], nesting_budget)762	}763}
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -38,6 +38,7 @@
 	fn burn_item() -> Weight;
 	fn set_collection_properties(amount: u32) -> Weight;
 	fn set_token_properties(amount: u32) -> Weight;
+	fn delete_token_properties(amount: u32) -> Weight;
 	fn set_property_permissions(amount: u32) -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
@@ -104,6 +105,11 @@
 		(50_000_000 as Weight).saturating_mul(amount as Weight)
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		// TODO calculate appropriate weight
+		(50_000_000 as Weight).saturating_mul(amount as Weight)
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		// TODO calculate appropriate weight
 		(50_000_000 as Weight).saturating_mul(amount as Weight)
@@ -209,6 +215,11 @@
 		(50_000_000 as Weight).saturating_mul(amount as Weight)
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		// TODO calculate appropriate weight
+		(50_000_000 as Weight).saturating_mul(amount as Weight)
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		// TODO calculate appropriate weight
 		(50_000_000 as Weight).saturating_mul(amount as Weight)
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -20,7 +20,7 @@
 use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight, BoundedVec};
 use up_data_structs::{
 	CollectionId, TokenId, CustomDataLimit, CreateItemExData, CreateRefungibleExData,
-	budget::Budget, Property, PropertyKeyPermission,
+	budget::Budget, Property, PropertyKey, PropertyKeyPermission,
 };
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::DispatchError;
@@ -74,6 +74,10 @@
 		<SelfWeightOf<T>>::set_token_properties(amount)
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		<SelfWeightOf<T>>::delete_token_properties(amount)
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		<SelfWeightOf<T>>::set_property_permissions(amount)
 	}
@@ -281,6 +285,15 @@
 		fail!(<Error<T>>::PropertiesNotAllowed)
 	}
 
+	fn delete_token_properties(
+		&self,
+		_sender: T::CrossAccountId,
+		_token_id: TokenId,
+		_property_keys: Vec<PropertyKey>,
+	) -> DispatchResultWithPostInfo {
+		fail!(<Error<T>>::PropertiesNotAllowed)
+	}
+
 	fn set_variable_metadata(
 		&self,
 		sender: T::CrossAccountId,
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -40,6 +40,7 @@
 	fn burn_item_fully() -> Weight;
 	fn set_collection_properties(amount: u32) -> Weight;
 	fn set_token_properties(amount: u32) -> Weight;
+	fn delete_token_properties(amount: u32) -> Weight;
 	fn set_property_permissions(amount: u32) -> Weight;
 	fn transfer_normal() -> Weight;
 	fn transfer_creating() -> Weight;
@@ -133,17 +134,22 @@
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
 
-	fn set_collection_properties(amount: u32) -> Weight {
+	fn set_collection_properties(_amount: u32) -> Weight {
+		// Error
+		0
+	}
+
+	fn set_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_token_properties(amount: u32) -> Weight {
+	fn delete_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_property_permissions(amount: u32) -> Weight {
+	fn set_property_permissions(_amount: u32) -> Weight {
 		// Error
 		0
 	}
@@ -317,17 +323,22 @@
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
 
-	fn set_collection_properties(amount: u32) -> Weight {
+	fn set_collection_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_token_properties(amount: u32) -> Weight {
+	fn set_token_properties(_amount: u32) -> Weight {
 		// Error
 		0
 	}
 
-	fn set_property_permissions(amount: u32) -> Weight {
+	fn delete_token_properties(_amount: u32) -> Weight {
+		// Error
+		0
+	}
+
+	fn set_property_permissions(_amount: u32) -> Weight {
 		// Error
 		0
 	}
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -39,7 +39,7 @@
 	MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
 	AccessMode, CreateItemData, CollectionLimits, CollectionId, CollectionMode, TokenId,
 	SchemaVersion, SponsorshipState, MetaUpdatePermission, CreateCollectionData, CustomDataLimit,
-	CreateItemExData, budget, CollectionField, Property, PropertyKeyPermission,
+	CreateItemExData, budget, CollectionField, Property, PropertyKey, PropertyKeyPermission,
 };
 use pallet_evm::account::CrossAccountId;
 use pallet_common::{
@@ -723,6 +723,21 @@
 			dispatch_call::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties))
 		}
 
+		#[weight = T::CommonWeightInfo::delete_token_properties(properties.len() as u32)]
+		#[transactional]
+		pub fn delete_token_properties(
+			origin,
+			collection_id: CollectionId,
+			token_id: TokenId,
+			properties: Vec<PropertyKey>
+		) -> DispatchResultWithPostInfo {
+			ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
+
+			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+			dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, properties))
+		}
+
 		#[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]
 		#[transactional]
 		pub fn set_property_permissions(
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -720,6 +720,17 @@
 		Ok(())
 	}
 
+	pub fn remove_property(&mut self, key: &PropertyKey) {
+		let property = self.map.get(key);
+
+		if let Some(value) = property {
+			let value_len = value.len() as u32;
+
+			self.map.remove(key);
+			self.consumed_space -= value_len;
+		}
+	}
+
 	pub fn get_property(&self, key: &PropertyKey) -> Option<&PropertyValue> {
 		self.map.get(key)
 	}
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,9 +16,7 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use up_data_structs::{
-	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,
-};
+use up_data_structs::{CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits};
 use sp_std::vec::Vec;
 use codec::Decode;
 use sp_runtime::DispatchError;
modifiedruntime/common/src/weights.rsdiffbeforeafterboth
--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -62,6 +62,10 @@
 		dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
 	}
 
+	fn delete_token_properties(amount: u32) -> Weight {
+		dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
+	}
+
 	fn set_property_permissions(amount: u32) -> Weight {
 		dispatch_weight::<T>() + max_weight_of!(set_property_permissions(amount))
 	}