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
before · pallets/balances-adapter/src/common.rs
1use alloc::{vec, vec::Vec};2use core::marker::PhantomData;3use crate::{Config, NativeFungibleHandle, Pallet};4use frame_support::{fail, weights::Weight};5use pallet_balances::{weights::SubstrateWeight as BalancesWeight, WeightInfo};6use pallet_common::{CommonCollectionOperations, CommonWeightInfo};7use up_data_structs::TokenId;89pub struct CommonWeights<T: Config>(PhantomData<T>);1011// All implementations with `Weight::default` used in methods that return error `UnsupportedOperation`.12impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {13	fn create_multiple_items(_amount: &[up_data_structs::CreateItemData]) -> Weight {14		Weight::default()15	}1617	fn create_multiple_items_ex(18		_cost: &up_data_structs::CreateItemExData<T::CrossAccountId>,19	) -> Weight {20		Weight::default()21	}2223	fn burn_item() -> Weight {24		Weight::default()25	}2627	fn set_collection_properties(_amount: u32) -> Weight {28		Weight::default()29	}3031	fn delete_collection_properties(_amount: u32) -> Weight {32		Weight::default()33	}3435	fn set_token_properties(_amount: u32) -> Weight {36		Weight::default()37	}3839	fn delete_token_properties(_amount: u32) -> Weight {40		Weight::default()41	}4243	fn set_token_property_permissions(_amount: u32) -> Weight {44		Weight::default()45	}4647	fn transfer() -> Weight {48		<BalancesWeight<T> as WeightInfo>::transfer_allow_death()49	}5051	fn approve() -> Weight {52		Weight::default()53	}5455	fn approve_from() -> Weight {56		Weight::default()57	}5859	fn transfer_from() -> Weight {60		<BalancesWeight<T> as WeightInfo>::transfer_allow_death()61	}6263	fn burn_from() -> Weight {64		Weight::default()65	}6667	fn burn_recursively_self_raw() -> Weight {68		Weight::default()69	}7071	fn burn_recursively_breadth_raw(_amount: u32) -> Weight {72		Weight::default()73	}7475	fn token_owner() -> Weight {76		Weight::default()77	}7879	fn set_allowance_for_all() -> Weight {80		Weight::default()81	}8283	fn force_repair_item() -> Weight {84		Weight::default()85	}86}8788/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallet89/// methods and adds weight info.90impl<T: Config> CommonCollectionOperations<T> for NativeFungibleHandle<T> {91	fn create_item(92		&self,93		_sender: <T>::CrossAccountId,94		_to: <T>::CrossAccountId,95		_data: up_data_structs::CreateItemData,96		_nesting_budget: &dyn up_data_structs::budget::Budget,97	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {98		fail!(<pallet_common::Error<T>>::UnsupportedOperation);99	}100101	fn create_multiple_items(102		&self,103		_sender: <T>::CrossAccountId,104		_to: <T>::CrossAccountId,105		_data: Vec<up_data_structs::CreateItemData>,106		_nesting_budget: &dyn up_data_structs::budget::Budget,107	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {108		fail!(<pallet_common::Error<T>>::UnsupportedOperation);109	}110111	fn create_multiple_items_ex(112		&self,113		_sender: <T>::CrossAccountId,114		_data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,115		_nesting_budget: &dyn up_data_structs::budget::Budget,116	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {117		fail!(<pallet_common::Error<T>>::UnsupportedOperation);118	}119120	fn burn_item(121		&self,122		_sender: <T>::CrossAccountId,123		_token: TokenId,124		_amount: u128,125	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {126		fail!(<pallet_common::Error<T>>::UnsupportedOperation);127	}128129	fn burn_item_recursively(130		&self,131		_sender: <T>::CrossAccountId,132		_token: TokenId,133		_self_budget: &dyn up_data_structs::budget::Budget,134		_breadth_budget: &dyn up_data_structs::budget::Budget,135	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {136		fail!(<pallet_common::Error<T>>::UnsupportedOperation);137	}138139	fn set_collection_properties(140		&self,141		_sender: <T>::CrossAccountId,142		_properties: Vec<up_data_structs::Property>,143	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {144		fail!(<pallet_common::Error<T>>::UnsupportedOperation);145	}146147	fn delete_collection_properties(148		&self,149		_sender: &<T>::CrossAccountId,150		_property_keys: Vec<up_data_structs::PropertyKey>,151	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {152		fail!(<pallet_common::Error<T>>::UnsupportedOperation);153	}154155	fn set_token_properties(156		&self,157		_sender: <T>::CrossAccountId,158		_token_id: TokenId,159		_properties: Vec<up_data_structs::Property>,160		_budget: &dyn up_data_structs::budget::Budget,161	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {162		fail!(<pallet_common::Error<T>>::UnsupportedOperation);163	}164165	fn delete_token_properties(166		&self,167		_sender: <T>::CrossAccountId,168		_token_id: TokenId,169		_property_keys: Vec<up_data_structs::PropertyKey>,170		_budget: &dyn up_data_structs::budget::Budget,171	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {172		fail!(<pallet_common::Error<T>>::UnsupportedOperation);173	}174175	fn get_token_properties_map(&self, _token_id: TokenId) -> up_data_structs::TokenProperties {176		// No token properties are defined on fungibles177		up_data_structs::TokenProperties::new()178	}179180	fn set_token_properties_map(&self, _token_id: TokenId, _map: up_data_structs::TokenProperties) {181		// No token properties are defined on fungibles182	}183184	fn properties_exist(&self, _token: TokenId) -> bool {185		// No token properties are defined on fungibles186		false187	}188189	fn set_token_property_permissions(190		&self,191		_sender: &<T>::CrossAccountId,192		_property_permissions: Vec<up_data_structs::PropertyKeyPermission>,193	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {194		fail!(<pallet_common::Error<T>>::UnsupportedOperation);195	}196197	fn transfer(198		&self,199		sender: <T>::CrossAccountId,200		to: <T>::CrossAccountId,201		_token: TokenId,202		amount: u128,203		budget: &dyn up_data_structs::budget::Budget,204	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {205		<Pallet<T>>::transfer(self, &sender, &to, amount, budget)206	}207208	fn approve(209		&self,210		_sender: <T>::CrossAccountId,211		_spender: <T>::CrossAccountId,212		_token: TokenId,213		_amount: u128,214	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {215		fail!(<pallet_common::Error<T>>::UnsupportedOperation);216	}217218	fn approve_from(219		&self,220		_sender: <T>::CrossAccountId,221		_from: <T>::CrossAccountId,222		_to: <T>::CrossAccountId,223		_token: TokenId,224		_amount: u128,225	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {226		fail!(<pallet_common::Error<T>>::UnsupportedOperation);227	}228229	fn transfer_from(230		&self,231		sender: <T>::CrossAccountId,232		from: <T>::CrossAccountId,233		to: <T>::CrossAccountId,234		_token: TokenId,235		amount: u128,236		budget: &dyn up_data_structs::budget::Budget,237	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {238		<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, budget)239	}240241	fn burn_from(242		&self,243		_sender: <T>::CrossAccountId,244		_from: <T>::CrossAccountId,245		_token: TokenId,246		_amount: u128,247		_budget: &dyn up_data_structs::budget::Budget,248	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {249		fail!(<pallet_common::Error<T>>::UnsupportedOperation);250	}251252	fn check_nesting(253		&self,254		_sender: <T>::CrossAccountId,255		_from: (up_data_structs::CollectionId, TokenId),256		_under: TokenId,257		_budget: &dyn up_data_structs::budget::Budget,258	) -> frame_support::sp_runtime::DispatchResult {259		fail!(<pallet_common::Error<T>>::UnsupportedOperation);260	}261262	fn nest(&self, _under: TokenId, _to_nest: (up_data_structs::CollectionId, TokenId)) {}263264	fn unnest(&self, _under: TokenId, _to_nest: (up_data_structs::CollectionId, TokenId)) {}265266	fn account_tokens(&self, account: <T>::CrossAccountId) -> Vec<TokenId> {267		let balance = <Pallet<T>>::total_balance(&account);268		if balance != 0 {269			vec![TokenId::default()]270		} else {271			vec![]272		}273	}274275	fn collection_tokens(&self) -> Vec<TokenId> {276		vec![TokenId::default()]277	}278279	fn token_exists(&self, token: TokenId) -> bool {280		token == TokenId::default()281	}282283	fn last_token_id(&self) -> TokenId {284		TokenId::default()285	}286287	fn token_owner(288		&self,289		_token: TokenId,290	) -> Result<<T>::CrossAccountId, up_data_structs::TokenOwnerError> {291		Err(up_data_structs::TokenOwnerError::MultipleOwners)292	}293294	fn check_token_indirect_owner(295		&self,296		_token: TokenId,297		_maybe_owner: &<T>::CrossAccountId,298		_nesting_budget: &dyn up_data_structs::budget::Budget,299	) -> Result<bool, frame_support::sp_runtime::DispatchError> {300		Ok(false)301	}302303	fn token_owners(&self, _token: TokenId) -> Vec<<T>::CrossAccountId> {304		vec![]305	}306307	fn token_property(308		&self,309		_token_id: TokenId,310		_key: &up_data_structs::PropertyKey,311	) -> Option<up_data_structs::PropertyValue> {312		None313	}314315	fn token_properties(316		&self,317		_token: TokenId,318		_keys: Option<Vec<up_data_structs::PropertyKey>>,319	) -> Vec<up_data_structs::Property> {320		vec![]321	}322323	fn total_supply(&self) -> u32 {324		1325	}326327	fn account_balance(&self, account: T::CrossAccountId) -> u32 {328		let balance = <Pallet<T>>::balance_of(&account);329		(balance != 0).into()330	}331332	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {333		if token != TokenId::default() {334			return 0;335		}336		<Pallet<T>>::balance_of(&account)337	}338339	fn total_pieces(&self, token: TokenId) -> Option<u128> {340		if token != TokenId::default() {341			return None;342		}343		Some(<Pallet<T>>::total_issuance())344	}345346	fn allowance(347		&self,348		_sender: <T>::CrossAccountId,349		_spender: <T>::CrossAccountId,350		_token: TokenId,351	) -> u128 {352		0353	}354355	fn refungible_extensions(&self) -> Option<&dyn pallet_common::RefungibleExtensions<T>> {356		None357	}358359	fn set_allowance_for_all(360		&self,361		_owner: <T>::CrossAccountId,362		_operator: <T>::CrossAccountId,363		_approve: bool,364	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {365		fail!(<pallet_common::Error<T>>::UnsupportedOperation);366	}367368	fn allowance_for_all(369		&self,370		_owner: <T>::CrossAccountId,371		_operator: <T>::CrossAccountId,372	) -> bool {373		false374	}375376	fn repair_item(377		&self,378		_token: TokenId,379	) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {380		fail!(<pallet_common::Error<T>>::UnsupportedOperation);381	}382}
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
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -265,12 +265,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 set_token_properties_raw(&self, token_id: TokenId, map: up_data_structs::TokenProperties) {
+		<TokenProperties<T>>::insert((self.id, token_id), map)
 	}
 
 	fn set_token_property_permissions(
@@ -287,10 +290,6 @@
 		)
 	}
 
-	fn properties_exist(&self, token: TokenId) -> bool {
-		<TokenProperties<T>>::contains_key((self.id, token))
-	}
-
 	fn burn_item(
 		&self,
 		sender: T::CrossAccountId,
@@ -482,13 +481,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/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(())