git.delta.rocks / unique-network / refs/commits / 7db537d352ab

difftreelog

fix property keys are optional in RPC

Daniel Shiposha2022-05-19parent: #0391082.patch.diff
in: master

7 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -76,7 +76,7 @@
 	fn collection_properties(
 		&self,
 		collection: CollectionId,
-		keys: Vec<String>,
+		keys: Option<Vec<String>>,
 		at: Option<BlockHash>,
 	) -> Result<Vec<Property>>;
 
@@ -85,7 +85,7 @@
 		&self,
 		collection: CollectionId,
 		token_id: TokenId,
-		properties: Vec<String>,
+		keys: Option<Vec<String>>,
 		at: Option<BlockHash>,
 	) -> Result<Vec<Property>>;
 
@@ -93,7 +93,7 @@
 	fn property_permissions(
 		&self,
 		collection: CollectionId,
-		keys: Vec<String>,
+		keys: Option<Vec<String>>,
 		at: Option<BlockHash>,
 	) -> Result<Vec<PropertyKeyPermission>>;
 
@@ -102,7 +102,7 @@
 		&self,
 		collection: CollectionId,
 		token_id: TokenId,
-		keys: Vec<String>,
+		keys: Option<Vec<String>>,
 		at: Option<BlockHash>,
 	) -> Result<TokenData<CrossAccountId>>;
 
@@ -277,7 +277,7 @@
 		collection: CollectionId,
 
 		#[map(|keys| string_keys_to_bytes_keys(keys))]
-		keys: Vec<String>
+		keys: Option<Vec<String>>
 	) -> Vec<Property>);
 
 	pass_method!(token_properties(
@@ -285,14 +285,14 @@
 		token_id: TokenId,
 
 		#[map(|keys| string_keys_to_bytes_keys(keys))]
-		properties: Vec<String>
+		keys: Option<Vec<String>>
 	) -> Vec<Property>);
 
 	pass_method!(property_permissions(
 		collection: CollectionId,
 
 		#[map(|keys| string_keys_to_bytes_keys(keys))]
-		keys: Vec<String>
+		keys: Option<Vec<String>>
 	) -> Vec<PropertyKeyPermission>);
 
 	pass_method!(token_data(
@@ -300,7 +300,7 @@
 		token_id: TokenId,
 
 		#[map(|keys| string_keys_to_bytes_keys(keys))]
-		keys: Vec<String>,
+		keys: Option<Vec<String>>,
 	) -> TokenData<CrossAccountId>);
 
 	pass_method!(total_supply(collection: CollectionId) -> u32);
@@ -318,6 +318,8 @@
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>);
 }
 
-fn string_keys_to_bytes_keys(keys: Vec<String>) -> Vec<Vec<u8>> {
-	keys.into_iter().map(|key| key.into_bytes()).collect()
+fn string_keys_to_bytes_keys(keys: Option<Vec<String>>) -> Option<Vec<Vec<u8>>> {
+	keys.map(|keys| {
+		keys.into_iter().map(|key| key.into_bytes()).collect()
+	})
 }
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -845,31 +845,39 @@
 
 	pub fn filter_collection_properties(
 		collection_id: CollectionId,
-		keys: Vec<PropertyKey>,
+		keys: Option<Vec<PropertyKey>>,
 	) -> Result<Vec<Property>, DispatchError> {
 		let properties = Self::collection_properties(collection_id);
 
-		let properties = keys
-			.into_iter()
+		let properties = keys.map(|keys| {
+			keys.into_iter()
 			.filter_map(|key| {
 				properties.get(&key).map(|value| Property {
 					key,
 					value: value.clone(),
 				})
 			})
-			.collect();
+			.collect()
+		}).unwrap_or(
+			properties.iter()
+				.map(|(key, value)| Property {
+					key: key.clone(),
+					value: value.clone(),
+				})
+				.collect()
+		);
 
 		Ok(properties)
 	}
 
 	pub fn filter_property_permissions(
 		collection_id: CollectionId,
-		keys: Vec<PropertyKey>,
+		keys: Option<Vec<PropertyKey>>,
 	) -> Result<Vec<PropertyKeyPermission>, DispatchError> {
 		let permissions = Self::property_permissions(collection_id);
 
-		let key_permissions = keys
-			.into_iter()
+		let key_permissions = keys.map(|keys| {
+			keys.into_iter()
 			.filter_map(|key| {
 				permissions
 					.get(&key)
@@ -878,7 +886,15 @@
 						permission: permission.clone(),
 					})
 			})
-			.collect();
+			.collect()
+		}).unwrap_or(
+			permissions.iter()
+				.map(|(key, permission)| PropertyKeyPermission {
+					key: key.clone(),
+					permission: permission.clone(),
+				})
+				.collect()
+		);
 
 		Ok(key_permissions)
 	}
