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.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-nonfungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/nonfungible/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_nonfungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;39 fn transfer() -> Weight;40 fn approve() -> Weight;41 fn transfer_from() -> Weight;42 fn burn_from() -> Weight;43 fn set_property_permissions(b: u32) -> Weight;44 fn set_token_properties(b: u32) -> Weight;45 fn delete_token_properties(b: u32) -> Weight;46}4748/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.49pub struct SubstrateWeight<T>(PhantomData<T>);50impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {51 // Storage: Nonfungible TokensMinted (r:1 w:1)52 // Storage: Nonfungible AccountBalance (r:1 w:1)53 // Storage: Nonfungible TokenData (r:0 w:1)54 // Storage: Nonfungible Owned (r:0 w:1)55 fn create_item() -> Weight {56 (18_450_000 as Weight)57 .saturating_add(T::DbWeight::get().reads(2 as Weight))58 .saturating_add(T::DbWeight::get().writes(4 as Weight))59 }60 // Storage: Nonfungible TokensMinted (r:1 w:1)61 // Storage: Nonfungible AccountBalance (r:1 w:1)62 // Storage: Nonfungible TokenData (r:0 w:4)63 // Storage: Nonfungible Owned (r:0 w:4)64 fn create_multiple_items(b: u32, ) -> Weight {65 (10_228_000 as Weight)66 // Standard Error: 1_00067 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))68 .saturating_add(T::DbWeight::get().reads(2 as Weight))69 .saturating_add(T::DbWeight::get().writes(2 as Weight))70 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))71 }72 // Storage: Nonfungible TokensMinted (r:1 w:1)73 // Storage: Nonfungible AccountBalance (r:4 w:4)74 // Storage: Nonfungible TokenData (r:0 w:4)75 // Storage: Nonfungible Owned (r:0 w:4)76 fn create_multiple_items_ex(b: u32, ) -> Weight {77 (6_543_000 as Weight)78 // Standard Error: 2_00079 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))80 .saturating_add(T::DbWeight::get().reads(1 as Weight))81 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))82 .saturating_add(T::DbWeight::get().writes(1 as Weight))83 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))84 }85 // Storage: Nonfungible TokenData (r:1 w:1)86 // Storage: Nonfungible TokensBurnt (r:1 w:1)87 // Storage: Nonfungible AccountBalance (r:1 w:1)88 // Storage: Nonfungible Allowance (r:1 w:0)89 // Storage: Nonfungible Owned (r:0 w:1)90 fn burn_item() -> Weight {91 (24_554_000 as Weight)92 .saturating_add(T::DbWeight::get().reads(4 as Weight))93 .saturating_add(T::DbWeight::get().writes(4 as Weight))94 }9596 // Storage: Nonfungible TokenData (r:1 w:1)97 // Storage: Nonfungible AccountBalance (r:2 w:2)98 // Storage: Nonfungible Allowance (r:1 w:0)99 // Storage: Nonfungible Owned (r:0 w:2)100 fn transfer() -> Weight {101 (28_339_000 as Weight)102 .saturating_add(T::DbWeight::get().reads(4 as Weight))103 .saturating_add(T::DbWeight::get().writes(5 as Weight))104 }105 // Storage: Nonfungible TokenData (r:1 w:0)106 // Storage: Nonfungible Allowance (r:1 w:1)107 fn approve() -> Weight {108 (17_616_000 as Weight)109 .saturating_add(T::DbWeight::get().reads(2 as Weight))110 .saturating_add(T::DbWeight::get().writes(1 as Weight))111 }112 // Storage: Nonfungible Allowance (r:1 w:1)113 // Storage: Nonfungible TokenData (r:1 w:1)114 // Storage: Nonfungible AccountBalance (r:2 w:2)115 // Storage: Nonfungible Owned (r:0 w:2)116 fn transfer_from() -> Weight {117 (32_196_000 as Weight)118 .saturating_add(T::DbWeight::get().reads(4 as Weight))119 .saturating_add(T::DbWeight::get().writes(6 as Weight))120 }121 // Storage: Nonfungible Allowance (r:1 w:1)122 // Storage: Nonfungible TokenData (r:1 w:1)123 // Storage: Nonfungible TokensBurnt (r:1 w:1)124 // Storage: Nonfungible AccountBalance (r:1 w:1)125 // Storage: Nonfungible Owned (r:0 w:1)126 fn burn_from() -> Weight {127 (27_580_000 as Weight)128 .saturating_add(T::DbWeight::get().reads(4 as Weight))129 .saturating_add(T::DbWeight::get().writes(5 as Weight))130 }131 // Storage: Common CollectionPropertyPermissions (r:1 w:1)132 fn set_property_permissions(b: u32, ) -> Weight {133 (0 as Weight)134 // Standard Error: 3_432_000135 .saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))136 .saturating_add(T::DbWeight::get().reads(1 as Weight))137 .saturating_add(T::DbWeight::get().writes(1 as Weight))138 }139 // Storage: Common CollectionPropertyPermissions (r:1 w:0)140 // Storage: Nonfungible TokenData (r:1 w:0)141 // Storage: Nonfungible TokenProperties (r:1 w:1)142 fn set_token_properties(b: u32, ) -> Weight {143 (0 as Weight)144 // Standard Error: 158_583_000145 .saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))146 .saturating_add(T::DbWeight::get().reads(3 as Weight))147 .saturating_add(T::DbWeight::get().writes(1 as Weight))148 }149 // Storage: Common CollectionPropertyPermissions (r:1 w:0)150 // Storage: Nonfungible TokenData (r:1 w:0)151 // Storage: Nonfungible TokenProperties (r:1 w:1)152 fn delete_token_properties(b: u32, ) -> Weight {153 (0 as Weight)154 // Standard Error: 169_018_000155 .saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))156 .saturating_add(T::DbWeight::get().reads(3 as Weight))157 .saturating_add(T::DbWeight::get().writes(1 as Weight))158 }159}160161// For backwards compatibility and tests162impl WeightInfo for () {163 // Storage: Nonfungible TokensMinted (r:1 w:1)164 // Storage: Nonfungible AccountBalance (r:1 w:1)165 // Storage: Nonfungible TokenData (r:0 w:1)166 // Storage: Nonfungible Owned (r:0 w:1)167 fn create_item() -> Weight {168 (18_450_000 as Weight)169 .saturating_add(RocksDbWeight::get().reads(2 as Weight))170 .saturating_add(RocksDbWeight::get().writes(4 as Weight))171 }172 // Storage: Nonfungible TokensMinted (r:1 w:1)173 // Storage: Nonfungible AccountBalance (r:1 w:1)174 // Storage: Nonfungible TokenData (r:0 w:4)175 // Storage: Nonfungible Owned (r:0 w:4)176 fn create_multiple_items(b: u32, ) -> Weight {177 (10_228_000 as Weight)178 // Standard Error: 1_000179 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))180 .saturating_add(RocksDbWeight::get().reads(2 as Weight))181 .saturating_add(RocksDbWeight::get().writes(2 as Weight))182 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))183 }184 // Storage: Nonfungible TokensMinted (r:1 w:1)185 // Storage: Nonfungible AccountBalance (r:4 w:4)186 // Storage: Nonfungible TokenData (r:0 w:4)187 // Storage: Nonfungible Owned (r:0 w:4)188 fn create_multiple_items_ex(b: u32, ) -> Weight {189 (6_543_000 as Weight)190 // Standard Error: 2_000191 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))192 .saturating_add(RocksDbWeight::get().reads(1 as Weight))193 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))194 .saturating_add(RocksDbWeight::get().writes(1 as Weight))195 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))196 }197 // Storage: Nonfungible TokenData (r:1 w:1)198 // Storage: Nonfungible TokensBurnt (r:1 w:1)199 // Storage: Nonfungible AccountBalance (r:1 w:1)200 // Storage: Nonfungible Allowance (r:1 w:0)201 // Storage: Nonfungible Owned (r:0 w:1)202 fn burn_item() -> Weight {203 (24_554_000 as Weight)204 .saturating_add(RocksDbWeight::get().reads(4 as Weight))205 .saturating_add(RocksDbWeight::get().writes(4 as Weight))206 }207208 // Storage: Nonfungible TokenData (r:1 w:1)209 // Storage: Nonfungible AccountBalance (r:2 w:2)210 // Storage: Nonfungible Allowance (r:1 w:0)211 // Storage: Nonfungible Owned (r:0 w:2)212 fn transfer() -> Weight {213 (28_339_000 as Weight)214 .saturating_add(RocksDbWeight::get().reads(4 as Weight))215 .saturating_add(RocksDbWeight::get().writes(5 as Weight))216 }217 // Storage: Nonfungible TokenData (r:1 w:0)218 // Storage: Nonfungible Allowance (r:1 w:1)219 fn approve() -> Weight {220 (17_616_000 as Weight)221 .saturating_add(RocksDbWeight::get().reads(2 as Weight))222 .saturating_add(RocksDbWeight::get().writes(1 as Weight))223 }224 // Storage: Nonfungible Allowance (r:1 w:1)225 // Storage: Nonfungible TokenData (r:1 w:1)226 // Storage: Nonfungible AccountBalance (r:2 w:2)227 // Storage: Nonfungible Owned (r:0 w:2)228 fn transfer_from() -> Weight {229 (32_196_000 as Weight)230 .saturating_add(RocksDbWeight::get().reads(4 as Weight))231 .saturating_add(RocksDbWeight::get().writes(6 as Weight))232 }233 // Storage: Nonfungible Allowance (r:1 w:1)234 // Storage: Nonfungible TokenData (r:1 w:1)235 // Storage: Nonfungible TokensBurnt (r:1 w:1)236 // Storage: Nonfungible AccountBalance (r:1 w:1)237 // Storage: Nonfungible Owned (r:0 w:1)238 fn burn_from() -> Weight {239 (27_580_000 as Weight)240 .saturating_add(RocksDbWeight::get().reads(4 as Weight))241 .saturating_add(RocksDbWeight::get().writes(5 as Weight))242 }243 // Storage: Common CollectionPropertyPermissions (r:1 w:1)244 fn set_property_permissions(b: u32, ) -> Weight {245 (0 as Weight)246 // Standard Error: 3_432_000247 .saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))248 .saturating_add(RocksDbWeight::get().reads(1 as Weight))249 .saturating_add(RocksDbWeight::get().writes(1 as Weight))250 }251 // Storage: Common CollectionPropertyPermissions (r:1 w:0)252 // Storage: Nonfungible TokenData (r:1 w:0)253 // Storage: Nonfungible TokenProperties (r:1 w:1)254 fn set_token_properties(b: u32, ) -> Weight {255 (0 as Weight)256 // Standard Error: 158_583_000257 .saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))258 .saturating_add(RocksDbWeight::get().reads(3 as Weight))259 .saturating_add(RocksDbWeight::get().writes(1 as Weight))260 }261 // Storage: Common CollectionPropertyPermissions (r:1 w:0)262 // Storage: Nonfungible TokenData (r:1 w:0)263 // Storage: Nonfungible TokenProperties (r:1 w:1)264 fn delete_token_properties(b: u32, ) -> Weight {265 (0 as Weight)266 // Standard Error: 169_018_000267 .saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))268 .saturating_add(RocksDbWeight::get().reads(3 as Weight))269 .saturating_add(RocksDbWeight::get().writes(1 as Weight))270 }271}1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-nonfungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/nonfungible/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_nonfungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;39 fn burn_recursively_self_raw() -> Weight;40 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;41 fn transfer() -> Weight;42 fn approve() -> Weight;43 fn transfer_from() -> Weight;44 fn burn_from() -> Weight;45 fn set_property_permissions(b: u32) -> Weight;46 fn set_token_properties(b: u32) -> Weight;47 fn delete_token_properties(b: u32) -> Weight;48}4950/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.51pub struct SubstrateWeight<T>(PhantomData<T>);52impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {53 // Storage: Nonfungible TokensMinted (r:1 w:1)54 // Storage: Nonfungible AccountBalance (r:1 w:1)55 // Storage: Nonfungible TokenData (r:0 w:1)56 // Storage: Nonfungible Owned (r:0 w:1)57 fn create_item() -> Weight {58 (18_450_000 as Weight)59 .saturating_add(T::DbWeight::get().reads(2 as Weight))60 .saturating_add(T::DbWeight::get().writes(4 as Weight))61 }62 // Storage: Nonfungible TokensMinted (r:1 w:1)63 // Storage: Nonfungible AccountBalance (r:1 w:1)64 // Storage: Nonfungible TokenData (r:0 w:4)65 // Storage: Nonfungible Owned (r:0 w:4)66 fn create_multiple_items(b: u32, ) -> Weight {67 (10_228_000 as Weight)68 // Standard Error: 1_00069 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))70 .saturating_add(T::DbWeight::get().reads(2 as Weight))71 .saturating_add(T::DbWeight::get().writes(2 as Weight))72 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))73 }74 // Storage: Nonfungible TokensMinted (r:1 w:1)75 // Storage: Nonfungible AccountBalance (r:4 w:4)76 // Storage: Nonfungible TokenData (r:0 w:4)77 // Storage: Nonfungible Owned (r:0 w:4)78 fn create_multiple_items_ex(b: u32, ) -> Weight {79 (6_543_000 as Weight)80 // Standard Error: 2_00081 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))82 .saturating_add(T::DbWeight::get().reads(1 as Weight))83 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))84 .saturating_add(T::DbWeight::get().writes(1 as Weight))85 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))86 }87 // Storage: Nonfungible TokenData (r:1 w:1)88 // Storage: Nonfungible TokensBurnt (r:1 w:1)89 // Storage: Nonfungible AccountBalance (r:1 w:1)90 // Storage: Nonfungible Allowance (r:1 w:0)91 // Storage: Nonfungible Owned (r:0 w:1)92 fn burn_item() -> Weight {93 (24_554_000 as Weight)94 .saturating_add(T::DbWeight::get().reads(4 as Weight))95 .saturating_add(T::DbWeight::get().writes(4 as Weight))96 }97 // Storage: Nonfungible TokenChildren (r:1 w:0)98 // Storage: Nonfungible TokenData (r:1 w:1)99 // Storage: Nonfungible TokensBurnt (r:1 w:1)100 // Storage: Nonfungible AccountBalance (r:1 w:1)101 // Storage: Nonfungible Allowance (r:1 w:0)102 // Storage: Nonfungible Owned (r:0 w:1)103 // Storage: Nonfungible TokenProperties (r:0 w:1)104 fn burn_recursively_self_raw() -> Weight {105 (86_136_000 as Weight)106 .saturating_add(T::DbWeight::get().reads(5 as Weight))107 .saturating_add(T::DbWeight::get().writes(5 as Weight))108 }109 // Storage: Nonfungible TokenChildren (r:1 w:0)110 // Storage: Nonfungible TokenData (r:1 w:1)111 // Storage: Nonfungible TokensBurnt (r:1 w:1)112 // Storage: Nonfungible AccountBalance (r:1 w:1)113 // Storage: Nonfungible Allowance (r:1 w:0)114 // Storage: Nonfungible Owned (r:0 w:1)115 // Storage: Nonfungible TokenProperties (r:0 w:1)116 // Storage: Common CollectionById (r:1 w:0)117 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {118 (0 as Weight)119 // Standard Error: 42_828_000120 .saturating_add((381_478_000 as Weight).saturating_mul(b as Weight))121 .saturating_add(T::DbWeight::get().reads(6 as Weight))122 .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))123 .saturating_add(T::DbWeight::get().writes(5 as Weight))124 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))125 }126 // Storage: Nonfungible TokenData (r:1 w:1)127 // Storage: Nonfungible AccountBalance (r:2 w:2)128 // Storage: Nonfungible Allowance (r:1 w:0)129 // Storage: Nonfungible Owned (r:0 w:2)130 fn transfer() -> Weight {131 (28_339_000 as Weight)132 .saturating_add(T::DbWeight::get().reads(4 as Weight))133 .saturating_add(T::DbWeight::get().writes(5 as Weight))134 }135 // Storage: Nonfungible TokenData (r:1 w:0)136 // Storage: Nonfungible Allowance (r:1 w:1)137 fn approve() -> Weight {138 (17_616_000 as Weight)139 .saturating_add(T::DbWeight::get().reads(2 as Weight))140 .saturating_add(T::DbWeight::get().writes(1 as Weight))141 }142 // Storage: Nonfungible Allowance (r:1 w:1)143 // Storage: Nonfungible TokenData (r:1 w:1)144 // Storage: Nonfungible AccountBalance (r:2 w:2)145 // Storage: Nonfungible Owned (r:0 w:2)146 fn transfer_from() -> Weight {147 (32_196_000 as Weight)148 .saturating_add(T::DbWeight::get().reads(4 as Weight))149 .saturating_add(T::DbWeight::get().writes(6 as Weight))150 }151 // Storage: Nonfungible Allowance (r:1 w:1)152 // Storage: Nonfungible TokenData (r:1 w:1)153 // Storage: Nonfungible TokensBurnt (r:1 w:1)154 // Storage: Nonfungible AccountBalance (r:1 w:1)155 // Storage: Nonfungible Owned (r:0 w:1)156 fn burn_from() -> Weight {157 (27_580_000 as Weight)158 .saturating_add(T::DbWeight::get().reads(4 as Weight))159 .saturating_add(T::DbWeight::get().writes(5 as Weight))160 }161 // Storage: Common CollectionPropertyPermissions (r:1 w:1)162 fn set_property_permissions(b: u32, ) -> Weight {163 (0 as Weight)164 // Standard Error: 3_432_000165 .saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))166 .saturating_add(T::DbWeight::get().reads(1 as Weight))167 .saturating_add(T::DbWeight::get().writes(1 as Weight))168 }169 // Storage: Common CollectionPropertyPermissions (r:1 w:0)170 // Storage: Nonfungible TokenData (r:1 w:0)171 // Storage: Nonfungible TokenProperties (r:1 w:1)172 fn set_token_properties(b: u32, ) -> Weight {173 (0 as Weight)174 // Standard Error: 158_583_000175 .saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))176 .saturating_add(T::DbWeight::get().reads(3 as Weight))177 .saturating_add(T::DbWeight::get().writes(1 as Weight))178 }179 // Storage: Common CollectionPropertyPermissions (r:1 w:0)180 // Storage: Nonfungible TokenData (r:1 w:0)181 // Storage: Nonfungible TokenProperties (r:1 w:1)182 fn delete_token_properties(b: u32, ) -> Weight {183 (0 as Weight)184 // Standard Error: 169_018_000185 .saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))186 .saturating_add(T::DbWeight::get().reads(3 as Weight))187 .saturating_add(T::DbWeight::get().writes(1 as Weight))188 }189}190191// For backwards compatibility and tests192impl WeightInfo for () {193 // Storage: Nonfungible TokensMinted (r:1 w:1)194 // Storage: Nonfungible AccountBalance (r:1 w:1)195 // Storage: Nonfungible TokenData (r:0 w:1)196 // Storage: Nonfungible Owned (r:0 w:1)197 fn create_item() -> Weight {198 (18_450_000 as Weight)199 .saturating_add(RocksDbWeight::get().reads(2 as Weight))200 .saturating_add(RocksDbWeight::get().writes(4 as Weight))201 }202 // Storage: Nonfungible TokensMinted (r:1 w:1)203 // Storage: Nonfungible AccountBalance (r:1 w:1)204 // Storage: Nonfungible TokenData (r:0 w:4)205 // Storage: Nonfungible Owned (r:0 w:4)206 fn create_multiple_items(b: u32, ) -> Weight {207 (10_228_000 as Weight)208 // Standard Error: 1_000209 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))210 .saturating_add(RocksDbWeight::get().reads(2 as Weight))211 .saturating_add(RocksDbWeight::get().writes(2 as Weight))212 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))213 }214 // Storage: Nonfungible TokensMinted (r:1 w:1)215 // Storage: Nonfungible AccountBalance (r:4 w:4)216 // Storage: Nonfungible TokenData (r:0 w:4)217 // Storage: Nonfungible Owned (r:0 w:4)218 fn create_multiple_items_ex(b: u32, ) -> Weight {219 (6_543_000 as Weight)220 // Standard Error: 2_000221 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))222 .saturating_add(RocksDbWeight::get().reads(1 as Weight))223 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))224 .saturating_add(RocksDbWeight::get().writes(1 as Weight))225 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))226 }227 // Storage: Nonfungible TokenData (r:1 w:1)228 // Storage: Nonfungible TokensBurnt (r:1 w:1)229 // Storage: Nonfungible AccountBalance (r:1 w:1)230 // Storage: Nonfungible Allowance (r:1 w:0)231 // Storage: Nonfungible Owned (r:0 w:1)232 fn burn_item() -> Weight {233 (24_554_000 as Weight)234 .saturating_add(RocksDbWeight::get().reads(4 as Weight))235 .saturating_add(RocksDbWeight::get().writes(4 as Weight))236 }237 // Storage: Nonfungible TokenChildren (r:1 w:0)238 // Storage: Nonfungible TokenData (r:1 w:1)239 // Storage: Nonfungible TokensBurnt (r:1 w:1)240 // Storage: Nonfungible AccountBalance (r:1 w:1)241 // Storage: Nonfungible Allowance (r:1 w:0)242 // Storage: Nonfungible Owned (r:0 w:1)243 // Storage: Nonfungible TokenProperties (r:0 w:1)244 fn burn_recursively_self_raw() -> Weight {245 (86_136_000 as Weight)246 .saturating_add(RocksDbWeight::get().reads(5 as Weight))247 .saturating_add(RocksDbWeight::get().writes(5 as Weight))248 }249 // Storage: Nonfungible TokenChildren (r:1 w:0)250 // Storage: Nonfungible TokenData (r:1 w:1)251 // Storage: Nonfungible TokensBurnt (r:1 w:1)252 // Storage: Nonfungible AccountBalance (r:1 w:1)253 // Storage: Nonfungible Allowance (r:1 w:0)254 // Storage: Nonfungible Owned (r:0 w:1)255 // Storage: Nonfungible TokenProperties (r:0 w:1)256 // Storage: Common CollectionById (r:1 w:0)257 fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {258 (0 as Weight)259 // Standard Error: 42_828_000260 .saturating_add((381_478_000 as Weight).saturating_mul(b as Weight))261 .saturating_add(RocksDbWeight::get().reads(6 as Weight))262 .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))263 .saturating_add(RocksDbWeight::get().writes(5 as Weight))264 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))265 }266 // Storage: Nonfungible TokenData (r:1 w:1)267 // Storage: Nonfungible AccountBalance (r:2 w:2)268 // Storage: Nonfungible Allowance (r:1 w:0)269 // Storage: Nonfungible Owned (r:0 w:2)270 fn transfer() -> Weight {271 (28_339_000 as Weight)272 .saturating_add(RocksDbWeight::get().reads(4 as Weight))273 .saturating_add(RocksDbWeight::get().writes(5 as Weight))274 }275 // Storage: Nonfungible TokenData (r:1 w:0)276 // Storage: Nonfungible Allowance (r:1 w:1)277 fn approve() -> Weight {278 (17_616_000 as Weight)279 .saturating_add(RocksDbWeight::get().reads(2 as Weight))280 .saturating_add(RocksDbWeight::get().writes(1 as Weight))281 }282 // Storage: Nonfungible Allowance (r:1 w:1)283 // Storage: Nonfungible TokenData (r:1 w:1)284 // Storage: Nonfungible AccountBalance (r:2 w:2)285 // Storage: Nonfungible Owned (r:0 w:2)286 fn transfer_from() -> Weight {287 (32_196_000 as Weight)288 .saturating_add(RocksDbWeight::get().reads(4 as Weight))289 .saturating_add(RocksDbWeight::get().writes(6 as Weight))290 }291 // Storage: Nonfungible Allowance (r:1 w:1)292 // Storage: Nonfungible TokenData (r:1 w:1)293 // Storage: Nonfungible TokensBurnt (r:1 w:1)294 // Storage: Nonfungible AccountBalance (r:1 w:1)295 // Storage: Nonfungible Owned (r:0 w:1)296 fn burn_from() -> Weight {297 (27_580_000 as Weight)298 .saturating_add(RocksDbWeight::get().reads(4 as Weight))299 .saturating_add(RocksDbWeight::get().writes(5 as Weight))300 }301 // Storage: Common CollectionPropertyPermissions (r:1 w:1)302 fn set_property_permissions(b: u32, ) -> Weight {303 (0 as Weight)304 // Standard Error: 3_432_000305 .saturating_add((126_888_000 as Weight).saturating_mul(b as Weight))306 .saturating_add(RocksDbWeight::get().reads(1 as Weight))307 .saturating_add(RocksDbWeight::get().writes(1 as Weight))308 }309 // Storage: Common CollectionPropertyPermissions (r:1 w:0)310 // Storage: Nonfungible TokenData (r:1 w:0)311 // Storage: Nonfungible TokenProperties (r:1 w:1)312 fn set_token_properties(b: u32, ) -> Weight {313 (0 as Weight)314 // Standard Error: 158_583_000315 .saturating_add((4_707_700_000 as Weight).saturating_mul(b as Weight))316 .saturating_add(RocksDbWeight::get().reads(3 as Weight))317 .saturating_add(RocksDbWeight::get().writes(1 as Weight))318 }319 // Storage: Common CollectionPropertyPermissions (r:1 w:0)320 // Storage: Nonfungible TokenData (r:1 w:0)321 // Storage: Nonfungible TokenProperties (r:1 w:1)322 fn delete_token_properties(b: u32, ) -> Weight {323 (0 as Weight)324 // Standard Error: 169_018_000325 .saturating_add((4_783_967_000 as Weight).saturating_mul(b as Weight))326 .saturating_add(RocksDbWeight::get().reads(3 as Weight))327 .saturating_add(RocksDbWeight::get().writes(1 as Weight))328 }329}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.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -17,12 +17,13 @@
use core::marker::PhantomData;
use sp_std::collections::btree_map::BTreeMap;
-use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
+use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};
use up_data_structs::{
CollectionId, TokenId, CreateItemExData, CreateRefungibleExData, budget::Budget, Property,
PropertyKey, PropertyValue, PropertyKeyPermission, CreateItemData,
};
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
+use pallet_structure::Error as StructureError;
use sp_runtime::DispatchError;
use sp_std::{vec::Vec, vec};
@@ -113,6 +114,15 @@
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 {
+ // Refungible token can't have children
+ 0
+ }
}
fn map_create_data<T: Config>(
@@ -205,6 +215,25 @@
)
}
+ fn burn_item_recursively(
+ &self,
+ sender: T::CrossAccountId,
+ token: TokenId,
+ self_budget: &dyn Budget,
+ _breadth_budget: &dyn Budget,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
+ with_weight(
+ <Pallet<T>>::burn(
+ self,
+ &sender,
+ token,
+ <Balance<T>>::get((self.id, token, &sender)),
+ ),
+ <CommonWeights<T>>::burn_recursively_self_raw(),
+ )
+ }
+
fn transfer(
&self,
from: T::CrossAccountId,
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;