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 type CollectionId = u32;32pub type TokenId = u32;33pub type DecimalPoints = u8;3435#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]36#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]37pub enum CollectionMode {38 Invalid,39 NFT,40 // decimal points41 Fungible(DecimalPoints),42 ReFungible,43}4445impl Default for CollectionMode {46 fn default() -> Self {47 Self::Invalid48 }49}5051impl CollectionMode {52 pub fn id(&self) -> u8 {53 match self {54 CollectionMode::Invalid => 0,55 CollectionMode::NFT => 1,56 CollectionMode::Fungible(_) => 2,57 CollectionMode::ReFungible => 3,58 }59 }60}6162pub trait SponsoringResolve<AccountId, Call> {63 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;64}6566#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]67#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]68pub enum AccessMode {69 Normal,70 WhiteList,71}72impl Default for AccessMode {73 fn default() -> Self {74 Self::Normal75 }76}7778#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]79#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]80pub enum SchemaVersion {81 ImageURL,82 Unique,83}84impl Default for SchemaVersion {85 fn default() -> Self {86 Self::ImageURL87 }88}8990#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]91#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]92pub struct Ownership<AccountId> {93 pub owner: AccountId,94 pub fraction: u128,95}9697#[derive(Encode, Decode, Debug, Clone, PartialEq)]98#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]99pub enum SponsorshipState<AccountId> {100 /// The fees are applied to the transaction sender101 Disabled,102 Unconfirmed(AccountId),103 /// Transactions are sponsored by specified account104 Confirmed(AccountId),105}106107impl<AccountId> SponsorshipState<AccountId> {108 pub fn sponsor(&self) -> Option<&AccountId> {109 match self {110 Self::Confirmed(sponsor) => Some(sponsor),111 _ => None,112 }113 }114115 pub fn pending_sponsor(&self) -> Option<&AccountId> {116 match self {117 Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),118 _ => None,119 }120 }121122 pub fn confirmed(&self) -> bool {123 matches!(self, Self::Confirmed(_))124 }125}126127impl<T> Default for SponsorshipState<T> {128 fn default() -> Self {129 Self::Disabled130 }131}132133#[derive(Encode, Decode, Clone, PartialEq)]134#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]135pub struct Collection<T: frame_system::Config> {136 pub owner: T::AccountId,137 pub mode: CollectionMode,138 pub access: AccessMode,139 pub decimal_points: DecimalPoints,140 pub name: Vec<u16>, // 64 include null escape char141 pub description: Vec<u16>, // 256 include null escape char142 pub token_prefix: Vec<u8>, // 16 include null escape char143 pub mint_mode: bool,144 pub offchain_schema: Vec<u8>,145 pub schema_version: SchemaVersion,146 pub sponsorship: SponsorshipState<T::AccountId>,147 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions148 pub variable_on_chain_schema: Vec<u8>, //149 pub const_on_chain_schema: Vec<u8>, //150 pub transfers_enabled: bool,151}152153#[derive(Encode, Decode, Debug, Clone, PartialEq)]154#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]155pub struct NftItemType<AccountId> {156 pub owner: AccountId,157 pub const_data: Vec<u8>,158 pub variable_data: Vec<u8>,159}160161#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]162#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]163pub struct FungibleItemType {164 pub value: u128,165}166167#[derive(Encode, Decode, Debug, Clone, PartialEq)]168#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]169pub struct ReFungibleItemType<AccountId> {170 pub owner: Vec<Ownership<AccountId>>,171 pub const_data: Vec<u8>,172 pub variable_data: Vec<u8>,173}174175#[derive(Encode, Decode, Debug, Clone, PartialEq)]176#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]177pub struct CollectionLimits<BlockNumber: Encode + Decode> {178 pub account_token_ownership_limit: u32,179 pub sponsored_data_size: u32,180 /// None - setVariableMetadata is not sponsored181 /// Some(v) - setVariableMetadata is sponsored182 /// if there is v block between txs183 pub sponsored_data_rate_limit: Option<BlockNumber>,184 pub token_limit: u32,185186 // Timeouts for item types in passed blocks187 pub sponsor_transfer_timeout: u32,188 pub owner_can_transfer: bool,189 pub owner_can_destroy: bool,190}191192impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {193 fn default() -> Self {194 Self {195 account_token_ownership_limit: 10_000_000,196 token_limit: u32::max_value(),197 sponsored_data_size: u32::MAX,198 sponsored_data_rate_limit: None,199 sponsor_transfer_timeout: 14400,200 owner_can_transfer: true,201 owner_can_destroy: true,202 }203 }204}205206pub trait ChainLimits {207 type CollectionNumberLimit: Get<u32>;208 type AccountTokenOwnershipLimit: Get<u32>;209 type CollectionAdminsLimit: Get<u64>;210 type CustomDataLimit: Get<u32>;211212 // Timeouts for item types in passed blocks213 type NftSponsorTransferTimeout: Get<u32>;214 type FungibleSponsorTransferTimeout: Get<u32>;215 type ReFungibleSponsorTransferTimeout: Get<u32>;216217 // Schema limits218 type OffchainSchemaLimit: Get<u32>;219 type VariableOnChainSchemaLimit: Get<u32>;220 type ConstOnChainSchemaLimit: Get<u32>;221222 /// How much items can be created per single223 /// create_many call224 type MaxItemsPerBatch: Get<u32>;225}226227/// BoundedVec doesn't supports serde228#[cfg(feature = "serde1")]229mod bounded_serde {230 use core::convert::TryFrom;231 use frame_support::{BoundedVec, traits::Get};232 use serde::{233 ser::{self, Serialize},234 de::{self, Deserialize, Error},235 };236 use sp_std::vec::Vec;237238 pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>239 where240 D: ser::Serializer,241 V: Serialize,242 {243 let vec: &Vec<_> = &value;244 vec.serialize(serializer)245 }246247 pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>248 where249 D: de::Deserializer<'de>,250 V: de::Deserialize<'de>,251 S: Get<u32>,252 {253 // TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?254 let vec = <Vec<V>>::deserialize(deserializer)?;255 let len = vec.len();256 TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))257 }258}259260#[derive(Encode, Decode, MaxEncodedLen, Default, Derivative)]261#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]262#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]263pub struct CreateNftData<T: ChainLimits> {264 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]265 #[derivative(Debug = "ignore")]266 pub const_data: BoundedVec<u8, T::CustomDataLimit>,267 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]268 #[derivative(Debug = "ignore")]269 pub variable_data: BoundedVec<u8, T::CustomDataLimit>,270}271272#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq)]273#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]274pub struct CreateFungibleData {275 pub value: u128,276}277278#[derive(Encode, Decode, MaxEncodedLen, Default, Derivative)]279#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]280#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]281pub struct CreateReFungibleData<T: ChainLimits> {282 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]283 #[derivative(Debug = "ignore")]284 pub const_data: BoundedVec<u8, T::CustomDataLimit>,285 #[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]286 #[derivative(Debug = "ignore")]287 pub variable_data: BoundedVec<u8, T::CustomDataLimit>,288 pub pieces: u128,289}290291#[derive(Encode, Decode, MaxEncodedLen, Derivative)]292#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]293#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]294pub enum CreateItemData<T: ChainLimits> {295 NFT(CreateNftData<T>),296 Fungible(CreateFungibleData),297 ReFungible(CreateReFungibleData<T>),298}299300impl<T: ChainLimits> CreateItemData<T> {301 pub fn data_size(&self) -> usize {302 match self {303 CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),304 CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),305 _ => 0,306 }307 }308}309310impl<T: ChainLimits> From<CreateNftData<T>> for CreateItemData<T> {311 fn from(item: CreateNftData<T>) -> Self {312 CreateItemData::NFT(item)313 }314}315316impl<T: ChainLimits> From<CreateReFungibleData<T>> for CreateItemData<T> {317 fn from(item: CreateReFungibleData<T>) -> Self {318 CreateItemData::ReFungible(item)319 }320}321322impl<T: ChainLimits> From<CreateFungibleData> for CreateItemData<T> {323 fn from(item: CreateFungibleData) -> Self {324 CreateItemData::Fungible(item)325 }326}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! {