git.delta.rocks / unique-network / refs/commits / 415353264b69

difftreelog

style reformat code

Yaroslav Bolyukin2022-05-30parent: #d048005.patch.diff
in: master

19 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -30,8 +30,7 @@
 // RMRK
 use rmrk_rpc::RmrkApi as RmrkRuntimeApi;
 use up_data_structs::{
-	RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName,
-	RmrkResourceId,
+	RmrkCollectionId, RmrkNftId, RmrkBaseId, RmrkNftChild, RmrkThemeName, RmrkResourceId,
 };
 
 pub use rmrk_unique_rpc::RmrkApi;
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -364,7 +364,8 @@
 			RmrkBaseInfo<AccountId>,
 			RmrkPartType,
 			RmrkTheme,
-		>*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+		>*/
+		+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
 		+ sp_api::Metadata<Block>
 		+ sp_offchain::OffchainWorkerApi<Block>
 		+ cumulus_primitives_core::CollectCollationInfo<Block>,
@@ -656,7 +657,8 @@
 			RmrkBaseInfo<AccountId>,
 			RmrkPartType,
 			RmrkTheme,
-		>*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+		>*/
+		+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
 		+ sp_api::Metadata<Block>
 		+ sp_offchain::OffchainWorkerApi<Block>
 		+ cumulus_primitives_core::CollectCollationInfo<Block>
@@ -800,7 +802,8 @@
 			RmrkBaseInfo<AccountId>,
 			RmrkPartType,
 			RmrkTheme,
-		>*/ + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
+		>*/
+		+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
 		+ sp_api::Metadata<Block>
 		+ sp_offchain::OffchainWorkerApi<Block>
 		+ cumulus_primitives_core::CollectCollationInfo<Block>
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -501,7 +501,6 @@
 			PhantomType<(
 				TokenData<T::CrossAccountId>,
 				RpcCollection<T::AccountId>,
-
 				// RMRK
 				RmrkCollectionInfo<T::AccountId>,
 				RmrkInstanceInfo<T::AccountId>,
@@ -526,19 +525,34 @@
 					if !v.offchain_schema.is_empty() {
 						props.push(Property {
 							key: b"_old_offchainSchema".to_vec().try_into().unwrap(),
-							value: v.offchain_schema.clone().into_inner().try_into().expect("offchain schema too big"),
+							value: v
+								.offchain_schema
+								.clone()
+								.into_inner()
+								.try_into()
+								.expect("offchain schema too big"),
 						});
 					}
 					if !v.variable_on_chain_schema.is_empty() {
 						props.push(Property {
 							key: b"_old_variableOnChainSchema".to_vec().try_into().unwrap(),
-							value: v.variable_on_chain_schema.clone().into_inner().try_into().expect("offchain schema too big"),
+							value: v
+								.variable_on_chain_schema
+								.clone()
+								.into_inner()
+								.try_into()
+								.expect("offchain schema too big"),
 						});
 					}
 					if !v.const_on_chain_schema.is_empty() {
 						props.push(Property {
 							key: b"_old_constOnChainSchema".to_vec().try_into().unwrap(),
-							value: v.const_on_chain_schema.clone().into_inner().try_into().expect("offchain schema too big"),
+							value: v
+								.const_on_chain_schema
+								.clone()
+								.into_inner()
+								.try_into()
+								.expect("offchain schema too big"),
 						});
 					}
 					props.push(Property {
@@ -546,13 +560,17 @@
 						value: match v.schema_version {
 							SchemaVersion::ImageURL => b"ImageUrl".as_slice(),
 							SchemaVersion::Unique => b"Unique".as_slice(),
-						}.to_vec().try_into().unwrap(),
+						}
+						.to_vec()
+						.try_into()
+						.unwrap(),
 					});
 					Self::set_scoped_collection_properties(
 						id,
 						PropertyScope::None,
 						props.into_iter(),
-					).expect("existing data larger than properties");
+					)
+					.expect("existing data larger than properties");
 					let mut new = CollectionVersion2::from(v.clone());
 					new.permissions.access = Some(v.access);
 					new.permissions.mint_mode = Some(v.mint_mode);
@@ -644,18 +662,12 @@
 
 		let token_property_permissions = <CollectionPropertyPermissions<T>>::get(collection)
 			.into_iter()
-			.map(|(key, permission)| PropertyKeyPermission {
-				key,
-				permission,
-			})
+			.map(|(key, permission)| PropertyKeyPermission { key, permission })
 			.collect();
 
 		let properties = <CollectionProperties<T>>::get(collection)
 			.into_iter()
-			.map(|(key, value)| Property {
-				key,
-				value,
-			})
+			.map(|(key, value)| Property { key, value })
 			.collect();
 
 		let permissions = CollectionPermissions {
@@ -751,7 +763,9 @@
 				.unwrap_or_else(|| Ok(CollectionLimits::default()))?,
 			permissions: data
 				.permissions
-				.map(|permissions| Self::clamp_permissions(data.mode.clone(), &Default::default(), permissions))
+				.map(|permissions| {
+					Self::clamp_permissions(data.mode.clone(), &Default::default(), permissions)
+				})
 				.unwrap_or_else(|| Ok(CollectionPermissions::default()))?,
 		};
 
@@ -1005,10 +1019,7 @@
 			.unwrap_or_else(|| {
 				properties
 					.into_iter()
-					.map(|(key, value)| Property {
-						key,
-						value,
-					})
+					.map(|(key, value)| Property { key, value })
 					.collect()
 			});
 
@@ -1037,10 +1048,7 @@
 			.unwrap_or_else(|| {
 				permissions
 					.into_iter()
-					.map(|(key, permission)| PropertyKeyPermission {
-						key,
-						permission,
-					})
+					.map(|(key, permission)| PropertyKeyPermission { key, permission })
 					.collect()
 			});
 
@@ -1276,17 +1284,9 @@
 		budget: &dyn Budget,
 	) -> DispatchResult;
 
-	fn nest(
-		&self,
-		under: TokenId,
-		to_nest: (CollectionId, TokenId)
-	);
+	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));
 
-	fn unnest(
-		&self,
-		under: TokenId,
-		to_nest: (CollectionId, TokenId)
-	);
+	fn unnest(&self, under: TokenId, to_nest: (CollectionId, TokenId));
 
 	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;
 	fn collection_tokens(&self) -> Vec<TokenId>;
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -298,17 +298,9 @@
 		fail!(<Error<T>>::FungibleDisallowsNesting)
 	}
 
-	fn nest(
-		&self,
-		_under: TokenId,
-		_to_nest: (CollectionId, TokenId)
-	) {}
+	fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}
 
-	fn unnest(
-		&self,
-		_under: TokenId,
-		_to_nest: (CollectionId, TokenId)
-	) {}
+	fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}
 
 	fn collection_tokens(&self) -> Vec<TokenId> {
 		vec![TokenId::default()]
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -184,11 +184,7 @@
 
 		if balance == 0 {
 			<Balance<T>>::remove((collection.id, owner));
-			<PalletStructure<T>>::unnest_if_nested(
-				owner,
-				collection.id,
-				TokenId::default()
-			);
+			<PalletStructure<T>>::unnest_if_nested(owner, collection.id, TokenId::default());
 		} else {
 			<Balance<T>>::insert((collection.id, owner), balance);
 		}
@@ -249,18 +245,14 @@
 			to,
 			collection.id,
 			TokenId::default(),
-			nesting_budget
+			nesting_budget,
 		)?;
 
 		if let Some(balance_to) = balance_to {
 			// from != to
 			if balance_from == 0 {
 				<Balance<T>>::remove((collection.id, from));
-				<PalletStructure<T>>::unnest_if_nested(
-					from,
-					collection.id,
-					TokenId::default()
-				);
+				<PalletStructure<T>>::unnest_if_nested(from, collection.id, TokenId::default());
 			} else {
 				<Balance<T>>::insert((collection.id, from), balance_from);
 			}
@@ -333,7 +325,11 @@
 		<TotalSupply<T>>::insert(collection.id, total_supply);
 		for (user, amount) in balances {
 			<Balance<T>>::insert((collection.id, &user), amount);
-			<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId::default());
+			<PalletStructure<T>>::nest_if_sent_to_token_unchecked(
+				&user,
+				collection.id,
+				TokenId::default(),
+			);
 			<PalletEvm<T>>::deposit_log(
 				ERC20Events::Transfer {
 					from: H160::default(),
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -22,7 +22,7 @@
 	PropertyKeyPermission, PropertyValue,
 };
 use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, with_weight, weights::WeightInfo as _
+	CommonCollectionOperations, CommonWeightInfo, with_weight, weights::WeightInfo as _,
 };
 use sp_runtime::DispatchError;
 use sp_std::vec::Vec;
@@ -353,19 +353,11 @@
 		<Pallet<T>>::check_nesting(self, sender, from, under, budget)
 	}
 
-	fn nest(
-		&self,
-		under: TokenId,
-		to_nest: (CollectionId, TokenId)
-	) {
+	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {
 		<Pallet<T>>::nest((self.id, under), to_nest);
 	}
 
-	fn unnest(
-		&self,
-		under: TokenId,
-		to_unnest: (CollectionId, TokenId)
-	) {
+	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {
 		<Pallet<T>>::unnest((self.id, under), to_unnest);
 	}
 
@@ -415,10 +407,7 @@
 		.unwrap_or_else(|| {
 			properties
 				.into_iter()
-				.map(|(key, value)| Property {
-					key,
-					value,
-				})
+				.map(|(key, value)| Property { key, value })
 				.collect()
 		})
 	}
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -426,11 +426,10 @@
 	Ok(a)
 }
 
-fn has_token_permission<T: Config>(
-	collection_id: CollectionId,
-	key: &PropertyKey,
-) -> bool {
-	if let Ok(token_property_permissions) = CollectionPropertyPermissions::<T>::try_get(collection_id) {
+fn has_token_permission<T: Config>(collection_id: CollectionId, key: &PropertyKey) -> bool {
+	if let Ok(token_property_permissions) =
+		CollectionPropertyPermissions::<T>::try_get(collection_id)
+	{
 		return token_property_permissions.contains_key(key);
 	}
 
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -164,31 +164,44 @@
 		fn on_runtime_upgrade() -> Weight {
 			if StorageVersion::get::<Pallet<T>>() < StorageVersion::new(1) {
 				let mut had_consts = BTreeSet::new();
-				<TokenData<T>>::translate::<ItemDataVersion1<T::CrossAccountId>, _>(|(collection, token), v| {
-					let mut props = vec![];
-					if !v.const_data.is_empty() {
-						props.push(Property {
-							key: b"_old_constData".to_vec().try_into().unwrap(),
-							value: v.const_data.clone().into_inner().try_into().expect("const too long"),
-						});
-						had_consts.insert(collection);
-					}
-					if !v.variable_data.is_empty() {
-						props.push(Property {
-							key: b"_old_variableData".to_vec().try_into().unwrap(),
-							value: v.variable_data.clone().into_inner().try_into().expect("variable too long"),
-						})
-					}
-					if !props.is_empty() {
-						Self::set_scoped_token_properties(
-							collection,
-							token,
-							PropertyScope::None,
-							props.into_iter(),
-						).expect("existing token data exceeds property storage");
-					}
-					Some(<ItemDataVersion2<T::CrossAccountId>>::from(v))
-				});
+				<TokenData<T>>::translate::<ItemDataVersion1<T::CrossAccountId>, _>(
+					|(collection, token), v| {
+						let mut props = vec![];
+						if !v.const_data.is_empty() {
+							props.push(Property {
+								key: b"_old_constData".to_vec().try_into().unwrap(),
+								value: v
+									.const_data
+									.clone()
+									.into_inner()
+									.try_into()
+									.expect("const too long"),
+							});
+							had_consts.insert(collection);
+						}
+						if !v.variable_data.is_empty() {
+							props.push(Property {
+								key: b"_old_variableData".to_vec().try_into().unwrap(),
+								value: v
+									.variable_data
+									.clone()
+									.into_inner()
+									.try_into()
+									.expect("variable too long"),
+							})
+						}
+						if !props.is_empty() {
+							Self::set_scoped_token_properties(
+								collection,
+								token,
+								PropertyScope::None,
+								props.into_iter(),
+							)
+							.expect("existing token data exceeds property storage");
+						}
+						Some(<ItemDataVersion2<T::CrossAccountId>>::from(v))
+					},
+				);
 				for collection in had_consts {
 					<PalletCommon<T>>::set_property_permission_unchecked(
 						collection,
@@ -199,8 +212,9 @@
 								collection_admin: true,
 								token_owner: false,
 							},
-						}
-					).expect("failed to configure permission");
+						},
+					)
+					.expect("failed to configure permission");
 				}
 			}
 
@@ -263,7 +277,7 @@
 		collection_id: CollectionId,
 		token_id: TokenId,
 		scope: PropertyScope,
-		properties: impl Iterator<Item=Property>,
+		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)
@@ -347,11 +361,7 @@
 			<AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);
 		}
 
-		<PalletStructure<T>>::unnest_if_nested(
-			&token_data.owner,
-			collection.id,
-			token
-		);
+		<PalletStructure<T>>::unnest_if_nested(&token_data.owner, collection.id, token);
 
 		<Owned<T>>::remove((collection.id, &token_data.owner, token));
 		<TokensBurnt<T>>::insert(collection.id, burnt);
@@ -589,16 +599,12 @@
 			to,
 			collection.id,
 			token,
-			nesting_budget
+			nesting_budget,
 		)?;
 
 		// =========
 
-		<PalletStructure<T>>::unnest_if_nested(
-			from,
-			collection.id,
-			token
-		);
+		<PalletStructure<T>>::unnest_if_nested(from, collection.id, token);
 
 		<TokenData<T>>::insert(
 			(collection.id, token),
@@ -709,7 +715,11 @@
 					},
 				);
 
-				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&data.owner, collection.id, TokenId(token));
+				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(
+					&data.owner,
+					collection.id,
+					TokenId(token),
+				);
 
 				if let Err(e) = Self::set_token_properties(
 					collection,
@@ -958,31 +968,24 @@
 		Ok(())
 	}
 
