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

difftreelog

Add properties RPC

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

8 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -19,7 +19,10 @@
 use codec::Decode;
 use jsonrpc_core::{Error as RpcError, ErrorCode, Result};
 use jsonrpc_derive::rpc;
-use up_data_structs::{RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId};
+use up_data_structs::{
+	RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property, PropertyKey,
+	PropertyKeyPermission,
+};
 use sp_api::{BlockId, BlockT, ProvideRuntimeApi, ApiExt};
 use sp_blockchain::HeaderBackend;
 use up_rpc::UniqueApi as UniqueRuntimeApi;
@@ -76,6 +79,31 @@
 		at: Option<BlockHash>,
 	) -> Result<Vec<u8>>;
 
+	#[rpc(name = "unique_collectionProperties")]
+	fn collection_properties(
+		&self,
+		collection: CollectionId,
+		keys: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<Property>>;
+
+	#[rpc(name = "unique_tokenProperties")]
+	fn token_properties(
+		&self,
+		collection: CollectionId,
+		token_id: TokenId,
+		properties: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<Property>>;
+
+	#[rpc(name = "unique_propertyPermissions")]
+	fn property_permissions(
+		&self,
+		collection: CollectionId,
+		keys: Vec<String>,
+		at: Option<BlockHash>,
+	) -> Result<Vec<PropertyKeyPermission>>;
+
 	#[rpc(name = "unique_totalSupply")]
 	fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
 	#[rpc(name = "unique_accountBalance")]
@@ -177,7 +205,9 @@
 
 macro_rules! pass_method {
 	(
-		$method_name:ident($($name:ident: $ty:ty),* $(,)?) -> $result:ty $(=> $mapper:expr)?
+		$method_name:ident(
+			$($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?
+		) -> $result:ty $(=> $mapper:expr)?
 		$(; changed_in $ver:expr, $changed_method_name:ident ($($changed_name:expr), * $(,)?) => $fixer:expr)*
 	) => {
 		fn $method_name(
@@ -205,7 +235,7 @@
 			let result = $(if _api_version < $ver {
 				api.$changed_method_name(&at, $($changed_name),*).map(|r| r.map($fixer))
 			} else)*
-			{ api.$method_name(&at, $($name),*) };
+			{ api.$method_name(&at, $($((|$map_arg: $ty| $map))? ($name)),*) };
 
 			let result = result.map_err(|e| RpcError {
 				code: ErrorCode::ServerError(Error::RuntimeError.into()),
@@ -242,6 +272,28 @@
 	pass_method!(const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
 	pass_method!(variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
 
+	pass_method!(collection_properties(
+		collection: CollectionId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		keys: Vec<String>
+	) -> Vec<Property>);
+
+	pass_method!(token_properties(
+		collection: CollectionId,
+		token_id: TokenId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		properties: Vec<String>
+	) -> Vec<Property>);
+
+	pass_method!(property_permissions(
+		collection: CollectionId,
+
+		#[map(|keys| string_keys_to_bytes_keys(keys))]
+		keys: Vec<String>
+	) -> Vec<PropertyKeyPermission>);
+
 	pass_method!(total_supply(collection: CollectionId) -> u32);
 	pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);
 	pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
@@ -256,3 +308,7 @@
 	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>);
 	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()
+}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -388,6 +388,7 @@
 
 	/// Collection properties
 	#[pallet::storage]
+	#[pallet::getter(fn collection_properties)]
 	pub type CollectionProperties<T> = StorageMap<
 		Hasher = Blake2_128Concat,
 		Key = CollectionId,
@@ -397,7 +398,7 @@
 	>;
 
 	#[pallet::storage]
-	#[pallet::getter(fn property_permission)]
+	#[pallet::getter(fn property_permissions)]
 	pub type CollectionPropertyPermissions<T> = StorageMap<
 		Hasher = Blake2_128Concat,
 		Key = CollectionId,
@@ -656,9 +657,7 @@
 		CollectionProperties::<T>::insert(
 			id,
 			Properties::from_collection_props_vec(data.properties)
-				.map_err(|e| -> Error::<T> {
-					e.into()
-				})?,
+				.map_err(|e| -> Error<T> { e.into() })?,
 		);
 
 		let token_props_permissions: PropertiesPermissionMap = data
@@ -667,9 +666,7 @@
 			.map(|property| (property.key, property.permission))
 			.collect::<BTreeMap<_, _>>()
 			.try_into()
-			.map_err(|_| -> Error::<T> {
-				PropertiesError::PropertyLimitReached.into()
-			})?;
+			.map_err(|_| -> Error<T> { PropertiesError::PropertyLimitReached.into() })?;
 
 		CollectionPropertyPermissions::<T>::insert(id, token_props_permissions);
 
@@ -754,9 +751,7 @@
 		CollectionProperties::<T>::try_mutate(collection.id, |properties| {
 			properties.try_set_property(property.clone())
 		})
-		.map_err(|e| -> Error::<T> {
-			e.into()
-		})?;
+		.map_err(|e| -> Error<T> { e.into() })?;
 
 		Self::deposit_event(Event::CollectionPropertySet(collection.id, property));
 
@@ -786,7 +781,10 @@
 			properties.remove_property(&property_key);
 		});
 
-		Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, property_key));
+		Self::deposit_event(Event::CollectionPropertyDeleted(
+			collection.id,
+			property_key,
+		));
 
 		Ok(())
 	}
@@ -823,9 +821,7 @@
 			let property_permission = property_permission.clone();
 			permissions.try_insert(property_permission.key, property_permission.permission)
 		})
