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

difftreelog

source

runtime/common/src/construct_runtime/util.rs7.5 KiBsourcehistory
1#[macro_export]2macro_rules! construct_runtime_impl {3    (4        pub enum $runtime:ident where5            $($where_ident:ident = $where_ty:ty),* $(,)?6        {7            $(8                $(#[runtimes($($pallet_runtimes:ident),+ $(,)?)])?9                $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal10            ),*11            $(,)?12        }13    ) => {14        $crate::construct_runtime_helper! {15            runtime($runtime),16            where_clause($($where_ident = $where_ty),*),17            pallets(18                $(19                    $(#[runtimes($($pallet_runtimes),+)])?20                    $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index21                ),*,22            ),2324            opal_pallets(),25            quartz_pallets(),26            unique_pallets(),27        }28    }29}3031#[macro_export]32macro_rules! construct_runtime_helper {33    (34        runtime($runtime:ident),35        where_clause($($where_clause:tt)*),36        pallets(37            #[runtimes($($pallet_runtimes:ident),+)]38            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,3940            $($pallets_tl:tt)*41        ),4243        opal_pallets($($opal_pallets:tt)*),44        quartz_pallets($($quartz_pallets:tt)*),45        unique_pallets($($unique_pallets:tt)*),46    ) => {47        $crate::add_runtime_specific_pallets! {48            runtime($runtime),49            where_clause($($where_clause)*),50            pallets(51                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,52                $($pallets_tl)*53            ),5455            runtimes($($pallet_runtimes),+,),5657            opal_pallets($($opal_pallets)*),58            quartz_pallets($($quartz_pallets)*),59            unique_pallets($($unique_pallets)*),60        }61    };6263    (64        runtime($runtime:ident),65        where_clause($($where_clause:tt)*),66        pallets(67            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,6869            $($pallets_tl:tt)*70        ),7172        opal_pallets($($opal_pallets:tt)*),73        quartz_pallets($($quartz_pallets:tt)*),74        unique_pallets($($unique_pallets:tt)*),75    ) => {76        $crate::construct_runtime_helper! {77            runtime($runtime),78            where_clause($($where_clause)*),79            pallets($($pallets_tl)*),8081            opal_pallets(82                $($opal_pallets)*83                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,84            ),8586            quartz_pallets(87                $($quartz_pallets)*88                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,89            ),9091            unique_pallets(92                $($unique_pallets)*93                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,94            ),95        }96    };9798    (99        runtime($runtime:ident),100        where_clause($($where_clause:tt)*),101        pallets(),102103        opal_pallets($($opal_pallets:tt)*),104        quartz_pallets($($quartz_pallets:tt)*),105        unique_pallets($($unique_pallets:tt)*),106    ) => {107        #[cfg(feature = "opal-runtime")]108        frame_support::construct_runtime! {109            pub enum $runtime where110                $($where_clause)*111            {112                $($opal_pallets)*113            }114        }115116        #[cfg(feature = "quartz-runtime")]117        frame_support::construct_runtime! {118            pub enum $runtime where119                $($where_clause)*120            {121                $($quartz_pallets)*122            }123        }124125        #[cfg(feature = "unique-runtime")]126        frame_support::construct_runtime! {127            pub enum $runtime where128                $($where_clause)*129            {130                $($unique_pallets)*131            }132        }133    };134}135136#[macro_export]137macro_rules! add_runtime_specific_pallets {138    (139        runtime($runtime:ident),140        where_clause($($where_clause:tt)*),141        pallets(142            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,143            $($pallets_tl:tt)*144        ),145146        runtimes(147            opal,148149            $($runtime_tl:tt)*150        ),151152        opal_pallets($($opal_pallets:tt)*),153        quartz_pallets($($quartz_pallets:tt)*),154        unique_pallets($($unique_pallets:tt)*),155    ) => {156        $crate::add_runtime_specific_pallets! {157            runtime($runtime),158            where_clause($($where_clause)*),159            pallets(160                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,161                $($pallets_tl)*162            ),163164            runtimes($($runtime_tl)*),165166            opal_pallets(167                $($opal_pallets)*168                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,169            ),170            quartz_pallets($($quartz_pallets)*),171            unique_pallets($($unique_pallets)*),172        }173    };174175    (176        runtime($runtime:ident),177        where_clause($($where_clause:tt)*),178        pallets(179            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,180            $($pallets_tl:tt)*181        ),182183        runtimes(184            quartz,185186            $($runtime_tl:tt)*187        ),188189        opal_pallets($($opal_pallets:tt)*),190        quartz_pallets($($quartz_pallets:tt)*),191        unique_pallets($($unique_pallets:tt)*),192    ) => {193        $crate::add_runtime_specific_pallets! {194            runtime($runtime),195            where_clause($($where_clause)*),196            pallets(197                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,198                $($pallets_tl)*199            ),200201            runtimes($($runtime_tl)*),202203            opal_pallets($($opal_pallets)*),204            quartz_pallets(205                $($quartz_pallets)*206                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,207            ),208            unique_pallets($($unique_pallets)*),209        }210    };211212    (213        runtime($runtime:ident),214        where_clause($($where_clause:tt)*),215        pallets(216            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,217            $($pallets_tl:tt)*218        ),219220        runtimes(221            unique,222223            $($runtime_tl:tt)*224        ),225226        opal_pallets($($opal_pallets:tt)*),227        quartz_pallets($($quartz_pallets:tt)*),228        unique_pallets($($unique_pallets:tt)*),229    ) => {230        $crate::add_runtime_specific_pallets! {231            runtime($runtime),232            where_clause($($where_clause)*),233            pallets(234                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,235                $($pallets_tl)*236            ),237238            runtimes($($runtime_tl)*),239240            opal_pallets($($opal_pallets)*),241            quartz_pallets($($quartz_pallets)*),242            unique_pallets(243                $($unique_pallets)*244                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,245            ),246        }247    };248249    (250        runtime($runtime:ident),251        where_clause($($where_clause:tt)*),252        pallets(253            $_pallet_name:ident: $_pallet_mod:ident::{$($_pallet_parts:ty),*} = $_index:literal,254            $($pallets_tl:tt)*255        ),256257        runtimes(),258259        opal_pallets($($opal_pallets:tt)*),260        quartz_pallets($($quartz_pallets:tt)*),261        unique_pallets($($unique_pallets:tt)*),262    ) => {263        $crate::construct_runtime_helper! {264            runtime($runtime),265            where_clause($($where_clause)*),266            pallets($($pallets_tl)*),267268            opal_pallets($($opal_pallets)*),269            quartz_pallets($($quartz_pallets)*),270            unique_pallets($($unique_pallets)*),271        }272    };273}