-	fn nest(
-		under: (CollectionId, TokenId),
-		to_nest: (CollectionId, TokenId),
-	) {
-		<TokenChildren<T>>::insert(
-			(under.0, under.1, (to_nest.0, to_nest.1)),
-			true
-		);
+	fn nest(under: (CollectionId, TokenId), to_nest: (CollectionId, TokenId)) {
+		<TokenChildren<T>>::insert((under.0, under.1, (to_nest.0, to_nest.1)), true);
 	}
 
-	fn unnest(
-		under: (CollectionId, TokenId),
-		to_unnest: (CollectionId, TokenId),
-	) {
-		<TokenChildren<T>>::remove(
-			(under.0, under.1, to_unnest)
-		);
+	fn unnest(under: (CollectionId, TokenId), to_unnest: (CollectionId, TokenId)) {
+		<TokenChildren<T>>::remove((under.0, under.1, to_unnest));
 	}
 
 	fn collection_has_tokens(collection_id: CollectionId) -> bool {
-		<TokenData<T>>::iter_prefix((collection_id,)).next().is_some()
+		<TokenData<T>>::iter_prefix((collection_id,))
+			.next()
+			.is_some()
 	}
 
 	fn token_has_children(collection_id: CollectionId, token_id: TokenId) -> bool {
-		<TokenChildren<T>>::iter_prefix((collection_id, token_id)).next().is_some()
+		<TokenChildren<T>>::iter_prefix((collection_id, token_id))
+			.next()
+			.is_some()
 	}
 
 	/// Delegated to `create_multiple_items`
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -21,7 +21,9 @@
 use sp_runtime::{DispatchError, Permill, traits::StaticLookup};
 use sp_std::vec::Vec;
 use up_data_structs::*;
-use pallet_common::{Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations};
+use pallet_common::{
+	Pallet as PalletCommon, Error as CommonError, CollectionHandle, CommonCollectionOperations,
+};
 use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle, TokenData};
 use pallet_evm::account::CrossAccountId;
 use core::convert::AsRef;
@@ -38,18 +40,17 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-    use super::*;
-    use pallet_evm::account;
+	use super::*;
+	use pallet_evm::account;
 
 	#[pallet::config]
-	pub trait Config: frame_system::Config
-                    + pallet_common::Config
-                    + pallet_nonfungible::Config
-                    + account::Config {
+	pub trait Config:
+		frame_system::Config + pallet_common::Config + pallet_nonfungible::Config + account::Config
+	{
 		type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
 	}
 
-    #[pallet::storage]
+	#[pallet::storage]
 	#[pallet::getter(fn collection_index)]
 	pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;
 
@@ -60,33 +61,33 @@
 	#[pallet::event]
 	#[pallet::generate_deposit(pub(super) fn deposit_event)]
 	pub enum Event<T: Config> {
-        CollectionCreated {
+		CollectionCreated {
 			issuer: T::AccountId,
 			collection_id: RmrkCollectionId,
 		},
-        CollectionDestroyed {
+		CollectionDestroyed {
 			issuer: T::AccountId,
 			collection_id: RmrkCollectionId,
 		},
-        IssuerChanged {
+		IssuerChanged {
 			old_issuer: T::AccountId,
 			new_issuer: T::AccountId,
 			collection_id: RmrkCollectionId,
 		},
-        CollectionLocked {
+		CollectionLocked {
 			issuer: T::AccountId,
 			collection_id: RmrkCollectionId,
 		},
-        NftMinted {
+		NftMinted {
 			owner: T::AccountId,
 			collection_id: RmrkCollectionId,
 			nft_id: RmrkNftId,
 		},
-        NFTBurned {
+		NFTBurned {
 			owner: T::AccountId,
 			nft_id: RmrkNftId,
 		},
-        PropertySet {
+		PropertySet {
 			collection_id: RmrkCollectionId,
 			maybe_nft_id: Option<RmrkNftId>,
 			key: RmrkKeyString,
@@ -96,24 +97,24 @@
 
 	#[pallet::error]
 	pub enum Error<T> {
-        /* Unique-specific events */
-        CorruptedCollectionType,
-        NftTypeEncodeError,
-        RmrkPropertyKeyIsTooLong,
-        RmrkPropertyValueIsTooLong,
+		/* Unique-specific events */
+		CorruptedCollectionType,
+		NftTypeEncodeError,
+		RmrkPropertyKeyIsTooLong,
+		RmrkPropertyValueIsTooLong,
 
-        /* RMRK compatible events */
-        CollectionNotEmpty,
-        NoAvailableCollectionId,
-        NoAvailableNftId,
-        CollectionUnknown,
-        NoPermission,
-        CollectionFullOrLocked,
+		/* RMRK compatible events */
+		CollectionNotEmpty,
+		NoAvailableCollectionId,
+		NoAvailableNftId,
+		CollectionUnknown,
+		NoPermission,
+		CollectionFullOrLocked,
 	}
 
 	#[pallet::call]
 	impl<T: Config> Pallet<T> {
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn create_collection(
 			origin: OriginFor<T>,
@@ -121,127 +122,141 @@
 			max: Option<u32>,
 			symbol: RmrkCollectionSymbol,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
+			let sender = ensure_signed(origin)?;
 
-            let limits = CollectionLimits {
-                owner_can_transfer: Some(false),
-                token_limit: max,
-                ..Default::default()
-            };
+			let limits = CollectionLimits {
+				owner_can_transfer: Some(false),
+				token_limit: max,
+				..Default::default()
+			};
 
-            let data = CreateCollectionData {
-                limits: Some(limits),
-                token_prefix: symbol.into_inner()
-                    .try_into()
-                    .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,
-                ..Default::default()
-            };
+			let data = CreateCollectionData {
+				limits: Some(limits),
+				token_prefix: symbol
+					.into_inner()
+					.try_into()
+					.map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,
+				..Default::default()
+			};
 
-            let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
+			let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
 
-            if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
-                return Err(<Error<T>>::NoAvailableCollectionId.into());
-            }
+			if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
+				return Err(<Error<T>>::NoAvailableCollectionId.into());
+			}
 
-            let collection_id = collection_id_res?;
+			let collection_id = collection_id_res?;
 
-            <PalletCommon<T>>::set_scoped_collection_properties(
-                collection_id,
-                PropertyScope::Rmrk,
-                [
-                    Self::rmrk_property(Metadata, &metadata)?,
-                    Self::rmrk_property(CollectionType, &misc::CollectionType::Regular)?,
-                ].into_iter()
-            )?;
+			<PalletCommon<T>>::set_scoped_collection_properties(
+				collection_id,
+				PropertyScope::Rmrk,
+				[
+					Self::rmrk_property(Metadata, &metadata)?,
+					Self::rmrk_property(CollectionType, &misc::CollectionType::Regular)?,
+				]
+				.into_iter(),
+			)?;
 
-            <CollectionIndex<T>>::mutate(|n| *n += 1);
+			<CollectionIndex<T>>::mutate(|n| *n += 1);
 
-            Self::deposit_event(Event::CollectionCreated {
-                issuer: sender,
-                collection_id: collection_id.0
-            });
+			Self::deposit_event(Event::CollectionCreated {
+				issuer: sender,
+				collection_id: collection_id.0,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn destroy_collection(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
-            let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+			let sender = ensure_signed(origin)?;
+			let cross_sender = T::CrossAccountId::from_sub(sender.clone());
 
-            let unique_collection_id = collection_id.into();
+			let unique_collection_id = collection_id.into();
 
-            let collection = Self::get_typed_nft_collection(unique_collection_id, misc::CollectionType::Regular)?;
+			let collection = Self::get_typed_nft_collection(
+				unique_collection_id,
+				misc::CollectionType::Regular,
+			)?;
 
-            ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);
+			ensure!(
+				collection.total_supply() == 0,
+				<Error<T>>::CollectionNotEmpty
+			);
 
-            <PalletNft<T>>::destroy_collection(collection, &cross_sender)
-                .map_err(Self::map_common_err_to_proxy)?;
+			<PalletNft<T>>::destroy_collection(collection, &cross_sender)
+				.map_err(Self::map_common_err_to_proxy)?;
 
-            Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });
+			Self::deposit_event(Event::CollectionDestroyed {
+				issuer: sender,
+				collection_id,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn change_collection_issuer(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
 			new_issuer: <T::Lookup as StaticLookup>::Source,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
+			let sender = ensure_signed(origin)?;
 
-            let new_issuer = T::Lookup::lookup(new_issuer)?;
+			let new_issuer = T::Lookup::lookup(new_issuer)?;
 
-            Self::change_collection_owner(
-                collection_id.into(),
-                misc::CollectionType::Regular,
-                sender.clone(),
-                new_issuer.clone()
-            )?;
+			Self::change_collection_owner(
+				collection_id.into(),
+				misc::CollectionType::Regular,
+				sender.clone(),
+				new_issuer.clone(),
+			)?;
 
-            Self::deposit_event(Event::IssuerChanged {
+			Self::deposit_event(Event::IssuerChanged {
 				old_issuer: sender,
 				new_issuer,
 				collection_id,
 			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn lock_collection(
 			origin: OriginFor<T>,
 			collection_id: RmrkCollectionId,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
-            let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+			let sender = ensure_signed(origin)?;
+			let cross_sender = T::CrossAccountId::from_sub(sender.clone());
 
-            let collection = Self::get_typed_nft_collection(
-                collection_id.into(),
-                misc::CollectionType::Regular
-            )?;
+			let collection = Self::get_typed_nft_collection(
+				collection_id.into(),
+				misc::CollectionType::Regular,
+			)?;
 
-            Self::check_collection_owner(&collection, &cross_sender)?;
+			Self::check_collection_owner(&collection, &cross_sender)?;
 
-            let token_count = collection.total_supply();
+			let token_count = collection.total_supply();
 
-            let mut collection = collection.into_inner();
-            collection.limits.token_limit = Some(token_count);
-            collection.save()?;
+			let mut collection = collection.into_inner();
+			collection.limits.token_limit = Some(token_count);
+			collection.save()?;
 
-			Self::deposit_event(Event::CollectionLocked { issuer: sender, collection_id });
+			Self::deposit_event(Event::CollectionLocked {
+				issuer: sender,
+				collection_id,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn mint_nft(
 			origin: OriginFor<T>,
@@ -251,47 +266,49 @@
 			royalty_amount: Option<Permill>,
 			metadata: RmrkString,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
-            let sender = T::CrossAccountId::from_sub(sender);
-            let cross_owner = T::CrossAccountId::from_sub(owner.clone());
+			let sender = ensure_signed(origin)?;
+			let sender = T::CrossAccountId::from_sub(sender);
+			let cross_owner = T::CrossAccountId::from_sub(owner.clone());
 
-            let royalty_info = royalty_amount.map(|amount| rmrk::RoyaltyInfo {
-                recipient: recipient.unwrap_or_else(|| owner.clone()),
-                amount
-            });
+			let royalty_info = royalty_amount.map(|amount| rmrk::RoyaltyInfo {
+				recipient: recipient.unwrap_or_else(|| owner.clone()),
+				amount,
+			});
 
-            let collection = Self::get_typed_nft_collection(
-                collection_id.into(),
-                misc::CollectionType::Regular,
-            )?;
+			let collection = Self::get_typed_nft_collection(
+				collection_id.into(),
+				misc::CollectionType::Regular,
+			)?;
 
-            let nft_id = Self::create_nft(
-                &sender,
-                &cross_owner,
-                &collection,
-                NftType::Regular,
-                [
-                    Self::rmrk_property(RoyaltyInfo, &royalty_info)?,
-                    Self::rmrk_property(Metadata, &metadata)?,
-                    Self::rmrk_property(Equipped, &false)?,
-                    Self::rmrk_property(ResourceCollection, &None::<CollectionId>)?,
-                    Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,
-                ].into_iter()
-            ).map_err(|err| match err {
-                DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),
-                err => Self::map_common_err_to_proxy(err)
-            })?;
+			let nft_id = Self::create_nft(
+				&sender,
+				&cross_owner,
+				&collection,
+				NftType::Regular,
+				[
+					Self::rmrk_property(RoyaltyInfo, &royalty_info)?,
+					Self::rmrk_property(Metadata, &metadata)?,
+					Self::rmrk_property(Equipped, &false)?,
+					Self::rmrk_property(ResourceCollection, &None::<CollectionId>)?,
+					Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,
+				]
+				.into_iter(),
+			)
+			.map_err(|err| match err {
+				DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),
+				err => Self::map_common_err_to_proxy(err),
+			})?;
 
-            Self::deposit_event(Event::NftMinted {
-                owner,
-                collection_id,
-                nft_id: nft_id.0
-            });
+			Self::deposit_event(Event::NftMinted {
+				owner,
+				collection_id,
+				nft_id: nft_id.0,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn burn_nft(
 			origin: OriginFor<T>,
@@ -299,21 +316,24 @@
 			nft_id: RmrkNftId,
 		) -> DispatchResult {
 			let sender = ensure_signed(origin)?;
-            let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+			let cross_sender = T::CrossAccountId::from_sub(sender.clone());
 
-            Self::destroy_nft(
-                cross_sender,
-                collection_id.into(),
-                misc::CollectionType::Regular,
-                nft_id.into()
-            )?;
+			Self::destroy_nft(
+				cross_sender,
+				collection_id.into(),
+				misc::CollectionType::Regular,
+				nft_id.into(),
+			)?;
 
-            Self::deposit_event(Event::NFTBurned { owner: sender, nft_id });
+			Self::deposit_event(Event::NFTBurned {
+				owner: sender,
+				nft_id,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
 		#[transactional]
 		pub fn set_property(
 			origin: OriginFor<T>,
@@ -322,323 +342,346 @@
 			key: RmrkKeyString,
 			value: RmrkValueString,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
-            let sender = T::CrossAccountId::from_sub(sender);
+			let sender = ensure_signed(origin)?;
+			let sender = T::CrossAccountId::from_sub(sender);
 
-            let collection_id: CollectionId = rmrk_collection_id.into();
+			let collection_id: CollectionId = rmrk_collection_id.into();
 
-            match maybe_nft_id {
-                Some(nft_id) => {
-                    let token_id: TokenId = nft_id.into();
+			match maybe_nft_id {
+				Some(nft_id) => {
+					let token_id: TokenId = nft_id.into();
 
-                    Self::ensure_nft_owner(collection_id, token_id, &sender)?;
-                    Self::ensure_nft_type(collection_id, token_id, NftType::Regular)?;
+					Self::ensure_nft_owner(collection_id, token_id, &sender)?;
+					Self::ensure_nft_type(collection_id, token_id, NftType::Regular)?;
 
-                    <PalletNft<T>>::set_scoped_token_property(
-                        collection_id,
-                        token_id,
-                        PropertyScope::Rmrk,
-                        Self::rmrk_property(UserProperty(key.as_slice()), &value)?
-                    )?;
-                },
-                None => {
-                    let collection = Self::get_typed_nft_collection(
-                        collection_id,
-                        misc::CollectionType::Regular
-                    )?;
+					<PalletNft<T>>::set_scoped_token_property(
+						collection_id,
+						token_id,
+						PropertyScope::Rmrk,
+						Self::rmrk_property(UserProperty(key.as_slice()), &value)?,
+					)?;
+				}
+				None => {
+					let collection = Self::get_typed_nft_collection(
+						collection_id,
+						misc::CollectionType::Regular,
+					)?;
 
-                    Self::check_collection_owner(&collection, &sender)?;
+					Self::check_collection_owner(&collection, &sender)?;
 
-                    <PalletCommon<T>>::set_scoped_collection_property(
-                        collection_id,
-                        PropertyScope::Rmrk,
-                        Self::rmrk_property(UserProperty(key.as_slice()), &value)?
-                    )?;
-                }
-            }
+					<PalletCommon<T>>::set_scoped_collection_property(
+						collection_id,
+						PropertyScope::Rmrk,
+						Self::rmrk_property(UserProperty(key.as_slice()), &value)?,
+					)?;
+				}
+			}
 
-            Self::deposit_event(
-                Event::PropertySet {
-                    collection_id: rmrk_collection_id,
-                    maybe_nft_id,
-                    key,
-                    value
-                }
-            );
+			Self::deposit_event(Event::PropertySet {
+				collection_id: rmrk_collection_id,
+				maybe_nft_id,
+				key,
+				value,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 	}
 }
 
 impl<T: Config> Pallet<T> {
-    pub fn rmrk_property_key(rmrk_key: RmrkProperty) -> Result<PropertyKey, DispatchError> {
-        let key = rmrk_key.to_key::<T>()?;
+	pub fn rmrk_property_key(rmrk_key: RmrkProperty) -> Result<PropertyKey, DispatchError> {
+		let key = rmrk_key.to_key::<T>()?;
 
-        let scoped_key = PropertyScope::Rmrk.apply(key)
-            .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)?;
+		let scoped_key = PropertyScope::Rmrk
+			.apply(key)
+			.map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)?;
 
-        Ok(scoped_key)
-    }
+		Ok(scoped_key)
+	}
 
-    pub fn rmrk_property<E: Encode>(rmrk_key: RmrkProperty, value: &E) -> Result<Property, DispatchError> {
-        let key = rmrk_key.to_key::<T>()?;
+	pub fn rmrk_property<E: Encode>(
+		rmrk_key: RmrkProperty,
+		value: &E,
+	) -> Result<Property, DispatchError> {
+		let key = rmrk_key.to_key::<T>()?;
 
-        let value = value.encode()
-            .try_into()
-            .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;
+		let value = value
+			.encode()
+			.try_into()
+			.map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;
 
-        let property = Property {
-            key,
-            value,
-        };
+		let property = Property { key, value };
 
-        Ok(property)
-    }
+		Ok(property)
+	}
 
-    pub fn create_nft(
-        sender: &T::CrossAccountId,
-        owner: &T::CrossAccountId,
-        collection: &NonfungibleHandle<T>,
-        nft_type: NftType,
-        properties: impl Iterator<Item=Property>
-    ) -> Result<TokenId, DispatchError> {
-        todo!("store nft type");
-        let data = CreateNftExData {
-            properties: BoundedVec::default(),
-            owner: owner.clone(),
-        };
+	pub fn create_nft(
+		sender: &T::CrossAccountId,
+		owner: &T::CrossAccountId,
+		collection: &NonfungibleHandle<T>,
+		nft_type: NftType,
+		properties: impl Iterator<Item = Property>,
+	) -> Result<TokenId, DispatchError> {
+		todo!("store nft type");
+		let data = CreateNftExData {
+			properties: BoundedVec::default(),
+			owner: owner.clone(),
+		};
 
-        let budget = budget::Value::new(2);
+		let budget = budget::Value::new(2);
 
-        <PalletNft<T>>::create_item(
-            collection,
-            sender,
-            data,
-            &budget,
-        )?;
+		<PalletNft<T>>::create_item(collection, sender, data, &budget)?;
 
-        let nft_id = <PalletNft<T>>::current_token_id(collection.id);
+		let nft_id = <PalletNft<T>>::current_token_id(collection.id);
 
-        <PalletNft<T>>::set_scoped_token_properties(
-            collection.id,
-            nft_id,
-            PropertyScope::Rmrk,
-            properties
-        )?;
+		<PalletNft<T>>::set_scoped_token_properties(
+			collection.id,
+			nft_id,
+			PropertyScope::Rmrk,
+			properties,
+		)?;
 
-        Ok(nft_id)
-    }
+		Ok(nft_id)
+	}
 
-    fn destroy_nft(
-        sender: T::CrossAccountId,
-        collection_id: CollectionId,
-        collection_type: misc::CollectionType,
-        token_id: TokenId
-    ) -> DispatchResult {
-        let collection = Self::get_typed_nft_collection(
-            collection_id,
-            collection_type
-        )?;
+	fn destroy_nft(
+		sender: T::CrossAccountId,
+		collection_id: CollectionId,
+		collection_type: misc::CollectionType,
+		token_id: TokenId,
+	) -> DispatchResult {
+		let collection = Self::get_typed_nft_collection(collection_id, collection_type)?;
 
-        <PalletNft<T>>::burn(&collection, &sender, token_id)
-            .map_err(Self::map_common_err_to_proxy)?;
+		<PalletNft<T>>::burn(&collection, &sender, token_id)
+			.map_err(Self::map_common_err_to_proxy)?;
 
-        Ok(())
-    }
+		Ok(())
+	}
 
-    fn change_collection_owner(
-        collection_id: CollectionId,
-        collection_type: misc::CollectionType,
-        sender: T::AccountId,
-        new_owner: T::AccountId,
-    ) -> DispatchResult {
-        let collection = Self::get_typed_nft_collection(
-            collection_id,
-            collection_type
-        )?;
-        Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;
+	fn change_collection_owner(
+		collection_id: CollectionId,
+		collection_type: misc::CollectionType,
+		sender: T::AccountId,
+		new_owner: T::AccountId,
+	) -> DispatchResult {
+		let collection = Self::get_typed_nft_collection(collection_id, collection_type)?;
+		Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;
 
-        let mut collection = collection.into_inner();
+		let mut collection = collection.into_inner();
 
-        collection.owner = new_owner;
-        collection.save()
-    }
+		collection.owner = new_owner;
+		collection.save()
+	}
 
-    fn check_collection_owner(collection: &NonfungibleHandle<T>, account: &T::CrossAccountId) -> DispatchResult {
-        collection.check_is_owner(account)
-            .map_err(Self::map_common_err_to_proxy)
-    }
+	fn check_collection_owner(
+		collection: &NonfungibleHandle<T>,
+		account: &T::CrossAccountId,
+	) -> DispatchResult {
+		collection
+			.check_is_owner(account)
+			.map_err(Self::map_common_err_to_proxy)
+	}
 
-    pub fn last_collection_idx() -> RmrkCollectionId {
-        <CollectionIndex<T>>::get()
-    }
+	pub fn last_collection_idx() -> RmrkCollectionId {
+		<CollectionIndex<T>>::get()
+	}
 
-    pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
-        let collection = <CollectionHandle<T>>::try_get(collection_id)
-            .map_err(|_| <Error<T>>::CollectionUnknown)?;
+	pub fn get_nft_collection(
+		collection_id: CollectionId,
+	) -> Result<NonfungibleHandle<T>, DispatchError> {
+		let collection = <CollectionHandle<T>>::try_get(collection_id)
+			.map_err(|_| <Error<T>>::CollectionUnknown)?;
 
-        match collection.mode {
-            CollectionMode::NFT => Ok(NonfungibleHandle::cast(collection)),
-            _ => Err(<Error<T>>::CollectionUnknown.into())
-        }
-    }
+		match collection.mode {
+			CollectionMode::NFT => Ok(NonfungibleHandle::cast(collection)),
+			_ => Err(<Error<T>>::CollectionUnknown.into()),
+		}
+	}
 
-    pub fn collection_exists(collection_id: CollectionId) -> bool {
-        <CollectionHandle<T>>::try_get(collection_id).is_ok()
-    }
+	pub fn collection_exists(collection_id: CollectionId) -> bool {
+		<CollectionHandle<T>>::try_get(collection_id).is_ok()
+	}
 
-    pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {
-        <TokenData<T>>::contains_key((collection_id, nft_id))
-    }
+	pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {
+		<TokenData<T>>::contains_key((collection_id, nft_id))
+	}
 
-    pub fn get_collection_property(collection_id: CollectionId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {
-        let collection_property = <PalletCommon<T>>::collection_properties(collection_id)
-            .get(&Self::rmrk_property_key(key)?)
-            .ok_or(<Error<T>>::CollectionUnknown)?
-            .clone();
+	pub fn get_collection_property(
+		collection_id: CollectionId,
+		key: RmrkProperty,
+	) -> Result<PropertyValue, DispatchError> {
+		let collection_property = <PalletCommon<T>>::collection_properties(collection_id)
+			.get(&Self::rmrk_property_key(key)?)
+			.ok_or(<Error<T>>::CollectionUnknown)?
+			.clone();
 
-        Ok(collection_property)
-    }
+		Ok(collection_property)
+	}
 
-    pub fn get_collection_type(collection_id: CollectionId) -> Result<misc::CollectionType, DispatchError> {
-        let value = Self::get_collection_property(collection_id, CollectionType)?;
+	pub fn get_collection_type(
+		collection_id: CollectionId,
+	) -> Result<misc::CollectionType, DispatchError> {
+		let value = Self::get_collection_property(collection_id, CollectionType)?;
 
-        let mut value = value.as_slice();
+		let mut value = value.as_slice();
 
-        misc::CollectionType::decode(&mut value)
-            .map_err(|_| <Error<T>>::CorruptedCollectionType.into())
-    }
+		misc::CollectionType::decode(&mut value)
+			.map_err(|_| <Error<T>>::CorruptedCollectionType.into())
+	}
 
-    pub fn ensure_collection_type(collection_id: CollectionId, collection_type: misc::CollectionType) -> DispatchResult {
-        let actual_type = Self::get_collection_type(collection_id)?;
-        ensure!(actual_type == collection_type, <CommonError<T>>::NoPermission);
+	pub fn ensure_collection_type(
+		collection_id: CollectionId,
+		collection_type: misc::CollectionType,
+	) -> DispatchResult {
+		let actual_type = Self::get_collection_type(collection_id)?;
+		ensure!(
+			actual_type == collection_type,
+			<CommonError<T>>::NoPermission
+		);
 
-        Ok(())
-    }
+		Ok(())
+	}
 
-    pub fn get_nft_property(collection_id: CollectionId, nft_id: TokenId, key: RmrkProperty) -> Result<PropertyValue, DispatchError> {
-        let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))
-            .get(&Self::rmrk_property_key(key)?)
-            .ok_or(<Error<T>>::NoAvailableNftId)?
-            .clone();
+	pub fn get_nft_property(
+		collection_id: CollectionId,
+		nft_id: TokenId,
+		key: RmrkProperty,
+	) -> Result<PropertyValue, DispatchError> {
+		let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))
+			.get(&Self::rmrk_property_key(key)?)
+			.ok_or(<Error<T>>::NoAvailableNftId)?
+			.clone();
 
-        Ok(nft_property)
-    }
+		Ok(nft_property)
+	}
 
-    pub fn get_nft_type(_collection_id: CollectionId, _token_id: TokenId) -> Result<NftType, DispatchError> {
-        todo!("should get it from properties?")
-    }
+	pub fn get_nft_type(
+		_collection_id: CollectionId,
+		_token_id: TokenId,
+	) -> Result<NftType, DispatchError> {
+		todo!("should get it from properties?")
+	}
 
-    pub fn ensure_nft_type(collection_id: CollectionId, token_id: TokenId, nft_type: NftType) -> DispatchResult {
-        let actual_type = Self::get_nft_type(collection_id, token_id)?;
-        ensure!(actual_type == nft_type, <Error<T>>::NoPermission);
+	pub fn ensure_nft_type(
+		collection_id: CollectionId,
+		token_id: TokenId,
+		nft_type: NftType,
+	) -> DispatchResult {
+		let actual_type = Self::get_nft_type(collection_id, token_id)?;
+		ensure!(actual_type == nft_type, <Error<T>>::NoPermission);
 
-        Ok(())
-    }
+		Ok(())
+	}
 
-    pub fn ensure_nft_owner(
-        collection_id: CollectionId,
-        token_id: TokenId,
-        possible_owner: &T::CrossAccountId
-    ) -> DispatchResult {
-        let token_data = <TokenData<T>>::get((collection_id, token_id))
-            .ok_or(<Error<T>>::NoAvailableNftId)?;
+	pub fn ensure_nft_owner(
+		collection_id: CollectionId,
+		token_id: TokenId,
+		possible_owner: &T::CrossAccountId,
+	) -> DispatchResult {
+		let token_data =
+			<TokenData<T>>::get((collection_id, token_id)).ok_or(<Error<T>>::NoAvailableNftId)?;
 
-        ensure!(token_data.owner == *possible_owner, <Error<T>>::NoPermission);
+		ensure!(
+			token_data.owner == *possible_owner,
+			<Error<T>>::NoPermission
+		);
 
-        Ok(())
-    }
+		Ok(())
+	}
 
-    pub fn filter_user_properties<Key, Value, R, Mapper>(
-        collection_id: CollectionId,
-        token_id: Option<TokenId>,
-        filter_keys: Option<Vec<RmrkPropertyKey>>,
-        mapper: Mapper,
-    ) -> Result<Vec<R>, DispatchError>
-    where
-        Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,
-        Value: Decode + Default,
-        Mapper: Fn(Key, Value) -> R
-    {
-        filter_keys.map(|keys| {
-            let properties = keys.into_iter()
-                .filter_map(|key| {
-                    let key: Key = key.try_into().ok()?;
+	pub fn filter_user_properties<Key, Value, R, Mapper>(
+		collection_id: CollectionId,
+		token_id: Option<TokenId>,
+		filter_keys: Option<Vec<RmrkPropertyKey>>,
+		mapper: Mapper,
+	) -> Result<Vec<R>, DispatchError>
+	where
+		Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,
+		Value: Decode + Default,
+		Mapper: Fn(Key, Value) -> R,
+	{
+		filter_keys
+			.map(|keys| {
+				let properties = keys
+					.into_iter()
+					.filter_map(|key| {
+						let key: Key = key.try_into().ok()?;
 
-                    let value = match token_id {
-                        Some(token_id) => Self::get_nft_property(
-                            collection_id,
-                            token_id,
-                            UserProperty(key.as_ref())
-                        ),
-                        None => Self::get_collection_property(
-                            collection_id,
-                            UserProperty(key.as_ref())
-                        )
-                    }.ok()?.decode_or_default();
+						let value = match token_id {
+							Some(token_id) => Self::get_nft_property(
+								collection_id,
+								token_id,
+								UserProperty(key.as_ref()),
+							),
+							None => Self::get_collection_property(
+								collection_id,
+								UserProperty(key.as_ref()),
+							),
+						}
+						.ok()?
+						.decode_or_default();
 
-                    Some(mapper(key, value))
-                })
-                .collect();
+						Some(mapper(key, value))
+					})
+					.collect();
 
-            Ok(properties)
-        }).unwrap_or_else(|| {
-            let properties = Self::iterate_user_properties(collection_id, token_id, mapper)?
-                .collect();
+				Ok(properties)
+			})
+			.unwrap_or_else(|| {
+				let properties =
+					Self::iterate_user_properties(collection_id, token_id, mapper)?.collect();
 
-            Ok(properties)
-        })
-    }
+				Ok(properties)
+			})
+	}
 
-    pub fn iterate_user_properties<Key, Value, R, Mapper>(
-        collection_id: CollectionId,
-        token_id: Option<TokenId>,
-        mapper: Mapper,
-    ) -> Result<impl Iterator<Item=R>, DispatchError>
-    where
-        Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,
-        Value: Decode + Default,
-        Mapper: Fn(Key, Value) -> R
-    {
-        let key_prefix = Self::rmrk_property_key(UserProperty(b""))?;
+	pub fn iterate_user_properties<Key, Value, R, Mapper>(
+		collection_id: CollectionId,
+		token_id: Option<TokenId>,
+		mapper: Mapper,
+	) -> Result<impl Iterator<Item = R>, DispatchError>
+	where
+		Key: TryFrom<RmrkPropertyKey> + AsRef<[u8]>,
+		Value: Decode + Default,
+		Mapper: Fn(Key, Value) -> R,
+	{
+		let key_prefix = Self::rmrk_property_key(UserProperty(b""))?;
 
-        let properties = match token_id {
-            Some(token_id) => <PalletNft<T>>::token_properties((collection_id, token_id)),
-            None => <PalletCommon<T>>::collection_properties(collection_id)
-        };
+		let properties = match token_id {
+			Some(token_id) => <PalletNft<T>>::token_properties((collection_id, token_id)),
+			None => <PalletCommon<T>>::collection_properties(collection_id),
+		};
 
-        let properties = properties
-            .into_iter()
-            .filter_map(move |(key, value)| {
-                let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;
+		let properties = properties.into_iter().filter_map(move |(key, value)| {
+			let key = key.as_slice().strip_prefix(key_prefix.as_slice())?;
 
-                let key: Key = key.to_vec().try_into().ok()?;
-                let value: Value = value.decode_or_default();
+			let key: Key = key.to_vec().try_into().ok()?;
+			let value: Value = value.decode_or_default();
 
-                Some(mapper(key, value))
-            });
+			Some(mapper(key, value))
+		});
 
-        Ok(properties)
-    }
+		Ok(properties)
+	}
 
-    pub fn get_typed_nft_collection(
-        collection_id: CollectionId,
-        collection_type: misc::CollectionType
-    ) -> Result<NonfungibleHandle<T>, DispatchError> {
-        Self::ensure_collection_type(collection_id, collection_type)?;
+	pub fn get_typed_nft_collection(
+		collection_id: CollectionId,
+		collection_type: misc::CollectionType,
+	) -> Result<NonfungibleHandle<T>, DispatchError> {
+		Self::ensure_collection_type(collection_id, collection_type)?;
 
-        Self::get_nft_collection(collection_id)
-    }
+		Self::get_nft_collection(collection_id)
+	}
 
-    fn map_common_err_to_proxy(err: DispatchError) -> DispatchError {
-        map_common_err_to_proxy! {
-            match err {
-                NoPermission => NoPermission,
-                CollectionTokenLimitExceeded => CollectionFullOrLocked,
-                PublicMintingNotAllowed => NoPermission,
-                TokenNotFound => NoAvailableNftId
-            }
-        }
-    }
+	fn map_common_err_to_proxy(err: DispatchError) -> DispatchError {
+		map_common_err_to_proxy! {
+			match err {
+				NoPermission => NoPermission,
+				CollectionTokenLimitExceeded => CollectionFullOrLocked,
+				PublicMintingNotAllowed => NoPermission,
+				TokenNotFound => NoAvailableNftId
+			}
+		}
+	}
 }
modifiedpallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/misc.rs
+++ b/pallets/proxy-rmrk-core/src/misc.rs
@@ -15,41 +15,42 @@
 }
 
 pub trait RmrkDecode<T: Decode + Default, S> {
-    fn decode_or_default(&self) -> T;
+	fn decode_or_default(&self) -> T;
 }
 
 impl<T: Decode + Default, S> RmrkDecode<T, S> for BoundedVec<u8, S> {
-    fn decode_or_default(&self) -> T {
-        let mut value = self.as_slice();
+	fn decode_or_default(&self) -> T {
+		let mut value = self.as_slice();
 
-        T::decode(&mut value).unwrap_or_default()
-    }
+		T::decode(&mut value).unwrap_or_default()
+	}
 }
 
 pub trait RmrkRebind<T, S> {
-    fn rebind(&self) -> BoundedVec<u8, S>;
+	fn rebind(&self) -> BoundedVec<u8, S>;
 }
 
-impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T> where BoundedVec<u8, S>: TryFrom<Vec<u8>> {
-    fn rebind(&self) -> BoundedVec<u8, S> {
-        BoundedVec::<u8, S>::try_from(
-            self.clone().into_inner()
-        ).unwrap_or_default()
-    }
+impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T>
+where
+	BoundedVec<u8, S>: TryFrom<Vec<u8>>,
+{
+	fn rebind(&self) -> BoundedVec<u8, S> {
+		BoundedVec::<u8, S>::try_from(self.clone().into_inner()).unwrap_or_default()
+	}
 }
 
 #[derive(Encode, Decode, PartialEq, Eq)]
 pub enum CollectionType {
-    Regular,
-    Resource,
-    Base,
+	Regular,
+	Resource,
+	Base,
 }
 
 #[derive(Encode, Decode, PartialEq, Eq)]
 pub enum NftType {
-    Regular,
-    Resource,
-    FixedPart,
-    SlotPart,
-    Theme
+	Regular,
+	Resource,
+	FixedPart,
+	SlotPart,
+	Theme,
 }
modifiedpallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/property.rs
+++ b/pallets/proxy-rmrk-core/src/property.rs
@@ -2,38 +2,38 @@
 use core::convert::AsRef;
 
 pub enum RmrkProperty<'r> {
-    Metadata,
-    CollectionType,
-    RoyaltyInfo,
-    Equipped,
-    ResourceCollection,
-    ResourcePriorities,
-    ResourceType,
-    PendingResourceAccept,
-    PendingResourceRemoval,
-    Parts,
-    Base,
-    Src,
-    Slot,
-    License,
-    Thumb,
-    EquippedNft,
-    BaseType,
-    ExternalPartId,
-    EquippableList,
-    ZIndex,
-    ThemeName,
-    ThemeInherit,
-    UserProperty(&'r [u8]),
+	Metadata,
+	CollectionType,
+	RoyaltyInfo,
+	Equipped,
+	ResourceCollection,
+	ResourcePriorities,
+	ResourceType,
+	PendingResourceAccept,
+	PendingResourceRemoval,
+	Parts,
+	Base,
+	Src,
+	Slot,
+	License,
+	Thumb,
+	EquippedNft,
+	BaseType,
+	ExternalPartId,
+	EquippableList,
+	ZIndex,
+	ThemeName,
+	ThemeInherit,
+	UserProperty(&'r [u8]),
 }
 
 impl<'r> RmrkProperty<'r> {
-    pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {
-        fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {
-            container.as_ref()
-        }
+	pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {
+		fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {
+			container.as_ref()
+		}
 
-        macro_rules! key {
+		macro_rules! key {
             ($($component:expr),+) => {
                 PropertyKey::try_from([$(key!(@ &$component)),+].concat())
                     .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)
@@ -44,30 +44,30 @@
             };
         }
 
-        match self {
-            Self::Metadata => key!("metadata"),
-            Self::CollectionType => key!("collection-type"),
-            Self::RoyaltyInfo => key!("royalty-info"),
-            Self::Equipped => key!("equipped"),
-            Self::ResourceCollection => key!("resource-collection"),
-            Self::ResourcePriorities => key!("resource-priorities"),
-            Self::ResourceType => key!("resource-type"),
-            Self::PendingResourceAccept => key!("pending-accept"),
-            Self::PendingResourceRemoval => key!("pending-removal"),
-            Self::Parts => key!("parts"),
-            Self::Base => key!("base"),
-            Self::Src => key!("src"),
-            Self::Slot => key!("slot"),
-            Self::License => key!("license"),
-            Self::Thumb => key!("thumb"),
-            Self::EquippedNft => key!("equipped-nft"),
-            Self::BaseType => key!("base-type"),
-            Self::ExternalPartId => key!("ext-part-id"),
-            Self::EquippableList => key!("equippable-list"),
-            Self::ZIndex => key!("z-index"),
-            Self::ThemeName => key!("theme-name"),
-            Self::ThemeInherit => key!("theme-inherit"),
-            Self::UserProperty(name) => key!("userprop-", name),
-        }
-    }
+		match self {
+			Self::Metadata => key!("metadata"),
+			Self::CollectionType => key!("collection-type"),
+			Self::RoyaltyInfo => key!("royalty-info"),
+			Self::Equipped => key!("equipped"),
+			Self::ResourceCollection => key!("resource-collection"),
+			Self::ResourcePriorities => key!("resource-priorities"),
+			Self::ResourceType => key!("resource-type"),
+			Self::PendingResourceAccept => key!("pending-accept"),
+			Self::PendingResourceRemoval => key!("pending-removal"),
+			Self::Parts => key!("parts"),
+			Self::Base => key!("base"),
+			Self::Src => key!("src"),
+			Self::Slot => key!("slot"),
+			Self::License => key!("license"),
+			Self::Thumb => key!("thumb"),
+			Self::EquippedNft => key!("equipped-nft"),
+			Self::BaseType => key!("base-type"),
+			Self::ExternalPartId => key!("ext-part-id"),
+			Self::EquippableList => key!("equippable-list"),
+			Self::ZIndex => key!("z-index"),
+			Self::ThemeName => key!("theme-name"),
+			Self::ThemeInherit => key!("theme-inherit"),
+			Self::UserProperty(name) => key!("userprop-", name),
+		}
+	}
 }
modifiedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-equip/src/lib.rs
+++ b/pallets/proxy-rmrk-equip/src/lib.rs
@@ -21,7 +21,11 @@
 use sp_runtime::DispatchError;
 use up_data_structs::*;
 use pallet_common::{Pallet as PalletCommon, Error as CommonError};
-use pallet_rmrk_core::{Pallet as PalletCore, misc::{self, *}, property::RmrkProperty::*};
+use pallet_rmrk_core::{
+	Pallet as PalletCore,
+	misc::{self, *},
+	property::RmrkProperty::*,
+};
 use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle};
 use pallet_evm::account::CrossAccountId;
 
@@ -29,212 +33,206 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-    use super::*;
+	use super::*;
 
 	#[pallet::config]
-	pub trait Config: frame_system::Config
-                    + pallet_rmrk_core::Config {
+	pub trait Config: frame_system::Config + pallet_rmrk_core::Config {
 		type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
 	}
 
-    #[pallet::storage]
+	#[pallet::storage]
 	#[pallet::getter(fn internal_part_id)]
-	pub type InernalPartId<T: Config> = StorageDoubleMap<
-        _,
-        Twox64Concat,
-        CollectionId,
-        Twox64Concat,
-        RmrkPartId,
-        TokenId
-    >;
+	pub type InernalPartId<T: Config> =
+		StorageDoubleMap<_, Twox64Concat, CollectionId, Twox64Concat, RmrkPartId, TokenId>;
 
-    #[pallet::storage]
+	#[pallet::storage]
 	#[pallet::getter(fn base_has_default_theme)]
-    pub type BaseHasDefaultTheme<T: Config> = StorageMap<
-        _,
-        Twox64Concat,
-        CollectionId,
-        bool,
-        ValueQuery
-    >;
+	pub type BaseHasDefaultTheme<T: Config> =
+		StorageMap<_, Twox64Concat, CollectionId, bool, ValueQuery>;
 
-    #[pallet::pallet]
+	#[pallet::pallet]
 	#[pallet::generate_store(pub(super) trait Store)]
 	pub struct Pallet<T>(_);
 
 	#[pallet::event]
 	#[pallet::generate_deposit(pub(super) fn deposit_event)]
 	pub enum Event<T: Config> {
-        BaseCreated {
+		BaseCreated {
 			issuer: T::AccountId,
 			base_id: RmrkBaseId,
 		},
-    }
+	}
 
-    #[pallet::error]
+	#[pallet::error]
 	pub enum Error<T> {
-        PermissionError,
-        NoAvailableBaseId,
-        NoAvailablePartId,
-        BaseDoesntExist,
-        NeedsDefaultThemeFirst,
-    }
+		PermissionError,
+		NoAvailableBaseId,
+		NoAvailablePartId,
+		BaseDoesntExist,
+		NeedsDefaultThemeFirst,
+	}
 
-    #[pallet::call]
+	#[pallet::call]
 	impl<T: Config> Pallet<T> {
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
-        #[transactional]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[transactional]
 		pub fn create_base(
 			origin: OriginFor<T>,
 			base_type: RmrkString,
 			symbol: RmrkString,
 			parts: BoundedVec<RmrkPartType, RmrkPartsLimit>,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
-            let cross_sender = T::CrossAccountId::from_sub(sender.clone());
+			let sender = ensure_signed(origin)?;
+			let cross_sender = T::CrossAccountId::from_sub(sender.clone());
 
-            let data = CreateCollectionData {
-                limits: None,
-                token_prefix: symbol.into_inner()
-                    .try_into()
-                    .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,
-                ..Default::default()
-            };
+			let data = CreateCollectionData {
+				limits: None,
+				token_prefix: symbol
+					.into_inner()
+					.try_into()
+					.map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,
+				..Default::default()
+			};
 
-            let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
+			let collection_id_res = <PalletNft<T>>::init_collection(sender.clone(), data);
 
-            if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
-                return Err(<Error<T>>::NoAvailableBaseId.into());
-            }
+			if let Err(DispatchError::Arithmetic(_)) = &collection_id_res {
+				return Err(<Error<T>>::NoAvailableBaseId.into());
+			}
 
-            let collection_id = collection_id_res?;
+			let collection_id = collection_id_res?;
 
-            <PalletCommon<T>>::set_scoped_collection_properties(
-                collection_id,
-                PropertyScope::Rmrk,
-                [
-                    <PalletCore<T>>::rmrk_property(CollectionType, &misc::CollectionType::Base)?,
-                    <PalletCore<T>>::rmrk_property(BaseType, &base_type)?,
-                ].into_iter()
-            )?;
+			<PalletCommon<T>>::set_scoped_collection_properties(
+				collection_id,
+				PropertyScope::Rmrk,
+				[
+					<PalletCore<T>>::rmrk_property(CollectionType, &misc::CollectionType::Base)?,
+					<PalletCore<T>>::rmrk_property(BaseType, &base_type)?,
+				]
+				.into_iter(),
+			)?;
 
-            let collection = <PalletCore<T>>::get_nft_collection(collection_id)?;
+			let collection = <PalletCore<T>>::get_nft_collection(collection_id)?;
 
-            for part in parts {
-                let part_id = part.id();
-                let part_token_id = Self::create_part(
-                    &cross_sender,
-                    &collection,
-                    part
-                )?;
+			for part in parts {
+				let part_id = part.id();
+				let part_token_id = Self::create_part(&cross_sender, &collection, part)?;
 
-                <InernalPartId<T>>::insert(collection_id, part_id, part_token_id);
+				<InernalPartId<T>>::insert(collection_id, part_id, part_token_id);
 
-                <PalletNft<T>>::set_scoped_token_property(
-                    collection_id,
-                    part_token_id,
-                    PropertyScope::Rmrk,
-                    <PalletCore<T>>::rmrk_property(ExternalPartId, &part_id)?
-                )?;
-            }
+				<PalletNft<T>>::set_scoped_token_property(
+					collection_id,
+					part_token_id,
+					PropertyScope::Rmrk,
+					<PalletCore<T>>::rmrk_property(ExternalPartId, &part_id)?,
+				)?;
+			}
 
-            Self::deposit_event(Event::BaseCreated { issuer: sender, base_id: collection_id.0 });
+			Self::deposit_event(Event::BaseCreated {
+				issuer: sender,
+				base_id: collection_id.0,
+			});
 
-            Ok(())
-        }
+			Ok(())
+		}
 
-        #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
-        #[transactional]
+		#[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]
+		#[transactional]
 		pub fn theme_add(
 			origin: OriginFor<T>,
 			base_id: RmrkBaseId,
 			theme: RmrkTheme,
 		) -> DispatchResult {
-            let sender = ensure_signed(origin)?;
+			let sender = ensure_signed(origin)?;
 
-            let sender = T::CrossAccountId::from_sub(sender);
-            let owner = &sender;
+			let sender = T::CrossAccountId::from_sub(sender);
+			let owner = &sender;
 
-            let collection_id: CollectionId = base_id.into();
+			let collection_id: CollectionId = base_id.into();
 
-            let collection = <PalletCore<T>>::get_typed_nft_collection(
-                collection_id,
-                misc::CollectionType::Base
-            ).map_err(|_| <Error<T>>::BaseDoesntExist)?;
+			let collection = <PalletCore<T>>::get_typed_nft_collection(
+				collection_id,
+				misc::CollectionType::Base,
+			)
+			.map_err(|_| <Error<T>>::BaseDoesntExist)?;
 
-            if theme.name.as_slice() == b"default" {
-                <BaseHasDefaultTheme<T>>::insert(collection_id, true);
-            } else if !Self::base_has_default_theme(collection_id) {
-                return Err(<Error<T>>::NeedsDefaultThemeFirst.into());
-            }
+			if theme.name.as_slice() == b"default" {
+				<BaseHasDefaultTheme<T>>::insert(collection_id, true);
+			} else if !Self::base_has_default_theme(collection_id) {
+				return Err(<Error<T>>::NeedsDefaultThemeFirst.into());
+			}
 
-            let token_id = <PalletCore<T>>::create_nft(
-                &sender,
-                owner,
-                &collection,
-                NftType::Theme,
-                [
-                    <PalletCore<T>>::rmrk_property(ThemeName, &theme.name)?,
-                    <PalletCore<T>>::rmrk_property(ThemeInherit, &theme.inherit)?
-                ].into_iter()
-            ).map_err(|_| <Error<T>>::PermissionError)?;
+			let token_id = <PalletCore<T>>::create_nft(
+				&sender,
+				owner,
+				&collection,
+				NftType::Theme,
+				[
+					<PalletCore<T>>::rmrk_property(ThemeName, &theme.name)?,
+					<PalletCore<T>>::rmrk_property(ThemeInherit, &theme.inherit)?,
+				]
+				.into_iter(),
+			)
+			.map_err(|_| <Error<T>>::PermissionError)?;
 
-            for property in theme.properties {
-                <PalletNft<T>>::set_scoped_token_property(
-                    collection_id,
-                    token_id,
-                    PropertyScope::Rmrk,
-                    <PalletCore<T>>::rmrk_property(
-                        UserProperty(property.key.as_slice()),
-                        &property.value
-                    )?
-                )?;
-            }
+			for property in theme.properties {
+				<PalletNft<T>>::set_scoped_token_property(
+					collection_id,
+					token_id,
+					PropertyScope::Rmrk,
+					<PalletCore<T>>::rmrk_property(
+						UserProperty(property.key.as_slice()),
+						&property.value,
+					)?,
+				)?;
+			}
 
-            Ok(())
-        }
-    }
+			Ok(())
+		}
+	}
 }
 
 impl<T: Config> Pallet<T> {
-    fn create_part(
-        sender: &T::CrossAccountId,
-        collection: &NonfungibleHandle<T>,
-        part: RmrkPartType
-    ) -> Result<TokenId, DispatchError> {
-        let owner = sender;
+	fn create_part(
+		sender: &T::CrossAccountId,
+		collection: &NonfungibleHandle<T>,
+		part: RmrkPartType,
+	) -> Result<TokenId, DispatchError> {
+		let owner = sender;
 
-        let src = part.src();
-        let z_index = part.z_index();
+		let src = part.src();
+		let z_index = part.z_index();
 
-        let nft_type = match part {
-            RmrkPartType::FixedPart(_) => NftType::FixedPart,
-            RmrkPartType::SlotPart(_) => NftType::SlotPart,
-        };
+		let nft_type = match part {
+			RmrkPartType::FixedPart(_) => NftType::FixedPart,
+			RmrkPartType::SlotPart(_) => NftType::SlotPart,
+		};
 
-        let token_id = <PalletCore<T>>::create_nft(
-            sender,
-            owner,
-            collection,
-            nft_type,
-            [
-                <PalletCore<T>>::rmrk_property(Src, &src)?,
-                <PalletCore<T>>::rmrk_property(ZIndex, &z_index)?
-            ].into_iter()
-        ).map_err(|err| match err {
-            DispatchError::Arithmetic(_) => <Error<T>>::NoAvailablePartId.into(),
-            err => err
-        })?;
+		let token_id = <PalletCore<T>>::create_nft(
+			sender,
+			owner,
+			collection,
+			nft_type,
+			[
+				<PalletCore<T>>::rmrk_property(Src, &src)?,
+				<PalletCore<T>>::rmrk_property(ZIndex, &z_index)?,
+			]
+			.into_iter(),
+		)
+		.map_err(|err| match err {
+			DispatchError::Arithmetic(_) => <Error<T>>::NoAvailablePartId.into(),
+			err => err,
+		})?;
 
-        if let RmrkPartType::SlotPart(part) = part {
-            <PalletNft<T>>::set_scoped_token_property(
-                collection.id,
-                token_id,
-                PropertyScope::Rmrk,
-                <PalletCore<T>>::rmrk_property(EquippableList, &part.equippable)?
-            )?;
-        }
+		if let RmrkPartType::SlotPart(part) = part {
+			<PalletNft<T>>::set_scoped_token_property(
+				collection.id,
+				token_id,
+				PropertyScope::Rmrk,
+				<PalletCore<T>>::rmrk_property(EquippableList, &part.equippable)?,
+			)?;
+		}
 
-        Ok(token_id)
-    }
+		Ok(token_id)
+	}
 }
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -313,17 +313,9 @@
 		fail!(<Error<T>>::RefungibleDisallowsNesting)
 	}
 
-	fn nest(
-		&self,
-		_under: TokenId,
-		_to_nest: (CollectionId, TokenId)
-	) {}
+	fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}
 
-	fn unnest(
-		&self,
-		_under: TokenId,
-		_to_nest: (CollectionId, TokenId)
-	) {}
+	fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}
 
 	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
 		<Owned<T>>::iter_prefix((self.id, account))
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -22,9 +22,7 @@
 	CreateCollectionData, CreateRefungibleExData, mapping::TokenAddressMapping, budget::Budget,
 };
 use pallet_evm::account::CrossAccountId;
-use pallet_common::{
-	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
-};
+use pallet_common::{Error as CommonError, Event as CommonEvent, Pallet as PalletCommon};
 use pallet_structure::Pallet as PalletStructure;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
@@ -230,7 +228,9 @@
 	}
 
 	fn collection_has_tokens(collection_id: CollectionId) -> bool {
-		<TokenData<T>>::iter_prefix((collection_id,)).next().is_some()
+		<TokenData<T>>::iter_prefix((collection_id,))
+			.next()
+			.is_some()
 	}
 
 	pub fn burn_token(collection: &RefungibleHandle<T>, token_id: TokenId) -> DispatchResult {
@@ -388,18 +388,14 @@
 			to,
 			collection.id,
 			token,
-			nesting_budget
+			nesting_budget,
 		)?;
 
 		if let Some(balance_to) = balance_to {
 			// from != to
 			if balance_from == 0 {
 				<Balance<T>>::remove((collection.id, token, from));
-				<PalletStructure<T>>::unnest_if_nested(
-					from,
-					collection.id,
-					token
-				);
+				<PalletStructure<T>>::unnest_if_nested(from, collection.id, token);
 			} else {
 				<Balance<T>>::insert((collection.id, token, from), balance_from);
 			}
@@ -497,7 +493,6 @@
 		for (i, token) in data.iter().enumerate() {
 			let token_id = TokenId(first_token_id + i as u32 + 1);
 			for (to, _) in token.users.iter() {
-
 				<PalletStructure<T>>::check_nesting(
 					sender.clone(),
 					to,
@@ -531,7 +526,11 @@
 				}
 				<Balance<T>>::insert((collection.id, token_id, &user), amount);
 				<Owned<T>>::insert((collection.id, &user, TokenId(token_id)), true);
-				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(&user, collection.id, TokenId(token_id));
+				<PalletStructure<T>>::nest_if_sent_to_token_unchecked(
+					&user,
+					collection.id,
+					TokenId(token_id),
+				);
 
 				// TODO: ERC20 transfer event
 				<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
modifiedpallets/structure/src/lib.rsdiffbeforeafterboth
--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -189,17 +189,11 @@
 		under: &T::CrossAccountId,
 		collection_id: CollectionId,
 		token_id: TokenId,
-		nesting_budget: &dyn Budget
+		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		Self::try_exec_if_owner_is_valid_nft(
-			under,
-			|d, parent_id| d.check_nesting(
-				from,
-				(collection_id, token_id),
-				parent_id,
-				nesting_budget
-			)
-		)
+		Self::try_exec_if_owner_is_valid_nft(under, |d, parent_id| {
+			d.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)
+		})
 	}
 
 	pub fn nest_if_sent_to_token(
@@ -207,69 +201,51 @@
 		under: &T::CrossAccountId,
 		collection_id: CollectionId,
 		token_id: TokenId,
-		nesting_budget: &dyn Budget
+		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		Self::try_exec_if_owner_is_valid_nft(
-			under,
-			|d, parent_id| {
-				d.check_nesting(
-					from,
-					(collection_id, token_id),
-					parent_id,
-					nesting_budget
-				)?;
+		Self::try_exec_if_owner_is_valid_nft(under, |d, parent_id| {
+			d.check_nesting(from, (collection_id, token_id), parent_id, nesting_budget)?;
 
-				d.nest(parent_id, (collection_id, token_id));
+			d.nest(parent_id, (collection_id, token_id));
 
-				Ok(())
-			}
-		)
+			Ok(())
+		})
 	}
 
 	pub fn nest_if_sent_to_token_unchecked(
 		owner: &T::CrossAccountId,
 		collection_id: CollectionId,
-		token_id: TokenId
+		token_id: TokenId,
 	) {
-		Self::exec_if_owner_is_valid_nft(
-			owner,
-			|d, parent_id| d.nest(
-				parent_id,
-				(collection_id, token_id)
-			)
-		);
+		Self::exec_if_owner_is_valid_nft(owner, |d, parent_id| {
+			d.nest(parent_id, (collection_id, token_id))
+		});
 	}
 
 	pub fn unnest_if_nested(
 		owner: &T::CrossAccountId,
 		collection_id: CollectionId,
-		token_id: TokenId
+		token_id: TokenId,
 	) {
-		Self::exec_if_owner_is_valid_nft(
-			owner,
-			|d, parent_id| d.unnest(
-			parent_id,
-			(collection_id, token_id)
-			)
-		);
+		Self::exec_if_owner_is_valid_nft(owner, |d, parent_id| {
+			d.unnest(parent_id, (collection_id, token_id))
+		});
 	}
 
 	fn exec_if_owner_is_valid_nft(
 		account: &T::CrossAccountId,
-		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId)
+		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId),
 	) {
-		Self::try_exec_if_owner_is_valid_nft(
-			account,
-			|d, id| {
-				action(d, id);
-				Ok(())
-			}
-		).unwrap();
+		Self::try_exec_if_owner_is_valid_nft(account, |d, id| {
+			action(d, id);
+			Ok(())
+		})
+		.unwrap();
 	}
 
 	fn try_exec_if_owner_is_valid_nft(
 		account: &T::CrossAccountId,
-		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId) -> DispatchResult
+		action: impl FnOnce(&dyn CommonCollectionOperations<T>, TokenId) -> DispatchResult,
 	) -> DispatchResult {
 		let account = T::CrossTokenAddressMapping::address_to_token(account);
 
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -37,11 +37,10 @@
 use frame_system::{self as system, ensure_signed};
 use sp_runtime::{sp_std::prelude::Vec};
 use up_data_structs::{
-	MAX_COLLECTION_NAME_LENGTH,
-	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, AccessMode, CreateItemData,
-	CollectionLimits, CollectionPermissions, CollectionId, CollectionMode, TokenId, SponsorshipState,
-	CreateCollectionData, CreateItemExData, budget, Property, PropertyKey,
-	PropertyKeyPermission,
+	MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
+	AccessMode, CreateItemData, CollectionLimits, CollectionPermissions, CollectionId,
+	CollectionMode, TokenId, SponsorshipState, CreateCollectionData, CreateItemExData, budget,
+	Property, PropertyKey, PropertyKeyPermission,
 };
 use pallet_evm::account::CrossAccountId;
 use pallet_common::{
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
before · primitives/data-structs/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::{20	convert::{TryFrom, TryInto},21	fmt,22};23use frame_support::{24	storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},25	traits::Get,26	parameter_types,27};2829#[cfg(feature = "serde")]30use serde::{Serialize, Deserialize};3132use sp_core::U256;33use sp_runtime::{ArithmeticError, sp_std::prelude::Vec, Permill};34use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};35use frame_support::{BoundedVec, traits::ConstU32};36use derivative::Derivative;37use scale_info::TypeInfo;3839pub mod rmrk;4041// RMRK42use rmrk::{43	CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,44};45pub use rmrk::{46	primitives::{47		CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,48		PartId as RmrkPartId, ResourceId as RmrkResourceId,49	},50	NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,51	FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart, EquippableList as RmrkEquippableList,52	BasicResource as RmrkBasicResource, ComposableResource as RmrkComposableResource, SlotResource as RmrkSlotResource,53};5455mod bounded;56pub mod budget;57pub mod mapping;58mod migration;5960pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;61pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;62pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;6364pub const MAX_TOKEN_OWNERSHIP: u32 = if cfg!(not(feature = "limit-testing")) {65	100_00066} else {67	1068};69pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {70	100_00071} else {72	1073};74pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {75	204876} else {77	1078};79pub const COLLECTION_ADMINS_LIMIT: u32 = 5;80pub const COLLECTION_TOKEN_LIMIT: u32 = u32::MAX;81pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {82	1_000_00083} else {84	1085};8687// Timeouts for item types in passed blocks88pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;89pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;90pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;9192pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5;9394// Schema limits95pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;96pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;97pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;9899pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;100101pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;102pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;103pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;104105pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;106pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;107pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;108109pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;110pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;111112// RMRK constants113pub const RMRK_STRING_LIMIT: u32 = 128;114pub const RMRK_COLLECTION_SYMBOL_LIMIT: u32 = 100;115pub const RMRK_RESOURCE_SYMBOL_LIMIT: u32 = 10;116pub const RMRK_KEY_LIMIT: u32 = 32;117pub const RMRK_VALUE_LIMIT: u32 = 256;118119/// How much items can be created per single120/// create_many call121pub const MAX_ITEMS_PER_BATCH: u32 = 200;122123pub type CustomDataLimit = ConstU32<CUSTOM_DATA_LIMIT>;124125#[derive(126	Encode,127	Decode,128	PartialEq,129	Eq,130	PartialOrd,131	Ord,132	Clone,133	Copy,134	Debug,135	Default,136	TypeInfo,137	MaxEncodedLen,138)]139#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]140pub struct CollectionId(pub u32);141impl EncodeLike<u32> for CollectionId {}142impl EncodeLike<CollectionId> for u32 {}143144#[derive(145	Encode,146	Decode,147	PartialEq,148	Eq,149	PartialOrd,150	Ord,151	Clone,152	Copy,153	Debug,154	Default,155	TypeInfo,156	MaxEncodedLen,157)]158#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]159pub struct TokenId(pub u32);160impl EncodeLike<u32> for TokenId {}161impl EncodeLike<TokenId> for u32 {}162163impl TokenId {164	pub fn try_next(self) -> Result<TokenId, ArithmeticError> {165		self.0166			.checked_add(1)167			.ok_or(ArithmeticError::Overflow)168			.map(Self)169	}170}171172impl From<TokenId> for U256 {173	fn from(t: TokenId) -> Self {174		t.0.into()175	}176}177178impl TryFrom<U256> for TokenId {179	type Error = &'static str;180181	fn try_from(value: U256) -> Result<Self, Self::Error> {182		Ok(TokenId(value.try_into().map_err(|_| "too large token id")?))183	}184}185186#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]187#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]188pub struct TokenData<CrossAccountId> {189	pub properties: Vec<Property>,190	pub owner: Option<CrossAccountId>,191}192193pub struct OverflowError;194impl From<OverflowError> for &'static str {195	fn from(_: OverflowError) -> Self {196		"overflow occured"197	}198}199200pub type DecimalPoints = u8;201202#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]203#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]204pub enum CollectionMode {205	NFT,206	// decimal points207	Fungible(DecimalPoints),208	ReFungible,209}210211impl CollectionMode {212	pub fn id(&self) -> u8 {213		match self {214			CollectionMode::NFT => 1,215			CollectionMode::Fungible(_) => 2,216			CollectionMode::ReFungible => 3,217		}218	}219}220221pub trait SponsoringResolve<AccountId, Call> {222	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;223}224225#[derive(Encode, Decode, Eq, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]226#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]227pub enum AccessMode {228	Normal,229	AllowList,230}231impl Default for AccessMode {232	fn default() -> Self {233		Self::Normal234	}235}236237#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]238#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]239pub enum SchemaVersion {240	ImageURL,241	Unique,242}243impl Default for SchemaVersion {244	fn default() -> Self {245		Self::ImageURL246	}247}248249#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, TypeInfo)]250#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]251pub struct Ownership<AccountId> {252	pub owner: AccountId,253	pub fraction: u128,254}255256#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]257#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]258pub enum SponsorshipState<AccountId> {259	/// The fees are applied to the transaction sender260	Disabled,261	Unconfirmed(AccountId),262	/// Transactions are sponsored by specified account263	Confirmed(AccountId),264}265266impl<AccountId> SponsorshipState<AccountId> {267	pub fn sponsor(&self) -> Option<&AccountId> {268		match self {269			Self::Confirmed(sponsor) => Some(sponsor),270			_ => None,271		}272	}273274	pub fn pending_sponsor(&self) -> Option<&AccountId> {275		match self {276			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),277			_ => None,278		}279	}280281	pub fn confirmed(&self) -> bool {282		matches!(self, Self::Confirmed(_))283	}284}285286impl<T> Default for SponsorshipState<T> {287	fn default() -> Self {288		Self::Disabled289	}290}291292/// Used in storage293#[struct_versioning::versioned(version = 2, upper)]294#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]295pub struct Collection<AccountId> {296	pub owner: AccountId,297	pub mode: CollectionMode,298	#[version(..2)]299	pub access: AccessMode,300	pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,301	pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,302	pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,303304	#[version(..2)]305	pub mint_mode: bool,306307	#[version(..2)]308	pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,309310	#[version(..2)]311	pub schema_version: SchemaVersion,312	pub sponsorship: SponsorshipState<AccountId>,313314	pub limits: CollectionLimits,315316	#[version(2.., upper(Default::default()))]317	pub permissions: CollectionPermissions,318319	#[version(..2)]320	pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,321322	#[version(..2)]323	pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,324325	#[version(..2)]326	pub meta_update_permission: MetaUpdatePermission,327}328329/// Used in RPC calls330#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]331#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]332pub struct RpcCollection<AccountId> {333	pub owner: AccountId,334	pub mode: CollectionMode,335	pub name: Vec<u16>,336	pub description: Vec<u16>,337	pub token_prefix: Vec<u8>,338	pub sponsorship: SponsorshipState<AccountId>,339	pub limits: CollectionLimits,340	pub permissions: CollectionPermissions,341	pub token_property_permissions: Vec<PropertyKeyPermission>,342	pub properties: Vec<Property>,343}344345#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]346#[derivative(Debug, Default(bound = ""))]347pub struct CreateCollectionData<AccountId> {348	#[derivative(Default(value = "CollectionMode::NFT"))]349	pub mode: CollectionMode,350	pub access: Option<AccessMode>,351	pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,352	pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,353	pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,354	pub pending_sponsor: Option<AccountId>,355	pub limits: Option<CollectionLimits>,356	pub permissions: Option<CollectionPermissions>,357	pub token_property_permissions: CollectionPropertiesPermissionsVec,358	pub properties: CollectionPropertiesVec,359}360361pub type CollectionPropertiesPermissionsVec =362	BoundedVec<PropertyKeyPermission, ConstU32<MAX_PROPERTIES_PER_ITEM>>;363364pub type CollectionPropertiesVec =365	BoundedVec<Property, ConstU32<MAX_PROPERTIES_PER_ITEM>>;366367/// All fields are wrapped in `Option`s, where None means chain default368// When adding/removing fields from this struct - don't forget to also update clamp_limits369#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]370#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]371pub struct CollectionLimits {372	pub account_token_ownership_limit: Option<u32>,373	pub sponsored_data_size: Option<u32>,374375	/// FIXME should we delete this or repurpose it?376	/// None - setVariableMetadata is not sponsored377	/// Some(v) - setVariableMetadata is sponsored378	///           if there is v block between txs379	pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,380	pub token_limit: Option<u32>,381382	// Timeouts for item types in passed blocks383	pub sponsor_transfer_timeout: Option<u32>,384	pub sponsor_approve_timeout: Option<u32>,385	pub owner_can_transfer: Option<bool>,386	pub owner_can_destroy: Option<bool>,387	pub transfers_enabled: Option<bool>,388}389390impl CollectionLimits {391	pub fn account_token_ownership_limit(&self) -> u32 {392		self.account_token_ownership_limit393			.unwrap_or(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)394			.min(MAX_TOKEN_OWNERSHIP)395	}396	pub fn sponsored_data_size(&self) -> u32 {397		self.sponsored_data_size398			.unwrap_or(CUSTOM_DATA_LIMIT)399			.min(CUSTOM_DATA_LIMIT)400	}401	pub fn token_limit(&self) -> u32 {402		self.token_limit403			.unwrap_or(COLLECTION_TOKEN_LIMIT)404			.min(COLLECTION_TOKEN_LIMIT)405	}406	pub fn sponsor_transfer_timeout(&self, default: u32) -> u32 {407		self.sponsor_transfer_timeout408			.unwrap_or(default)409			.min(MAX_SPONSOR_TIMEOUT)410	}411	pub fn sponsor_approve_timeout(&self) -> u32 {412		self.sponsor_approve_timeout413			.unwrap_or(SPONSOR_APPROVE_TIMEOUT)414			.min(MAX_SPONSOR_TIMEOUT)415	}416	pub fn owner_can_transfer(&self) -> bool {417		self.owner_can_transfer.unwrap_or(true)418	}419	pub fn owner_can_destroy(&self) -> bool {420		self.owner_can_destroy.unwrap_or(true)421	}422	pub fn transfers_enabled(&self) -> bool {423		self.transfers_enabled.unwrap_or(true)424	}425	pub fn sponsored_data_rate_limit(&self) -> Option<u32> {426		match self427			.sponsored_data_rate_limit428			.unwrap_or(SponsoringRateLimit::SponsoringDisabled)429		{430			SponsoringRateLimit::SponsoringDisabled => None,431			SponsoringRateLimit::Blocks(v) => Some(v.min(MAX_SPONSOR_TIMEOUT)),432		}433	}434}435436// When adding/removing fields from this struct - don't forget to also update clamp_limits437#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]438#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]439pub struct CollectionPermissions {440	pub access: Option<AccessMode>,441	pub mint_mode: Option<bool>,442	pub nesting: Option<NestingRule>,443}444445impl CollectionPermissions {446	pub fn access(&self) -> AccessMode {447		self.access.unwrap_or(AccessMode::Normal)448	}449	pub fn mint_mode(&self) -> bool {450		self.mint_mode.unwrap_or(false)451	}452	pub fn nesting(&self) -> &NestingRule {453		static DEFAULT: NestingRule = NestingRule::Disabled;454		self.nesting.as_ref().unwrap_or(&DEFAULT)455	}456}457458#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]459#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]460#[derivative(Debug)]461pub enum NestingRule {462	/// No one can nest tokens463	Disabled,464	/// Owner can nest any tokens465	Owner,466	/// Owner can nest tokens from specified collections467	OwnerRestricted(468		#[cfg_attr(feature = "serde1", serde(with = "bounded::set_serde"))]469		#[derivative(Debug(format_with = "bounded::set_debug"))]470		BoundedBTreeSet<CollectionId, ConstU32<16>>,471	),472}473474#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]475#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]476pub enum SponsoringRateLimit {477	SponsoringDisabled,478	Blocks(u32),479}480481#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]482#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]483#[derivative(Debug)]484pub struct CreateNftData {485	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]486	#[derivative(Debug(format_with = "bounded::vec_debug"))]487	pub properties: CollectionPropertiesVec,488}489490#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]491#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]492pub struct CreateFungibleData {493	pub value: u128,494}495496#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]497#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]498#[derivative(Debug)]499pub struct CreateReFungibleData {500	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]501	#[derivative(Debug(format_with = "bounded::vec_debug"))]502	pub const_data: BoundedVec<u8, CustomDataLimit>,503	pub pieces: u128,504}505506#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]507#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]508pub enum MetaUpdatePermission {509	ItemOwner,510	Admin,511	None,512}513514#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]515#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]516pub enum CreateItemData {517	NFT(CreateNftData),518	Fungible(CreateFungibleData),519	ReFungible(CreateReFungibleData),520}521522#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]523#[derivative(Debug)]524pub struct CreateNftExData<CrossAccountId> {525	#[derivative(Debug(format_with = "bounded::vec_debug"))]526	pub properties: CollectionPropertiesVec,527	pub owner: CrossAccountId,528}529530#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]531#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]532pub struct CreateRefungibleExData<CrossAccountId> {533	#[derivative(Debug(format_with = "bounded::vec_debug"))]534	pub const_data: BoundedVec<u8, CustomDataLimit>,535	#[derivative(Debug(format_with = "bounded::map_debug"))]536	pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,537}538539#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]540#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]541pub enum CreateItemExData<CrossAccountId> {542	NFT(543		#[derivative(Debug(format_with = "bounded::vec_debug"))]544		BoundedVec<CreateNftExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,545	),546	Fungible(547		#[derivative(Debug(format_with = "bounded::map_debug"))]548		BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,549	),550	/// Many tokens, each may have only one owner551	RefungibleMultipleItems(552		#[derivative(Debug(format_with = "bounded::vec_debug"))]553		BoundedVec<CreateRefungibleExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,554	),555	/// Single token, which may have many owners556	RefungibleMultipleOwners(CreateRefungibleExData<CrossAccountId>),557}558559impl CreateItemData {560	pub fn data_size(&self) -> usize {561		match self {562			CreateItemData::ReFungible(data) => data.const_data.len(),563			_ => 0,564		}565	}566}567568impl From<CreateNftData> for CreateItemData {569	fn from(item: CreateNftData) -> Self {570		CreateItemData::NFT(item)571	}572}573574impl From<CreateReFungibleData> for CreateItemData {575	fn from(item: CreateReFungibleData) -> Self {576		CreateItemData::ReFungible(item)577	}578}579580impl From<CreateFungibleData> for CreateItemData {581	fn from(item: CreateFungibleData) -> Self {582		CreateItemData::Fungible(item)583	}584}585586#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]587#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]588pub struct CollectionStats {589	pub created: u32,590	pub destroyed: u32,591	pub alive: u32,592}593594#[derive(Encode, Decode, Clone, Debug)]595#[cfg_attr(feature = "std", derive(PartialEq))]596pub struct PhantomType<T>(core::marker::PhantomData<T>);597598impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {599	type Identity = PhantomType<T>;600601	fn type_info() -> scale_info::Type {602		use scale_info::{603			Type, Path,604			build::{FieldsBuilder, UnnamedFields},605			type_params,606		};607		Type::builder()608			.path(Path::new("up_data_structs", "PhantomType"))609			.type_params(type_params!(T))610			.composite(<FieldsBuilder<UnnamedFields>>::default().field(|b| b.ty::<[T; 0]>()))611	}612}613impl<T> MaxEncodedLen for PhantomType<T> {614	fn max_encoded_len() -> usize {615		0616	}617}618619pub type PropertyKey = BoundedVec<u8, ConstU32<MAX_PROPERTY_KEY_LENGTH>>;620pub type PropertyValue = BoundedVec<u8, ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;621622#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]623#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]624pub struct PropertyPermission {625	pub mutable: bool,626	pub collection_admin: bool,627	pub token_owner: bool,628}629630impl PropertyPermission {631	pub fn none() -> Self {632		Self {633			mutable: true,634			collection_admin: false,635			token_owner: false,636		}637	}638}639640#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]641#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]642pub struct Property {643	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]644	pub key: PropertyKey,645646	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]647	pub value: PropertyValue,648}649650impl Into<(PropertyKey, PropertyValue)> for Property {651	fn into(self) -> (PropertyKey, PropertyValue) {652		(self.key, self.value)653	}654}655656#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]657#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]658pub struct PropertyKeyPermission {659	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]660	pub key: PropertyKey,661662	pub permission: PropertyPermission,663}664665impl Into<(PropertyKey, PropertyPermission)> for PropertyKeyPermission {666	fn into(self) -> (PropertyKey, PropertyPermission) {667		(self.key, self.permission)668	}669}670671#[derive(Debug)]672pub enum PropertiesError {673	NoSpaceForProperty,674	PropertyLimitReached,675	InvalidCharacterInPropertyKey,676	PropertyKeyIsTooLong,677	EmptyPropertyKey,678}679680#[derive(Clone, Copy)]681pub enum PropertyScope {682	None,683	Rmrk,684}685686impl PropertyScope {687	pub fn apply(self, key: PropertyKey) -> Result<PropertyKey, PropertiesError> {688		let scope_str: &[u8] = match self {689			Self::None => return Ok(key),690			Self::Rmrk => b"rmrk",691		};692693		[scope_str, b":", key.as_slice()]694			.concat()695			.try_into()696			.map_err(|_| PropertiesError::PropertyKeyIsTooLong)697	}698}699700pub trait TrySetProperty: Sized {701	type Value;702703	fn try_scoped_set(704		&mut self,705		scope: PropertyScope,706		key: PropertyKey,707		value: Self::Value,708	) -> Result<(), PropertiesError>;709710	fn try_scoped_set_from_iter<I, KV>(711		&mut self,712		scope: PropertyScope,713		iter: I,714	) -> Result<(), PropertiesError>715	where716		I: Iterator<Item = KV>,717		KV: Into<(PropertyKey, Self::Value)>,718	{719		for kv in iter {720			let (key, value) = kv.into();721			self.try_scoped_set(scope, key, value)?;722		}723724		Ok(())725	}726727	fn try_set(&mut self, key: PropertyKey, value: Self::Value) -> Result<(), PropertiesError> {728		self.try_scoped_set(PropertyScope::None, key, value)729	}730731	fn try_set_from_iter<I, KV>(&mut self, iter: I) -> Result<(), PropertiesError>732	where733		I: Iterator<Item = KV>,734		KV: Into<(PropertyKey, Self::Value)>,735	{736		self.try_scoped_set_from_iter(PropertyScope::None, iter)737	}738}739740#[derive(Encode, Decode, TypeInfo, Derivative, Clone, PartialEq, MaxEncodedLen)]741#[derivative(Default(bound = ""))]742pub struct PropertiesMap<Value>(743	BoundedBTreeMap<PropertyKey, Value, ConstU32<MAX_PROPERTIES_PER_ITEM>>,744);745746impl<Value> PropertiesMap<Value> {747	pub fn new() -> Self {748		Self(BoundedBTreeMap::new())749	}750751	pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<Value>, PropertiesError> {752		Self::check_property_key(key)?;753754		Ok(self.0.remove(key))755	}756757	pub fn get(&self, key: &PropertyKey) -> Option<&Value> {758		self.0.get(key)759	}760761	pub fn contains_key(&self, key: &PropertyKey) -> bool {762		self.0.contains_key(key)763	}764765	fn check_property_key(key: &PropertyKey) -> Result<(), PropertiesError> {766		if key.is_empty() {767			return Err(PropertiesError::EmptyPropertyKey);768		}769770		for byte in key.as_slice().iter() {771			let byte = *byte;772773			if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' {774				return Err(PropertiesError::InvalidCharacterInPropertyKey);775			}776		}777778		Ok(())779	}780}781782impl<Value> IntoIterator for PropertiesMap<Value> {783	type Item = (PropertyKey, Value);784	type IntoIter = <785		BoundedBTreeMap<786			PropertyKey,787			Value,788			ConstU32<MAX_PROPERTIES_PER_ITEM>789		> as IntoIterator790	>::IntoIter;791792	fn into_iter(self) -> Self::IntoIter {793        self.0.into_iter()794    }795}796797impl<Value> TrySetProperty for PropertiesMap<Value> {798	type Value = Value;799800	fn try_scoped_set(801		&mut self,802		scope: PropertyScope,803		key: PropertyKey,804		value: Self::Value,805	) -> Result<(), PropertiesError> {806		Self::check_property_key(&key)?;807808		let key = scope.apply(key)?;809		self.0810			.try_insert(key, value)811			.map_err(|_| PropertiesError::PropertyLimitReached)?;812813		Ok(())814	}815}816817pub type PropertiesPermissionMap = PropertiesMap<PropertyPermission>;818819#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, MaxEncodedLen)]820pub struct Properties {821	map: PropertiesMap<PropertyValue>,822	consumed_space: u32,823	space_limit: u32,824}825826impl Properties {827	pub fn new(space_limit: u32) -> Self {828		Self {829			map: PropertiesMap::new(),830			consumed_space: 0,831			space_limit,832		}833	}834835	pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<PropertyValue>, PropertiesError> {836		let value = self.map.remove(key)?;837838		if let Some(ref value) = value {839			let value_len = value.len() as u32;840			self.consumed_space -= value_len;841		}842843		Ok(value)844	}845846	pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue> {847		self.map.get(key)848	}849}850851impl IntoIterator for Properties {852	type Item = (PropertyKey, PropertyValue);853	type IntoIter = <PropertiesMap<PropertyValue> as IntoIterator>::IntoIter;854855	fn into_iter(self) -> Self::IntoIter {856        self.map.into_iter()857    }858}859860impl TrySetProperty for Properties {861	type Value = PropertyValue;862863	fn try_scoped_set(864		&mut self,865		scope: PropertyScope,866		key: PropertyKey,867		value: Self::Value,868	) -> Result<(), PropertiesError> {869		let value_len = value.len();870871		if self.consumed_space as usize + value_len > self.space_limit as usize872			&& !cfg!(feature = "runtime-benchmarks")873		{874			return Err(PropertiesError::NoSpaceForProperty);875		}876877		self.map.try_scoped_set(scope, key, value)?;878879		self.consumed_space += value_len as u32;880881		Ok(())882	}883}884885pub struct CollectionProperties;886887impl Get<Properties> for CollectionProperties {888	fn get() -> Properties {889		Properties::new(MAX_COLLECTION_PROPERTIES_SIZE)890	}891}892893pub struct TokenProperties;894895impl Get<Properties> for TokenProperties {896	fn get() -> Properties {897		Properties::new(MAX_TOKEN_PROPERTIES_SIZE)898	}899}900901// RMRK902// todo document?903parameter_types! {904	#[derive(PartialEq, TypeInfo)]905	pub const RmrkStringLimit: u32 = 128;906	#[derive(PartialEq)]907	pub const RmrkCollectionSymbolLimit: u32 = 100;908	#[derive(PartialEq)]909	pub const RmrkResourceSymbolLimit: u32 = 10;910	#[derive(PartialEq)]911	pub const RmrkKeyLimit: u32 = 32;912	#[derive(PartialEq)]913	pub const RmrkValueLimit: u32 = 256;914	#[derive(PartialEq)]915	pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;916	#[derive(PartialEq)]917	pub const RmrkPartsLimit: u32 = 3;918}919920impl From<RmrkCollectionId> for CollectionId {921	fn from(id: RmrkCollectionId) -> Self {922		Self(id)923	}924}925926impl From<RmrkNftId> for TokenId {927	fn from(id: RmrkNftId) -> Self {928		Self(id)929	}930}931932pub type RmrkCollectionInfo<AccountId> =933	CollectionInfo<RmrkString, RmrkCollectionSymbol, AccountId>;934pub type RmrkInstanceInfo<AccountId> = NftInfo<AccountId, Permill, RmrkString>;935pub type RmrkResourceInfo = ResourceInfo<936	RmrkBoundedResource,937	RmrkString,938	RmrkBoundedParts,939>;940pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;941pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;942pub type RmrkPartType =943	PartType<RmrkString, BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>>;944pub type RmrkThemeProperty = ThemeProperty<RmrkString>;945pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;946947pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;948pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;949pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;950951type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;952type RmrkBoundedParts = BoundedVec<RmrkPartId, RmrkPartsLimit>;953954pub type RmrkRpcString = Vec<u8>;955pub type RmrkThemeName = RmrkRpcString;956pub type RmrkPropertyKey = RmrkRpcString;957958pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;
after · primitives/data-structs/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::{20	convert::{TryFrom, TryInto},21	fmt,22};23use frame_support::{24	storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},25	traits::Get,26	parameter_types,27};2829#[cfg(feature = "serde")]30use serde::{Serialize, Deserialize};3132use sp_core::U256;33use sp_runtime::{ArithmeticError, sp_std::prelude::Vec, Permill};34use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};35use frame_support::{BoundedVec, traits::ConstU32};36use derivative::Derivative;37use scale_info::TypeInfo;3839pub mod rmrk;4041// RMRK42use rmrk::{43	CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,44};45pub use rmrk::{46	primitives::{47		CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,48		PartId as RmrkPartId, ResourceId as RmrkResourceId,49	},50	NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,51	FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart, EquippableList as RmrkEquippableList,52	BasicResource as RmrkBasicResource, ComposableResource as RmrkComposableResource,53	SlotResource as RmrkSlotResource,54};5556mod bounded;57pub mod budget;58pub mod mapping;59mod migration;6061pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;62pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;63pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;6465pub const MAX_TOKEN_OWNERSHIP: u32 = if cfg!(not(feature = "limit-testing")) {66	100_00067} else {68	1069};70pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {71	100_00072} else {73	1074};75pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {76	204877} else {78	1079};80pub const COLLECTION_ADMINS_LIMIT: u32 = 5;81pub const COLLECTION_TOKEN_LIMIT: u32 = u32::MAX;82pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {83	1_000_00084} else {85	1086};8788// Timeouts for item types in passed blocks89pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;90pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;91pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;9293pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5;9495// Schema limits96pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;97pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;98pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;99100pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;101102pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;103pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;104pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;105106pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;107pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;108pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;109110pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;111pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;112113// RMRK constants114pub const RMRK_STRING_LIMIT: u32 = 128;115pub const RMRK_COLLECTION_SYMBOL_LIMIT: u32 = 100;116pub const RMRK_RESOURCE_SYMBOL_LIMIT: u32 = 10;117pub const RMRK_KEY_LIMIT: u32 = 32;118pub const RMRK_VALUE_LIMIT: u32 = 256;119120/// How much items can be created per single121/// create_many call122pub const MAX_ITEMS_PER_BATCH: u32 = 200;123124pub type CustomDataLimit = ConstU32<CUSTOM_DATA_LIMIT>;125126#[derive(127	Encode,128	Decode,129	PartialEq,130	Eq,131	PartialOrd,132	Ord,133	Clone,134	Copy,135	Debug,136	Default,137	TypeInfo,138	MaxEncodedLen,139)]140#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]141pub struct CollectionId(pub u32);142impl EncodeLike<u32> for CollectionId {}143impl EncodeLike<CollectionId> for u32 {}144145#[derive(146	Encode,147	Decode,148	PartialEq,149	Eq,150	PartialOrd,151	Ord,152	Clone,153	Copy,154	Debug,155	Default,156	TypeInfo,157	MaxEncodedLen,158)]159#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]160pub struct TokenId(pub u32);161impl EncodeLike<u32> for TokenId {}162impl EncodeLike<TokenId> for u32 {}163164impl TokenId {165	pub fn try_next(self) -> Result<TokenId, ArithmeticError> {166		self.0167			.checked_add(1)168			.ok_or(ArithmeticError::Overflow)169			.map(Self)170	}171}172173impl From<TokenId> for U256 {174	fn from(t: TokenId) -> Self {175		t.0.into()176	}177}178179impl TryFrom<U256> for TokenId {180	type Error = &'static str;181182	fn try_from(value: U256) -> Result<Self, Self::Error> {183		Ok(TokenId(value.try_into().map_err(|_| "too large token id")?))184	}185}186187#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]188#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]189pub struct TokenData<CrossAccountId> {190	pub properties: Vec<Property>,191	pub owner: Option<CrossAccountId>,192}193194pub struct OverflowError;195impl From<OverflowError> for &'static str {196	fn from(_: OverflowError) -> Self {197		"overflow occured"198	}199}200201pub type DecimalPoints = u8;202203#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]204#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]205pub enum CollectionMode {206	NFT,207	// decimal points208	Fungible(DecimalPoints),209	ReFungible,210}211212impl CollectionMode {213	pub fn id(&self) -> u8 {214		match self {215			CollectionMode::NFT => 1,216			CollectionMode::Fungible(_) => 2,217			CollectionMode::ReFungible => 3,218		}219	}220}221222pub trait SponsoringResolve<AccountId, Call> {223	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;224}225226#[derive(Encode, Decode, Eq, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]227#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]228pub enum AccessMode {229	Normal,230	AllowList,231}232impl Default for AccessMode {233	fn default() -> Self {234		Self::Normal235	}236}237238#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]239#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]240pub enum SchemaVersion {241	ImageURL,242	Unique,243}244impl Default for SchemaVersion {245	fn default() -> Self {246		Self::ImageURL247	}248}249250#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, TypeInfo)]251#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]252pub struct Ownership<AccountId> {253	pub owner: AccountId,254	pub fraction: u128,255}256257#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]258#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]259pub enum SponsorshipState<AccountId> {260	/// The fees are applied to the transaction sender261	Disabled,262	Unconfirmed(AccountId),263	/// Transactions are sponsored by specified account264	Confirmed(AccountId),265}266267impl<AccountId> SponsorshipState<AccountId> {268	pub fn sponsor(&self) -> Option<&AccountId> {269		match self {270			Self::Confirmed(sponsor) => Some(sponsor),271			_ => None,272		}273	}274275	pub fn pending_sponsor(&self) -> Option<&AccountId> {276		match self {277			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),278			_ => None,279		}280	}281282	pub fn confirmed(&self) -> bool {283		matches!(self, Self::Confirmed(_))284	}285}286287impl<T> Default for SponsorshipState<T> {288	fn default() -> Self {289		Self::Disabled290	}291}292293/// Used in storage294#[struct_versioning::versioned(version = 2, upper)]295#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]296pub struct Collection<AccountId> {297	pub owner: AccountId,298	pub mode: CollectionMode,299	#[version(..2)]300	pub access: AccessMode,301	pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,302	pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,303	pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,304305	#[version(..2)]306	pub mint_mode: bool,307308	#[version(..2)]309	pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,310311	#[version(..2)]312	pub schema_version: SchemaVersion,313	pub sponsorship: SponsorshipState<AccountId>,314315	pub limits: CollectionLimits,316317	#[version(2.., upper(Default::default()))]318	pub permissions: CollectionPermissions,319320	#[version(..2)]321	pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,322323	#[version(..2)]324	pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,325326	#[version(..2)]327	pub meta_update_permission: MetaUpdatePermission,328}329330/// Used in RPC calls331#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]332#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]333pub struct RpcCollection<AccountId> {334	pub owner: AccountId,335	pub mode: CollectionMode,336	pub name: Vec<u16>,337	pub description: Vec<u16>,338	pub token_prefix: Vec<u8>,339	pub sponsorship: SponsorshipState<AccountId>,340	pub limits: CollectionLimits,341	pub permissions: CollectionPermissions,342	pub token_property_permissions: Vec<PropertyKeyPermission>,343	pub properties: Vec<Property>,344}345346#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]347#[derivative(Debug, Default(bound = ""))]348pub struct CreateCollectionData<AccountId> {349	#[derivative(Default(value = "CollectionMode::NFT"))]350	pub mode: CollectionMode,351	pub access: Option<AccessMode>,352	pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,353	pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,354	pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,355	pub pending_sponsor: Option<AccountId>,356	pub limits: Option<CollectionLimits>,357	pub permissions: Option<CollectionPermissions>,358	pub token_property_permissions: CollectionPropertiesPermissionsVec,359	pub properties: CollectionPropertiesVec,360}361362pub type CollectionPropertiesPermissionsVec =363	BoundedVec<PropertyKeyPermission, ConstU32<MAX_PROPERTIES_PER_ITEM>>;364365pub type CollectionPropertiesVec = BoundedVec<Property, ConstU32<MAX_PROPERTIES_PER_ITEM>>;366367/// All fields are wrapped in `Option`s, where None means chain default368// When adding/removing fields from this struct - don't forget to also update clamp_limits369#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]370#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]371pub struct CollectionLimits {372	pub account_token_ownership_limit: Option<u32>,373	pub sponsored_data_size: Option<u32>,374375	/// FIXME should we delete this or repurpose it?376	/// None - setVariableMetadata is not sponsored377	/// Some(v) - setVariableMetadata is sponsored378	///           if there is v block between txs379	pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,380	pub token_limit: Option<u32>,381382	// Timeouts for item types in passed blocks383	pub sponsor_transfer_timeout: Option<u32>,384	pub sponsor_approve_timeout: Option<u32>,385	pub owner_can_transfer: Option<bool>,386	pub owner_can_destroy: Option<bool>,387	pub transfers_enabled: Option<bool>,388}389390impl CollectionLimits {391	pub fn account_token_ownership_limit(&self) -> u32 {392		self.account_token_ownership_limit393			.unwrap_or(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)394			.min(MAX_TOKEN_OWNERSHIP)395	}396	pub fn sponsored_data_size(&self) -> u32 {397		self.sponsored_data_size398			.unwrap_or(CUSTOM_DATA_LIMIT)399			.min(CUSTOM_DATA_LIMIT)400	}401	pub fn token_limit(&self) -> u32 {402		self.token_limit403			.unwrap_or(COLLECTION_TOKEN_LIMIT)404			.min(COLLECTION_TOKEN_LIMIT)405	}406	pub fn sponsor_transfer_timeout(&self, default: u32) -> u32 {407		self.sponsor_transfer_timeout408			.unwrap_or(default)409			.min(MAX_SPONSOR_TIMEOUT)410	}411	pub fn sponsor_approve_timeout(&self) -> u32 {412		self.sponsor_approve_timeout413			.unwrap_or(SPONSOR_APPROVE_TIMEOUT)414			.min(MAX_SPONSOR_TIMEOUT)415	}416	pub fn owner_can_transfer(&self) -> bool {417		self.owner_can_transfer.unwrap_or(true)418	}419	pub fn owner_can_destroy(&self) -> bool {420		self.owner_can_destroy.unwrap_or(true)421	}422	pub fn transfers_enabled(&self) -> bool {423		self.transfers_enabled.unwrap_or(true)424	}425	pub fn sponsored_data_rate_limit(&self) -> Option<u32> {426		match self427			.sponsored_data_rate_limit428			.unwrap_or(SponsoringRateLimit::SponsoringDisabled)429		{430			SponsoringRateLimit::SponsoringDisabled => None,431			SponsoringRateLimit::Blocks(v) => Some(v.min(MAX_SPONSOR_TIMEOUT)),432		}433	}434}435436// When adding/removing fields from this struct - don't forget to also update clamp_limits437#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]438#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]439pub struct CollectionPermissions {440	pub access: Option<AccessMode>,441	pub mint_mode: Option<bool>,442	pub nesting: Option<NestingRule>,443}444445impl CollectionPermissions {446	pub fn access(&self) -> AccessMode {447		self.access.unwrap_or(AccessMode::Normal)448	}449	pub fn mint_mode(&self) -> bool {450		self.mint_mode.unwrap_or(false)451	}452	pub fn nesting(&self) -> &NestingRule {453		static DEFAULT: NestingRule = NestingRule::Disabled;454		self.nesting.as_ref().unwrap_or(&DEFAULT)455	}456}457458#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]459#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]460#[derivative(Debug)]461pub enum NestingRule {462	/// No one can nest tokens463	Disabled,464	/// Owner can nest any tokens465	Owner,466	/// Owner can nest tokens from specified collections467	OwnerRestricted(468		#[cfg_attr(feature = "serde1", serde(with = "bounded::set_serde"))]469		#[derivative(Debug(format_with = "bounded::set_debug"))]470		BoundedBTreeSet<CollectionId, ConstU32<16>>,471	),472}473474#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]475#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]476pub enum SponsoringRateLimit {477	SponsoringDisabled,478	Blocks(u32),479}480481#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]482#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]483#[derivative(Debug)]484pub struct CreateNftData {485	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]486	#[derivative(Debug(format_with = "bounded::vec_debug"))]487	pub properties: CollectionPropertiesVec,488}489490#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]491#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]492pub struct CreateFungibleData {493	pub value: u128,494}495496#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]497#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]498#[derivative(Debug)]499pub struct CreateReFungibleData {500	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]501	#[derivative(Debug(format_with = "bounded::vec_debug"))]502	pub const_data: BoundedVec<u8, CustomDataLimit>,503	pub pieces: u128,504}505506#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]507#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]508pub enum MetaUpdatePermission {509	ItemOwner,510	Admin,511	None,512}513514#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]515#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]516pub enum CreateItemData {517	NFT(CreateNftData),518	Fungible(CreateFungibleData),519	ReFungible(CreateReFungibleData),520}521522#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]523#[derivative(Debug)]524pub struct CreateNftExData<CrossAccountId> {525	#[derivative(Debug(format_with = "bounded::vec_debug"))]526	pub properties: CollectionPropertiesVec,527	pub owner: CrossAccountId,528}529530#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]531#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]532pub struct CreateRefungibleExData<CrossAccountId> {533	#[derivative(Debug(format_with = "bounded::vec_debug"))]534	pub const_data: BoundedVec<u8, CustomDataLimit>,535	#[derivative(Debug(format_with = "bounded::map_debug"))]536	pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,537}538539#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]540#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]541pub enum CreateItemExData<CrossAccountId> {542	NFT(543		#[derivative(Debug(format_with = "bounded::vec_debug"))]544		BoundedVec<CreateNftExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,545	),546	Fungible(547		#[derivative(Debug(format_with = "bounded::map_debug"))]548		BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,549	),550	/// Many tokens, each may have only one owner551	RefungibleMultipleItems(552		#[derivative(Debug(format_with = "bounded::vec_debug"))]553		BoundedVec<CreateRefungibleExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,554	),555	/// Single token, which may have many owners556	RefungibleMultipleOwners(CreateRefungibleExData<CrossAccountId>),557}558559impl CreateItemData {560	pub fn data_size(&self) -> usize {561		match self {562			CreateItemData::ReFungible(data) => data.const_data.len(),563			_ => 0,564		}565	}566}567568impl From<CreateNftData> for CreateItemData {569	fn from(item: CreateNftData) -> Self {570		CreateItemData::NFT(item)571	}572}573574impl From<CreateReFungibleData> for CreateItemData {575	fn from(item: CreateReFungibleData) -> Self {576		CreateItemData::ReFungible(item)577	}578}579580impl From<CreateFungibleData> for CreateItemData {581	fn from(item: CreateFungibleData) -> Self {582		CreateItemData::Fungible(item)583	}584}585586#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]587#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]588pub struct CollectionStats {589	pub created: u32,590	pub destroyed: u32,591	pub alive: u32,592}593594#[derive(Encode, Decode, Clone, Debug)]595#[cfg_attr(feature = "std", derive(PartialEq))]596pub struct PhantomType<T>(core::marker::PhantomData<T>);597598impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {599	type Identity = PhantomType<T>;600601	fn type_info() -> scale_info::Type {602		use scale_info::{603			Type, Path,604			build::{FieldsBuilder, UnnamedFields},605			type_params,606		};607		Type::builder()608			.path(Path::new("up_data_structs", "PhantomType"))609			.type_params(type_params!(T))610			.composite(<FieldsBuilder<UnnamedFields>>::default().field(|b| b.ty::<[T; 0]>()))611	}612}613impl<T> MaxEncodedLen for PhantomType<T> {614	fn max_encoded_len() -> usize {615		0616	}617}618619pub type PropertyKey = BoundedVec<u8, ConstU32<MAX_PROPERTY_KEY_LENGTH>>;620pub type PropertyValue = BoundedVec<u8, ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;621622#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]623#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]624pub struct PropertyPermission {625	pub mutable: bool,626	pub collection_admin: bool,627	pub token_owner: bool,628}629630impl PropertyPermission {631	pub fn none() -> Self {632		Self {633			mutable: true,634			collection_admin: false,635			token_owner: false,636		}637	}638}639640#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]641#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]642pub struct Property {643	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]644	pub key: PropertyKey,645646	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]647	pub value: PropertyValue,648}649650impl Into<(PropertyKey, PropertyValue)> for Property {651	fn into(self) -> (PropertyKey, PropertyValue) {652		(self.key, self.value)653	}654}655656#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]657#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]658pub struct PropertyKeyPermission {659	#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]660	pub key: PropertyKey,661662	pub permission: PropertyPermission,663}664665impl Into<(PropertyKey, PropertyPermission)> for PropertyKeyPermission {666	fn into(self) -> (PropertyKey, PropertyPermission) {667		(self.key, self.permission)668	}669}670671#[derive(Debug)]672pub enum PropertiesError {673	NoSpaceForProperty,674	PropertyLimitReached,675	InvalidCharacterInPropertyKey,676	PropertyKeyIsTooLong,677	EmptyPropertyKey,678}679680#[derive(Clone, Copy)]681pub enum PropertyScope {682	None,683	Rmrk,684}685686impl PropertyScope {687	pub fn apply(self, key: PropertyKey) -> Result<PropertyKey, PropertiesError> {688		let scope_str: &[u8] = match self {689			Self::None => return Ok(key),690			Self::Rmrk => b"rmrk",691		};692693		[scope_str, b":", key.as_slice()]694			.concat()695			.try_into()696			.map_err(|_| PropertiesError::PropertyKeyIsTooLong)697	}698}699700pub trait TrySetProperty: Sized {701	type Value;702703	fn try_scoped_set(704		&mut self,705		scope: PropertyScope,706		key: PropertyKey,707		value: Self::Value,708	) -> Result<(), PropertiesError>;709710	fn try_scoped_set_from_iter<I, KV>(711		&mut self,712		scope: PropertyScope,713		iter: I,714	) -> Result<(), PropertiesError>715	where716		I: Iterator<Item = KV>,717		KV: Into<(PropertyKey, Self::Value)>,718	{719		for kv in iter {720			let (key, value) = kv.into();721			self.try_scoped_set(scope, key, value)?;722		}723724		Ok(())725	}726727	fn try_set(&mut self, key: PropertyKey, value: Self::Value) -> Result<(), PropertiesError> {728		self.try_scoped_set(PropertyScope::None, key, value)729	}730731	fn try_set_from_iter<I, KV>(&mut self, iter: I) -> Result<(), PropertiesError>732	where733		I: Iterator<Item = KV>,734		KV: Into<(PropertyKey, Self::Value)>,735	{736		self.try_scoped_set_from_iter(PropertyScope::None, iter)737	}738}739740#[derive(Encode, Decode, TypeInfo, Derivative, Clone, PartialEq, MaxEncodedLen)]741#[derivative(Default(bound = ""))]742pub struct PropertiesMap<Value>(743	BoundedBTreeMap<PropertyKey, Value, ConstU32<MAX_PROPERTIES_PER_ITEM>>,744);745746impl<Value> PropertiesMap<Value> {747	pub fn new() -> Self {748		Self(BoundedBTreeMap::new())749	}750751	pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<Value>, PropertiesError> {752		Self::check_property_key(key)?;753754		Ok(self.0.remove(key))755	}756757	pub fn get(&self, key: &PropertyKey) -> Option<&Value> {758		self.0.get(key)759	}760761	pub fn contains_key(&self, key: &PropertyKey) -> bool {762		self.0.contains_key(key)763	}764765	fn check_property_key(key: &PropertyKey) -> Result<(), PropertiesError> {766		if key.is_empty() {767			return Err(PropertiesError::EmptyPropertyKey);768		}769770		for byte in key.as_slice().iter() {771			let byte = *byte;772773			if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' {774				return Err(PropertiesError::InvalidCharacterInPropertyKey);775			}776		}777778		Ok(())779	}780}781782impl<Value> IntoIterator for PropertiesMap<Value> {783	type Item = (PropertyKey, Value);784	type IntoIter = <785		BoundedBTreeMap<786			PropertyKey,787			Value,788			ConstU32<MAX_PROPERTIES_PER_ITEM>789		> as IntoIterator790	>::IntoIter;791792	fn into_iter(self) -> Self::IntoIter {793		self.0.into_iter()794	}795}796797impl<Value> TrySetProperty for PropertiesMap<Value> {798	type Value = Value;799800	fn try_scoped_set(801		&mut self,802		scope: PropertyScope,803		key: PropertyKey,804		value: Self::Value,805	) -> Result<(), PropertiesError> {806		Self::check_property_key(&key)?;807808		let key = scope.apply(key)?;809		self.0810			.try_insert(key, value)811			.map_err(|_| PropertiesError::PropertyLimitReached)?;812813		Ok(())814	}815}816817pub type PropertiesPermissionMap = PropertiesMap<PropertyPermission>;818819#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, MaxEncodedLen)]820pub struct Properties {821	map: PropertiesMap<PropertyValue>,822	consumed_space: u32,823	space_limit: u32,824}825826impl Properties {827	pub fn new(space_limit: u32) -> Self {828		Self {829			map: PropertiesMap::new(),830			consumed_space: 0,831			space_limit,832		}833	}834835	pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<PropertyValue>, PropertiesError> {836		let value = self.map.remove(key)?;837838		if let Some(ref value) = value {839			let value_len = value.len() as u32;840			self.consumed_space -= value_len;841		}842843		Ok(value)844	}845846	pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue> {847		self.map.get(key)848	}849}850851impl IntoIterator for Properties {852	type Item = (PropertyKey, PropertyValue);853	type IntoIter = <PropertiesMap<PropertyValue> as IntoIterator>::IntoIter;854855	fn into_iter(self) -> Self::IntoIter {856		self.map.into_iter()857	}858}859860impl TrySetProperty for Properties {861	type Value = PropertyValue;862863	fn try_scoped_set(864		&mut self,865		scope: PropertyScope,866		key: PropertyKey,867		value: Self::Value,868	) -> Result<(), PropertiesError> {869		let value_len = value.len();870871		if self.consumed_space as usize + value_len > self.space_limit as usize872			&& !cfg!(feature = "runtime-benchmarks")873		{874			return Err(PropertiesError::NoSpaceForProperty);875		}876877		self.map.try_scoped_set(scope, key, value)?;878879		self.consumed_space += value_len as u32;880881		Ok(())882	}883}884885pub struct CollectionProperties;886887impl Get<Properties> for CollectionProperties {888	fn get() -> Properties {889		Properties::new(MAX_COLLECTION_PROPERTIES_SIZE)890	}891}892893pub struct TokenProperties;894895impl Get<Properties> for TokenProperties {896	fn get() -> Properties {897		Properties::new(MAX_TOKEN_PROPERTIES_SIZE)898	}899}900901// RMRK902// todo document?903parameter_types! {904	#[derive(PartialEq, TypeInfo)]905	pub const RmrkStringLimit: u32 = 128;906	#[derive(PartialEq)]907	pub const RmrkCollectionSymbolLimit: u32 = 100;908	#[derive(PartialEq)]909	pub const RmrkResourceSymbolLimit: u32 = 10;910	#[derive(PartialEq)]911	pub const RmrkKeyLimit: u32 = 32;912	#[derive(PartialEq)]913	pub const RmrkValueLimit: u32 = 256;914	#[derive(PartialEq)]915	pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;916	#[derive(PartialEq)]917	pub const RmrkPartsLimit: u32 = 3;918}919920impl From<RmrkCollectionId> for CollectionId {921	fn from(id: RmrkCollectionId) -> Self {922		Self(id)923	}924}925926impl From<RmrkNftId> for TokenId {927	fn from(id: RmrkNftId) -> Self {928		Self(id)929	}930}931932pub type RmrkCollectionInfo<AccountId> =933	CollectionInfo<RmrkString, RmrkCollectionSymbol, AccountId>;934pub type RmrkInstanceInfo<AccountId> = NftInfo<AccountId, Permill, RmrkString>;935pub type RmrkResourceInfo = ResourceInfo<RmrkBoundedResource, RmrkString, RmrkBoundedParts>;936pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;937pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;938pub type RmrkPartType =939	PartType<RmrkString, BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>>;940pub type RmrkThemeProperty = ThemeProperty<RmrkString>;941pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;942943pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;944pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;945pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;946947type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;948type RmrkBoundedParts = BoundedVec<RmrkPartId, RmrkPartsLimit>;949950pub type RmrkRpcString = Vec<u8>;951pub type RmrkThemeName = RmrkRpcString;952pub type RmrkPropertyKey = RmrkRpcString;953954pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;
modifiedprimitives/data-structs/src/rmrk.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/rmrk.rs
+++ b/primitives/data-structs/src/rmrk.rs
@@ -20,37 +20,37 @@
 
 #[cfg(feature = "std")]
 mod serialize {
-    use core::convert::AsRef;
-    use serde::ser::{self, Serialize};
+	use core::convert::AsRef;
+	use serde::ser::{self, Serialize};
 
-    pub mod vec {
-        use super::*;
+	pub mod vec {
+		use super::*;
 
-        pub fn serialize<D, V, C>(value: &C, serializer: D) -> Result<D::Ok, D::Error>
-        where
-            D: ser::Serializer,
-            V: Serialize,
-            C: AsRef<[V]>,
-        {
-            value.as_ref().serialize(serializer)
-        }
-    }
+		pub fn serialize<D, V, C>(value: &C, serializer: D) -> Result<D::Ok, D::Error>
+		where
+			D: ser::Serializer,
+			V: Serialize,
+			C: AsRef<[V]>,
+		{
+			value.as_ref().serialize(serializer)
+		}
+	}
 
-    pub mod opt_vec {
-        use super::*;
+	pub mod opt_vec {
+		use super::*;
 
-        pub fn serialize<D, V, C>(value: &Option<C>, serializer: D) -> Result<D::Ok, D::Error>
-        where
-            D: ser::Serializer,
-            V: Serialize,
-            C: AsRef<[V]>,
-        {
-            match value {
-                Some(value) => super::vec::serialize(value, serializer),
-                None => serializer.serialize_none()
-            }
-        }
-    }
+		pub fn serialize<D, V, C>(value: &Option<C>, serializer: D) -> Result<D::Ok, D::Error>
+		where
+			D: ser::Serializer,
+			V: Serialize,
+			C: AsRef<[V]>,
+		{
+			match value {
+				Some(value) => super::vec::serialize(value, serializer),
+				None => serializer.serialize_none(),
+			}
+		}
+	}
 }
 
 /// Collection info.
@@ -58,13 +58,11 @@
 #[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			AccountId: Serialize,
 			BoundedString: AsRef<[u8]>,
 			BoundedSymbol: AsRef<[u8]>
-		"#
-	)
+		"#)
 )]
 pub struct CollectionInfo<BoundedString, BoundedSymbol, AccountId> {
 	/// Current bidder and bid price.
@@ -91,9 +89,9 @@
 #[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
 pub struct RoyaltyInfo<AccountId, RoyaltyAmount> {
 	/// Recipient (AccountId) of the royalty
-    pub recipient: AccountId,
+	pub recipient: AccountId,
 	/// Amount (Permill) of the royalty
-    pub amount: RoyaltyAmount,
+	pub amount: RoyaltyAmount,
 }
 
 /// Nft info.
@@ -101,13 +99,11 @@
 #[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			AccountId: Serialize,
 			RoyaltyAmount: Serialize,
 			BoundedString: AsRef<[u8]>
-		"#
-	)
+		"#)
 )]
 pub struct NftInfo<AccountId, RoyaltyAmount, BoundedString> {
 	/// The owner of the NFT, can be either an Account or a tuple (CollectionId, NftId)
@@ -129,22 +125,19 @@
 #[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]
 pub struct NftChild {
 	pub collection_id: CollectionId,
-	pub nft_id: NftId
+	pub nft_id: NftId,
 }
 
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[derive(Encode, Decode, PartialEq, TypeInfo)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedKey: AsRef<[u8]>,
 			BoundedValue: AsRef<[u8]>
-		"#
-	)
+		"#)
 )]
-pub struct PropertyInfo<BoundedKey, BoundedValue>
-{
+pub struct PropertyInfo<BoundedKey, BoundedValue> {
 	/// Key of the property
 	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]
 	pub key: BoundedKey,
@@ -156,10 +149,7 @@
 
 #[derive(Encode, Decode, Default, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(feature = "std", derive(Serialize))]
-#[cfg_attr(
-	feature = "std",
-	serde(bound = "BoundedString: AsRef<[u8]>")
-)]
+#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]
 pub struct BasicResource<BoundedString> {
 	/// If the resource is Media, the base property is absent. Media src should be a URI like an
 	/// IPFS hash.
@@ -188,12 +178,10 @@
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedString: AsRef<[u8]>,
 			BoundedParts: AsRef<[PartId]>
-		"#
-	)
+		"#)
 )]
 pub struct ComposableResource<BoundedString, BoundedParts> {
 	/// If a resource is composed, it will have an array of parts that compose it
@@ -235,10 +223,7 @@
 
 #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(feature = "std", derive(Serialize))]
-#[cfg_attr(
-	feature = "std",
-	serde(bound = "BoundedString: AsRef<[u8]>")
-)]
+#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]
 pub struct SlotResource<BoundedString> {
 	/// A Base is uniquely identified by the combination of the word `base`, its minting block
 	/// number, and user provided symbol during Base creation, glued by dashes `-`, e.g.
@@ -279,14 +264,12 @@
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedString: AsRef<[u8]>,
 			BoundedParts: AsRef<[PartId]>
-		"#
-	)
+		"#)
 )]