@@ -1148,7 +1164,7 @@
 
 	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;
 	fn const_metadata(&self, token: TokenId) -> Vec<u8>;
-	fn token_properties(&self, token_id: TokenId, keys: Vec<PropertyKey>) -> Vec<Property>;
+	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property>;
 	/// Amount of unique collection tokens
 	fn total_supply(&self) -> u32;
 	/// Amount of different tokens account has (Applicable to nonfungible/refungible)
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -319,7 +319,7 @@
 		Vec::new()
 	}
 
-	fn token_properties(&self, _token_id: TokenId, _keys: Vec<PropertyKey>) -> Vec<Property> {
+	fn token_properties(&self, _token_id: TokenId, _keys: Option<Vec<PropertyKey>>) -> Vec<Property> {
 		Vec::new()
 	}
 
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,22	PropertyKey, PropertyKeyPermission,23};24use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};25use sp_runtime::DispatchError;26use sp_std::vec::Vec;2728use crate::{29	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,30	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,31};3233pub struct CommonWeights<T: Config>(PhantomData<T>);34impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {35	fn create_item() -> Weight {36		<SelfWeightOf<T>>::create_item()37	}3839	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			_ => 0,43		}44	}4546	fn create_multiple_items(amount: u32) -> Weight {47		<SelfWeightOf<T>>::create_multiple_items(amount)48	}4950	fn burn_item() -> Weight {51		<SelfWeightOf<T>>::burn_item()52	}5354	fn set_collection_properties(amount: u32) -> Weight {55		<SelfWeightOf<T>>::set_collection_properties(amount)56	}5758	fn delete_collection_properties(amount: u32) -> Weight {59		<SelfWeightOf<T>>::delete_collection_properties(amount)60	}6162	fn set_token_properties(amount: u32) -> Weight {63		<SelfWeightOf<T>>::set_token_properties(amount)64	}6566	fn delete_token_properties(amount: u32) -> Weight {67		<SelfWeightOf<T>>::delete_token_properties(amount)68	}6970	fn set_property_permissions(amount: u32) -> Weight {71		<SelfWeightOf<T>>::set_property_permissions(amount)72	}7374	fn transfer() -> Weight {75		<SelfWeightOf<T>>::transfer()76	}7778	fn approve() -> Weight {79		<SelfWeightOf<T>>::approve()80	}8182	fn transfer_from() -> Weight {83		<SelfWeightOf<T>>::transfer_from()84	}8586	fn burn_from() -> Weight {87		<SelfWeightOf<T>>::burn_from()88	}89}9091fn map_create_data<T: Config>(92	data: up_data_structs::CreateItemData,93	to: &T::CrossAccountId,94) -> Result<CreateItemData<T>, DispatchError> {95	match data {96		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {97			const_data: data.const_data,98			properties: data.properties,99			owner: to.clone(),100		}),101		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),102	}103}104105impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {106	fn create_item(107		&self,108		sender: T::CrossAccountId,109		to: T::CrossAccountId,110		data: up_data_structs::CreateItemData,111		nesting_budget: &dyn Budget,112	) -> DispatchResultWithPostInfo {113		with_weight(114			<Pallet<T>>::create_item(115				self,116				&sender,117				map_create_data::<T>(data, &to)?,118				nesting_budget,119			),120			<CommonWeights<T>>::create_item(),121		)122	}123124	fn create_multiple_items(125		&self,126		sender: T::CrossAccountId,127		to: T::CrossAccountId,128		data: Vec<up_data_structs::CreateItemData>,129		nesting_budget: &dyn Budget,130	) -> DispatchResultWithPostInfo {131		let data = data132			.into_iter()133			.map(|d| map_create_data::<T>(d, &to))134			.collect::<Result<Vec<_>, DispatchError>>()?;135136		let amount = data.len();137		with_weight(138			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),139			<CommonWeights<T>>::create_multiple_items(amount as u32),140		)141	}142143	fn create_multiple_items_ex(144		&self,145		sender: <T>::CrossAccountId,146		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,147		nesting_budget: &dyn Budget,148	) -> DispatchResultWithPostInfo {149		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);150		let data = match data {151			up_data_structs::CreateItemExData::NFT(nft) => nft,152			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),153		};154155		with_weight(156			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),157			weight,158		)159	}160161	fn set_collection_properties(162		&self,163		sender: T::CrossAccountId,164		properties: Vec<Property>,165	) -> DispatchResultWithPostInfo {166		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);167168		with_weight(169			<Pallet<T>>::set_collection_properties(self, &sender, properties),170			weight,171		)172	}173174	fn delete_collection_properties(175		&self,176		sender: &T::CrossAccountId,177		property_keys: Vec<PropertyKey>,178	) -> DispatchResultWithPostInfo {179		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);180181		with_weight(182			<Pallet<T>>::delete_collection_properties(self, &sender, property_keys),183			weight,184		)185	}186187	fn set_token_properties(188		&self,189		sender: T::CrossAccountId,190		token_id: TokenId,191		properties: Vec<Property>,192	) -> DispatchResultWithPostInfo {193		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);194195		with_weight(196			<Pallet<T>>::set_token_properties(self, &sender, token_id, properties),197			weight,198		)199	}200201	fn delete_token_properties(202		&self,203		sender: T::CrossAccountId,204		token_id: TokenId,205		property_keys: Vec<PropertyKey>,206	) -> DispatchResultWithPostInfo {207		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);208209		with_weight(210			<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),211			weight,212		)213	}214215	fn set_property_permissions(216		&self,217		sender: &T::CrossAccountId,218		property_permissions: Vec<PropertyKeyPermission>,219	) -> DispatchResultWithPostInfo {220		let weight =221			<CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);222223		with_weight(224			<Pallet<T>>::set_property_permissions(self, sender, property_permissions),225			weight,226		)227	}228229	fn burn_item(230		&self,231		sender: T::CrossAccountId,232		token: TokenId,233		amount: u128,234	) -> DispatchResultWithPostInfo {235		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);236		if amount == 1 {237			with_weight(238				<Pallet<T>>::burn(self, &sender, token),239				<CommonWeights<T>>::burn_item(),240			)241		} else {242			Ok(().into())243		}244	}245246	fn transfer(247		&self,248		from: T::CrossAccountId,249		to: T::CrossAccountId,250		token: TokenId,251		amount: u128,252		nesting_budget: &dyn Budget,253	) -> DispatchResultWithPostInfo {254		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);255		if amount == 1 {256			with_weight(257				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),258				<CommonWeights<T>>::transfer(),259			)260		} else {261			Ok(().into())262		}263	}264265	fn approve(266		&self,267		sender: T::CrossAccountId,268		spender: T::CrossAccountId,269		token: TokenId,270		amount: u128,271	) -> DispatchResultWithPostInfo {272		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);273274		with_weight(275			if amount == 1 {276				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))277			} else {278				<Pallet<T>>::set_allowance(self, &sender, token, None)279			},280			<CommonWeights<T>>::approve(),281		)282	}283284	fn transfer_from(285		&self,286		sender: T::CrossAccountId,287		from: T::CrossAccountId,288		to: T::CrossAccountId,289		token: TokenId,290		amount: u128,291		nesting_budget: &dyn Budget,292	) -> DispatchResultWithPostInfo {293		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);294295		if amount == 1 {296			with_weight(297				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),298				<CommonWeights<T>>::transfer_from(),299			)300		} else {301			Ok(().into())302		}303	}304305	fn burn_from(306		&self,307		sender: T::CrossAccountId,308		from: T::CrossAccountId,309		token: TokenId,310		amount: u128,311		nesting_budget: &dyn Budget,312	) -> DispatchResultWithPostInfo {313		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);314315		if amount == 1 {316			with_weight(317				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),318				<CommonWeights<T>>::burn_from(),319			)320		} else {321			Ok(().into())322		}323	}324325	fn check_nesting(326		&self,327		sender: T::CrossAccountId,328		from: (CollectionId, TokenId),329		under: TokenId,330		budget: &dyn Budget,331	) -> sp_runtime::DispatchResult {332		<Pallet<T>>::check_nesting(self, sender, from, under, budget)333	}334335	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {336		<Owned<T>>::iter_prefix((self.id, account))337			.map(|(id, _)| id)338			.collect()339	}340341	fn collection_tokens(&self) -> Vec<TokenId> {342		<TokenData<T>>::iter_prefix((self.id,))343			.map(|(id, _)| id)344			.collect()345	}346347	fn token_exists(&self, token: TokenId) -> bool {348		<Pallet<T>>::token_exists(self, token)349	}350351	fn last_token_id(&self) -> TokenId {352		TokenId(<TokensMinted<T>>::get(self.id))353	}354355	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {356		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)357	}358	fn const_metadata(&self, token: TokenId) -> Vec<u8> {359		<TokenData<T>>::get((self.id, token))360			.map(|t| t.const_data)361			.unwrap_or_default()362			.into_inner()363	}364365	fn token_properties(&self, token_id: TokenId, keys: Vec<PropertyKey>) -> Vec<Property> {366		let properties = <Pallet<T>>::token_properties((self.id, token_id));367368		keys.into_iter()369			.filter_map(|key| {370				properties.get(&key).map(|value| Property {371					key,372					value: value.clone(),373				})374			})375			.collect()376	}377378	fn total_supply(&self) -> u32 {379		<Pallet<T>>::total_supply(self)380	}381382	fn account_balance(&self, account: T::CrossAccountId) -> u32 {383		<AccountBalance<T>>::get((self.id, account))384	}385386	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {387		if <TokenData<T>>::get((self.id, token))388			.map(|a| a.owner == account)389			.unwrap_or(false)390		{391			1392		} else {393			0394		}395	}396397	fn allowance(398		&self,399		sender: T::CrossAccountId,400		spender: T::CrossAccountId,401		token: TokenId,402	) -> u128 {403		if <TokenData<T>>::get((self.id, token))404			.map(|a| a.owner != sender)405			.unwrap_or(true)406		{407			0408		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {409			1410		} else {411			0412		}413	}414}
after · 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,22	PropertyKey, PropertyKeyPermission,23};24use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};25use sp_runtime::DispatchError;26use sp_std::vec::Vec;2728use crate::{29	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,30	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,31};3233pub struct CommonWeights<T: Config>(PhantomData<T>);34impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {35	fn create_item() -> Weight {36		<SelfWeightOf<T>>::create_item()37	}3839	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			_ => 0,43		}44	}4546	fn create_multiple_items(amount: u32) -> Weight {47		<SelfWeightOf<T>>::create_multiple_items(amount)48	}4950	fn burn_item() -> Weight {51		<SelfWeightOf<T>>::burn_item()52	}5354	fn set_collection_properties(amount: u32) -> Weight {55		<SelfWeightOf<T>>::set_collection_properties(amount)56	}5758	fn delete_collection_properties(amount: u32) -> Weight {59		<SelfWeightOf<T>>::delete_collection_properties(amount)60	}6162	fn set_token_properties(amount: u32) -> Weight {63		<SelfWeightOf<T>>::set_token_properties(amount)64	}6566	fn delete_token_properties(amount: u32) -> Weight {67		<SelfWeightOf<T>>::delete_token_properties(amount)68	}6970	fn set_property_permissions(amount: u32) -> Weight {71		<SelfWeightOf<T>>::set_property_permissions(amount)72	}7374	fn transfer() -> Weight {75		<SelfWeightOf<T>>::transfer()76	}7778	fn approve() -> Weight {79		<SelfWeightOf<T>>::approve()80	}8182	fn transfer_from() -> Weight {83		<SelfWeightOf<T>>::transfer_from()84	}8586	fn burn_from() -> Weight {87		<SelfWeightOf<T>>::burn_from()88	}89}9091fn map_create_data<T: Config>(92	data: up_data_structs::CreateItemData,93	to: &T::CrossAccountId,94) -> Result<CreateItemData<T>, DispatchError> {95	match data {96		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {97			const_data: data.const_data,98			properties: data.properties,99			owner: to.clone(),100		}),101		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),102	}103}104105impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {106	fn create_item(107		&self,108		sender: T::CrossAccountId,109		to: T::CrossAccountId,110		data: up_data_structs::CreateItemData,111		nesting_budget: &dyn Budget,112	) -> DispatchResultWithPostInfo {113		with_weight(114			<Pallet<T>>::create_item(115				self,116				&sender,117				map_create_data::<T>(data, &to)?,118				nesting_budget,119			),120			<CommonWeights<T>>::create_item(),121		)122	}123124	fn create_multiple_items(125		&self,126		sender: T::CrossAccountId,127		to: T::CrossAccountId,128		data: Vec<up_data_structs::CreateItemData>,129		nesting_budget: &dyn Budget,130	) -> DispatchResultWithPostInfo {131		let data = data132			.into_iter()133			.map(|d| map_create_data::<T>(d, &to))134			.collect::<Result<Vec<_>, DispatchError>>()?;135136		let amount = data.len();137		with_weight(138			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),139			<CommonWeights<T>>::create_multiple_items(amount as u32),140		)141	}142143	fn create_multiple_items_ex(144		&self,145		sender: <T>::CrossAccountId,146		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,147		nesting_budget: &dyn Budget,148	) -> DispatchResultWithPostInfo {149		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);150		let data = match data {151			up_data_structs::CreateItemExData::NFT(nft) => nft,152			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),153		};154155		with_weight(156			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),157			weight,158		)159	}160161	fn set_collection_properties(162		&self,163		sender: T::CrossAccountId,164		properties: Vec<Property>,165	) -> DispatchResultWithPostInfo {166		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);167168		with_weight(169			<Pallet<T>>::set_collection_properties(self, &sender, properties),170			weight,171		)172	}173174	fn delete_collection_properties(175		&self,176		sender: &T::CrossAccountId,177		property_keys: Vec<PropertyKey>,178	) -> DispatchResultWithPostInfo {179		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);180181		with_weight(182			<Pallet<T>>::delete_collection_properties(self, &sender, property_keys),183			weight,184		)185	}186187	fn set_token_properties(188		&self,189		sender: T::CrossAccountId,190		token_id: TokenId,191		properties: Vec<Property>,192	) -> DispatchResultWithPostInfo {193		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);194195		with_weight(196			<Pallet<T>>::set_token_properties(self, &sender, token_id, properties),197			weight,198		)199	}200201	fn delete_token_properties(202		&self,203		sender: T::CrossAccountId,204		token_id: TokenId,205		property_keys: Vec<PropertyKey>,206	) -> DispatchResultWithPostInfo {207		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);208209		with_weight(210			<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),211			weight,212		)213	}214215	fn set_property_permissions(216		&self,217		sender: &T::CrossAccountId,218		property_permissions: Vec<PropertyKeyPermission>,219	) -> DispatchResultWithPostInfo {220		let weight =221			<CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);222223		with_weight(224			<Pallet<T>>::set_property_permissions(self, sender, property_permissions),225			weight,226		)227	}228229	fn burn_item(230		&self,231		sender: T::CrossAccountId,232		token: TokenId,233		amount: u128,234	) -> DispatchResultWithPostInfo {235		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);236		if amount == 1 {237			with_weight(238				<Pallet<T>>::burn(self, &sender, token),239				<CommonWeights<T>>::burn_item(),240			)241		} else {242			Ok(().into())243		}244	}245246	fn transfer(247		&self,248		from: T::CrossAccountId,249		to: T::CrossAccountId,250		token: TokenId,251		amount: u128,252		nesting_budget: &dyn Budget,253	) -> DispatchResultWithPostInfo {254		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);255		if amount == 1 {256			with_weight(257				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),258				<CommonWeights<T>>::transfer(),259			)260		} else {261			Ok(().into())262		}263	}264265	fn approve(266		&self,267		sender: T::CrossAccountId,268		spender: T::CrossAccountId,269		token: TokenId,270		amount: u128,271	) -> DispatchResultWithPostInfo {272		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);273274		with_weight(275			if amount == 1 {276				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))277			} else {278				<Pallet<T>>::set_allowance(self, &sender, token, None)279			},280			<CommonWeights<T>>::approve(),281		)282	}283284	fn transfer_from(285		&self,286		sender: T::CrossAccountId,287		from: T::CrossAccountId,288		to: T::CrossAccountId,289		token: TokenId,290		amount: u128,291		nesting_budget: &dyn Budget,292	) -> DispatchResultWithPostInfo {293		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);294295		if amount == 1 {296			with_weight(297				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),298				<CommonWeights<T>>::transfer_from(),299			)300		} else {301			Ok(().into())302		}303	}304305	fn burn_from(306		&self,307		sender: T::CrossAccountId,308		from: T::CrossAccountId,309		token: TokenId,310		amount: u128,311		nesting_budget: &dyn Budget,312	) -> DispatchResultWithPostInfo {313		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);314315		if amount == 1 {316			with_weight(317				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),318				<CommonWeights<T>>::burn_from(),319			)320		} else {321			Ok(().into())322		}323	}324325	fn check_nesting(326		&self,327		sender: T::CrossAccountId,328		from: (CollectionId, TokenId),329		under: TokenId,330		budget: &dyn Budget,331	) -> sp_runtime::DispatchResult {332		<Pallet<T>>::check_nesting(self, sender, from, under, budget)333	}334335	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {336		<Owned<T>>::iter_prefix((self.id, account))337			.map(|(id, _)| id)338			.collect()339	}340341	fn collection_tokens(&self) -> Vec<TokenId> {342		<TokenData<T>>::iter_prefix((self.id,))343			.map(|(id, _)| id)344			.collect()345	}346347	fn token_exists(&self, token: TokenId) -> bool {348		<Pallet<T>>::token_exists(self, token)349	}350351	fn last_token_id(&self) -> TokenId {352		TokenId(<TokensMinted<T>>::get(self.id))353	}354355	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {356		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)357	}358	fn const_metadata(&self, token: TokenId) -> Vec<u8> {359		<TokenData<T>>::get((self.id, token))360			.map(|t| t.const_data)361			.unwrap_or_default()362			.into_inner()363	}364365	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {366		let properties = <Pallet<T>>::token_properties((self.id, token_id));367368		keys.map(|keys| {369			keys.into_iter()370			.filter_map(|key| {371				properties.get(&key).map(|value| Property {372					key,373					value: value.clone(),374				})375			})376			.collect()377		}).unwrap_or(378			properties.iter().map(|(key, value)| Property {379				key: key.clone(),380				value: value.clone(),381			})382			.collect()383		)384	}385386	fn total_supply(&self) -> u32 {387		<Pallet<T>>::total_supply(self)388	}389390	fn account_balance(&self, account: T::CrossAccountId) -> u32 {391		<AccountBalance<T>>::get((self.id, account))392	}393394	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {395		if <TokenData<T>>::get((self.id, token))396			.map(|a| a.owner == account)397			.unwrap_or(false)398		{399			1400		} else {401			0402		}403	}404405	fn allowance(406		&self,407		sender: T::CrossAccountId,408		spender: T::CrossAccountId,409		token: TokenId,410	) -> u128 {411		if <TokenData<T>>::get((self.id, token))412			.map(|a| a.owner != sender)413			.unwrap_or(true)414		{415			0416		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {417			1418		} else {419			0420		}421	}422}
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -340,7 +340,7 @@
 			.into_inner()
 	}
 
