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

difftreelog

fix use OptionQuery for TokenProperties

Daniel Shiposha2023-10-02parent: #5ef5e6b.patch.diff
in: master

9 files changed

modifiedpallets/balances-adapter/src/common.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -172,18 +172,16 @@
 		fail!(<pallet_common::Error<T>>::UnsupportedOperation);
 	}
 
-	fn get_token_properties_map(&self, _token_id: TokenId) -> up_data_structs::TokenProperties {
+	fn get_token_properties_raw(
+		&self,
+		_token_id: TokenId,
+	) -> Option<up_data_structs::TokenProperties> {
 		// No token properties are defined on fungibles
-		up_data_structs::TokenProperties::new()
+		None
 	}
 
-	fn set_token_properties_map(&self, _token_id: TokenId, _map: up_data_structs::TokenProperties) {
-		// No token properties are defined on fungibles
-	}
-
-	fn properties_exist(&self, _token: TokenId) -> bool {
+	fn set_token_properties_raw(&self, _token_id: TokenId, _map: up_data_structs::TokenProperties) {
 		// No token properties are defined on fungibles
-		false
 	}
 
 	fn set_token_property_permissions(
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -2098,18 +2098,13 @@
 	/// Get token properties raw map.
 	///
 	/// * `token_id` - The token which properties are needed.
-	fn get_token_properties_map(&self, token_id: TokenId) -> TokenProperties;
+	fn get_token_properties_raw(&self, token_id: TokenId) -> Option<TokenProperties>;
 
 	/// Set token properties raw map.
 	///
 	/// * `token_id` - The token for which the properties are being set.
 	/// * `map` - The raw map containing the token's properties.
-	fn set_token_properties_map(&self, token_id: TokenId, map: TokenProperties);
-
-	/// Whether the given token has properties.
-	///
-	/// * `token_id` - The token in question.
-	fn properties_exist(&self, token: TokenId) -> bool;
+	fn set_token_properties_raw(&self, token_id: TokenId, map: TokenProperties);
 
 	/// Set token property permissions.
 	///
@@ -2590,7 +2585,7 @@
 			<PalletEvm<T>>::deposit_log(log);
 
 			self.collection
-				.set_token_properties_map(token_id, stored_properties.into_inner());
+				.set_token_properties_raw(token_id, stored_properties.into_inner());
 		}
 
 		Ok(())
@@ -2624,7 +2619,7 @@
 			true
 		},
 		get_properties: |token_id| {
-			debug_assert!(!collection.properties_exist(token_id));
+			debug_assert!(collection.get_token_properties_raw(token_id).is_none());
 			TokenProperties::new()
 		},
 		_phantom: PhantomData,
@@ -2686,7 +2681,11 @@
 		is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
 		property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),
 		check_token_exist: |token_id| collection.token_exists(token_id),
-		get_properties: |token_id| collection.get_token_properties_map(token_id),
+		get_properties: |token_id| {
+			collection
+				.get_token_properties_raw(token_id)
+				.unwrap_or_default()
+		},
 		_phantom: PhantomData,
 	}
 }
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -364,18 +364,16 @@
 		fail!(<Error<T>>::SettingPropertiesNotAllowed)
 	}
 
