difftreelog
refactor move ChainLimits to constants
in: master
5 files changed
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth1//! Implements EVM sponsoring logic via OnChargeEVMTransaction23use crate::{4 Collection, CollectionById, Config, FungibleTransferBasket, NftTransferBasket,5 eth::{account::EvmBackwardsAddressMapping, map_eth_to_id}, limit,6};7use evm_coder::{Call, abi::AbiReader};8use frame_support::{9 storage::{StorageMap, StorageDoubleMap},10 traits::Get,11};12use sp_core::H160;13use sp_std::prelude::*;14use up_sponsorship::SponsorshipHandler;15use super::{16 account::CrossAccountId,17 erc::{UniqueFungibleCall, UniqueNFTCall, ERC721Call, ERC20Call, ERC721UniqueExtensionsCall},18};19use core::convert::TryInto;20use core::marker::PhantomData;2122struct AnyError;2324fn try_sponsor<T: Config>(25 caller: &H160,26 collection_id: u32,27 collection: &Collection<T>,28 call: &[u8],29) -> Result<(), AnyError> {30 let (method_id, mut reader) = AbiReader::new_call(call).map_err(|_| AnyError)?;31 match &collection.mode {32 crate::CollectionMode::NFT => {33 let call: UniqueNFTCall = UniqueNFTCall::parse(method_id, &mut reader)34 .map_err(|_| AnyError)?35 .ok_or(AnyError)?;36 match call {37 UniqueNFTCall::ERC721UniqueExtensions(38 ERC721UniqueExtensionsCall::TransferNft { token_id, .. },39 )40 | UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, .. }) => {41 let token_id: u32 = token_id.try_into().map_err(|_| AnyError)?;42 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;43 let collection_limits = &collection.limits;44 let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {45 collection_limits.sponsor_transfer_timeout46 } else {47 <limit!(T, NftSponsorTransferTimeout)>::get()48 };4950 let mut sponsor = true;51 if <NftTransferBasket<T>>::contains_key(collection_id, token_id) {52 let last_tx_block = <NftTransferBasket<T>>::get(collection_id, token_id);53 let limit_time = last_tx_block + limit.into();54 if block_number <= limit_time {55 sponsor = false;56 }57 }58 if sponsor {59 <NftTransferBasket<T>>::insert(collection_id, token_id, block_number);60 return Ok(());61 }62 }63 _ => {}64 }65 }66 crate::CollectionMode::Fungible(_) => {67 let call: UniqueFungibleCall = UniqueFungibleCall::parse(method_id, &mut reader)68 .map_err(|_| AnyError)?69 .ok_or(AnyError)?;70 #[allow(clippy::single_match)]71 match call {72 UniqueFungibleCall::ERC20(ERC20Call::Transfer { .. }) => {73 let who = T::CrossAccountId::from_eth(*caller);74 let collection_limits = &collection.limits;75 let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {76 collection_limits.sponsor_transfer_timeout77 } else {78 <limit!(T, FungibleSponsorTransferTimeout)>::get()79 };8081 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;82 let mut sponsored = true;83 if <FungibleTransferBasket<T>>::contains_key(collection_id, who.as_sub()) {84 let last_tx_block =85 <FungibleTransferBasket<T>>::get(collection_id, who.as_sub());86 let limit_time = last_tx_block + limit.into();87 if block_number <= limit_time {88 sponsored = false;89 }90 }91 if sponsored {92 <FungibleTransferBasket<T>>::insert(93 collection_id,94 who.as_sub(),95 block_number,96 );97 return Ok(());98 }99 }100 _ => {}101 }102 }103 _ => {}104 }105 Err(AnyError)106}107108pub struct NftEthSponsorshipHandler<T: Config>(PhantomData<*const T>);109impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for NftEthSponsorshipHandler<T> {110 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {111 if let Some(collection_id) = map_eth_to_id(&call.0) {112 if let Some(collection) = <CollectionById<T>>::get(collection_id) {113 if !collection.sponsorship.confirmed() {114 return None;115 }116 if try_sponsor(who, collection_id, &collection, &call.1).is_ok() {117 return collection118 .sponsorship119 .sponsor()120 .cloned()121 .map(T::EvmBackwardsAddressMapping::from_account_id);122 }123 }124 }125 None126 }127}1//! Implements EVM sponsoring logic via OnChargeEVMTransaction23use crate::{4 Collection, CollectionById, Config, FungibleTransferBasket, NftTransferBasket,5 eth::{account::EvmBackwardsAddressMapping, map_eth_to_id},6};7use evm_coder::{Call, abi::AbiReader};8use frame_support::{9 storage::{StorageMap, StorageDoubleMap},10};11use sp_core::H160;12use sp_std::prelude::*;13use up_sponsorship::SponsorshipHandler;14use super::{15 account::CrossAccountId,16 erc::{UniqueFungibleCall, UniqueNFTCall, ERC721Call, ERC20Call, ERC721UniqueExtensionsCall},17};18use core::convert::TryInto;19use core::marker::PhantomData;20use nft_data_structs::{NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT};2122struct AnyError;2324fn try_sponsor<T: Config>(25 caller: &H160,26 collection_id: u32,27 collection: &Collection<T>,28 call: &[u8],29) -> Result<(), AnyError> {30 let (method_id, mut reader) = AbiReader::new_call(call).map_err(|_| AnyError)?;31 match &collection.mode {32 crate::CollectionMode::NFT => {33 let call: UniqueNFTCall = UniqueNFTCall::parse(method_id, &mut reader)34 .map_err(|_| AnyError)?35 .ok_or(AnyError)?;36 match call {37 UniqueNFTCall::ERC721UniqueExtensions(38 ERC721UniqueExtensionsCall::TransferNft { token_id, .. },39 )40 | UniqueNFTCall::ERC721(ERC721Call::TransferFrom { token_id, .. }) => {41 let token_id: u32 = token_id.try_into().map_err(|_| AnyError)?;42 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;43 let collection_limits = &collection.limits;44 let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {45 collection_limits.sponsor_transfer_timeout46 } else {47 NFT_SPONSOR_TRANSFER_TIMEOUT48 };4950 let mut sponsor = true;51 if <NftTransferBasket<T>>::contains_key(collection_id, token_id) {52 let last_tx_block = <NftTransferBasket<T>>::get(collection_id, token_id);53 let limit_time = last_tx_block + limit.into();54 if block_number <= limit_time {55 sponsor = false;56 }57 }58 if sponsor {59 <NftTransferBasket<T>>::insert(collection_id, token_id, block_number);60 return Ok(());61 }62 }63 _ => {}64 }65 }66 crate::CollectionMode::Fungible(_) => {67 let call: UniqueFungibleCall = UniqueFungibleCall::parse(method_id, &mut reader)68 .map_err(|_| AnyError)?69 .ok_or(AnyError)?;70 #[allow(clippy::single_match)]71 match call {72 UniqueFungibleCall::ERC20(ERC20Call::Transfer { .. }) => {73 let who = T::CrossAccountId::from_eth(*caller);74 let collection_limits = &collection.limits;75 let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {76 collection_limits.sponsor_transfer_timeout77 } else {78 FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT79 };8081 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;82 let mut sponsored = true;83 if <FungibleTransferBasket<T>>::contains_key(collection_id, who.as_sub()) {84 let last_tx_block =85 <FungibleTransferBasket<T>>::get(collection_id, who.as_sub());86 let limit_time = last_tx_block + limit.into();87 if block_number <= limit_time {88 sponsored = false;89 }90 }91 if sponsored {92 <FungibleTransferBasket<T>>::insert(93 collection_id,94 who.as_sub(),95 block_number,96 );97 return Ok(());98 }99 }100 _ => {}101 }102 }103 _ => {}104 }105 Err(AnyError)106}107108pub struct NftEthSponsorshipHandler<T: Config>(PhantomData<*const T>);109impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for NftEthSponsorshipHandler<T> {110 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {111 if let Some(collection_id) = map_eth_to_id(&call.0) {112 if let Some(collection) = <CollectionById<T>>::get(collection_id) {113 if !collection.sponsorship.confirmed() {114 return None;115 }116 if try_sponsor(who, collection_id, &collection, &call.1).is_ok() {117 return collection118 .sponsorship119 .sponsor()120 .cloned()121 .map(T::EvmBackwardsAddressMapping::from_account_id);122 }123 }124 }125 None126 }127}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.rsdiffbeforeafterboth--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -28,6 +28,29 @@
pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;
pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;
+pub const COLLECTION_NUMBER_LIMIT: u32 = 100000;
+pub const CUSTOM_DATA_LIMIT: u32 = 2048;
+pub const COLLECTION_ADMINS_LIMIT: u64 = 5;
+pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = 1000000;
+
+// Timeouts for item types in passed blocks
+pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;
+pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;
+pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;
+
+// Schema limits
+pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;
+pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;
+pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024;
+
+/// How much items can be created per single
+/// create_many call
+pub const MAX_ITEMS_PER_BATCH: u32 = 200;
+
+parameter_types! {
+ pub const CustomDataLimit: u32 = CUSTOM_DATA_LIMIT;
+}
+
pub type CollectionId = u32;
pub type TokenId = u32;
pub type DecimalPoints = u8;
@@ -203,27 +226,6 @@
}
}
-pub trait ChainLimits {
- type CollectionNumberLimit: Get<u32>;
- type AccountTokenOwnershipLimit: Get<u32>;
- type CollectionAdminsLimit: Get<u64>;
- type CustomDataLimit: Get<u32>;
-
- // Timeouts for item types in passed blocks
- type NftSponsorTransferTimeout: Get<u32>;
- type FungibleSponsorTransferTimeout: Get<u32>;
- type ReFungibleSponsorTransferTimeout: Get<u32>;
-
- // Schema limits
- type OffchainSchemaLimit: Get<u32>;
- type VariableOnChainSchemaLimit: Get<u32>;
- type ConstOnChainSchemaLimit: Get<u32>;
-
- /// How much items can be created per single
- /// create_many call
- type MaxItemsPerBatch: Get<u32>;
-}
-
/// BoundedVec doesn't supports serde
#[cfg(feature = "serde1")]
mod bounded_serde {
@@ -257,16 +259,16 @@
}
}
-#[derive(Encode, Decode, MaxEncodedLen, Default, Derivative)]
+#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
-#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]
-pub struct CreateNftData<T: ChainLimits> {
+#[derivative(Debug)]
+pub struct CreateNftData {
#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]
#[derivative(Debug = "ignore")]
- pub const_data: BoundedVec<u8, T::CustomDataLimit>,
+ pub const_data: BoundedVec<u8, CustomDataLimit>,
#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]
#[derivative(Debug = "ignore")]
- pub variable_data: BoundedVec<u8, T::CustomDataLimit>,
+ pub variable_data: BoundedVec<u8, CustomDataLimit>,
}
#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq)]
@@ -275,29 +277,28 @@
pub value: u128,
}
-#[derive(Encode, Decode, MaxEncodedLen, Default, Derivative)]
+#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
-#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]
-pub struct CreateReFungibleData<T: ChainLimits> {
+#[derivative(Debug)]
+pub struct CreateReFungibleData {
#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]
#[derivative(Debug = "ignore")]
- pub const_data: BoundedVec<u8, T::CustomDataLimit>,
+ pub const_data: BoundedVec<u8, CustomDataLimit>,
#[cfg_attr(feature = "serde1", serde(with = "bounded_serde"))]
#[derivative(Debug = "ignore")]
- pub variable_data: BoundedVec<u8, T::CustomDataLimit>,
+ pub variable_data: BoundedVec<u8, CustomDataLimit>,
pub pieces: u128,
}
-#[derive(Encode, Decode, MaxEncodedLen, Derivative)]
+#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
-#[derivative(Debug(bound = ""), PartialEq(bound = ""), Clone(bound = ""))]
-pub enum CreateItemData<T: ChainLimits> {
- NFT(CreateNftData<T>),
+pub enum CreateItemData {
+ NFT(CreateNftData),
Fungible(CreateFungibleData),
- ReFungible(CreateReFungibleData<T>),
+ ReFungible(CreateReFungibleData),
}
-impl<T: ChainLimits> CreateItemData<T> {
+impl CreateItemData {
pub fn data_size(&self) -> usize {
match self {
CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),
@@ -307,19 +308,19 @@
}
}
-impl<T: ChainLimits> From<CreateNftData<T>> for CreateItemData<T> {
- fn from(item: CreateNftData<T>) -> Self {
+impl From<CreateNftData> for CreateItemData {
+ fn from(item: CreateNftData) -> Self {
CreateItemData::NFT(item)
}
}
-impl<T: ChainLimits> From<CreateReFungibleData<T>> for CreateItemData<T> {
- fn from(item: CreateReFungibleData<T>) -> Self {
+impl From<CreateReFungibleData> for CreateItemData {
+ fn from(item: CreateReFungibleData) -> Self {
CreateItemData::ReFungible(item)
}
}
-impl<T: ChainLimits> From<CreateFungibleData> for CreateItemData<T> {
+impl From<CreateFungibleData> for CreateItemData {
fn from(item: CreateFungibleData) -> Self {
CreateItemData::Fungible(item)
}
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! {