difftreelog
refactor move ChainLimits to constants
in: master
5 files changed
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/sponsoring.rs
+++ b/pallets/nft/src/eth/sponsoring.rs
@@ -2,12 +2,11 @@
use crate::{
Collection, CollectionById, Config, FungibleTransferBasket, NftTransferBasket,
- eth::{account::EvmBackwardsAddressMapping, map_eth_to_id}, limit,
+ eth::{account::EvmBackwardsAddressMapping, map_eth_to_id},
};
use evm_coder::{Call, abi::AbiReader};
use frame_support::{
storage::{StorageMap, StorageDoubleMap},
- traits::Get,
};
use sp_core::H160;
use sp_std::prelude::*;
@@ -18,6 +17,7 @@
};
use core::convert::TryInto;
use core::marker::PhantomData;
+use nft_data_structs::{NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT};
struct AnyError;
@@ -44,7 +44,7 @@
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
} else {
- <limit!(T, NftSponsorTransferTimeout)>::get()
+ NFT_SPONSOR_TRANSFER_TIMEOUT
};
let mut sponsor = true;
@@ -75,7 +75,7 @@
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
} else {
- <limit!(T, FungibleSponsorTransferTimeout)>::get()
+ FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
};
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -38,7 +38,9 @@
use core::ops::{Deref, DerefMut};
use nft_data_structs::{
MAX_DECIMAL_POINTS, MAX_SPONSOR_TIMEOUT, MAX_TOKEN_OWNERSHIP, MAX_REFUNGIBLE_PIECES,
- AccessMode, ChainLimits, Collection, CreateItemData, CollectionLimits, CollectionId,
+ CUSTOM_DATA_LIMIT, COLLECTION_NUMBER_LIMIT, ACCOUNT_TOKEN_OWNERSHIP_LIMIT,
+ VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, COLLECTION_ADMINS_LIMIT,
+ OFFCHAIN_SCHEMA_LIMIT, AccessMode, Collection, CreateItemData, CollectionLimits, CollectionId,
CollectionMode, TokenId, SchemaVersion, SponsorshipState, Ownership, NftItemType,
FungibleItemType, ReFungibleItemType,
};
@@ -243,15 +245,6 @@
<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,
>;
type TreasuryAccountId: Get<Self::AccountId>;
- type ChainLimits: ChainLimits;
-}
-
-pub type ChainLimitsOf<T> = <T as Config>::ChainLimits;
-#[macro_export]
-macro_rules! limit {
- ($config:ty, $limit:ident) => {
- <$crate::ChainLimitsOf<$config> as nft_data_structs::ChainLimits>::$limit
- }
}
// # Used definitions
@@ -495,7 +488,7 @@
let destroyed_count = DestroyedCollectionCount::get();
// bound Total number of collections
- ensure!(created_count - destroyed_count < <limit!(T, CollectionNumberLimit)>::get(), Error::<T>::TotalCollectionsLimitExceeded);
+ ensure!(created_count - destroyed_count < COLLECTION_NUMBER_LIMIT, Error::<T>::TotalCollectionsLimitExceeded);
// check params
ensure!(decimal_points <= MAX_DECIMAL_POINTS, Error::<T>::CollectionDecimalPointLimitExceeded);
@@ -511,7 +504,7 @@
CreatedCollectionCount::put(next_id);
let limits = CollectionLimits {
- sponsored_data_size: <limit!(T, CustomDataLimit)>::get(),
+ sponsored_data_size: CUSTOM_DATA_LIMIT,
..Default::default()
};
@@ -740,7 +733,7 @@
match admin_arr.binary_search(&new_admin_id) {
Ok(_) => {},
Err(idx) => {
- ensure!(admin_arr.len() < <limit!(T, CollectionAdminsLimit)>::get() as usize, Error::<T>::CollectionAdminsLimitExceeded);
+ ensure!(admin_arr.len() < COLLECTION_ADMINS_LIMIT as usize, Error::<T>::CollectionAdminsLimitExceeded);
admin_arr.insert(idx, new_admin_id);
<AdminList<T>>::insert(collection_id, admin_arr);
}
@@ -864,7 +857,7 @@
#[weight = <T as Config>::WeightInfo::create_item(data.data_size())]
#[transactional]
- pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData<ChainLimitsOf<T>>) -> DispatchResult {
+ pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let collection = Self::get_collection(collection_id)?;
@@ -895,7 +888,7 @@
.map(|data| { data.data_size() })
.sum())]
#[transactional]
- pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData<ChainLimitsOf<T>>>) -> DispatchResult {
+ pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResult {
ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
@@ -1140,7 +1133,7 @@
Self::check_owner_or_admin_permissions(&target_collection, &sender)?;
// check schema limit
- ensure!(schema.len() as u32 <= <limit!(T, OffchainSchemaLimit)>::get(), "");
+ ensure!(schema.len() as u32 <= OFFCHAIN_SCHEMA_LIMIT, "");
target_collection.offchain_schema = schema;
target_collection.save()
@@ -1170,7 +1163,7 @@
Self::check_owner_or_admin_permissions(&target_collection, &sender)?;
// check schema limit
- ensure!(schema.len() as u32 <= <limit!(T, ConstOnChainSchemaLimit)>::get(), "");
+ ensure!(schema.len() as u32 <= CONST_ON_CHAIN_SCHEMA_LIMIT, "");
target_collection.const_on_chain_schema = schema;
target_collection.save()
@@ -1200,7 +1193,7 @@
Self::check_owner_or_admin_permissions(&target_collection, &sender)?;
// check schema limit
- ensure!(schema.len() as u32 <= <limit!(T, VariableOnChainSchemaLimit)>::get(), "");
+ ensure!(schema.len() as u32 <= VARIABLE_ON_CHAIN_SCHEMA_LIMIT, "");
target_collection.variable_on_chain_schema = schema;
target_collection.save()
@@ -1221,7 +1214,7 @@
// collection bounds
ensure!(new_limits.sponsor_transfer_timeout <= MAX_SPONSOR_TIMEOUT &&
new_limits.account_token_ownership_limit <= MAX_TOKEN_OWNERSHIP &&
- new_limits.sponsored_data_size <= <ChainLimitsOf<T> as ChainLimits>::CustomDataLimit::get(),
+ new_limits.sponsored_data_size <= CUSTOM_DATA_LIMIT,
Error::<T>::CollectionLimitBoundsExceeded);
// token_limit check prev
@@ -1246,7 +1239,7 @@
sender: &T::CrossAccountId,
collection: &CollectionHandle<T>,
owner: &T::CrossAccountId,
- data: CreateItemData<ChainLimitsOf<T>>,
+ data: CreateItemData,
) -> DispatchResult {
Self::can_create_items_in_collection(collection, sender, owner, 1)?;
Self::validate_create_item_args(collection, &data)?;
@@ -1457,7 +1450,7 @@
Self::token_exists(collection, item_id)?;
ensure!(
- <limit!(T, CustomDataLimit)>::get() >= data.len() as u32,
+ CUSTOM_DATA_LIMIT >= data.len() as u32,
Error::<T>::TokenVariableDataLimitExceeded
);
@@ -1484,7 +1477,7 @@
sender: &T::CrossAccountId,
collection: &CollectionHandle<T>,
owner: &T::CrossAccountId,
- items_data: Vec<CreateItemData<ChainLimitsOf<T>>>,
+ items_data: Vec<CreateItemData>,
) -> DispatchResult {
Self::can_create_items_in_collection(collection, sender, owner, items_data.len() as u32)?;
@@ -1598,18 +1591,18 @@
fn validate_create_item_args(
target_collection: &CollectionHandle<T>,
- data: &CreateItemData<ChainLimitsOf<T>>,
+ data: &CreateItemData,
) -> DispatchResult {
match target_collection.mode {
CollectionMode::NFT => {
if let CreateItemData::NFT(data) = data {
// check sizes
ensure!(
- <limit!(T, CustomDataLimit)>::get() >= data.const_data.len() as u32,
+ CUSTOM_DATA_LIMIT >= data.const_data.len() as u32,
Error::<T>::TokenConstDataLimitExceeded
);
ensure!(
- <limit!(T, CustomDataLimit)>::get() >= data.variable_data.len() as u32,
+ CUSTOM_DATA_LIMIT >= data.variable_data.len() as u32,
Error::<T>::TokenVariableDataLimitExceeded
);
} else {
@@ -1626,11 +1619,11 @@
if let CreateItemData::ReFungible(data) = data {
// check sizes
ensure!(
- <limit!(T, CustomDataLimit)>::get() >= data.const_data.len() as u32,
+ CUSTOM_DATA_LIMIT >= data.const_data.len() as u32,
Error::<T>::TokenConstDataLimitExceeded
);
ensure!(
- <limit!(T, CustomDataLimit)>::get() >= data.variable_data.len() as u32,
+ CUSTOM_DATA_LIMIT >= data.variable_data.len() as u32,
Error::<T>::TokenVariableDataLimitExceeded
);
@@ -1655,7 +1648,7 @@
fn create_item_no_validation(
collection: &CollectionHandle<T>,
owner: &T::CrossAccountId,
- data: CreateItemData<ChainLimitsOf<T>>,
+ data: CreateItemData,
) -> DispatchResult {
match data {
CreateItemData::NFT(data) => {
@@ -2278,7 +2271,7 @@
// bound Owned tokens by a single address
let count = <AccountItemCount<T>>::get(owner.as_sub());
ensure!(
- count < <limit!(T, AccountTokenOwnershipLimit)>::get(),
+ count < ACCOUNT_TOKEN_OWNERSHIP_LIMIT,
Error::<T>::AddressOwnershipLimitExceeded
);
pallets/nft/src/sponsorship.rsdiffbeforeafterboth--- a/pallets/nft/src/sponsorship.rs
+++ b/pallets/nft/src/sponsorship.rs
@@ -1,22 +1,25 @@
use crate::{
Config, Call, CollectionById, CreateItemBasket, VariableMetaDataBasket,
- ReFungibleTransferBasket, FungibleTransferBasket, NftTransferBasket,
- CreateItemData, CollectionMode, limit,
+ ReFungibleTransferBasket, FungibleTransferBasket, NftTransferBasket, CreateItemData,
+ CollectionMode,
};
use core::marker::PhantomData;
use up_sponsorship::SponsorshipHandler;
use frame_support::{
- traits::{IsSubType, Get},
+ traits::{IsSubType},
storage::{StorageMap, StorageDoubleMap},
};
-use nft_data_structs::{TokenId, CollectionId};
+use nft_data_structs::{
+ TokenId, CollectionId, NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+};
pub struct NftSponsorshipHandler<T>(PhantomData<T>);
impl<T: Config> NftSponsorshipHandler<T> {
pub fn withdraw_create_item(
who: &T::AccountId,
collection_id: &CollectionId,
- _properties: &CreateItemData<T::ChainLimits>,
+ _properties: &CreateItemData,
) -> Option<T::AccountId> {
let collection = CollectionById::<T>::get(collection_id)?;
@@ -61,7 +64,7 @@
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
} else {
- <limit!(T, NftSponsorTransferTimeout)>::get()
+ NFT_SPONSOR_TRANSFER_TIMEOUT
};
let mut sponsored = true;
@@ -83,7 +86,7 @@
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
} else {
- <limit!(T, FungibleSponsorTransferTimeout)>::get()
+ FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
};
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
@@ -106,7 +109,7 @@
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
} else {
- <limit!(T, ReFungibleSponsorTransferTimeout)>::get()
+ REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
};
let mut sponsored = true;
primitives/nft/src/lib.rsdiffbeforeafterboth1#![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};8use max_encoded_len::MaxEncodedLen;9pub use frame_support::{10 BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,11 dispatch::DispatchResult,12 ensure, fail, parameter_types,13 traits::{14 Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,15 Randomness, IsSubType, WithdrawReasons,16 },17 weights::{18 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},19 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,20 WeightToFeePolynomial, DispatchClass,21 },22 StorageValue, transactional,23};24use derivative::Derivative;2526pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;27pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;28pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;29pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;3031pub const COLLECTION_NUMBER_LIMIT: u32 = 100000;32pub const CUSTOM_DATA_LIMIT: u32 = 2048;33pub const COLLECTION_ADMINS_LIMIT: u64 = 5;34pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = 1000000;3536// Timeouts for item types in passed blocks37pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;38pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;39pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;4041// Schema limits42pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;43pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;44pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;4546/// How much items can be created per single47/// create_many call48pub const MAX_ITEMS_PER_BATCH: u32 = 200;4950parameter_types! {51 pub const CustomDataLimit: u32 = CUSTOM_DATA_LIMIT;52}5354pub type CollectionId = u32;55pub type TokenId = u32;56pub type DecimalPoints = u8;5758#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]59#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]60pub enum CollectionMode {61 Invalid,62 NFT,63 // decimal points64 Fungible(DecimalPoints),65 ReFungible,66}6768impl Default for CollectionMode {69 fn default() -> Self {70 Self::Invalid71 }72}7374impl CollectionMode {75 pub fn id(&self) -> u8 {76 match self {77 CollectionMode::Invalid => 0,78 CollectionMode::NFT => 1,79 CollectionMode::Fungible(_) => 2,80 CollectionMode::ReFungible => 3,81 }82 }83}8485pub trait SponsoringResolve<AccountId, Call> {86 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;87}8889#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]90#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]91pub enum AccessMode {92 Normal,93 WhiteList,94}95impl Default for AccessMode {96 fn default() -> Self {97 Self::Normal98 }99}100101#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]102#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]103pub enum SchemaVersion {104 ImageURL,105 Unique,106}107impl Default for SchemaVersion {108 fn default() -> Self {109 Self::ImageURL110 }111}112113#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]114#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]115pub struct Ownership<AccountId> {116 pub owner: AccountId,117 pub fraction: u128,118}119120#[derive(Encode, Decode, Debug, Clone, PartialEq)]121#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]122pub enum SponsorshipState<AccountId> {123 /// The fees are applied to the transaction sender124 Disabled,125 Unconfirmed(AccountId),126 /// Transactions are sponsored by specified account127 Confirmed(AccountId),128}129130impl<AccountId> SponsorshipState<AccountId> {131 pub fn sponsor(&self) -> Option<&AccountId> {132 match self {133 Self::Confirmed(sponsor) => Some(sponsor),134 _ => None,135 }136 }137138 pub fn pending_sponsor(&self) -> Option<&AccountId> {139 match self {140 Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),141 _ => None,142 }143 }144145 pub fn confirmed(&self) -> bool {146 matches!(self, Self::Confirmed(_))147 }148}149150impl<T> Default for SponsorshipState<T> {151 fn default() -> Self {152 Self::Disabled153 }154}155156#[derive(Encode, Decode, Clone, PartialEq)]157#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]158pub struct Collection<T: frame_system::Config> {159 pub owner: T::AccountId,160 pub mode: CollectionMode,161 pub access: AccessMode,162 pub decimal_points: DecimalPoints,163 pub name: Vec<u16>, // 64 include null escape char164 pub description: Vec<u16>, // 256 include null escape char165 pub token_prefix: Vec<u8>, // 16 include null escape char166 pub mint_mode: bool,167 pub offchain_schema: Vec<u8>,168 pub schema_version: SchemaVersion,169 pub sponsorship: SponsorshipState<T::AccountId>,170 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions171 pub variable_on_chain_schema: Vec<u8>, //172 pub const_on_chain_schema: Vec<u8>, //173 pub transfers_enabled: bool,174}175176#[derive(Encode, Decode, Debug, Clone, PartialEq)]177#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]178pub struct NftItemType<AccountId> {179 pub owner: AccountId,180 pub const_data: Vec<u8>,181 pub variable_data: Vec<u8>,182}183184#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]185#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]186pub struct FungibleItemType {187 pub value: u128,188}189190#[derive(Encode, Decode, Debug, Clone, PartialEq)]191#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]192pub struct ReFungibleItemType<AccountId> {193 pub owner: Vec<Ownership<AccountId>>,194 pub const_data: Vec<u8>,195 pub variable_data: Vec<u8>,196}197198#[derive(Encode, Decode, Debug, Clone, PartialEq)]199#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]200pub struct CollectionLimits<BlockNumber: Encode + Decode> {201 pub account_token_ownership_limit: u32,202 pub sponsored_data_size: u32,203 /// None - setVariableMetadata is not sponsored204 /// Some(v) - setVariableMetadata is sponsored205 /// if there is v block between txs206 pub sponsored_data_rate_limit: Option<BlockNumber>,207 pub token_limit: u32,208209 // Timeouts for item types in passed blocks210 pub sponsor_transfer_timeout: u32,211 pub owner_can_transfer: bool,212 pub owner_can_destroy: bool,213}214215impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {216 fn default() -> Self {217 Self {218 account_token_ownership_limit: 10_000_000,219 token_limit: u32::max_value(),220 sponsored_data_size: u32::MAX,221 sponsored_data_rate_limit: None,222 sponsor_transfer_timeout: 14400,223 owner_can_transfer: true,224 owner_can_destroy: true,225 }226 }227}228229/// BoundedVec doesn't supports serde230#[cfg(feature = "serde1")]231mod bounded_serde {232 use core::convert::TryFrom;233 use frame_support::{BoundedVec, traits::Get};234 use serde::{235 ser::{self, Serialize},236 de::{self, Deserialize, Error},237 };238 use sp_std::vec::Vec;239240 pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>241 where242 D: ser::Serializer,243 V: Serialize,244 {245 let vec: &Vec<_> = &value;246 vec.serialize(serializer)247 }248249 pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>250 where251 D: de::Deserializer<'de>,252 V: de::Deserialize<'de>,253 S: Get<u32>,254 {255 // TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?256 let vec = <Vec<V>>::deserialize(deserializer)?;257 let len = vec.len();258 TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))259 }260}261262#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]263#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]264#[derivative(Debug)]265pub struct CreateNftData {266 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]267 #[derivative(Debug = "ignore")]268 pub const_data: BoundedVec<u8, CustomDataLimit>,269 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]270 #[derivative(Debug = "ignore")]271 pub variable_data: BoundedVec<u8, CustomDataLimit>,272}273274#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq)]275#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]276pub struct CreateFungibleData {277 pub value: u128,278}279280#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]281#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]282#[derivative(Debug)]283pub struct CreateReFungibleData {284 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]285 #[derivative(Debug = "ignore")]286 pub const_data: BoundedVec<u8, CustomDataLimit>,287 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]288 #[derivative(Debug = "ignore")]289 pub variable_data: BoundedVec<u8, CustomDataLimit>,290 pub pieces: u128,291}292293#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug)]294#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]295pub enum CreateItemData {296 NFT(CreateNftData),297 Fungible(CreateFungibleData),298 ReFungible(CreateReFungibleData),299}300301impl CreateItemData {302 pub fn data_size(&self) -> usize {303 match self {304 CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),305 CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),306 _ => 0,307 }308 }309}310311impl From<CreateNftData> for CreateItemData {312 fn from(item: CreateNftData) -> Self {313 CreateItemData::NFT(item)314 }315}316317impl From<CreateReFungibleData> for CreateItemData {318 fn from(item: CreateReFungibleData) -> Self {319 CreateItemData::ReFungible(item)320 }321}322323impl From<CreateFungibleData> for CreateItemData {324 fn from(item: CreateFungibleData) -> Self {325 CreateItemData::Fungible(item)326 }327}runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -683,35 +683,6 @@
}
parameter_types! {
- pub const CollectionNumberLimit: u32 = 100000;
- pub const AccountTokenOwnershipLimit: u32 = 1000000;
- pub const CollectionAdminsLimit: u64 = 5;
- pub const CustomDataLimit: u32 = 2048;
- pub const NftSponsorTransferTimeout: u32 = 5;
- pub const FungibleSponsorTransferTimeout: u32 = 5;
- pub const ReFungibleSponsorTransferTimeout: u32 = 5;
- pub const OffchainSchemaLimit: u32 = 1024;
- pub const VariableOnChainSchemaLimit: u32 = 1024;
- pub const ConstOnChainSchemaLimit: u32 = 1024;
- pub const MaxItemsPerBatch: u32 = 200;
-}
-
-pub struct ChainLimits;
-impl nft_data_structs::ChainLimits for ChainLimits {
- type CollectionNumberLimit = CollectionNumberLimit;
- type AccountTokenOwnershipLimit = AccountTokenOwnershipLimit;
- type CollectionAdminsLimit = CollectionAdminsLimit;
- type CustomDataLimit = CustomDataLimit;
- type NftSponsorTransferTimeout = NftSponsorTransferTimeout;
- type FungibleSponsorTransferTimeout = FungibleSponsorTransferTimeout;
- type ReFungibleSponsorTransferTimeout = ReFungibleSponsorTransferTimeout;
- type OffchainSchemaLimit = OffchainSchemaLimit;
- type VariableOnChainSchemaLimit = VariableOnChainSchemaLimit;
- type ConstOnChainSchemaLimit = ConstOnChainSchemaLimit;
- type MaxItemsPerBatch = MaxItemsPerBatch;
-}
-
-parameter_types! {
pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
}
@@ -728,7 +699,6 @@
type Currency = Balances;
type CollectionCreationPrice = CollectionCreationPrice;
type TreasuryAccountId = TreasuryAccountId;
- type ChainLimits = ChainLimits;
}
parameter_types! {