-	fn get_token_properties_map(&self, _token_id: TokenId) -> up_data_structs::TokenProperties {
+	fn get_token_properties_raw(
+		&self,
+		_token_id: TokenId,
+	) -> Option<up_data_structs::TokenProperties> {
 		// No token properties are defined on fungibles
-		up_data_structs::TokenProperties::new()
+		None
 	}
 
-	fn set_token_properties_map(&self, _token_id: TokenId, _map: up_data_structs::TokenProperties) {
-		// No token properties are defined on fungibles
-	}
-
-	fn properties_exist(&self, _token: TokenId) -> bool {
+	fn set_token_properties_raw(&self, _token_id: TokenId, _map: up_data_structs::TokenProperties) {
 		// No token properties are defined on fungibles
-		false
 	}
 
 	fn check_nesting(
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
before · pallets/nonfungible/src/common.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/>.1617use core::marker::PhantomData;1819use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};20use up_data_structs::{21	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,22	PropertyKeyPermission, PropertyValue, TokenOwnerError,23};24use pallet_common::{25	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf, init_token_properties_delta,27};28use pallet_structure::Pallet as PalletStructure;29use sp_runtime::DispatchError;30use sp_std::{vec::Vec, vec};3132use crate::{33	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,34	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted, TokenProperties,35};3637pub struct CommonWeights<T: Config>(PhantomData<T>);38impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {39	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {40		match data {41			CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)42				.saturating_add(init_token_properties_delta::<T, _>(43					t.iter().map(|t| t.properties.len() as u32),44					<SelfWeightOf<T>>::init_token_properties,45				)),46			_ => Weight::zero(),47		}48	}4950	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {51		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(52			init_token_properties_delta::<T, _>(53				data.iter().map(|t| match t {54					up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,55					_ => 0,56				}),57				<SelfWeightOf<T>>::init_token_properties,58			),59		)60	}6162	fn burn_item() -> Weight {63		<SelfWeightOf<T>>::burn_item()64	}6566	fn set_collection_properties(amount: u32) -> Weight {67		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)68	}6970	fn delete_collection_properties(amount: u32) -> Weight {71		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)72	}7374	fn set_token_properties(amount: u32) -> Weight {75		<SelfWeightOf<T>>::set_token_properties(amount)76	}7778	fn delete_token_properties(amount: u32) -> Weight {79		<SelfWeightOf<T>>::delete_token_properties(amount)80	}8182	fn set_token_property_permissions(amount: u32) -> Weight {83		<SelfWeightOf<T>>::set_token_property_permissions(amount)84	}8586	fn transfer() -> Weight {87		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 288	}8990	fn approve() -> Weight {91		<SelfWeightOf<T>>::approve()92	}9394	fn approve_from() -> Weight {95		<SelfWeightOf<T>>::approve_from()96	}9798	fn transfer_from() -> Weight {99		Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()100	}101102	fn burn_from() -> Weight {103		<SelfWeightOf<T>>::burn_from()104	}105106	fn burn_recursively_self_raw() -> Weight {107		<SelfWeightOf<T>>::burn_recursively_self_raw()108	}109110	fn burn_recursively_breadth_raw(amount: u32) -> Weight {111		<SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)112			.saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))113	}114115	fn token_owner() -> Weight {116		<SelfWeightOf<T>>::token_owner()117	}118119	fn set_allowance_for_all() -> Weight {120		<SelfWeightOf<T>>::set_allowance_for_all()121	}122123	fn force_repair_item() -> Weight {124		<SelfWeightOf<T>>::repair_item()125	}126}127128fn map_create_data<T: Config>(129	data: up_data_structs::CreateItemData,130	to: &T::CrossAccountId,131) -> Result<CreateItemData<T>, DispatchError> {132	match data {133		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {134			properties: data.properties,135			owner: to.clone(),136		}),137		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),138	}139}140141/// Implementation of `CommonCollectionOperations` for `NonfungibleHandle`. It wraps Nonfungible Pallete142/// methods and adds weight info.143impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {144	fn create_item(145		&self,146		sender: T::CrossAccountId,147		to: T::CrossAccountId,148		data: up_data_structs::CreateItemData,149		nesting_budget: &dyn Budget,150	) -> DispatchResultWithPostInfo {151		let weight = <CommonWeights<T>>::create_item(&data);152		with_weight(153			<Pallet<T>>::create_item(154				self,155				&sender,156				map_create_data::<T>(data, &to)?,157				nesting_budget,158			),159			weight,160		)161	}162163	fn create_multiple_items(164		&self,165		sender: T::CrossAccountId,166		to: T::CrossAccountId,167		data: Vec<up_data_structs::CreateItemData>,168		nesting_budget: &dyn Budget,169	) -> DispatchResultWithPostInfo {170		let weight = <CommonWeights<T>>::create_multiple_items(&data);171		let data = data172			.into_iter()173			.map(|d| map_create_data::<T>(d, &to))174			.collect::<Result<Vec<_>, DispatchError>>()?;175176		with_weight(177			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),178			weight,179		)180	}181182	fn create_multiple_items_ex(183		&self,184		sender: <T>::CrossAccountId,185		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,186		nesting_budget: &dyn Budget,187	) -> DispatchResultWithPostInfo {188		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);189		let data = match data {190			up_data_structs::CreateItemExData::NFT(nft) => nft,191			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),192		};193194		with_weight(195			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),196			weight,197		)198	}199200	fn set_collection_properties(201		&self,202		sender: T::CrossAccountId,203		properties: Vec<Property>,204	) -> DispatchResultWithPostInfo {205		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);206207		with_weight(208			<Pallet<T>>::set_collection_properties(self, &sender, properties),209			weight,210		)211	}212213	fn delete_collection_properties(214		&self,215		sender: &T::CrossAccountId,216		property_keys: Vec<PropertyKey>,217	) -> DispatchResultWithPostInfo {218		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);219220		with_weight(221			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),222			weight,223		)224	}225226	fn set_token_properties(227		&self,228		sender: T::CrossAccountId,229		token_id: TokenId,230		properties: Vec<Property>,231		nesting_budget: &dyn Budget,232	) -> DispatchResultWithPostInfo {233		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);234235		with_weight(236			<Pallet<T>>::set_token_properties(237				self,238				&sender,239				token_id,240				properties.into_iter(),241				nesting_budget,242			),243			weight,244		)245	}246247	fn delete_token_properties(248		&self,249		sender: T::CrossAccountId,250		token_id: TokenId,251		property_keys: Vec<PropertyKey>,252		nesting_budget: &dyn Budget,253	) -> DispatchResultWithPostInfo {254		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);255256		with_weight(257			<Pallet<T>>::delete_token_properties(258				self,259				&sender,260				token_id,261				property_keys.into_iter(),262				nesting_budget,263			),264			weight,265		)266	}267268	fn get_token_properties_map(&self, token_id: TokenId) -> up_data_structs::TokenProperties {269		<TokenProperties<T>>::get((self.id, token_id))270	}271272	fn set_token_properties_map(&self, token_id: TokenId, map: up_data_structs::TokenProperties) {273		<TokenProperties<T>>::set((self.id, token_id), map)274	}275276	fn set_token_property_permissions(277		&self,278		sender: &T::CrossAccountId,279		property_permissions: Vec<PropertyKeyPermission>,280	) -> DispatchResultWithPostInfo {281		let weight =282			<CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);283284		with_weight(285			<Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),286			weight,287		)288	}289290	fn properties_exist(&self, token: TokenId) -> bool {291		<TokenProperties<T>>::contains_key((self.id, token))292	}293294	fn burn_item(295		&self,296		sender: T::CrossAccountId,297		token: TokenId,298		amount: u128,299	) -> DispatchResultWithPostInfo {300		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);301		if amount == 1 {302			with_weight(303				<Pallet<T>>::burn(self, &sender, token),304				<CommonWeights<T>>::burn_item(),305			)306		} else {307			<Pallet<T>>::check_token_immediate_ownership(self, token, &sender)?;308			Ok(().into())309		}310	}311312	fn burn_item_recursively(313		&self,314		sender: T::CrossAccountId,315		token: TokenId,316		self_budget: &dyn Budget,317		breadth_budget: &dyn Budget,318	) -> DispatchResultWithPostInfo {319		<Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)320	}321322	fn transfer(323		&self,324		from: T::CrossAccountId,325		to: T::CrossAccountId,326		token: TokenId,327		amount: u128,328		nesting_budget: &dyn Budget,329	) -> DispatchResultWithPostInfo {330		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);331		if amount == 1 {332			<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget)333		} else {334			<Pallet<T>>::check_token_immediate_ownership(self, token, &from)?;335			Ok(().into())336		}337	}338339	fn approve(340		&self,341		sender: T::CrossAccountId,342		spender: T::CrossAccountId,343		token: TokenId,344		amount: u128,345	) -> DispatchResultWithPostInfo {346		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);347348		with_weight(349			if amount == 1 {350				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))351			} else {352				<Pallet<T>>::set_allowance(self, &sender, token, None)353			},354			<CommonWeights<T>>::approve(),355		)356	}357358	fn approve_from(359		&self,360		sender: T::CrossAccountId,361		from: T::CrossAccountId,362		to: T::CrossAccountId,363		token: TokenId,364		amount: u128,365	) -> DispatchResultWithPostInfo {366		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);367368		with_weight(369			if amount == 1 {370				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, Some(&to))371			} else {372				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, None)373			},374			<CommonWeights<T>>::approve_from(),375		)376	}377378	fn transfer_from(379		&self,380		sender: T::CrossAccountId,381		from: T::CrossAccountId,382		to: T::CrossAccountId,383		token: TokenId,384		amount: u128,385		nesting_budget: &dyn Budget,386	) -> DispatchResultWithPostInfo {387		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);388389		if amount == 1 {390			<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget)391		} else {392			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;393394			Ok(().into())395		}396	}397398	fn burn_from(399		&self,400		sender: T::CrossAccountId,401		from: T::CrossAccountId,402		token: TokenId,403		amount: u128,404		nesting_budget: &dyn Budget,405	) -> DispatchResultWithPostInfo {406		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);407408		if amount == 1 {409			with_weight(410				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),411				<CommonWeights<T>>::burn_from(),412			)413		} else {414			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;415416			Ok(().into())417		}418	}419420	fn check_nesting(421		&self,422		sender: T::CrossAccountId,423		from: (CollectionId, TokenId),424		under: TokenId,425		nesting_budget: &dyn Budget,426	) -> sp_runtime::DispatchResult {427		<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)428	}429430	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {431		<Pallet<T>>::nest((self.id, under), to_nest);432	}433434	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {435		<Pallet<T>>::unnest((self.id, under), to_unnest);436	}437438	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {439		<Owned<T>>::iter_prefix((self.id, account))440			.map(|(id, _)| id)441			.collect()442	}443444	fn collection_tokens(&self) -> Vec<TokenId> {445		<TokenData<T>>::iter_prefix((self.id,))446			.map(|(id, _)| id)447			.collect()448	}449450	fn token_exists(&self, token: TokenId) -> bool {451		<Pallet<T>>::token_exists(self, token)452	}453454	fn last_token_id(&self) -> TokenId {455		TokenId(<TokensMinted<T>>::get(self.id))456	}457458	fn token_owner(&self, token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError> {459		<TokenData<T>>::get((self.id, token))460			.map(|t| t.owner)461			.ok_or(TokenOwnerError::NotFound)462	}463464	fn check_token_indirect_owner(465		&self,466		token: TokenId,467		maybe_owner: &T::CrossAccountId,468		nesting_budget: &dyn Budget,469	) -> Result<bool, DispatchError> {470		<PalletStructure<T>>::check_indirectly_owned(471			maybe_owner.clone(),472			self.id,473			token,474			None,475			nesting_budget,476		)477	}478479	/// Returns token owners.480	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {481		self.token_owner(token).map_or_else(|_| vec![], |t| vec![t])482	}483484	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {485		<Pallet<T>>::token_properties((self.id, token_id))486			.get(key)487			.cloned()488	}489490	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {491		let properties = <Pallet<T>>::token_properties((self.id, token_id));492493		keys.map(|keys| {494			keys.into_iter()495				.filter_map(|key| {496					properties.get(&key).map(|value| Property {497						key,498						value: value.clone(),499					})500				})501				.collect()502		})503		.unwrap_or_else(|| {504			properties505				.into_iter()506				.map(|(key, value)| Property { key, value })507				.collect()508		})509	}510511	fn total_supply(&self) -> u32 {512		<Pallet<T>>::total_supply(self)513	}514515	fn account_balance(&self, account: T::CrossAccountId) -> u32 {516		<AccountBalance<T>>::get((self.id, account))517	}518519	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {520		if <TokenData<T>>::get((self.id, token))521			.map(|a| a.owner == account)522			.unwrap_or(false)523		{524			1525		} else {526			0527		}528	}529530	fn allowance(531		&self,532		sender: T::CrossAccountId,533		spender: T::CrossAccountId,534		token: TokenId,535	) -> u128 {536		if <TokenData<T>>::get((self.id, token))537			.map(|a| a.owner != sender)538			.unwrap_or(true)539		{540			0541		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {542			1543		} else {544			0545		}546	}547548	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {549		None550	}551552	fn total_pieces(&self, token: TokenId) -> Option<u128> {553		if <TokenData<T>>::contains_key((self.id, token)) {554			Some(1)555		} else {556			None557		}558	}559560	fn set_allowance_for_all(561		&self,562		owner: T::CrossAccountId,563		operator: T::CrossAccountId,564		approve: bool,565	) -> DispatchResultWithPostInfo {566		with_weight(567			<Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),568			<CommonWeights<T>>::set_allowance_for_all(),569		)570	}571572	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {573		<Pallet<T>>::allowance_for_all(self, &owner, &operator)574	}575576	fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo {577		with_weight(578			<Pallet<T>>::repair_item(self, token),579			<CommonWeights<T>>::force_repair_item(),580		)581	}582}
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -272,7 +272,8 @@
 			.try_into()
 			.map_err(|_| "key too long")?;
 