-	fn token_properties(&self, _token_id: TokenId, _keys: Vec<PropertyKey>) -> Vec<Property> {
+	fn token_properties(&self, _token_id: TokenId, _keys: Option<Vec<PropertyKey>>) -> Vec<Property> {
 		Vec::new()
 	}
 
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -43,20 +43,24 @@
 		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;
 		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
 
-		fn collection_properties(collection: CollectionId, properties: Vec<Vec<u8>>) -> Result<Vec<Property>>;
+		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;
 
 		fn token_properties(
 			collection: CollectionId,
 			token_id: TokenId,
-			properties: Vec<Vec<u8>>
+			properties: Option<Vec<Vec<u8>>>
 		) -> Result<Vec<Property>>;
 
 		fn property_permissions(
 			collection: CollectionId,
-			properties: Vec<Vec<u8>>
+			properties: Option<Vec<Vec<u8>>>
 		) -> Result<Vec<PropertyKeyPermission>>;
 
-		fn token_data(collection: CollectionId, token_id: TokenId, keys: Vec<Vec<u8>>) -> Result<TokenData<CrossAccountId>>;
+		fn token_data(
+			collection: CollectionId,
+			token_id: TokenId,
+			keys: Option<Vec<Vec<u8>>>
+		) -> Result<TokenData<CrossAccountId>>;
 
 		fn total_supply(collection: CollectionId) -> Result<u32>;
 		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -35,9 +35,11 @@
 
                 fn collection_properties(
                     collection: CollectionId,
-                    keys: Vec<Vec<u8>>
+                    keys: Option<Vec<Vec<u8>>>
                 ) -> Result<Vec<Property>, DispatchError> {
-                    let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;
+                    let keys = keys.map(
+                        |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)
+                    ).transpose()?;
 
                     pallet_common::Pallet::<Runtime>::filter_collection_properties(collection, keys)
                 }
