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

difftreelog

refactor remove "invalid" collection mode

Yaroslav Bolyukin2021-09-14parent: #d15a825.patch.diff
in: master

7 files changed

modifiedpallets/nft/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/nft/src/eth/mod.rs
+++ b/pallets/nft/src/eth/mod.rs
@@ -103,7 +103,6 @@
 					CollectionMode::ReFungible => {
 						include_bytes!("stubs/UniqueRefungible.raw") as &[u8]
 					}
-					CollectionMode::Invalid => include_bytes!("stubs/UniqueInvalid.raw") as &[u8],
 				}
 				.to_owned()
 			})
deletedpallets/nft/src/eth/stubs/UniqueInvalid.rawdiffbeforeafterboth
--- a/pallets/nft/src/eth/stubs/UniqueInvalid.raw
+++ /dev/null
@@ -1 +0,0 @@
-TODO
\ No newline at end of file
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1347,7 +1347,6 @@
 				sender.clone(),
 				recipient.clone(),
 			)?,
-			_ => (),
 		};
 
 		Self::deposit_event(RawEvent::Transfer(
@@ -1493,7 +1492,6 @@
 				from.clone(),
 				recipient.clone(),
 			)?,
-			_ => (),
 		};
 
 		if matches!(collection.mode, CollectionMode::Fungible(_)) {
@@ -1534,7 +1532,6 @@
 				Self::set_re_fungible_variable_data(collection, item_id, data)?
 			}
 			CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),
-			_ => fail!(Error::<T>::UnexpectedCollectionType),
 		};
 
 		Ok(())
@@ -1618,7 +1615,6 @@
 			CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,
 			CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,
 			CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,
-			_ => (),
 		};
 
 		Ok(())
@@ -1723,9 +1719,6 @@
 					fail!(Error::<T>::NotReFungibleDataUsedToMintReFungibleCollectionToken);
 				}
 			}
-			_ => {
-				fail!(Error::<T>::UnexpectedCollectionType);
-			}
 		};
 
 		Ok(())
@@ -2034,7 +2027,6 @@
 				.iter()
 				.find(|i| i.owner == *subject)
 				.map(|i| i.fraction),
-			CollectionMode::Invalid => None,
 		}
 	}
 
@@ -2071,7 +2063,6 @@
 			CollectionMode::ReFungible => {
 				<ReFungibleItemList<T>>::contains_key(collection_id, item_id)
 			}
-			_ => false,
 		};
 
 		ensure!(exists, Error::<T>::TokenNotFound);
modifiedpallets/nft/src/sponsorship.rsdiffbeforeafterboth
--- a/pallets/nft/src/sponsorship.rs
+++ b/pallets/nft/src/sponsorship.rs
@@ -127,7 +127,6 @@
 
 					sponsored
 				}
-				_ => false,
 			};
 		}
 