-		.map_err(|_| -> Error::<T> {
-			PropertiesError::PropertyLimitReached.into()
-		})?;
+		.map_err(|_| -> Error<T> { PropertiesError::PropertyLimitReached.into() })?;
 
 		Self::deposit_event(Event::PropertyPermissionSet(
 			collection.id,
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, BoundedVec};20use up_data_structs::{21	TokenId, CustomDataLimit, 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	}8990	fn set_variable_metadata(bytes: u32) -> Weight {91		<SelfWeightOf<T>>::set_variable_metadata(bytes)92	}93}9495fn map_create_data<T: Config>(96	data: up_data_structs::CreateItemData,97	to: &T::CrossAccountId,98) -> Result<CreateItemData<T>, DispatchError> {99	match data {100		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {101			const_data: data.const_data,102			variable_data: data.variable_data,103			owner: to.clone(),104		}),105		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),106	}107}108109impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {110	fn create_item(111		&self,112		sender: T::CrossAccountId,113		to: T::CrossAccountId,114		data: up_data_structs::CreateItemData,115		nesting_budget: &dyn Budget,116	) -> DispatchResultWithPostInfo {117		with_weight(118			<Pallet<T>>::create_item(119				self,120				&sender,121				map_create_data::<T>(data, &to)?,122				nesting_budget,123			),124			<CommonWeights<T>>::create_item(),125		)126	}127128	fn create_multiple_items(129		&self,130		sender: T::CrossAccountId,131		to: T::CrossAccountId,132		data: Vec<up_data_structs::CreateItemData>,133		nesting_budget: &dyn Budget,134	) -> DispatchResultWithPostInfo {135		let data = data136			.into_iter()137			.map(|d| map_create_data::<T>(d, &to))138			.collect::<Result<Vec<_>, DispatchError>>()?;139140		let amount = data.len();141		with_weight(142			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),143			<CommonWeights<T>>::create_multiple_items(amount as u32),144		)145	}146147	fn create_multiple_items_ex(148		&self,149		sender: <T>::CrossAccountId,150		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,151		nesting_budget: &dyn Budget,152	) -> DispatchResultWithPostInfo {153		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);154		let data = match data {155			up_data_structs::CreateItemExData::NFT(nft) => nft,156			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),157		};158159		with_weight(160			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),161			weight,162		)163	}164165	fn set_collection_properties(166		&self,167		sender: T::CrossAccountId,168		properties: Vec<Property>,169	) -> DispatchResultWithPostInfo {170		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);171172		with_weight(173			<Pallet<T>>::set_collection_properties(self, &sender, properties),174			weight,175		)176	}177178	fn delete_collection_properties(179		&self,180		sender: &T::CrossAccountId,181		property_keys: Vec<PropertyKey>,182	) -> DispatchResultWithPostInfo {183		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);184185		with_weight(186			<Pallet<T>>::delete_collection_properties(self, &sender, property_keys),187			weight188		)189	}190191	fn set_token_properties(192		&self,193		sender: T::CrossAccountId,194		token_id: TokenId,195		properties: Vec<Property>,196	) -> DispatchResultWithPostInfo {197		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);198199		with_weight(200			<Pallet<T>>::set_token_properties(self, &sender, token_id, properties),201			weight,202		)203	}204205	fn delete_token_properties(206		&self,207		sender: T::CrossAccountId,208		token_id: TokenId,209		property_keys: Vec<PropertyKey>,210	) -> DispatchResultWithPostInfo {211		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);212213		with_weight(214			<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),215			weight,216		)217	}218219	fn set_property_permissions(220		&self,221		sender: &T::CrossAccountId,222		property_permissions: Vec<PropertyKeyPermission>,223	) -> DispatchResultWithPostInfo {224		let weight =225			<CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);226227		with_weight(228			<Pallet<T>>::set_property_permissions(self, sender, property_permissions),229			weight,230		)231	}232233	fn burn_item(234		&self,235		sender: T::CrossAccountId,236		token: TokenId,237		amount: u128,238	) -> DispatchResultWithPostInfo {239		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);240		if amount == 1 {241			with_weight(242				<Pallet<T>>::burn(self, &sender, token),243				<CommonWeights<T>>::burn_item(),244			)245		} else {246			Ok(().into())247		}248	}249250	fn transfer(251		&self,252		from: T::CrossAccountId,253		to: T::CrossAccountId,254		token: TokenId,255		amount: u128,256		nesting_budget: &dyn Budget,257	) -> DispatchResultWithPostInfo {258		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);259		if amount == 1 {260			with_weight(261				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),262				<CommonWeights<T>>::transfer(),263			)264		} else {265			Ok(().into())266		}267	}268269	fn approve(270		&self,271		sender: T::CrossAccountId,272		spender: T::CrossAccountId,273		token: TokenId,274		amount: u128,275	) -> DispatchResultWithPostInfo {276		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);277278		with_weight(279			if amount == 1 {280				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))281			} else {282				<Pallet<T>>::set_allowance(self, &sender, token, None)283			},284			<CommonWeights<T>>::approve(),285		)286	}287288	fn transfer_from(289		&self,290		sender: T::CrossAccountId,291		from: T::CrossAccountId,292		to: T::CrossAccountId,293		token: TokenId,294		amount: u128,295		nesting_budget: &dyn Budget,296	) -> DispatchResultWithPostInfo {297		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);298299		if amount == 1 {300			with_weight(301				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),302				<CommonWeights<T>>::transfer_from(),303			)304		} else {305			Ok(().into())306		}307	}308309	fn burn_from(310		&self,311		sender: T::CrossAccountId,312		from: T::CrossAccountId,313		token: TokenId,314		amount: u128,315		nesting_budget: &dyn Budget,316	) -> DispatchResultWithPostInfo {317		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);318319		if amount == 1 {320			with_weight(321				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),322				<CommonWeights<T>>::burn_from(),323			)324		} else {325			Ok(().into())326		}327	}328329	fn set_variable_metadata(330		&self,331		sender: T::CrossAccountId,332		token: TokenId,333		data: BoundedVec<u8, CustomDataLimit>,334	) -> DispatchResultWithPostInfo {335		let len = data.len();336		with_weight(337			<Pallet<T>>::set_variable_metadata(self, &sender, token, data),338			<CommonWeights<T>>::set_variable_metadata(len as u32),339		)340	}341342	fn check_nesting(343		&self,344		sender: T::CrossAccountId,345		from: (CollectionId, TokenId),346		under: TokenId,347		budget: &dyn Budget,348	) -> sp_runtime::DispatchResult {349		<Pallet<T>>::check_nesting(self, sender, from, under, budget)350	}351352	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {353		<Owned<T>>::iter_prefix((self.id, account))354			.map(|(id, _)| id)355			.collect()356	}357358	fn collection_tokens(&self) -> Vec<TokenId> {359		<TokenData<T>>::iter_prefix((self.id,))360			.map(|(id, _)| id)361			.collect()362	}363364	fn token_exists(&self, token: TokenId) -> bool {365		<Pallet<T>>::token_exists(self, token)366	}367368	fn last_token_id(&self) -> TokenId {369		TokenId(<TokensMinted<T>>::get(self.id))370	}371372	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {373		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)374	}375	fn const_metadata(&self, token: TokenId) -> Vec<u8> {376		<TokenData<T>>::get((self.id, token))377			.map(|t| t.const_data)378			.unwrap_or_default()379			.into_inner()380	}381	fn variable_metadata(&self, token: TokenId) -> Vec<u8> {382		<TokenData<T>>::get((self.id, token))383			.map(|t| t.variable_data)384			.unwrap_or_default()385			.into_inner()386	}387388	fn total_supply(&self) -> u32 {389		<Pallet<T>>::total_supply(self)390	}391392	fn account_balance(&self, account: T::CrossAccountId) -> u32 {393		<AccountBalance<T>>::get((self.id, account))394	}395396	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {397		if <TokenData<T>>::get((self.id, token))398			.map(|a| a.owner == account)399			.unwrap_or(false)400		{401			1402		} else {403			0404		}405	}406407	fn allowance(408		&self,409		sender: T::CrossAccountId,410		spender: T::CrossAccountId,411		token: TokenId,412	) -> u128 {413		if <TokenData<T>>::get((self.id, token))414			.map(|a| a.owner != sender)415			.unwrap_or(true)416		{417			0418		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {419			1420		} else {421			0422		}423	}424}
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, BoundedVec};20use up_data_structs::{21	TokenId, CustomDataLimit, 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	}8990	fn set_variable_metadata(bytes: u32) -> Weight {91		<SelfWeightOf<T>>::set_variable_metadata(bytes)92	}93}9495fn map_create_data<T: Config>(96	data: up_data_structs::CreateItemData,97	to: &T::CrossAccountId,98) -> Result<CreateItemData<T>, DispatchError> {99	match data {100		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {101			const_data: data.const_data,102			variable_data: data.variable_data,103			owner: to.clone(),104		}),105		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),106	}107}108109impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {110	fn create_item(111		&self,112		sender: T::CrossAccountId,113		to: T::CrossAccountId,114		data: up_data_structs::CreateItemData,115		nesting_budget: &dyn Budget,116	) -> DispatchResultWithPostInfo {117		with_weight(118			<Pallet<T>>::create_item(119				self,120				&sender,121				map_create_data::<T>(data, &to)?,122				nesting_budget,123			),124			<CommonWeights<T>>::create_item(),125		)126	}127128	fn create_multiple_items(129		&self,130		sender: T::CrossAccountId,131		to: T::CrossAccountId,132		data: Vec<up_data_structs::CreateItemData>,133		nesting_budget: &dyn Budget,134	) -> DispatchResultWithPostInfo {135		let data = data136			.into_iter()137			.map(|d| map_create_data::<T>(d, &to))138			.collect::<Result<Vec<_>, DispatchError>>()?;139140		let amount = data.len();141		with_weight(142			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),143			<CommonWeights<T>>::create_multiple_items(amount as u32),144		)145	}146147	fn create_multiple_items_ex(148		&self,149		sender: <T>::CrossAccountId,150		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,151		nesting_budget: &dyn Budget,152	) -> DispatchResultWithPostInfo {153		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);154		let data = match data {155			up_data_structs::CreateItemExData::NFT(nft) => nft,156			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),157		};158159		with_weight(160			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),161			weight,162		)163	}164165	fn set_collection_properties(166		&self,167		sender: T::CrossAccountId,168		properties: Vec<Property>,169	) -> DispatchResultWithPostInfo {170		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);171172		with_weight(173			<Pallet<T>>::set_collection_properties(self, &sender, properties),174			weight,175		)176	}177178	fn delete_collection_properties(179		&self,180		sender: &T::CrossAccountId,181		property_keys: Vec<PropertyKey>,182	) -> DispatchResultWithPostInfo {183		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);184185		with_weight(186			<Pallet<T>>::delete_collection_properties(self, &sender, property_keys),187			weight,188		)189	}190191	fn set_token_properties(192		&self,193		sender: T::CrossAccountId,194		token_id: TokenId,195		properties: Vec<Property>,196	) -> DispatchResultWithPostInfo {197		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);198199		with_weight(200			<Pallet<T>>::set_token_properties(self, &sender, token_id, properties),201			weight,202		)203	}204205	fn delete_token_properties(206		&self,207		sender: T::CrossAccountId,208		token_id: TokenId,209		property_keys: Vec<PropertyKey>,210	) -> DispatchResultWithPostInfo {211		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);212213		with_weight(214			<Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),215			weight,216		)217	}218219	fn set_property_permissions(220		&self,221		sender: &T::CrossAccountId,222		property_permissions: Vec<PropertyKeyPermission>,223	) -> DispatchResultWithPostInfo {224		let weight =225			<CommonWeights<T>>::set_property_permissions(property_permissions.len() as u32);226227		with_weight(228			<Pallet<T>>::set_property_permissions(self, sender, property_permissions),229			weight,230		)231	}232233	fn burn_item(234		&self,235		sender: T::CrossAccountId,236		token: TokenId,237		amount: u128,238	) -> DispatchResultWithPostInfo {239		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);240		if amount == 1 {241			with_weight(242				<Pallet<T>>::burn(self, &sender, token),243				<CommonWeights<T>>::burn_item(),244			)245		} else {246			Ok(().into())247		}248	}249250	fn transfer(251		&self,252		from: T::CrossAccountId,253		to: T::CrossAccountId,254		token: TokenId,255		amount: u128,256		nesting_budget: &dyn Budget,257	) -> DispatchResultWithPostInfo {258		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);259		if amount == 1 {260			with_weight(261				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),262				<CommonWeights<T>>::transfer(),263			)264		} else {265			Ok(().into())266		}267	}268269	fn approve(270		&self,271		sender: T::CrossAccountId,272		spender: T::CrossAccountId,273		token: TokenId,274		amount: u128,275	) -> DispatchResultWithPostInfo {276		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);277278		with_weight(279			if amount == 1 {280				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))281			} else {282				<Pallet<T>>::set_allowance(self, &sender, token, None)283			},284			<CommonWeights<T>>::approve(),285		)286	}287288	fn transfer_from(289		&self,290		sender: T::CrossAccountId,291		from: T::CrossAccountId,292		to: T::CrossAccountId,293		token: TokenId,294		amount: u128,295		nesting_budget: &dyn Budget,296	) -> DispatchResultWithPostInfo {297		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);298299		if amount == 1 {300			with_weight(301				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),302				<CommonWeights<T>>::transfer_from(),303			)304		} else {305			Ok(().into())306		}307	}308309	fn burn_from(310		&self,311		sender: T::CrossAccountId,312		from: T::CrossAccountId,313		token: TokenId,314		amount: u128,315		nesting_budget: &dyn Budget,316	) -> DispatchResultWithPostInfo {317		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);318319		if amount == 1 {320			with_weight(321				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),322				<CommonWeights<T>>::burn_from(),323			)324		} else {325			Ok(().into())326		}327	}328329	fn set_variable_metadata(330		&self,331		sender: T::CrossAccountId,332		token: TokenId,333		data: BoundedVec<u8, CustomDataLimit>,334	) -> DispatchResultWithPostInfo {335		let len = data.len();336		with_weight(337			<Pallet<T>>::set_variable_metadata(self, &sender, token, data),338			<CommonWeights<T>>::set_variable_metadata(len as u32),339		)340	}341342	fn check_nesting(343		&self,344		sender: T::CrossAccountId,345		from: (CollectionId, TokenId),346		under: TokenId,347		budget: &dyn Budget,348	) -> sp_runtime::DispatchResult {349		<Pallet<T>>::check_nesting(self, sender, from, under, budget)350	}351352	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {353		<Owned<T>>::iter_prefix((self.id, account))354			.map(|(id, _)| id)355			.collect()356	}357358	fn collection_tokens(&self) -> Vec<TokenId> {359		<TokenData<T>>::iter_prefix((self.id,))360			.map(|(id, _)| id)361			.collect()362	}363364	fn token_exists(&self, token: TokenId) -> bool {365		<Pallet<T>>::token_exists(self, token)366	}367368	fn last_token_id(&self) -> TokenId {369		TokenId(<TokensMinted<T>>::get(self.id))370	}371372	fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId> {373		<TokenData<T>>::get((self.id, token)).map(|t| t.owner)374	}375	fn const_metadata(&self, token: TokenId) -> Vec<u8> {376		<TokenData<T>>::get((self.id, token))377			.map(|t| t.const_data)378			.unwrap_or_default()379			.into_inner()380	}381	fn variable_metadata(&self, token: TokenId) -> Vec<u8> {382		<TokenData<T>>::get((self.id, token))383			.map(|t| t.variable_data)384			.unwrap_or_default()385			.into_inner()386	}387388	fn total_supply(&self) -> u32 {389		<Pallet<T>>::total_supply(self)390	}391392	fn account_balance(&self, account: T::CrossAccountId) -> u32 {393		<AccountBalance<T>>::get((self.id, account))394	}395396	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {397		if <TokenData<T>>::get((self.id, token))398			.map(|a| a.owner == account)399			.unwrap_or(false)400		{401			1402		} else {403			0404		}405	}406407	fn allowance(408		&self,409		sender: T::CrossAccountId,410		spender: T::CrossAccountId,411		token: TokenId,412	) -> u128 {413		if <TokenData<T>>::get((self.id, token))414			.map(|a| a.owner != sender)415			.unwrap_or(true)416		{417			0418		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {419			1420		} else {421			0422		}423	}424}
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -96,6 +96,7 @@
 	>;
 
 	#[pallet::storage]