-		let props = <TokenProperties<T>>::get((self.id, token_id));
+		let props =
+			<TokenProperties<T>>::get((self.id, token_id)).ok_or("Token properties not found")?;
 		let prop = props.get(&key).ok_or("key not found")?;
 
 		Ok(prop.to_vec().into())
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -102,8 +102,8 @@
 use up_data_structs::{
 	AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
 	mapping::TokenAddressMapping, budget::Budget, Property, PropertyKey, PropertyValue,
-	PropertyKeyPermission, PropertyScope, TrySetProperty, TokenChild, AuxPropertyValue,
-	PropertiesPermissionMap, TokenProperties as TokenPropertiesT,
+	PropertyKeyPermission, PropertyScope, TokenChild, AuxPropertyValue, PropertiesPermissionMap,
+	TokenProperties as TokenPropertiesT,
 };
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_common::{
@@ -201,7 +201,7 @@
 	pub type TokenProperties<T: Config> = StorageNMap<
 		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
 		Value = TokenPropertiesT,
-		QueryKind = ValueQuery,
+		QueryKind = OptionQuery,
 	>;
 
 	/// Custom data of a token that is serialized to bytes,
@@ -340,40 +340,8 @@
 	/// - `token`: Token ID.
 	pub fn token_exists(collection: &NonfungibleHandle<T>, token: TokenId) -> bool {
 		<TokenData<T>>::contains_key((collection.id, token))
-	}
-
-	/// Set the token property with the scope.
-	///
-	/// - `property`: Contains key-value pair.
-	pub fn set_scoped_token_property(
-		collection_id: CollectionId,
-		token_id: TokenId,
-		scope: PropertyScope,
-		property: Property,
-	) -> DispatchResult {
-		TokenProperties::<T>::try_mutate((collection_id, token_id), |properties| {
-			properties.try_scoped_set(scope, property.key, property.value)
-		})
-		.map_err(<CommonError<T>>::from)?;
-
-		Ok(())
 	}
 
-	/// Batch operation to set multiple properties with the same scope.
-	pub fn set_scoped_token_properties(
-		collection_id: CollectionId,
-		token_id: TokenId,
-		scope: PropertyScope,
-		properties: impl Iterator<Item = Property>,
-	) -> DispatchResult {
-		TokenProperties::<T>::try_mutate((collection_id, token_id), |stored_properties| {
-			stored_properties.try_scoped_set_from_iter(scope, properties)
-		})
-		.map_err(<CommonError<T>>::from)?;
-
-		Ok(())
-	}
-
 	/// Add or edit auxiliary data for the property.
 	///
 	/// - `f`: function that adds or edits auxiliary data.
@@ -1394,7 +1362,9 @@
 
 	pub fn repair_item(collection: &NonfungibleHandle<T>, token: TokenId) -> DispatchResult {
 		<TokenProperties<T>>::mutate((collection.id, token), |properties| {
-			properties.recompute_consumed_space();
+			if let Some(properties) = properties {
+				properties.recompute_consumed_space();
+			}
 		});
 
 		Ok(())
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -435,16 +435,15 @@
 		)
 	}
 