-#[derivative(Default(bound=""))]
+#[derivative(Default(bound = ""))]
 pub enum ResourceTypes<BoundedString: Default, BoundedParts> {
 	#[derivative(Default)]
 	Basic(BasicResource<BoundedString>),
@@ -294,18 +277,15 @@
 	Slot(SlotResource<BoundedString>),
 }
 
-
 #[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedResource: AsRef<[u8]>,
 			BoundedString: AsRef<[u8]>,
 			BoundedParts: AsRef<[PartId]>
-		"#
-	)
+		"#)
 )]
 pub struct ResourceInfo<BoundedResource, BoundedString: Default, BoundedParts> {
 	/// id is a 5-character string of reasonable uniqueness.
@@ -328,12 +308,10 @@
 #[derive(Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			AccountId: Serialize,
 			BoundedString: AsRef<[u8]>
-		"#
-	)
+		"#)
 )]
 pub struct BaseInfo<AccountId, BoundedString> {
 	/// Original creator of the Base
@@ -350,10 +328,7 @@
 
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]
-#[cfg_attr(
-	feature = "std",
-	serde(bound = "BoundedString: AsRef<[u8]>")
-)]
+#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]
 pub struct FixedPart<BoundedString> {
 	pub id: PartId,
 	pub z: ZIndex,
@@ -368,29 +343,24 @@
 	feature = "std",
 	serde(bound = "BoundedCollectionList: AsRef<[CollectionId]>")
 )]
