1234567891011121314151617use 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};2728macro_rules! max_weight_of {29 ($method:ident ( $($args:tt)* )) => {30 <FungibleWeights<T>>::$method($($args)*)31 .max(<NonfungibleWeights<T>>::$method($($args)*))32 .max(<RefungibleWeights<T>>::$method($($args)*))33 };34}3536pub struct CommonWeights<T>(PhantomData<T>)37where38 T: FungibleConfig + NonfungibleConfig + RefungibleConfig;39impl<T> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T>40where41 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,42{43 fn create_item() -> Weight {44 dispatch_weight::<T>() + max_weight_of!(create_item())45 }4647 fn create_multiple_items(data: &[CreateItemData]) -> Weight {48 dispatch_weight::<T>() + max_weight_of!(create_multiple_items(data))49 }5051 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {52 dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))53 }5455 fn burn_item() -> Weight {56 dispatch_weight::<T>() + max_weight_of!(burn_item())57 }5859 fn set_collection_properties(amount: u32) -> Weight {60 dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))61 }6263 fn delete_collection_properties(amount: u32) -> Weight {64 dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))65 }6667 fn set_token_properties(amount: u32) -> Weight {68 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))69 }7071 fn delete_token_properties(amount: u32) -> Weight {72 dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))73 }7475 fn set_token_property_permissions(amount: u32) -> Weight {76 dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))77 }7879 fn transfer() -> Weight {80 dispatch_weight::<T>() + max_weight_of!(transfer())81 }8283 fn approve() -> Weight {84 dispatch_weight::<T>() + max_weight_of!(approve())85 }8687 fn transfer_from() -> Weight {88 dispatch_weight::<T>() + max_weight_of!(transfer_from())89 }9091 fn burn_from() -> Weight {92 dispatch_weight::<T>() + max_weight_of!(burn_from())93 }9495 fn burn_recursively_self_raw() -> Weight {96 max_weight_of!(burn_recursively_self_raw())97 }9899 fn burn_recursively_breadth_raw(amount: u32) -> Weight {100 max_weight_of!(burn_recursively_breadth_raw(amount))101 }102}103104impl<T> RefungibleExtensionsWeightInfo for CommonWeights<T>105where106 T: FungibleConfig + NonfungibleConfig + RefungibleConfig,107{108 fn repartition() -> Weight {109 dispatch_weight::<T>() + <<T as RefungibleConfig>::WeightInfo>::repartition_item()110 }111}