-	fn get_token_properties_map(&self, token_id: TokenId) -> up_data_structs::TokenProperties {
+	fn get_token_properties_raw(
+		&self,
+		token_id: TokenId,
+	) -> Option<up_data_structs::TokenProperties> {
 		<TokenProperties<T>>::get((self.id, token_id))
 	}
 
-	fn set_token_properties_map(&self, token_id: TokenId, map: up_data_structs::TokenProperties) {
-		<TokenProperties<T>>::set((self.id, token_id), map)
-	}
-
-	fn properties_exist(&self, token: TokenId) -> bool {
-		<TokenProperties<T>>::contains_key((self.id, token))
+	fn set_token_properties_raw(&self, token_id: TokenId, map: up_data_structs::TokenProperties) {
+		<TokenProperties<T>>::insert((self.id, token_id), map)
 	}
 
 	fn check_nesting(
@@ -514,13 +513,15 @@
 	}
 
 	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {
-		<Pallet<T>>::token_properties((self.id, token_id))
+		<Pallet<T>>::token_properties((self.id, token_id))?
 			.get(key)
 			.cloned()
 	}
 
 	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {
-		let properties = <Pallet<T>>::token_properties((self.id, token_id));
+		let Some(properties) = <Pallet<T>>::token_properties((self.id, token_id)) else {
+			return vec![];
+		};
 
 		keys.map(|keys| {
 			keys.into_iter()
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -283,7 +283,8 @@
 			.try_into()
 			.map_err(|_| "key too long")?;
 
-		let props = <TokenProperties<T>>::get((self.id, token_id));
+		let props =
+			<TokenProperties<T>>::get((self.id, token_id)).ok_or("Token properties not found")?;
 		let prop = props.get(&key).ok_or("key not found")?;
 
 		Ok(prop.to_vec().into())
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -106,8 +106,8 @@
 use up_data_structs::{
 	AccessMode, budget::Budget, CollectionId, CreateCollectionData, mapping::TokenAddressMapping,
 	MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyScope,
-	PropertyValue, TokenId, TrySetProperty, PropertiesPermissionMap,
-	CreateRefungibleExMultipleOwners, TokenOwnerError, TokenProperties as TokenPropertiesT,
+	PropertyValue, TokenId, PropertiesPermissionMap, CreateRefungibleExMultipleOwners,
+	TokenOwnerError, TokenProperties as TokenPropertiesT,
 };
 
 pub use pallet::*;
@@ -175,7 +175,7 @@
 	pub type TokenProperties<T: Config> = StorageNMap<
 		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
 		Value = TokenPropertiesT,
-		QueryKind = ValueQuery,
+		QueryKind = OptionQuery,
 	>;
 
 	/// Total amount of pieces for token
@@ -292,35 +292,7 @@
 	/// - `token`: Token ID.
 	pub fn token_exists(collection: &RefungibleHandle<T>, token: TokenId) -> bool {
 		<TotalSupply<T>>::contains_key((collection.id, token))
-	}
-
-	pub fn set_scoped_token_property(
-		collection_id: CollectionId,
-		token_id: TokenId,
-		scope: PropertyScope,
-		property: Property,
-	) -> DispatchResult {
-		TokenProperties::<T>::try_mutate((collection_id, token_id), |properties| {
-			properties.try_scoped_set(scope, property.key, property.value)
-		})
-		.map_err(<CommonError<T>>::from)?;
-
-		Ok(())
 	}
-
-	pub fn set_scoped_token_properties(
-		collection_id: CollectionId,
-		token_id: TokenId,
-		scope: PropertyScope,
-		properties: impl Iterator<Item = Property>,
-	) -> DispatchResult {
-		TokenProperties::<T>::try_mutate((collection_id, token_id), |stored_properties| {
-			stored_properties.try_scoped_set_from_iter(scope, properties)
-		})
-		.map_err(<CommonError<T>>::from)?;
-
-		Ok(())
-	}
 }
 
 // unchecked calls skips any permission checks
@@ -1426,7 +1398,9 @@
 
 	pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {
 		<TokenProperties<T>>::mutate((collection.id, token), |properties| {
-			properties.recompute_consumed_space();
+			if let Some(properties) = properties {
+				properties.recompute_consumed_space();
+			}
 		});
 
 		Ok(())