--- a/runtime/common/src/construct_runtime/mod.rs +++ b/runtime/common/src/construct_runtime/mod.rs @@ -2,8 +2,10 @@ #[macro_export] macro_rules! construct_runtime { - () => { + ($select_runtime:ident) => { $crate::construct_runtime_impl! { + select_runtime($select_runtime); + pub enum Runtime where Block = Block, NodeBlock = opaque::Block, --- a/runtime/common/src/construct_runtime/util.rs +++ b/runtime/common/src/construct_runtime/util.rs @@ -1,7 +1,9 @@ #[macro_export] macro_rules! construct_runtime_impl { ( - pub enum $runtime:ident where + select_runtime($select_runtime:ident); + + pub enum Runtime where $($where_ident:ident = $where_ty:ty),* $(,)? { $( @@ -12,18 +14,16 @@ } ) => { $crate::construct_runtime_helper! { - runtime($runtime), + select_runtime($select_runtime), + selected_pallets(), + where_clause($($where_ident = $where_ty),*), pallets( $( $(#[runtimes($($pallet_runtimes),+)])? $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index ),*, - ), - - opal_pallets(), - quartz_pallets(), - unique_pallets(), + ) } } } @@ -31,103 +31,65 @@ #[macro_export] macro_rules! construct_runtime_helper { ( - runtime($runtime:ident), + select_runtime($select_runtime:ident), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( #[runtimes($($pallet_runtimes:ident),+)] $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal, $($pallets_tl:tt)* - ), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + ) ) => { $crate::add_runtime_specific_pallets! { - runtime($runtime), + select_runtime($select_runtime), + runtimes($($pallet_runtimes),+,), + selected_pallets($($selected_pallets)*), + where_clause($($where_clause)*), pallets( $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, $($pallets_tl)* - ), - - runtimes($($pallet_runtimes),+,), - - opal_pallets($($opal_pallets)*), - quartz_pallets($($quartz_pallets)*), - unique_pallets($($unique_pallets)*), + ) } }; ( - runtime($runtime:ident), + select_runtime($select_runtime:ident), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal, $($pallets_tl:tt)* - ), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + ) ) => { $crate::construct_runtime_helper! { - runtime($runtime), - where_clause($($where_clause)*), - pallets($($pallets_tl)*), - - opal_pallets( - $($opal_pallets)* + select_runtime($select_runtime), + selected_pallets( + $($selected_pallets)* $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, ), - quartz_pallets( - $($quartz_pallets)* - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - ), - - unique_pallets( - $($unique_pallets)* - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - ), + where_clause($($where_clause)*), + pallets($($pallets_tl)*) } }; ( - runtime($runtime:ident), + select_runtime($select_runtime:ident), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), - pallets(), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + pallets() ) => { - #[cfg(feature = "opal-runtime")] frame_support::construct_runtime! { - pub enum $runtime where - $($where_clause)* - { - $($opal_pallets)* - } - } - - #[cfg(feature = "quartz-runtime")] - frame_support::construct_runtime! { - pub enum $runtime where - $($where_clause)* - { - $($quartz_pallets)* - } - } - - #[cfg(feature = "unique-runtime")] - frame_support::construct_runtime! { - pub enum $runtime where + pub enum Runtime where $($where_clause)* { - $($unique_pallets)* + $($selected_pallets)* } } }; @@ -136,138 +98,109 @@ #[macro_export] macro_rules! add_runtime_specific_pallets { ( - runtime($runtime:ident), + select_runtime(opal), + runtimes(opal, $($_runtime_tl:tt)*), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal, $($pallets_tl:tt)* - ), - - runtimes( - opal, - - $($runtime_tl:tt)* - ), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + ) ) => { - $crate::add_runtime_specific_pallets! { - runtime($runtime), - where_clause($($where_clause)*), - pallets( + $crate::construct_runtime_helper! { + select_runtime(opal), + selected_pallets( + $($selected_pallets)* $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - $($pallets_tl)* ), - runtimes($($runtime_tl)*), - - opal_pallets( - $($opal_pallets)* - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - ), - quartz_pallets($($quartz_pallets)*), - unique_pallets($($unique_pallets)*), + where_clause($($where_clause)*), + pallets($($pallets_tl)*) } }; ( - runtime($runtime:ident), + select_runtime(quartz), + runtimes(quartz, $($_runtime_tl:tt)*), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal, $($pallets_tl:tt)* - ), - - runtimes( - quartz, - - $($runtime_tl:tt)* - ), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + ) ) => { - $crate::add_runtime_specific_pallets! { - runtime($runtime), - where_clause($($where_clause)*), - pallets( + $crate::construct_runtime_helper! { + select_runtime(quartz), + selected_pallets( + $($selected_pallets)* $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - $($pallets_tl)* ), - - runtimes($($runtime_tl)*), - opal_pallets($($opal_pallets)*), - quartz_pallets( - $($quartz_pallets)* - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - ), - unique_pallets($($unique_pallets)*), + where_clause($($where_clause)*), + pallets($($pallets_tl)*) } }; ( - runtime($runtime:ident), + select_runtime(unique), + runtimes(unique, $($_runtime_tl:tt)*), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal, $($pallets_tl:tt)* - ), + ) + ) => { + $crate::construct_runtime_helper! { + select_runtime(unique), + selected_pallets( + $($selected_pallets)* + $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, + ), - runtimes( - unique, + where_clause($($where_clause)*), + pallets($($pallets_tl)*) + } + }; - $($runtime_tl:tt)* - ), + ( + select_runtime($select_runtime:ident), + runtimes($_current_runtime:ident, $($runtime_tl:tt)*), + selected_pallets($($selected_pallets:tt)*), - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + where_clause($($where_clause:tt)*), + pallets($($pallets:tt)*) ) => { $crate::add_runtime_specific_pallets! { - runtime($runtime), - where_clause($($where_clause)*), - pallets( - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - $($pallets_tl)* - ), - + select_runtime($select_runtime), runtimes($($runtime_tl)*), + selected_pallets($($selected_pallets)*), - opal_pallets($($opal_pallets)*), - quartz_pallets($($quartz_pallets)*), - unique_pallets( - $($unique_pallets)* - $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index, - ), + where_clause($($where_clause)*), + pallets($($pallets)*) } }; ( - runtime($runtime:ident), + select_runtime($select_runtime:ident), + runtimes(), + selected_pallets($($selected_pallets:tt)*), + where_clause($($where_clause:tt)*), pallets( $_pallet_name:ident: $_pallet_mod:ident::{$($_pallet_parts:ty),*} = $_index:literal, $($pallets_tl:tt)* - ), - - runtimes(), - - opal_pallets($($opal_pallets:tt)*), - quartz_pallets($($quartz_pallets:tt)*), - unique_pallets($($unique_pallets:tt)*), + ) ) => { $crate::construct_runtime_helper! { - runtime($runtime), - where_clause($($where_clause)*), - pallets($($pallets_tl)*), + select_runtime($select_runtime), + selected_pallets($($selected_pallets)*), - opal_pallets($($opal_pallets)*), - quartz_pallets($($quartz_pallets)*), - unique_pallets($($unique_pallets)*), + where_clause($($where_clause)*), + pallets($($pallets_tl)*) } }; } --- a/runtime/opal/src/lib.rs +++ b/runtime/opal/src/lib.rs @@ -1126,7 +1126,7 @@ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit; } -construct_runtime!(); +construct_runtime!(opal); pub struct TransactionConverter; --- a/runtime/quartz/src/lib.rs +++ b/runtime/quartz/src/lib.rs @@ -33,7 +33,7 @@ #[cfg(feature = "scheduler")] use sp_runtime::{ - traits::Member, + traits::{Applyable, Member}, generic::Era, DispatchErrorWithPostInfo }; @@ -1137,7 +1137,7 @@ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit; } -construct_runtime!(); +construct_runtime!(quartz); pub struct TransactionConverter; --- a/runtime/unique/src/lib.rs +++ b/runtime/unique/src/lib.rs @@ -34,7 +34,7 @@ #[cfg(feature = "scheduler")] use sp_runtime::{ - traits::Member, + traits::{Applyable, Member}, generic::Era, DispatchErrorWithPostInfo }; @@ -1139,7 +1139,7 @@ type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit; } -construct_runtime!(); +construct_runtime!(unique); pub struct TransactionConverter;