@@ -45,17 +47,22 @@
                 fn token_properties(
                     collection: CollectionId,
                     token_id: TokenId,
-                    keys: Vec<Vec<u8>>
+                    keys: Option<Vec<Vec<u8>>>
                 ) -> Result<Vec<Property>, DispatchError> {
-                    let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;
+                    let keys = keys.map(
+                        |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)
+                    ).transpose()?;
+
                     dispatch_unique_runtime!(collection.token_properties(token_id, keys))
                 }
 
                 fn property_permissions(
                     collection: CollectionId,
-                    keys: Vec<Vec<u8>>
+                    keys: Option<Vec<Vec<u8>>>
                 ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {
-                    let keys = pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)?;
+                    let keys = keys.map(
+                        |keys| pallet_common::Pallet::<Runtime>::bytes_keys_to_property_keys(keys)
+                    ).transpose()?;
 
                     pallet_common::Pallet::<Runtime>::filter_property_permissions(collection, keys)
                 }
@@ -63,7 +70,7 @@
                 fn token_data(
                     collection: CollectionId,
                     token_id: TokenId,
-                    keys: Vec<Vec<u8>>
+                    keys: Option<Vec<Vec<u8>>>
                 ) -> Result<TokenData<CrossAccountId>, DispatchError> {
                     let token_data = TokenData {
                         const_data: Self::const_metadata(collection, token_id)?,