git.delta.rocks / unique-network / refs/commits / 7a2dbeac9ec6

difftreelog

source

runtime/common/src/weights.rs6.4 KiBsourcehistory
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;18use frame_support::{weights::Weight};19use pallet_common::{CommonWeightInfo, dispatch::dispatch_weight, RefungibleExtensionsWeightInfo};2021use pallet_fungible::{Config as FungibleConfig, common::CommonWeights as FungibleWeights};22use pallet_nonfungible::{Config as NonfungibleConfig, common::CommonWeights as NonfungibleWeights};23use pallet_refungible::{24	Config as RefungibleConfig, weights::WeightInfo, common::CommonWeights as RefungibleWeights,25};26use up_data_structs::{CreateItemExData, CreateItemData};2728#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]29macro_rules! max_weight_of {30	($method:ident ( $($args:tt)* )) => {31		<FungibleWeights<T>>::$method($($args)*)32		.max(<NonfungibleWeights<T>>::$method($($args)*))33		.max(<RefungibleWeights<T>>::$method($($args)*))34	};35}3637#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]38macro_rules! max_weight_of {39	($method:ident ( $($args:tt)* )) => {40		<FungibleWeights<T>>::$method($($args)*)41		.max(<NonfungibleWeights<T>>::$method($($args)*))4243	};44}4546#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]47pub struct CommonWeights<T>(PhantomData<T>)48where49	T: FungibleConfig + NonfungibleConfig + RefungibleConfig;5051#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]52impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>53where54	T: FungibleConfig + NonfungibleConfig + RefungibleConfig,55{56	fn create_item() -> Weight {57		dispatch_weight::<T>() + max_weight_of!(create_item())58	}5960	fn create_multiple_items(data: &[CreateItemData]) -> Weight {61		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))62	}6364	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {65		dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))66	}6768	fn burn_item() -> Weight {69		dispatch_weight::<T>() + max_weight_of!(burn_item())70	}7172	fn set_collection_properties(amount: u32) -> Weight {73		dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))74	}7576	fn delete_collection_properties(amount: u32) -> Weight {77		dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))78	}7980	fn set_token_properties(amount: u32) -> Weight {81		dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))82	}8384	fn delete_token_properties(amount: u32) -> Weight {85		dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))86	}8788	fn set_token_property_permissions(amount: u32) -> Weight {89		dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))90	}9192	fn transfer() -> Weight {93		dispatch_weight::<T>() + max_weight_of!(transfer())94	}9596	fn approve() -> Weight {97		dispatch_weight::<T>() + max_weight_of!(approve())98	}99100	fn transfer_from() -> Weight {101		dispatch_weight::<T>() + max_weight_of!(transfer_from())102	}103104	fn burn_from() -> Weight {105		dispatch_weight::<T>() + max_weight_of!(burn_from())106	}107108	fn burn_recursively_self_raw() -> Weight {109		max_weight_of!(burn_recursively_self_raw())110	}111112	fn burn_recursively_breadth_raw(amount: u32) -> Weight {113		max_weight_of!(burn_recursively_breadth_raw(amount))114	}115}116117#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))]118impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>119where120	T: FungibleConfig + NonfungibleConfig + RefungibleConfig,121{122	fn repartition() -> Weight {123		dispatch_weight::<T>() + <<T as RefungibleConfig>::WeightInfo>::repartition_item()124	}125}126127#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]128pub struct CommonWeights<T>(PhantomData<T>)129where130	T: FungibleConfig + NonfungibleConfig;131132#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]133impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>134where135	T: FungibleConfig + NonfungibleConfig,136{137	fn create_item() -> Weight {138		dispatch_weight::<T>() + max_weight_of!(create_item())139	}140141	fn create_multiple_items(data: &[CreateItemData]) -> Weight {142		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))143	}144145	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {146		dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))147	}148149	fn burn_item() -> Weight {150		dispatch_weight::<T>() + max_weight_of!(burn_item())151	}152153	fn set_collection_properties(amount: u32) -> Weight {154		dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))155	}156157	fn delete_collection_properties(amount: u32) -> Weight {158		dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))159	}160161	fn set_token_properties(amount: u32) -> Weight {162		dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))163	}164165	fn delete_token_properties(amount: u32) -> Weight {166		dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))167	}168169	fn set_token_property_permissions(amount: u32) -> Weight {170		dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))171	}172173	fn transfer() -> Weight {174		dispatch_weight::<T>() + max_weight_of!(transfer())175	}176177	fn approve() -> Weight {178		dispatch_weight::<T>() + max_weight_of!(approve())179	}180181	fn transfer_from() -> Weight {182		dispatch_weight::<T>() + max_weight_of!(transfer_from())183	}184185	fn burn_from() -> Weight {186		dispatch_weight::<T>() + max_weight_of!(burn_from())187	}188189	fn burn_recursively_self_raw() -> Weight {190		max_weight_of!(burn_recursively_self_raw())191	}192193	fn burn_recursively_breadth_raw(amount: u32) -> Weight {194		max_weight_of!(burn_recursively_breadth_raw(amount))195	}196}197198#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))]199impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>200where201	T: FungibleConfig + NonfungibleConfig,202{203	fn repartition() -> Weight {204		dispatch_weight::<T>()205	}206}