-#[derivative(Default(bound=""))]
+#[derivative(Default(bound = ""))]
 pub enum EquippableList<BoundedCollectionList> {
 	All,
 
 	#[derivative(Default)]
 	Empty,
 
-	Custom(
-		#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]
-		BoundedCollectionList
-	),
+	Custom(#[cfg_attr(feature = "std", serde(with = "serialize::vec"))] BoundedCollectionList),
 }
 
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedString: AsRef<[u8]>,
 			BoundedCollectionList: AsRef<[CollectionId]>
-		"#
-	)
+		"#)
 )]
 pub struct SlotPart<BoundedString, BoundedCollectionList> {
 	pub id: PartId,
@@ -406,12 +376,10 @@
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, Eq, MaxEncodedLen)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedString: AsRef<[u8]>,
 			BoundedCollectionList: AsRef<[CollectionId]>
-		"#
-	)
+		"#)
 )]
 pub enum PartType<BoundedString, BoundedCollectionList> {
 	FixedPart(FixedPart<BoundedString>),
@@ -422,21 +390,21 @@
 	pub fn id(&self) -> PartId {
 		match self {
 			Self::FixedPart(part) => part.id,
-			Self::SlotPart(part) => part.id
+			Self::SlotPart(part) => part.id,
 		}
 	}
 
 	pub fn src(&self) -> &BoundedString {
 		match self {
 			Self::FixedPart(part) => &part.src,
-			Self::SlotPart(part) => &part.src
+			Self::SlotPart(part) => &part.src,
 		}
 	}
 
 	pub fn z_index(&self) -> ZIndex {
 		match self {
 			Self::FixedPart(part) => part.z,
-			Self::SlotPart(part) => part.z
+			Self::SlotPart(part) => part.z,
 		}
 	}
 }