+	#[pallet::getter(fn token_properties)]
 	pub type TokenProperties<T: Config> = StorageNMap<
 		Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),
 		Value = up_data_structs::Properties,
@@ -265,9 +266,8 @@
 
 		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {
 			properties.try_set_property(property.clone())
-		}).map_err(|e| -> CommonError::<T> {
-			e.into()
-		})?;
+		})
+		.map_err(|e| -> CommonError<T> { e.into() })?;
 
 		<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
 			collection.id,
@@ -318,7 +318,7 @@
 		token_id: TokenId,
 		property_key: &PropertyKey,
 	) -> DispatchResult {
-		let permission = <PalletCommon<T>>::property_permission(collection.id)
+		let permission = <PalletCommon<T>>::property_permissions(collection.id)
 			.get(property_key)
 			.map(|p| p.clone())
 			.unwrap_or(PropertyPermission::None);
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -634,6 +634,7 @@
 pub type PropertyValue = BoundedVec<u8, ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;
 
 #[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub enum PropertyPermission {
 	None,
 	AdminConst,
@@ -644,14 +645,21 @@
 }
 
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct Property {
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub key: PropertyKey,
+
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub value: PropertyValue,
 }
 
 #[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]
+#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct PropertyKeyPermission {
+	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
 	pub key: PropertyKey,
