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

difftreelog

feat common construct_runtime

Daniel Shiposha2022-08-02parent: #3f04e2d.patch.diff
in: master

2 files changed

addedruntime/common/src/construct_runtime/mod.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/src/construct_runtime/mod.rs
@@ -0,0 +1,72 @@
+mod util;
+
+#[macro_export]
+macro_rules! construct_runtime {
+    () => {
+        $crate::construct_runtime_impl! {
+            pub enum Runtime where
+                Block = Block,
+                NodeBlock = opaque::Block,
+                UncheckedExtrinsic = UncheckedExtrinsic
+            {
+                ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,
+                ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
+
+                Aura: pallet_aura::{Pallet, Config<T>} = 22,
+                AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,
+
+                Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
+                RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,
+                Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,
+                TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,
+                Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
+                Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
+                System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,
+                Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+                // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
+                // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
+
+                // XCM helpers.
+                XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
+                PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
+                CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
+                DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
+
+                // Unique Pallets
+                Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
+                Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,
+
+                #[runtimes(opal)]
+                Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+
+                // free = 63
+
+                Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
+                // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
+                Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
+                Fungible: pallet_fungible::{Pallet, Storage} = 67,
+
+                #[runtimes(opal)]
+                Refungible: pallet_refungible::{Pallet, Storage} = 68,
+
+                Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,
+                Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,
+
+                #[runtimes(opal)]
+                RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,
+
+                #[runtimes(opal)]
+                RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
+
+                // Frontier
+                EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
+                Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
+
+                EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,
+                EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,
+                EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,
+                EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,
+            }
+        }
+    }
+}
addedruntime/common/src/construct_runtime/util.rsdiffbeforeafterboth
after · runtime/common/src/construct_runtime/util.rs
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}