@@ -445,12 +413,10 @@
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]
 #[cfg_attr(
 	feature = "std",
-	serde(
-		bound = r#"
+	serde(bound = r#"
 			BoundedString: AsRef<[u8]>,
 			PropertyList: AsRef<[ThemeProperty<BoundedString>]>,
-		"#
-	)
+		"#)
 )]
 pub struct Theme<BoundedString, PropertyList> {
 	/// Name of the theme
@@ -466,10 +432,7 @@
 
 #[cfg_attr(feature = "std", derive(Eq, Serialize))]
 #[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq)]
-#[cfg_attr(
-	feature = "std",
-	serde(bound = "BoundedString: AsRef<[u8]>")
-)]
+#[cfg_attr(feature = "std", serde(bound = "BoundedString: AsRef<[u8]>"))]
 pub struct ThemeProperty<BoundedString> {
 	/// Key of the property
 	#[cfg_attr(feature = "std", serde(with = "serialize::vec"))]
modifiedruntime/tests/src/tests.rsdiffbeforeafterboth
--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -19,9 +19,9 @@
 use up_data_structs::{
 	COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData,
 	CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, TokenId,
-	MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionMode,
-	AccessMode, CollectionPermissions, PropertyKeyPermission, PropertyPermission,
-	Property, CollectionPropertiesVec, CollectionPropertiesPermissionsVec,
+	MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionMode, AccessMode, CollectionPermissions,
+	PropertyKeyPermission, PropertyPermission, Property, CollectionPropertiesVec,
+	CollectionPropertiesPermissionsVec,
 };
 use frame_support::{assert_noop, assert_ok, assert_err};
 use sp_std::convert::TryInto;
@@ -47,12 +47,12 @@
 
 fn default_nft_data() -> CreateNftData {
 	CreateNftData {
-		properties: vec![
-			Property {
-				key: b"test-prop".to_vec().try_into().unwrap(),
-				value: b"test-nft-prop".to_vec().try_into().unwrap(),
-			},
-		].try_into().unwrap(),
+		properties: vec![Property {
+			key: b"test-prop".to_vec().try_into().unwrap(),
+			value: b"test-nft-prop".to_vec().try_into().unwrap(),
+		}]
+		.try_into()
+		.unwrap(),
 	}
 }
 
@@ -77,22 +77,23 @@
 	let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();
 	let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
 	let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
-	let token_property_permissions: CollectionPropertiesPermissionsVec = vec![
-		PropertyKeyPermission {
+	let token_property_permissions: CollectionPropertiesPermissionsVec =
+		vec![PropertyKeyPermission {
 			key: b"test-prop".to_vec().try_into().unwrap(),
 			permission: PropertyPermission {
 				mutable: true,
 				collection_admin: false,
 				token_owner: true,
 			},
-		},
-	].try_into().unwrap();
-	let properties: CollectionPropertiesVec = vec![
-		Property {
-			key: b"test-collection-prop".to_vec().try_into().unwrap(),
-			value: b"test-collection-value".to_vec().try_into().unwrap(),
-		}
-	].try_into().unwrap();
+		}]
+		.try_into()
+		.unwrap();
+	let properties: CollectionPropertiesVec = vec![Property {
+		key: b"test-collection-prop".to_vec().try_into().unwrap(),
+		value: b"test-collection-value".to_vec().try_into().unwrap(),
+	}]
+	.try_into()
+	.unwrap();
 
 	let data: CreateCollectionData<u64> = CreateCollectionData {
 		name: col_name1.try_into().unwrap(),
@@ -150,30 +151,21 @@
 fn get_collection_property_permissions(collection_id: CollectionId) -> Vec<PropertyKeyPermission> {
 	<pallet_common::Pallet<Test>>::property_permissions(collection_id)
 		.into_iter()
-		.map(|(key, permission)| PropertyKeyPermission {
-			key,
-			permission,
-		})
+		.map(|(key, permission)| PropertyKeyPermission { key, permission })
 		.collect()
 }
 
 fn get_collection_properties(collection_id: CollectionId) -> Vec<Property> {
 	<pallet_common::Pallet<Test>>::collection_properties(collection_id)
 		.into_iter()
-		.map(|(key, value)| Property {
-			key,
-			value,
-		})
+		.map(|(key, value)| Property { key, value })
 		.collect()
 }
 
 fn get_token_properties(collection_id: CollectionId, token_id: TokenId) -> Vec<Property> {
 	<pallet_nonfungible::Pallet<Test>>::token_properties((collection_id, token_id))
 		.into_iter()
-		.map(|(key, value)| Property {
-			key,
-			value,
-		})
+		.map(|(key, value)| Property { key, value })
 		.collect()
 }