modifiedprimitives/nft/src/lib.rsdiffbeforeafterboth
before · primitives/nft/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23#[cfg(feature = "serde")]4pub use serde::{Serialize, Deserialize};56use sp_runtime::sp_std::prelude::Vec;7use codec::{Decode, Encode, MaxEncodedLen};8pub use frame_support::{9	BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,10	dispatch::DispatchResult,11	ensure, fail, parameter_types,12	traits::{13		Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,14		Randomness, IsSubType, WithdrawReasons,15	},16	weights::{17		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},18		DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,19		WeightToFeePolynomial, DispatchClass,20	},21	StorageValue, transactional,22};23use derivative::Derivative;2425pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;26pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;27pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;28pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;2930pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {31	10000032} else {33	1034};35pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {36	204837} else {38	1039};40pub const COLLECTION_ADMINS_LIMIT: u64 = 5;41pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {42	100000043} else {44	1045};4647// Timeouts for item types in passed blocks48pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;49pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;50pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;5152// Schema limits53pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;54pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;55pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;5657pub const MAX_COLLECTION_NAME_LENGTH: usize = 64;58pub const MAX_COLLECTION_DESCRIPTION_LENGTH: usize = 256;59pub const MAX_TOKEN_PREFIX_LENGTH: usize = 16;6061/// How much items can be created per single62/// create_many call63pub const MAX_ITEMS_PER_BATCH: u32 = 200;6465parameter_types! {66	pub const CustomDataLimit: u32 = CUSTOM_DATA_LIMIT;67}6869pub type CollectionId = u32;70pub type TokenId = u32;71pub type DecimalPoints = u8;7273#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]74#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]75pub enum CollectionMode {76	Invalid,77	NFT,78	// decimal points79	Fungible(DecimalPoints),80	ReFungible,81}8283impl Default for CollectionMode {84	fn default() -> Self {85		Self::Invalid86	}87}8889impl CollectionMode {90	pub fn id(&self) -> u8 {91		match self {92			CollectionMode::Invalid => 0,93			CollectionMode::NFT => 1,94			CollectionMode::Fungible(_) => 2,95			CollectionMode::ReFungible => 3,96		}97	}98}99100pub trait SponsoringResolve<AccountId, Call> {101	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;102}103104#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]105#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]106pub enum AccessMode {107	Normal,108	WhiteList,109}110impl Default for AccessMode {111	fn default() -> Self {112		Self::Normal113	}114}115116#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]117#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]118pub enum SchemaVersion {119	ImageURL,120	Unique,121}122impl Default for SchemaVersion {123	fn default() -> Self {124		Self::ImageURL125	}126}127128#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]129#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]130pub struct Ownership<AccountId> {131	pub owner: AccountId,132	pub fraction: u128,133}134135#[derive(Encode, Decode, Debug, Clone, PartialEq)]136#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]137pub enum SponsorshipState<AccountId> {138	/// The fees are applied to the transaction sender139	Disabled,140	Unconfirmed(AccountId),141	/// Transactions are sponsored by specified account142	Confirmed(AccountId),143}144145impl<AccountId> SponsorshipState<AccountId> {146	pub fn sponsor(&self) -> Option<&AccountId> {147		match self {148			Self::Confirmed(sponsor) => Some(sponsor),149			_ => None,150		}151	}152153	pub fn pending_sponsor(&self) -> Option<&AccountId> {154		match self {155			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),156			_ => None,157		}158	}159160	pub fn confirmed(&self) -> bool {161		matches!(self, Self::Confirmed(_))162	}163}164165impl<T> Default for SponsorshipState<T> {166	fn default() -> Self {167		Self::Disabled168	}169}170171#[derive(Encode, Decode, Clone, PartialEq)]172#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]173pub struct Collection<T: frame_system::Config> {174	pub owner: T::AccountId,175	pub mode: CollectionMode,176	pub access: AccessMode,177	pub decimal_points: DecimalPoints,178	pub name: Vec<u16>,        // 64 include null escape char179	pub description: Vec<u16>, // 256 include null escape char180	pub token_prefix: Vec<u8>, // 16 include null escape char181	pub mint_mode: bool,182	pub offchain_schema: Vec<u8>,183	pub schema_version: SchemaVersion,184	pub sponsorship: SponsorshipState<T::AccountId>,185	pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions186	pub variable_on_chain_schema: Vec<u8>,        //187	pub const_on_chain_schema: Vec<u8>,           //188	pub meta_update_permission: MetaUpdatePermission,189	pub transfers_enabled: bool,190}191192#[derive(Encode, Decode, Debug, Clone, PartialEq)]193#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]194pub struct NftItemType<AccountId> {195	pub owner: AccountId,196	pub const_data: Vec<u8>,197	pub variable_data: Vec<u8>,198}199200#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]201#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]202pub struct FungibleItemType {203	pub value: u128,204}205206#[derive(Encode, Decode, Debug, Clone, PartialEq)]207#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]208pub struct ReFungibleItemType<AccountId> {209	pub owner: Vec<Ownership<AccountId>>,210	pub const_data: Vec<u8>,211	pub variable_data: Vec<u8>,212}213214#[derive(Encode, Decode, Debug, Clone, PartialEq)]215#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]216pub struct CollectionLimits<BlockNumber: Encode + Decode> {217	pub account_token_ownership_limit: u32,218	pub sponsored_data_size: u32,219	/// None - setVariableMetadata is not sponsored220	/// Some(v) - setVariableMetadata is sponsored221	///           if there is v block between txs222	pub sponsored_data_rate_limit: Option<BlockNumber>,223	pub token_limit: u32,224225	// Timeouts for item types in passed blocks226	pub sponsor_transfer_timeout: u32,227	pub owner_can_transfer: bool,228	pub owner_can_destroy: bool,229}230231impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {232	fn default() -> Self {233		Self {234			account_token_ownership_limit: 10_000_000,235			token_limit: u32::max_value(),236			sponsored_data_size: u32::MAX,237			sponsored_data_rate_limit: None,238			sponsor_transfer_timeout: 14400,239			owner_can_transfer: true,240			owner_can_destroy: true,241		}242	}243}244245/// BoundedVec doesn't supports serde246#[cfg(feature = "serde1")]247mod bounded_serde {248	use core::convert::TryFrom;249	use frame_support::{BoundedVec, traits::Get};250	use serde::{251		ser::{self, Serialize},252		de::{self, Deserialize, Error},253	};254	use sp_std::vec::Vec;255256	pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>257	where258		D: ser::Serializer,259		V: Serialize,260	{261		let vec: &Vec<_> = &value;262		vec.serialize(serializer)263	}264265	pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>266	where267		D: de::Deserializer<'de>,268		V: de::Deserialize<'de>,269		S: Get<u32>,270	{271		// TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?272		let vec = <Vec<V>>::deserialize(deserializer)?;273		let len = vec.len();274		TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))275	}276}277278#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]279#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]280#[derivative(Debug)]281pub struct CreateNftData {282	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]283	#[derivative(Debug = "ignore")]284	pub const_data: BoundedVec<u8, CustomDataLimit>,285	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]286	#[derivative(Debug = "ignore")]287	pub variable_data: BoundedVec<u8, CustomDataLimit>,288}289290#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq)]291#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]292pub struct CreateFungibleData {293	pub value: u128,294}295296#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]297#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]298#[derivative(Debug)]299pub struct CreateReFungibleData {300	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]301	#[derivative(Debug = "ignore")]302	pub const_data: BoundedVec<u8, CustomDataLimit>,303	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]304	#[derivative(Debug = "ignore")]305	pub variable_data: BoundedVec<u8, CustomDataLimit>,306	pub pieces: u128,307}308309#[derive(Encode, Decode, Debug, Clone, PartialEq)]310#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]311pub enum MetaUpdatePermission {312	ItemOwner,313	Admin,314	None,315}316317impl Default for MetaUpdatePermission {318	fn default() -> Self {319		Self::ItemOwner320	}321}322323#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug)]324#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]325pub enum CreateItemData {326	NFT(CreateNftData),327	Fungible(CreateFungibleData),328	ReFungible(CreateReFungibleData),329}330331impl CreateItemData {332	pub fn data_size(&self) -> usize {333		match self {334			CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),335			CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),336			_ => 0,337		}338	}339}340341impl From<CreateNftData> for CreateItemData {342	fn from(item: CreateNftData) -> Self {343		CreateItemData::NFT(item)344	}345}346347impl From<CreateReFungibleData> for CreateItemData {348	fn from(item: CreateReFungibleData) -> Self {349		CreateItemData::ReFungible(item)350	}351}352353impl From<CreateFungibleData> for CreateItemData {354	fn from(item: CreateFungibleData) -> Self {355		CreateItemData::Fungible(item)356	}357}
after · primitives/nft/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23#[cfg(feature = "serde")]4pub use serde::{Serialize, Deserialize};56use sp_runtime::sp_std::prelude::Vec;7use codec::{Decode, Encode, MaxEncodedLen};8pub use frame_support::{9	BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,10	dispatch::DispatchResult,11	ensure, fail, parameter_types,12	traits::{13		Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,14		Randomness, IsSubType, WithdrawReasons,15	},16	weights::{17		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},18		DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,19		WeightToFeePolynomial, DispatchClass,20	},21	StorageValue, transactional,22};23use derivative::Derivative;2425pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;26pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;27pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;28pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;2930pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {31	10000032} else {33	1034};35pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {36	204837} else {38	1039};40pub const COLLECTION_ADMINS_LIMIT: u64 = 5;41pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {42	100000043} else {44	1045};4647// Timeouts for item types in passed blocks48pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;49pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;50pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;5152// Schema limits53pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;54pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;55pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;5657pub const MAX_COLLECTION_NAME_LENGTH: usize = 64;58pub const MAX_COLLECTION_DESCRIPTION_LENGTH: usize = 256;59pub const MAX_TOKEN_PREFIX_LENGTH: usize = 16;6061/// How much items can be created per single62/// create_many call63pub const MAX_ITEMS_PER_BATCH: u32 = 200;6465parameter_types! {66	pub const CustomDataLimit: u32 = CUSTOM_DATA_LIMIT;67}6869pub type CollectionId = u32;70pub type TokenId = u32;71pub type DecimalPoints = u8;7273#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]74#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]75pub enum CollectionMode {76	NFT,77	// decimal points78	Fungible(DecimalPoints),79	ReFungible,80}8182impl CollectionMode {83	pub fn id(&self) -> u8 {84		match self {85			CollectionMode::NFT => 1,86			CollectionMode::Fungible(_) => 2,87			CollectionMode::ReFungible => 3,88		}89	}90}9192pub trait SponsoringResolve<AccountId, Call> {93	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;94}9596#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]97#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]98pub enum AccessMode {99	Normal,100	WhiteList,101}102impl Default for AccessMode {103	fn default() -> Self {104		Self::Normal105	}106}107108#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]109#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]110pub enum SchemaVersion {111	ImageURL,112	Unique,113}114impl Default for SchemaVersion {115	fn default() -> Self {116		Self::ImageURL117	}118}119120#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]121#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]122pub struct Ownership<AccountId> {123	pub owner: AccountId,124	pub fraction: u128,125}126127#[derive(Encode, Decode, Debug, Clone, PartialEq)]128#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]129pub enum SponsorshipState<AccountId> {130	/// The fees are applied to the transaction sender131	Disabled,132	Unconfirmed(AccountId),133	/// Transactions are sponsored by specified account134	Confirmed(AccountId),135}136137impl<AccountId> SponsorshipState<AccountId> {138	pub fn sponsor(&self) -> Option<&AccountId> {139		match self {140			Self::Confirmed(sponsor) => Some(sponsor),141			_ => None,142		}143	}144145	pub fn pending_sponsor(&self) -> Option<&AccountId> {146		match self {147			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),148			_ => None,149		}150	}151152	pub fn confirmed(&self) -> bool {153		matches!(self, Self::Confirmed(_))154	}155}156157impl<T> Default for SponsorshipState<T> {158	fn default() -> Self {159		Self::Disabled160	}161}162163#[derive(Encode, Decode, Clone, PartialEq)]164#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]165pub struct Collection<T: frame_system::Config> {166	pub owner: T::AccountId,167	pub mode: CollectionMode,168	pub access: AccessMode,169	pub decimal_points: DecimalPoints,170	pub name: Vec<u16>,        // 64 include null escape char171	pub description: Vec<u16>, // 256 include null escape char172	pub token_prefix: Vec<u8>, // 16 include null escape char173	pub mint_mode: bool,174	pub offchain_schema: Vec<u8>,175	pub schema_version: SchemaVersion,176	pub sponsorship: SponsorshipState<T::AccountId>,177	pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions178	pub variable_on_chain_schema: Vec<u8>,        //179	pub const_on_chain_schema: Vec<u8>,           //180	pub meta_update_permission: MetaUpdatePermission,181	pub transfers_enabled: bool,182}183184#[derive(Encode, Decode, Debug, Clone, PartialEq)]185#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]186pub struct NftItemType<AccountId> {187	pub owner: AccountId,188	pub const_data: Vec<u8>,189	pub variable_data: Vec<u8>,190}191192#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]193#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]194pub struct FungibleItemType {195	pub value: u128,196}197198#[derive(Encode, Decode, Debug, Clone, PartialEq)]199#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]200pub struct ReFungibleItemType<AccountId> {201	pub owner: Vec<Ownership<AccountId>>,202	pub const_data: Vec<u8>,203	pub variable_data: Vec<u8>,204}205206#[derive(Encode, Decode, Debug, Clone, PartialEq)]207#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]208pub struct CollectionLimits<BlockNumber: Encode + Decode> {209	pub account_token_ownership_limit: u32,210	pub sponsored_data_size: u32,211	/// None - setVariableMetadata is not sponsored212	/// Some(v) - setVariableMetadata is sponsored213	///           if there is v block between txs214	pub sponsored_data_rate_limit: Option<BlockNumber>,215	pub token_limit: u32,216217	// Timeouts for item types in passed blocks218	pub sponsor_transfer_timeout: u32,219	pub owner_can_transfer: bool,220	pub owner_can_destroy: bool,221}222223impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {224	fn default() -> Self {225		Self {226			account_token_ownership_limit: 10_000_000,227			token_limit: u32::max_value(),228			sponsored_data_size: u32::MAX,229			sponsored_data_rate_limit: None,230			sponsor_transfer_timeout: 14400,231			owner_can_transfer: true,232			owner_can_destroy: true,233		}234	}235}236237/// BoundedVec doesn't supports serde238#[cfg(feature = "serde1")]239mod bounded_serde {240	use core::convert::TryFrom;241	use frame_support::{BoundedVec, traits::Get};242	use serde::{243		ser::{self, Serialize},244		de::{self, Deserialize, Error},245	};246	use sp_std::vec::Vec;247248	pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>249	where250		D: ser::Serializer,251		V: Serialize,252	{253		let vec: &Vec<_> = &value;254		vec.serialize(serializer)255	}256257	pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>258	where259		D: de::Deserializer<'de>,260		V: de::Deserialize<'de>,261		S: Get<u32>,262	{263		// TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?264		let vec = <Vec<V>>::deserialize(deserializer)?;265		let len = vec.len();266		TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))267	}268}269270#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]271#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]272#[derivative(Debug)]273pub struct CreateNftData {274	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]275	#[derivative(Debug = "ignore")]276	pub const_data: BoundedVec<u8, CustomDataLimit>,277	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]278	#[derivative(Debug = "ignore")]279	pub variable_data: BoundedVec<u8, CustomDataLimit>,280}281282#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq)]283#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]284pub struct CreateFungibleData {285	pub value: u128,286}287288#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]289#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]290#[derivative(Debug)]291pub struct CreateReFungibleData {292	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]293	#[derivative(Debug = "ignore")]294	pub const_data: BoundedVec<u8, CustomDataLimit>,295	#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]296	#[derivative(Debug = "ignore")]297	pub variable_data: BoundedVec<u8, CustomDataLimit>,298	pub pieces: u128,299}300301#[derive(Encode, Decode, Debug, Clone, PartialEq)]302#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]303pub enum MetaUpdatePermission {304	ItemOwner,305	Admin,306	None,307}308309impl Default for MetaUpdatePermission {310	fn default() -> Self {311		Self::ItemOwner312	}313}314315#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug)]316#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]317pub enum CreateItemData {318	NFT(CreateNftData),319	Fungible(CreateFungibleData),320	ReFungible(CreateReFungibleData),321}322323impl CreateItemData {324	pub fn data_size(&self) -> usize {325		match self {326			CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),327			CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),328			_ => 0,329		}330	}331}332333impl From<CreateNftData> for CreateItemData {334	fn from(item: CreateNftData) -> Self {335		CreateItemData::NFT(item)336	}337}338339impl From<CreateReFungibleData> for CreateItemData {340	fn from(item: CreateReFungibleData) -> Self {341		CreateItemData::ReFungible(item)342	}343}344345impl From<CreateFungibleData> for CreateItemData {346	fn from(item: CreateFungibleData) -> Self {347		CreateItemData::Fungible(item)348	}349}
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -33,19 +33,6 @@
 });
 
 describe('(!negative test!) integration test: ext. createCollection():', () => {
-  it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
-    await usingApi(async (api) => {
-      const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
-
-      const badTransaction = async () => {
-        await createCollectionExpectSuccess({mode: {type: 'Invalid'}});
-      };
-      await expect(badTransaction()).to.be.rejected;
-
-      const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
-      expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');
-    });
-  });
   it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
     await createCollectionExpectFailure({ name: 'A'.repeat(65), mode: {type: 'NFT'}});
   });
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -224,10 +224,6 @@
   return result;
 }
 
