git.delta.rocks / unique-network / refs/commits / c01b00c42ad2

difftreelog

source

runtime/common/src/weights.rs2.6 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};2021use pallet_fungible::{Config as FungibleConfig, common::CommonWeights as FungibleWeights};22use pallet_nonfungible::{Config as NonfungibleConfig, common::CommonWeights as NonfungibleWeights};23use pallet_refungible::{Config as RefungibleConfig, common::CommonWeights as RefungibleWeights};24use up_data_structs::CreateItemExData;2526macro_rules! max_weight_of {27	($method:ident ( $($args:tt)* )) => {28		<FungibleWeights<T>>::$method($($args)*)29		.max(<NonfungibleWeights<T>>::$method($($args)*))30		.max(<RefungibleWeights<T>>::$method($($args)*))31	};32}3334pub struct CommonWeights<T>(PhantomData<T>)35where36	T: FungibleConfig + NonfungibleConfig + RefungibleConfig;37impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>38where39	T: FungibleConfig + NonfungibleConfig + RefungibleConfig,40{41	fn create_item() -> Weight {42		dispatch_weight::<T>() + max_weight_of!(create_item())43	}4445	fn create_multiple_items(amount: u32) -> Weight {46		dispatch_weight::<T>() + max_weight_of!(create_multiple_items(amount))47	}4849	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {50		dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))51	}5253	fn burn_item() -> Weight {54		dispatch_weight::<T>() + max_weight_of!(burn_item())55	}5657	fn transfer() -> Weight {58		dispatch_weight::<T>() + max_weight_of!(transfer())59	}6061	fn approve() -> Weight {62		dispatch_weight::<T>() + max_weight_of!(approve())63	}6465	fn transfer_from() -> Weight {66		dispatch_weight::<T>() + max_weight_of!(transfer_from())67	}6869	fn set_variable_metadata(bytes: u32) -> Weight {70		dispatch_weight::<T>() + max_weight_of!(set_variable_metadata(bytes))71	}7273	fn burn_from() -> Weight {74		dispatch_weight::<T>() + max_weight_of!(burn_from())75	}76}