+
 	pub permission: PropertyPermission,
 }
 
@@ -723,6 +731,10 @@
 	pub fn get_property(&self, key: &PropertyKey) -> Option<&PropertyValue> {
 		self.map.get(key)
 	}
+
+	pub fn iter(&self) -> impl Iterator<Item = (&PropertyKey, &PropertyValue)> {
+		self.map.iter()
+	}
 }
 
 pub struct CollectionProperties;
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,7 +16,10 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use up_data_structs::{CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits};
+use up_data_structs::{
+	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property, PropertyKey,
+	PropertyKeyPermission,
+};
 use sp_std::vec::Vec;
 use codec::Decode;
 use sp_runtime::DispatchError;
@@ -41,6 +44,19 @@
 		fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
 		fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
 
+		fn collection_properties(collection: CollectionId, properties: Vec<Vec<u8>>) -> Result<Vec<Property>>;
+
+		fn token_properties(
+			collection: CollectionId,
+			token_id: TokenId,
+			properties: Vec<Vec<u8>>
+		) -> Result<Vec<Property>>;
+
+		fn property_permissions(
+			collection: CollectionId,
+			properties: Vec<Vec<u8>>
+		) -> Result<Vec<PropertyKeyPermission>>;
+
 		fn total_supply(collection: CollectionId) -> Result<u32>;
 		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;
 		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -7,6 +7,14 @@
             $($custom_apis:tt)+
         )?
     ) => {
+        fn bytes_keys_to_property_keys(keys: Vec<Vec<u8>>) -> Result<Vec<PropertyKey>, DispatchError> {
+            keys.into_iter()
+                .map(|key| -> Result<PropertyKey, DispatchError> {
+                    key.try_into().map_err(|_| DispatchError::Other("Can't read property key"))
+                })
+                .collect::<Result<Vec<PropertyKey>, DispatchError>>()
+        }
+
         impl_runtime_apis! {
             $($($custom_apis)+)?
 
@@ -36,6 +44,76 @@
                     dispatch_unique_runtime!(collection.variable_metadata(token))
                 }
 
+                fn collection_properties(
+                    collection: CollectionId,
+                    keys: Vec<Vec<u8>>
+                ) -> Result<Vec<Property>, DispatchError> {
+                    let keys = bytes_keys_to_property_keys(keys)?;
+
+                    let properties = pallet_common::Pallet::<Runtime>::collection_properties(collection);
+
+                    let properties = keys.into_iter()
+                        .filter_map(|key| {
+                            properties.get_property(&key)
+                                .map(|value| {
+                                    Property {
+                                        key,
+                                        value: value.clone()
+                                    }
+                                })
+                        })
+                        .collect();
+
+                    Ok(properties)
+                }
+
+                fn token_properties(
+                    collection: CollectionId,
+                    token_id: TokenId,
+                    keys: Vec<Vec<u8>>
+                ) -> Result<Vec<Property>, DispatchError> {
+                    let keys = bytes_keys_to_property_keys(keys)?;
+
+                    let properties = pallet_nonfungible::Pallet::<Runtime>::token_properties((collection, token_id));
+
+                    let properties = keys.into_iter()
+                        .filter_map(|key| {
+                            properties.get_property(&key)
+                                .map(|value| {
+                                    Property {
+                                        key,
+                                        value: value.clone()
+                                    }
+                                })
+                        })
+                        .collect();
+
+                    Ok(properties)
+                }
+
+                fn property_permissions(
+                    collection: CollectionId,
+                    keys: Vec<Vec<u8>>
+                ) -> Result<Vec<PropertyKeyPermission>, DispatchError> {
+                    let keys = bytes_keys_to_property_keys(keys)?;
+
+                    let permissions = pallet_common::Pallet::<Runtime>::property_permissions(collection);
+
+                    let key_permissions = keys.into_iter()
+                        .filter_map(|key| {
+                            permissions.get(&key)
+                                .map(|permission| {
+                                    PropertyKeyPermission {
+                                        key,
+                                        permission: permission.clone()
+                                    }
+                                })
+                        })
+                        .collect();
+
+                    Ok(key_permissions)
+                }
+
                 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {
                     dispatch_unique_runtime!(collection.total_supply())
                 }
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,7 +67,7 @@
 	},
 };
 use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};
-use up_data_structs::{CollectionId, TokenId, CollectionStats, CollectionLimits, RpcCollection};
+use up_data_structs::*;
 // use pallet_contracts::weights::WeightInfo;
 // #[cfg(any(feature = "std", test))]
 use frame_system::{