-interface Invalid {
-  type: 'Invalid';
-}
-
 interface Nft {
   type: 'NFT';
 }
@@ -241,7 +237,7 @@
   type: 'ReFungible';
 }
 
-type CollectionMode = Nft | Fungible | ReFungible | Invalid;
+type CollectionMode = Nft | Fungible | ReFungible;
 
 export type CreateCollectionParams = {
   mode: CollectionMode,
@@ -275,8 +271,6 @@
       modeprm = { fungible: mode.decimalPoints };
     } else if (mode.type === 'ReFungible') {
       modeprm = { refungible: null };
-    } else if (mode.type === 'Invalid') {
-      modeprm = { invalid: null };
     }
 
     const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);
@@ -317,8 +311,6 @@
     modeprm = { fungible: mode.decimalPoints };
   } else if (mode.type === 'ReFungible') {
     modeprm = { refungible: null };
-  } else if (mode.type === 'Invalid') {
-    modeprm = { invalid: null };
   }
 
   await usingApi(async (api) => {
@@ -528,23 +520,23 @@
 export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {
 
   await usingApi(async (api) => {
-    const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag); 
+    const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
     const events = await submitTransactionAsync(sender, tx);
     const result = getGenericResult(events);
 
     expect(result.success).to.be.true;
-  }); 
+  });
 }
 
 export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {
 
   await usingApi(async (api) => {
-    const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag); 
+    const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
     const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
     const result = getGenericResult(events);
 
     expect(result.success).to.be.false;
-  }); 
+  });
 }
 
 export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {
@@ -576,7 +568,7 @@
     const result = getGenericResult(events);
 
     expect(result.success).to.be.true;
-  }); 
+  });
 }
 
 export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {
@@ -588,7 +580,7 @@
     const result = getGenericResult(events);
 
     expect(result.success).to.be.false;
-  }); 
+  });
 }
 
 export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {
@@ -833,7 +825,7 @@
     const expectedBlockNumber = blockNumber + blockSchedule;
 
     expect(blockNumber).to.be.greaterThan(0);
-    const transferTx = await api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value); 
+    const transferTx = await api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
     const scheduleTx = await api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx);
 
     await submitTransactionAsync(sender, scheduleTx);
@@ -1004,7 +996,7 @@
 export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {
   await usingApi(async (api) => {
     const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), createMode);
-    
+
     const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
     const result = getCreateItemResult(events);