difftreelog
Merge branch 'develop' into feature/CORE-302-ss58Format
in: master
17 files changed
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -20,8 +20,8 @@
use frame_benchmarking::{benchmarks, account};
use up_data_structs::{
CollectionMode, CreateCollectionData, CollectionId, Property, PropertyKey, PropertyValue,
- MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
- OFFCHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, MAX_PROPERTIES_PER_ITEM,
+ CollectionPermissions, NestingRule, MAX_COLLECTION_NAME_LENGTH,
+ MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, MAX_PROPERTIES_PER_ITEM,
};
use frame_support::{
traits::{Currency, Get},
@@ -74,15 +74,15 @@
}
pub fn create_collection_raw<T: Config, R>(
- owner: T::AccountId,
+ owner: T::CrossAccountId,
mode: CollectionMode,
handler: impl FnOnce(
- T::AccountId,
+ T::CrossAccountId,
CreateCollectionData<T::AccountId>,
) -> Result<CollectionId, DispatchError>,
cast: impl FnOnce(CollectionHandle<T>) -> R,
) -> Result<R, DispatchError> {
- T::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());
+ <T as Config>::Currency::deposit_creating(&owner.as_sub(), T::CollectionCreationPrice::get());
let name = create_u16_data::<MAX_COLLECTION_NAME_LENGTH>();
let description = create_u16_data::<MAX_COLLECTION_DESCRIPTION_LENGTH>();
let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();
@@ -93,13 +93,19 @@
name,
description,
token_prefix,
+ permissions: Some(CollectionPermissions {
+ nesting: Some(NestingRule::Permissive),
+ ..Default::default()
+ }),
..Default::default()
},
)
.and_then(CollectionHandle::try_get)
.map(cast)
}
-fn create_collection<T: Config>(owner: T::AccountId) -> Result<CollectionHandle<T>, DispatchError> {
+fn create_collection<T: Config>(
+ owner: T::CrossAccountId,
+) -> Result<CollectionHandle<T>, DispatchError> {
create_collection_raw(
owner,
CollectionMode::NFT,
@@ -127,7 +133,7 @@
bench_init!($($rest)*);
};
($name:ident: collection($owner:ident); $($rest:tt)*) => {
- let $name = create_collection::<T>($owner.clone())?;
+ let $name = create_collection::<T>(T::CrossAccountId::from_sub($owner.clone()))?;
bench_init!($($rest)*);
};
($name:ident: cross; $($rest:tt)*) => {
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1168,8 +1168,9 @@
);
Ok(new_limit)
}
+
pub fn clamp_permissions(
- mode: CollectionMode,
+ _mode: CollectionMode,
old_limit: &CollectionPermissions,
mut new_limit: CollectionPermissions,
) -> Result<CollectionPermissions, DispatchError> {
@@ -1204,6 +1205,22 @@
fn approve() -> Weight;
fn transfer_from() -> Weight;
fn burn_from() -> Weight;
+
+ /// Differs from burn_item in case of Fungible and Refungible, as it should burn
+ /// whole users's balance
+ ///
+ /// This method shouldn't be used directly, as it doesn't count breadth price, use `burn_recursively` instead
+ fn burn_recursively_self_raw() -> Weight;
+ /// Cost of iterating over `amount` children while burning, without counting child burning itself
+ ///
+ /// This method shouldn't be used directly, as it doesn't count depth price, use `burn_recursively` instead
+ fn burn_recursively_breadth_raw(amount: u32) -> Weight;
+
+ fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {
+ Self::burn_recursively_self_raw()
+ .saturating_mul(max_selfs.max(1) as u64)
+ .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))
+ }
}
pub trait CommonCollectionOperations<T: Config> {
@@ -1233,6 +1250,13 @@
token: TokenId,
amount: u128,
) -> DispatchResultWithPostInfo;
+ fn burn_item_recursively(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo;
fn set_collection_properties(
&self,
sender: T::CrossAccountId,
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -25,7 +25,9 @@
const SEED: u32 = 1;
-fn create_collection<T: Config>(owner: T::AccountId) -> Result<FungibleHandle<T>, DispatchError> {
+fn create_collection<T: Config>(
+ owner: T::CrossAccountId,
+) -> Result<FungibleHandle<T>, DispatchError> {
create_collection_raw(
owner,
CollectionMode::Fungible(0),
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -16,9 +16,10 @@
use core::marker::PhantomData;
-use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
+use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};
use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData};
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
+use pallet_structure::Error as StructureError;
use sp_runtime::ArithmeticError;
use sp_std::{vec::Vec, vec};
use up_data_structs::{Property, PropertyKey, PropertyValue, PropertyKeyPermission};
@@ -91,6 +92,16 @@
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
}
+
+ fn burn_recursively_self_raw() -> Weight {
+ // Read to get total balance
+ Self::burn_item() + T::DbWeight::get().reads(1)
+ }
+
+ fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
+ // Fungible tokens can't have children
+ 0
+ }
}
impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {
@@ -170,6 +181,26 @@
)
}
+ fn burn_item_recursively(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ _breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo {
+ // Should not happen?
+ ensure!(
+ token == TokenId::default(),
+ <Error<T>>::FungibleItemsHaveNoId
+ );
+ ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
+
+ with_weight(
+ <Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),
+ <CommonWeights<T>>::burn_recursively_self_raw(),
+ )
+ }
+
fn transfer(
&self,
from: T::CrossAccountId,
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -18,12 +18,9 @@
use crate::{Pallet, Config, NonfungibleHandle};
use sp_std::prelude::*;
-use pallet_common::benchmarking::{create_collection_raw, create_data, property_key, property_value};
+use pallet_common::benchmarking::{create_collection_raw, property_key, property_value};
use frame_benchmarking::{benchmarks, account};
-use up_data_structs::{
- CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, CUSTOM_DATA_LIMIT,
- budget::Unlimited,
-};
+use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, budget::Unlimited};
use pallet_common::bench_init;
const SEED: u32 = 1;
@@ -49,7 +46,7 @@
}
fn create_collection<T: Config>(
- owner: T::AccountId,
+ owner: T::CrossAccountId,
) -> Result<NonfungibleHandle<T>, DispatchError> {
create_collection_raw(
owner,
@@ -96,6 +93,26 @@
let item = create_max_item(&collection, &sender, burner.clone())?;
}: {<Pallet<T>>::burn(&collection, &burner, item)?}
+ burn_recursively_self_raw {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner); burner: cross_sub;
+ };
+ let item = create_max_item(&collection, &sender, burner.clone())?;
+ }: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)}
+
+ burn_recursively_breadth_plus_self_plus_self_per_each_raw {
+ let b in 0..200;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner); burner: cross_sub;
+ };
+ let item = create_max_item(&collection, &sender, burner.clone())?;
+ for i in 0..b {
+ create_max_item(&collection, &sender, T::CrossTokenAddressMapping::token_to_address(collection.id, item))?;
+ }
+ }: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)}
+
transfer {
bench_init!{
owner: sub; collection: collection(owner);
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -108,6 +108,15 @@
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
}
+
+ fn burn_recursively_self_raw() -> Weight {
+ <SelfWeightOf<T>>::burn_recursively_self_raw()
+ }
+
+ fn burn_recursively_breadth_raw(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)
+ .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))
+ }
}
fn map_create_data<T: Config>(
@@ -264,6 +273,16 @@
}
}
+ fn burn_item_recursively(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo {
+ <Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)
+ }
+
fn transfer(
&self,
from: T::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -18,7 +18,13 @@
use erc::ERC721Events;
use evm_coder::ToLog;
-use frame_support::{BoundedVec, ensure, fail, transactional, storage::with_transaction};
+use frame_support::{
+ BoundedVec, ensure, fail, transactional,
+ storage::with_transaction,
+ pallet_prelude::DispatchResultWithPostInfo,
+ pallet_prelude::Weight,
+ weights::{PostDispatchInfo, Pays},
+};
use up_data_structs::{
AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
mapping::TokenAddressMapping, NestingRule, budget::Budget, Property, PropertyPermission,
@@ -29,7 +35,7 @@
Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
eth::collection_id_to_address,
};
-use pallet_structure::Pallet as PalletStructure;
+use pallet_structure::{Pallet as PalletStructure, Error as StructureError};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
use sp_core::H160;
use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
@@ -39,6 +45,7 @@
use scale_info::TypeInfo;
pub use pallet::*;
+use weights::WeightInfo;
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
pub mod common;
@@ -373,7 +380,7 @@
<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
collection.id,
token,
- sender.clone(),
+ token_data.owner.clone(),
old_spender,
0,
));
@@ -396,6 +403,45 @@
Ok(())
}
+ #[transactional]
+ pub fn burn_recursively(
+ collection: &NonfungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
+
+ let current_token_account =
+ T::CrossTokenAddressMapping::token_to_address(collection.id, token);
+
+ let mut weight = 0 as Weight;
+
+ // This method is transactional, if user in fact doesn't have permissions to remove token -
+ // tokens removed here will be restored after rejected transaction
+ for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {
+ ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);
+ let PostDispatchInfo { actual_weight, .. } =
+ <PalletStructure<T>>::burn_item_recursively(
+ current_token_account.clone(),
+ collection,
+ token,
+ self_budget,
+ breadth_budget,
+ )?;
+ if let Some(actual_weight) = actual_weight {
+ weight = weight.saturating_add(actual_weight);
+ }
+ }
+
+ Self::burn(collection, sender, token)?;
+ DispatchResultWithPostInfo::Ok(PostDispatchInfo {
+ actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),
+ pays_fee: Pays::Yes,
+ })
+ }
+
pub fn set_token_property(
collection: &NonfungibleHandle<T>,
sender: &T::CrossAccountId,
@@ -964,6 +1010,7 @@
);
ensure_sender_allowed::<T>(handle.id, under, from, sender, nesting_budget)?
}
+ NestingRule::Permissive => {}
}
Ok(())
}
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -36,6 +36,8 @@
fn create_multiple_items(b: u32, ) -> Weight;
fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
+ fn burn_recursively_self_raw() -> Weight;
+ fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
@@ -92,7 +94,35 @@
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
-
+ // Storage: Nonfungible TokenChildren (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Nonfungible TokenProperties (r:0 w:1)
+ fn burn_recursively_self_raw() -> Weight {
+ (86_136_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ }
+ // Storage: Nonfungible TokenChildren (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Nonfungible TokenProperties (r:0 w:1)
+ // Storage: Common CollectionById (r:1 w:0)
+ fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {
+ (0 as Weight)
+ // Standard Error: 42_828_000
+ .saturating_add((381_478_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(6 as Weight))
+ .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(T::DbWeight::get().writes(5 as Weight))
+ .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))
+ }
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:2 w:2)
// Storage: Nonfungible Allowance (r:1 w:0)
@@ -204,7 +234,35 @@
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
-
+ // Storage: Nonfungible TokenChildren (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Nonfungible TokenProperties (r:0 w:1)
+ fn burn_recursively_self_raw() -> Weight {
+ (86_136_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(5 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ }
+ // Storage: Nonfungible TokenChildren (r:1 w:0)
+ // Storage: Nonfungible TokenData (r:1 w:1)
+ // Storage: Nonfungible TokensBurnt (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:1 w:1)
+ // Storage: Nonfungible Allowance (r:1 w:0)
+ // Storage: Nonfungible Owned (r:0 w:1)
+ // Storage: Nonfungible TokenProperties (r:0 w:1)
+ // Storage: Common CollectionById (r:1 w:0)
+ fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {
+ (0 as Weight)
+ // Standard Error: 42_828_000
+ .saturating_add((381_478_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(6 as Weight))
+ .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(RocksDbWeight::get().writes(5 as Weight))
+ .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))
+ }
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:2 w:2)
// Storage: Nonfungible Allowance (r:1 w:0)
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -50,7 +50,9 @@
Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
}
-fn create_collection<T: Config>(owner: T::AccountId) -> Result<RefungibleHandle<T>, DispatchError> {
+fn create_collection<T: Config>(
+ owner: T::CrossAccountId,
+) -> Result<RefungibleHandle<T>, DispatchError> {
create_collection_raw(
owner,
CollectionMode::NFT,
pallets/refungible/src/common.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use sp_std::collections::btree_map::BTreeMap;20use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};21use up_data_structs::{22 CollectionId, TokenId, CreateItemExData, CreateRefungibleExData, budget::Budget, Property,23 PropertyKey, PropertyValue, PropertyKeyPermission, CreateItemData,24};25use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};26use sp_runtime::DispatchError;27use sp_std::{vec::Vec, vec};2829use crate::{30 AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,31 SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,32};3334macro_rules! max_weight_of {35 ($($method:ident ($($args:tt)*)),*) => {36 037 $(38 .max(<SelfWeightOf<T>>::$method($($args)*))39 )*40 };41}4243pub struct CommonWeights<T: Config>(PhantomData<T>);44impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {45 fn create_item() -> Weight {46 <SelfWeightOf<T>>::create_item()47 }4849 fn create_multiple_items(data: &[CreateItemData]) -> Weight {50 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32)51 }5253 fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {54 match call {55 CreateItemExData::RefungibleMultipleOwners(i) => {56 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)57 }58 CreateItemExData::RefungibleMultipleItems(i) => {59 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)60 }61 _ => 0,62 }63 }6465 fn burn_item() -> Weight {66 max_weight_of!(burn_item_partial(), burn_item_fully())67 }6869 fn set_collection_properties(_amount: u32) -> Weight {70 // Error71 072 }7374 fn delete_collection_properties(_amount: u32) -> Weight {75 // Error76 077 }7879 fn set_token_properties(amount: u32) -> Weight {80 <SelfWeightOf<T>>::set_token_properties(amount)81 }8283 fn delete_token_properties(amount: u32) -> Weight {84 <SelfWeightOf<T>>::delete_token_properties(amount)85 }8687 fn set_property_permissions(amount: u32) -> Weight {88 <SelfWeightOf<T>>::set_property_permissions(amount)89 }9091 fn transfer() -> Weight {92 max_weight_of!(93 transfer_normal(),94 transfer_creating(),95 transfer_removing(),96 transfer_creating_removing()97 )98 }99100 fn approve() -> Weight {101 <SelfWeightOf<T>>::approve()102 }103104 fn transfer_from() -> Weight {105 max_weight_of!(106 transfer_from_normal(),107 transfer_from_creating(),108 transfer_from_removing(),109 transfer_from_creating_removing()110 )111 }112113 fn burn_from() -> Weight {114 <SelfWeightOf<T>>::burn_from()115 }116}117118fn map_create_data<T: Config>(119 data: up_data_structs::CreateItemData,120 to: &T::CrossAccountId,121) -> Result<CreateRefungibleExData<T::CrossAccountId>, DispatchError> {122 match data {123 up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateRefungibleExData {124 const_data: data.const_data,125 users: {126 let mut out = BTreeMap::new();127 out.insert(to.clone(), data.pieces);128 out.try_into().expect("limit > 0")129 },130 }),131 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),132 }133}134135impl<T: Config> CommonCollectionOperations<T> for RefungibleHandle<T> {136 fn create_item(137 &self,138 sender: T::CrossAccountId,139 to: T::CrossAccountId,140 data: up_data_structs::CreateItemData,141 nesting_budget: &dyn Budget,142 ) -> DispatchResultWithPostInfo {143 with_weight(144 <Pallet<T>>::create_item(145 self,146 &sender,147 map_create_data::<T>(data, &to)?,148 nesting_budget,149 ),150 <CommonWeights<T>>::create_item(),151 )152 }153154 fn create_multiple_items(155 &self,156 sender: T::CrossAccountId,157 to: T::CrossAccountId,158 data: Vec<up_data_structs::CreateItemData>,159 nesting_budget: &dyn Budget,160 ) -> DispatchResultWithPostInfo {161 let weight = <CommonWeights<T>>::create_multiple_items(&data);162 let data = data163 .into_iter()164 .map(|d| map_create_data::<T>(d, &to))165 .collect::<Result<Vec<_>, DispatchError>>()?;166167 with_weight(168 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),169 weight,170 )171 }172173 fn create_multiple_items_ex(174 &self,175 sender: <T>::CrossAccountId,176 data: CreateItemExData<T::CrossAccountId>,177 nesting_budget: &dyn Budget,178 ) -> DispatchResultWithPostInfo {179 let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);180 let data = match data {181 CreateItemExData::RefungibleMultipleOwners(r) => vec![r],182 CreateItemExData::RefungibleMultipleItems(r)183 if r.iter().all(|i| i.users.len() == 1) =>184 {185 r.into_inner()186 }187 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),188 };189190 with_weight(191 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),192 weight,193 )194 }195196 fn burn_item(197 &self,198 sender: T::CrossAccountId,199 token: TokenId,200 amount: u128,201 ) -> DispatchResultWithPostInfo {202 with_weight(203 <Pallet<T>>::burn(self, &sender, token, amount),204 <CommonWeights<T>>::burn_item(),205 )206 }207208 fn transfer(209 &self,210 from: T::CrossAccountId,211 to: T::CrossAccountId,212 token: TokenId,213 amount: u128,214 nesting_budget: &dyn Budget,215 ) -> DispatchResultWithPostInfo {216 with_weight(217 <Pallet<T>>::transfer(self, &from, &to, token, amount, nesting_budget),218 <CommonWeights<T>>::transfer(),219 )220 }221222 fn approve(223 &self,224 sender: T::CrossAccountId,225 spender: T::CrossAccountId,226 token: TokenId,227 amount: u128,228 ) -> DispatchResultWithPostInfo {229 with_weight(230 <Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),231 <CommonWeights<T>>::approve(),232 )233 }234235 fn transfer_from(236 &self,237 sender: T::CrossAccountId,238 from: T::CrossAccountId,239 to: T::CrossAccountId,240 token: TokenId,241 amount: u128,242 nesting_budget: &dyn Budget,243 ) -> DispatchResultWithPostInfo {244 with_weight(245 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount, nesting_budget),246 <CommonWeights<T>>::transfer_from(),247 )248 }249250 fn burn_from(251 &self,252 sender: T::CrossAccountId,253 from: T::CrossAccountId,254 token: TokenId,255 amount: u128,256 nesting_budget: &dyn Budget,257 ) -> DispatchResultWithPostInfo {258 with_weight(259 <Pallet<T>>::burn_from(self, &sender, &from, token, amount, nesting_budget),260 <CommonWeights<T>>::burn_from(),261 )262 }263264 fn set_collection_properties(265 &self,266 _sender: T::CrossAccountId,267 _property: Vec<Property>,268 ) -> DispatchResultWithPostInfo {269 fail!(<Error<T>>::SettingPropertiesNotAllowed)270 }271272 fn delete_collection_properties(273 &self,274 _sender: &T::CrossAccountId,275 _property_keys: Vec<PropertyKey>,276 ) -> DispatchResultWithPostInfo {277 fail!(<Error<T>>::SettingPropertiesNotAllowed)278 }279280 fn set_token_properties(281 &self,282 _sender: T::CrossAccountId,283 _token_id: TokenId,284 _property: Vec<Property>,285 ) -> DispatchResultWithPostInfo {286 fail!(<Error<T>>::SettingPropertiesNotAllowed)287 }288289 fn set_property_permissions(290 &self,291 _sender: &T::CrossAccountId,292 _property_permissions: Vec<PropertyKeyPermission>,293 ) -> DispatchResultWithPostInfo {294 fail!(<Error<T>>::SettingPropertiesNotAllowed)295 }296297 fn delete_token_properties(298 &self,299 _sender: T::CrossAccountId,300 _token_id: TokenId,301 _property_keys: Vec<PropertyKey>,302 ) -> DispatchResultWithPostInfo {303 fail!(<Error<T>>::SettingPropertiesNotAllowed)304 }305306 fn check_nesting(307 &self,308 _sender: <T>::CrossAccountId,309 _from: (CollectionId, TokenId),310 _under: TokenId,311 _budget: &dyn Budget,312 ) -> sp_runtime::DispatchResult {313 fail!(<Error<T>>::RefungibleDisallowsNesting)314 }315316 fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}317318 fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}319320 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {321 <Owned<T>>::iter_prefix((self.id, account))322 .map(|(id, _)| id)323 .collect()324 }325326 fn collection_tokens(&self) -> Vec<TokenId> {327 <TokenData<T>>::iter_prefix((self.id,))328 .map(|(id, _)| id)329 .collect()330 }331332 fn token_exists(&self, token: TokenId) -> bool {333 <Pallet<T>>::token_exists(self, token)334 }335336 fn last_token_id(&self) -> TokenId {337 TokenId(<TokensMinted<T>>::get(self.id))338 }339340 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {341 None342 }343344 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {345 None346 }347348 fn token_properties(349 &self,350 _token_id: TokenId,351 _keys: Option<Vec<PropertyKey>>,352 ) -> Vec<Property> {353 Vec::new()354 }355356 fn total_supply(&self) -> u32 {357 <Pallet<T>>::total_supply(self)358 }359360 fn account_balance(&self, account: T::CrossAccountId) -> u32 {361 <AccountBalance<T>>::get((self.id, account))362 }363364 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {365 <Balance<T>>::get((self.id, token, account))366 }367368 fn allowance(369 &self,370 sender: T::CrossAccountId,371 spender: T::CrossAccountId,372 token: TokenId,373 ) -> u128 {374 <Allowance<T>>::get((self.id, token, sender, spender))375 }376}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use sp_std::collections::btree_map::BTreeMap;20use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};21use up_data_structs::{22 CollectionId, TokenId, CreateItemExData, CreateRefungibleExData, budget::Budget, Property,23 PropertyKey, PropertyValue, PropertyKeyPermission, CreateItemData,24};25use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};26use pallet_structure::Error as StructureError;27use sp_runtime::DispatchError;28use sp_std::{vec::Vec, vec};2930use crate::{31 AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,32 SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,33};3435macro_rules! max_weight_of {36 ($($method:ident ($($args:tt)*)),*) => {37 038 $(39 .max(<SelfWeightOf<T>>::$method($($args)*))40 )*41 };42}4344pub struct CommonWeights<T: Config>(PhantomData<T>);45impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {46 fn create_item() -> Weight {47 <SelfWeightOf<T>>::create_item()48 }4950 fn create_multiple_items(data: &[CreateItemData]) -> Weight {51 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32)52 }5354 fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {55 match call {56 CreateItemExData::RefungibleMultipleOwners(i) => {57 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)58 }59 CreateItemExData::RefungibleMultipleItems(i) => {60 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)61 }62 _ => 0,63 }64 }6566 fn burn_item() -> Weight {67 max_weight_of!(burn_item_partial(), burn_item_fully())68 }6970 fn set_collection_properties(_amount: u32) -> Weight {71 // Error72 073 }7475 fn delete_collection_properties(_amount: u32) -> Weight {76 // Error77 078 }7980 fn set_token_properties(amount: u32) -> Weight {81 <SelfWeightOf<T>>::set_token_properties(amount)82 }8384 fn delete_token_properties(amount: u32) -> Weight {85 <SelfWeightOf<T>>::delete_token_properties(amount)86 }8788 fn set_property_permissions(amount: u32) -> Weight {89 <SelfWeightOf<T>>::set_property_permissions(amount)90 }9192 fn transfer() -> Weight {93 max_weight_of!(94 transfer_normal(),95 transfer_creating(),96 transfer_removing(),97 transfer_creating_removing()98 )99 }100101 fn approve() -> Weight {102 <SelfWeightOf<T>>::approve()103 }104105 fn transfer_from() -> Weight {106 max_weight_of!(107 transfer_from_normal(),108 transfer_from_creating(),109 transfer_from_removing(),110 transfer_from_creating_removing()111 )112 }113114 fn burn_from() -> Weight {115 <SelfWeightOf<T>>::burn_from()116 }117118 fn burn_recursively_self_raw() -> Weight {119 // Read to get total balance120 Self::burn_item() + T::DbWeight::get().reads(1)121 }122 fn burn_recursively_breadth_raw(_amount: u32) -> Weight {123 // Refungible token can't have children124 0125 }126}127128fn map_create_data<T: Config>(129 data: up_data_structs::CreateItemData,130 to: &T::CrossAccountId,131) -> Result<CreateRefungibleExData<T::CrossAccountId>, DispatchError> {132 match data {133 up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateRefungibleExData {134 const_data: data.const_data,135 users: {136 let mut out = BTreeMap::new();137 out.insert(to.clone(), data.pieces);138 out.try_into().expect("limit > 0")139 },140 }),141 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),142 }143}144145impl<T: Config> CommonCollectionOperations<T> for RefungibleHandle<T> {146 fn create_item(147 &self,148 sender: T::CrossAccountId,149 to: T::CrossAccountId,150 data: up_data_structs::CreateItemData,151 nesting_budget: &dyn Budget,152 ) -> DispatchResultWithPostInfo {153 with_weight(154 <Pallet<T>>::create_item(155 self,156 &sender,157 map_create_data::<T>(data, &to)?,158 nesting_budget,159 ),160 <CommonWeights<T>>::create_item(),161 )162 }163164 fn create_multiple_items(165 &self,166 sender: T::CrossAccountId,167 to: T::CrossAccountId,168 data: Vec<up_data_structs::CreateItemData>,169 nesting_budget: &dyn Budget,170 ) -> DispatchResultWithPostInfo {171 let weight = <CommonWeights<T>>::create_multiple_items(&data);172 let data = data173 .into_iter()174 .map(|d| map_create_data::<T>(d, &to))175 .collect::<Result<Vec<_>, DispatchError>>()?;176177 with_weight(178 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),179 weight,180 )181 }182183 fn create_multiple_items_ex(184 &self,185 sender: <T>::CrossAccountId,186 data: CreateItemExData<T::CrossAccountId>,187 nesting_budget: &dyn Budget,188 ) -> DispatchResultWithPostInfo {189 let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);190 let data = match data {191 CreateItemExData::RefungibleMultipleOwners(r) => vec![r],192 CreateItemExData::RefungibleMultipleItems(r)193 if r.iter().all(|i| i.users.len() == 1) =>194 {195 r.into_inner()196 }197 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),198 };199200 with_weight(201 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),202 weight,203 )204 }205206 fn burn_item(207 &self,208 sender: T::CrossAccountId,209 token: TokenId,210 amount: u128,211 ) -> DispatchResultWithPostInfo {212 with_weight(213 <Pallet<T>>::burn(self, &sender, token, amount),214 <CommonWeights<T>>::burn_item(),215 )216 }217218 fn burn_item_recursively(219 &self,220 sender: T::CrossAccountId,221 token: TokenId,222 self_budget: &dyn Budget,223 _breadth_budget: &dyn Budget,224 ) -> DispatchResultWithPostInfo {225 ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);226 with_weight(227 <Pallet<T>>::burn(228 self,229 &sender,230 token,231 <Balance<T>>::get((self.id, token, &sender)),232 ),233 <CommonWeights<T>>::burn_recursively_self_raw(),234 )235 }236237 fn transfer(238 &self,239 from: T::CrossAccountId,240 to: T::CrossAccountId,241 token: TokenId,242 amount: u128,243 nesting_budget: &dyn Budget,244 ) -> DispatchResultWithPostInfo {245 with_weight(246 <Pallet<T>>::transfer(self, &from, &to, token, amount, nesting_budget),247 <CommonWeights<T>>::transfer(),248 )249 }250251 fn approve(252 &self,253 sender: T::CrossAccountId,254 spender: T::CrossAccountId,255 token: TokenId,256 amount: u128,257 ) -> DispatchResultWithPostInfo {258 with_weight(259 <Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),260 <CommonWeights<T>>::approve(),261 )262 }263264 fn transfer_from(265 &self,266 sender: T::CrossAccountId,267 from: T::CrossAccountId,268 to: T::CrossAccountId,269 token: TokenId,270 amount: u128,271 nesting_budget: &dyn Budget,272 ) -> DispatchResultWithPostInfo {273 with_weight(274 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount, nesting_budget),275 <CommonWeights<T>>::transfer_from(),276 )277 }278279 fn burn_from(280 &self,281 sender: T::CrossAccountId,282 from: T::CrossAccountId,283 token: TokenId,284 amount: u128,285 nesting_budget: &dyn Budget,286 ) -> DispatchResultWithPostInfo {287 with_weight(288 <Pallet<T>>::burn_from(self, &sender, &from, token, amount, nesting_budget),289 <CommonWeights<T>>::burn_from(),290 )291 }292293 fn set_collection_properties(294 &self,295 _sender: T::CrossAccountId,296 _property: Vec<Property>,297 ) -> DispatchResultWithPostInfo {298 fail!(<Error<T>>::SettingPropertiesNotAllowed)299 }300301 fn delete_collection_properties(302 &self,303 _sender: &T::CrossAccountId,304 _property_keys: Vec<PropertyKey>,305 ) -> DispatchResultWithPostInfo {306 fail!(<Error<T>>::SettingPropertiesNotAllowed)307 }308309 fn set_token_properties(310 &self,311 _sender: T::CrossAccountId,312 _token_id: TokenId,313 _property: Vec<Property>,314 ) -> DispatchResultWithPostInfo {315 fail!(<Error<T>>::SettingPropertiesNotAllowed)316 }317318 fn set_property_permissions(319 &self,320 _sender: &T::CrossAccountId,321 _property_permissions: Vec<PropertyKeyPermission>,322 ) -> DispatchResultWithPostInfo {323 fail!(<Error<T>>::SettingPropertiesNotAllowed)324 }325326 fn delete_token_properties(327 &self,328 _sender: T::CrossAccountId,329 _token_id: TokenId,330 _property_keys: Vec<PropertyKey>,331 ) -> DispatchResultWithPostInfo {332 fail!(<Error<T>>::SettingPropertiesNotAllowed)333 }334335 fn check_nesting(336 &self,337 _sender: <T>::CrossAccountId,338 _from: (CollectionId, TokenId),339 _under: TokenId,340 _budget: &dyn Budget,341 ) -> sp_runtime::DispatchResult {342 fail!(<Error<T>>::RefungibleDisallowsNesting)343 }344345 fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}346347 fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}348349 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {350 <Owned<T>>::iter_prefix((self.id, account))351 .map(|(id, _)| id)352 .collect()353 }354355 fn collection_tokens(&self) -> Vec<TokenId> {356 <TokenData<T>>::iter_prefix((self.id,))357 .map(|(id, _)| id)358 .collect()359 }360361 fn token_exists(&self, token: TokenId) -> bool {362 <Pallet<T>>::token_exists(self, token)363 }364365 fn last_token_id(&self) -> TokenId {366 TokenId(<TokensMinted<T>>::get(self.id))367 }368369 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {370 None371 }372373 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {374 None375 }376377 fn token_properties(378 &self,379 _token_id: TokenId,380 _keys: Option<Vec<PropertyKey>>,381 ) -> Vec<Property> {382 Vec::new()383 }384385 fn total_supply(&self) -> u32 {386 <Pallet<T>>::total_supply(self)387 }388389 fn account_balance(&self, account: T::CrossAccountId) -> u32 {390 <AccountBalance<T>>::get((self.id, account))391 }392393 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {394 <Balance<T>>::get((self.id, token, account))395 }396397 fn allowance(398 &self,399 sender: T::CrossAccountId,400 spender: T::CrossAccountId,401 token: TokenId,402 ) -> u128 {403 <Allowance<T>>::get((self.id, token, sender, spender))404 }405}pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -60,8 +60,9 @@
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
-#[cfg(feature = "runtime-benchmarks")]
-mod benchmarking;
+// FIXME
+// #[cfg(feature = "runtime-benchmarks")]
+// mod benchmarking;
pub mod weights;
pallets/structure/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -5,6 +5,7 @@
use up_data_structs::{
CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
};
+use pallet_common::Config as CommonConfig;
use pallet_evm::account::CrossAccountId;
const SEED: u32 = 1;
@@ -14,8 +15,8 @@
let caller: T::AccountId = account("caller", 0, SEED);
let caller_cross = T::CrossAccountId::from_sub(caller.clone());
- T::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
- T::CollectionDispatch::create(caller, CreateCollectionData {
+ <T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
+ T::CollectionDispatch::create(caller_cross.clone(), CreateCollectionData {
mode: CollectionMode::NFT,
..Default::default()
})?;
pallets/structure/src/lib.rsdiffbeforeafterboth--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -3,7 +3,7 @@
use pallet_common::CommonCollectionOperations;
use sp_std::collections::btree_set::BTreeSet;
-use frame_support::dispatch::{DispatchError, DispatchResult};
+use frame_support::dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo};
use frame_support::fail;
pub use pallet::*;
use pallet_common::{dispatch::CollectionDispatch, CollectionHandle};
@@ -29,6 +29,8 @@
OuroborosDetected,
/// While searched for owner, encountered depth limit
DepthLimit,
+ /// While iterating over children, encountered breadth limit
+ BreadthLimit,
/// While searched for owner, found token owner by not-yet-existing token
TokenNotFound,
}
@@ -184,6 +186,19 @@
Err(<Error<T>>::DepthLimit.into())
}
+ pub fn burn_item_recursively(
+ from: T::CrossAccountId,
+ collection: CollectionId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo {
+ let handle = <CollectionHandle<T>>::try_get(collection)?;
+ let dispatch = T::CollectionDispatch::dispatch(handle);
+ let dispatch = dispatch.as_dyn();
+ dispatch.burn_item_recursively(from.clone(), token, self_budget, breadth_budget)
+ }
+
pub fn check_nesting(
from: T::CrossAccountId,
under: &T::CrossAccountId,
pallets/unique/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/unique/src/benchmarking.rs
+++ b/pallets/unique/src/benchmarking.rs
@@ -22,7 +22,10 @@
use frame_support::traits::{tokens::currency::Currency, Get};
use frame_benchmarking::{benchmarks, account};
use sp_runtime::DispatchError;
-use pallet_common::benchmarking::{create_data, create_var_data, create_u16_data};
+use pallet_common::{
+ Config as CommonConfig,
+ benchmarking::{create_data, create_u16_data},
+};
const SEED: u32 = 1;
@@ -30,7 +33,7 @@
owner: T::AccountId,
mode: CollectionMode,
) -> Result<CollectionId, DispatchError> {
- T::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());
+ <T as CommonConfig>::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());
let col_name = create_u16_data::<MAX_COLLECTION_NAME_LENGTH>();
let col_desc = create_u16_data::<MAX_COLLECTION_DESCRIPTION_LENGTH>();
let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();
@@ -54,7 +57,7 @@
let token_prefix = create_data::<MAX_TOKEN_PREFIX_LENGTH>();
let mode: CollectionMode = CollectionMode::NFT;
let caller: T::AccountId = account("caller", 0, SEED);
- T::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
+ <T as CommonConfig>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
}: _(RawOrigin::Signed(caller.clone()), col_name.clone(), col_desc.clone(), token_prefix.clone(), mode)
verify {
assert_eq!(<pallet_common::CollectionById<T>>::get(CollectionId(1)).unwrap().owner, caller);
@@ -77,16 +80,6 @@
let collection = create_nft_collection::<T>(caller.clone())?;
<Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(allowlist_account.clone()))?;
}: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))
-
- set_public_access_mode {
- let caller: T::AccountId = account("caller", 0, SEED);
- let collection = create_nft_collection::<T>(caller.clone())?;
- }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::AllowList)
-
- set_mint_permission {
- let caller: T::AccountId = account("caller", 0, SEED);
- let collection = create_nft_collection::<T>(caller.clone())?;
- }: _(RawOrigin::Signed(caller.clone()), collection, true)
change_collection_owner {
let caller: T::AccountId = account("caller", 0, SEED);
@@ -145,7 +138,6 @@
owner_can_transfer: Some(true),
sponsored_data_rate_limit: None,
transfers_enabled: Some(true),
- nesting_rule: None,
};
}: set_collection_limits(RawOrigin::Signed(caller.clone()), collection, cl)
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -469,6 +469,8 @@
#[derivative(Debug(format_with = "bounded::set_debug"))]
BoundedBTreeSet<CollectionId, ConstU32<16>>,
),
+ /// Used for tests
+ Permissive,
}
#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]
runtime/common/src/weights.rsdiffbeforeafterboth--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -89,4 +89,12 @@
fn burn_from() -> Weight {
dispatch_weight::<T>() + max_weight_of!(burn_from())
}
+
+ fn burn_recursively_self_raw() -> Weight {
+ max_weight_of!(burn_recursively_self_raw())
+ }
+
+ fn burn_recursively_breadth_raw(amount: u32) -> Weight {
+ max_weight_of!(burn_recursively_breadth_raw(amount))
+ }
}
runtime/unique/src/lib.rsdiffbeforeafterboth--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -73,6 +73,7 @@
CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits,
CollectionStats, RpcCollection,
mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
+ TokenChild,
};
// use pallet_contracts::weights::WeightInfo;