--- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -32,8 +32,10 @@ 'frame-support/runtime-benchmarks', 'frame-system/runtime-benchmarks', ] -unique-runtime = ['std'] -quartz-runtime = ['std'] +unique-runtime = [] +quartz-runtime = [] + +refungible = [] [dependencies.sp-core] default-features = false --- a/runtime/common/src/weights.rs +++ b/runtime/common/src/weights.rs @@ -25,33 +25,36 @@ }; use up_data_structs::{CreateItemExData, CreateItemData}; -#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))] macro_rules! max_weight_of { - ($method:ident ( $($args:tt)* )) => { - >::$method($($args)*) - .max(>::$method($($args)*)) - .max(>::$method($($args)*)) - }; + ($method:ident ( $($args:tt)* )) => {{ + let max_weight = >::$method($($args)*) + .max(>::$method($($args)*)); + + #[cfg(feature = "refungible")] + let max_weight = max_weight.max(>::$method($($args)*)); + + max_weight + }}; } -#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))] -macro_rules! max_weight_of { - ($method:ident ( $($args:tt)* )) => { - >::$method($($args)*) - .max(>::$method($($args)*)) +#[cfg(not(feature = "refungible"))] +pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig {} + +#[cfg(not(feature = "refungible"))] +impl CommonWeightConfigs for T {} + +#[cfg(feature = "refungible")] +pub trait CommonWeightConfigs: FungibleConfig + NonfungibleConfig + RefungibleConfig {} + +#[cfg(feature = "refungible")] +impl CommonWeightConfigs for T {} - }; -} -#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))] -pub struct CommonWeights(PhantomData) -where - T: FungibleConfig + NonfungibleConfig + RefungibleConfig; +pub struct CommonWeights(PhantomData); -#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))] impl CommonWeightInfo for CommonWeights where - T: FungibleConfig + NonfungibleConfig + RefungibleConfig, + T: CommonWeightConfigs, { fn create_item() -> Weight { dispatch_weight::() + max_weight_of!(create_item()) @@ -114,7 +117,7 @@ } } -#[cfg(not(any(feature = "unique-runtime", feature = "quartz-runtime")))] +#[cfg(feature = "refungible")] impl RefungibleExtensionsWeightInfo for CommonWeights where T: FungibleConfig + NonfungibleConfig + RefungibleConfig, @@ -124,78 +127,7 @@ } } -#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))] -pub struct CommonWeights(PhantomData) -where - T: FungibleConfig + NonfungibleConfig; - -#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))] -impl CommonWeightInfo for CommonWeights -where - T: FungibleConfig + NonfungibleConfig, -{ - fn create_item() -> Weight { - dispatch_weight::() + max_weight_of!(create_item()) - } - - fn create_multiple_items(data: &[CreateItemData]) -> Weight { - dispatch_weight::() + max_weight_of!(create_multiple_items(data)) - } - - fn create_multiple_items_ex(data: &CreateItemExData) -> Weight { - dispatch_weight::() + max_weight_of!(create_multiple_items_ex(data)) - } - - fn burn_item() -> Weight { - dispatch_weight::() + max_weight_of!(burn_item()) - } - - fn set_collection_properties(amount: u32) -> Weight { - dispatch_weight::() + max_weight_of!(set_collection_properties(amount)) - } - - fn delete_collection_properties(amount: u32) -> Weight { - dispatch_weight::() + max_weight_of!(delete_collection_properties(amount)) - } - - fn set_token_properties(amount: u32) -> Weight { - dispatch_weight::() + max_weight_of!(set_token_properties(amount)) - } - - fn delete_token_properties(amount: u32) -> Weight { - dispatch_weight::() + max_weight_of!(delete_token_properties(amount)) - } - - fn set_token_property_permissions(amount: u32) -> Weight { - dispatch_weight::() + max_weight_of!(set_token_property_permissions(amount)) - } - - fn transfer() -> Weight { - dispatch_weight::() + max_weight_of!(transfer()) - } - - fn approve() -> Weight { - dispatch_weight::() + max_weight_of!(approve()) - } - - fn transfer_from() -> Weight { - dispatch_weight::() + max_weight_of!(transfer_from()) - } - - fn burn_from() -> Weight { - dispatch_weight::() + 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)) - } -} - -#[cfg(any(feature = "unique-runtime", feature = "quartz-runtime"))] +#[cfg(not(feature = "refungible"))] impl RefungibleExtensionsWeightInfo for CommonWeights where T: FungibleConfig + NonfungibleConfig, --- a/runtime/opal/Cargo.toml +++ b/runtime/opal/Cargo.toml @@ -16,7 +16,7 @@ targets = ['x86_64-unknown-linux-gnu'] [features] -default = ['std'] +default = ['std', 'new-functionality'] runtime-benchmarks = [ 'hex-literal', 'frame-benchmarking', @@ -119,6 +119,9 @@ "orml-vesting/std", ] limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing'] +new-functionality = [ + 'unique-runtime-common/refungible', +] ################################################################################ # Substrate Dependencies --- a/runtime/quartz/Cargo.toml +++ b/runtime/quartz/Cargo.toml @@ -16,7 +16,7 @@ targets = ['x86_64-unknown-linux-gnu'] [features] -default = ['std'] +default = ['std', 'new-functionality'] runtime-benchmarks = [ 'hex-literal', 'frame-benchmarking', @@ -118,6 +118,7 @@ "orml-vesting/std", ] limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing'] +new-functionality = [] ################################################################################ # Substrate Dependencies --- a/runtime/unique/Cargo.toml +++ b/runtime/unique/Cargo.toml @@ -16,7 +16,7 @@ targets = ['x86_64-unknown-linux-gnu'] [features] -default = ['std', 'unique-runtime'] +default = ['std', 'new-functionality'] runtime-benchmarks = [ 'hex-literal', 'frame-benchmarking', @@ -119,7 +119,7 @@ "orml-vesting/std", ] limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing'] -unique-runtime = [] +new-functionality = [] ################################################################################ # Substrate Dependencies