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
after · runtime/common/src/construct_runtime/mod.rs
1mod util;23#[macro_export]4macro_rules! construct_runtime {5    () => {6        $crate::construct_runtime_impl! {7            pub enum Runtime where8                Block = Block,9                NodeBlock = opaque::Block,10                UncheckedExtrinsic = UncheckedExtrinsic11            {12                ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,13                ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,1415                Aura: pallet_aura::{Pallet, Config<T>} = 22,16                AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,1718                Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,19                RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,20                Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,21                TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,22                Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,23                Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,24                System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 36,25                Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,26                // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,27                // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,2829                // XCM helpers.30                XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,31                PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,32                CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,33                DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,3435                // Unique Pallets36                Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,37                Unique: pallet_unique::{Pallet, Call, Storage, Event<T>} = 61,3839                #[runtimes(opal)]40                Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,4142                // free = 634344                Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,45                // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,46                Common: pallet_common::{Pallet, Storage, Event<T>} = 66,47                Fungible: pallet_fungible::{Pallet, Storage} = 67,4849                #[runtimes(opal)]50                Refungible: pallet_refungible::{Pallet, Storage} = 68,5152                Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,53                Structure: pallet_structure::{Pallet, Call, Storage, Event<T>} = 70,5455                #[runtimes(opal)]56                RmrkCore: pallet_proxy_rmrk_core::{Pallet, Call, Storage, Event<T>} = 71,5758                #[runtimes(opal)]59                RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,6061                // Frontier62                EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,63                Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,6465                EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,66                EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,67                EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,68                EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,69            }70        }71    }72}
addedruntime/common/src/construct_runtime/util.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/src/construct_runtime/util.rs
@@ -0,0 +1,273 @@
+#[macro_export]
+macro_rules! construct_runtime_impl {
+    (
+        pub enum $runtime:ident where
+            $($where_ident:ident = $where_ty:ty),* $(,)?
+        {
+            $(
+                $(#[runtimes($($pallet_runtimes:ident),+ $(,)?)])?
+                $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal
+            ),*
+            $(,)?
+        }
+    ) => {
+        $crate::construct_runtime_helper! {
+            runtime($runtime),
+            where_clause($($where_ident = $where_ty),*),
+            pallets(
+                $(
+                    $(#[runtimes($($pallet_runtimes),+)])?
+                    $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index
+                ),*,
+            ),
+
+            opal_pallets(),
+            quartz_pallets(),
+            unique_pallets(),
+        }
+    }
+}
+
+#[macro_export]
+macro_rules! construct_runtime_helper {
+    (
+        runtime($runtime:ident),
+        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),
+            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),
+        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)*
+                $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,
+            ),
+        }
+    };
+
+    (
+        runtime($runtime:ident),
+        where_clause($($where_clause:tt)*),
+        pallets(),
+
+        opal_pallets($($opal_pallets:tt)*),
+        quartz_pallets($($quartz_pallets:tt)*),
+        unique_pallets($($unique_pallets:tt)*),
+    ) => {
+        #[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
+                $($where_clause)*
+            {
+                $($unique_pallets)*
+            }
+        }
+    };
+}
+
+#[macro_export]
+macro_rules! add_runtime_specific_pallets {
+    (
+        runtime($runtime:ident),
+        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(
+                $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)*),
+        }
+    };
+
+    (
+        runtime($runtime:ident),
+        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(
+                $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)*),
+        }
+    };
+
+    (
+        runtime($runtime:ident),
+        where_clause($($where_clause:tt)*),
+        pallets(
+            $pallet_name:ident: $pallet_mod:ident::{$($pallet_parts:ty),*} = $index:literal,
+            $($pallets_tl:tt)*
+        ),
+
+        runtimes(
+            unique,
+
+            $($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(
+                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,
+                $($pallets_tl)*
+            ),
+
+            runtimes($($runtime_tl)*),
+
+            opal_pallets($($opal_pallets)*),
+            quartz_pallets($($quartz_pallets)*),
+            unique_pallets(
+                $($unique_pallets)*
+                $pallet_name: $pallet_mod::{$($pallet_parts),*} = $index,
+            ),
+        }
+    };
+
+    (
+        runtime($runtime:ident),
+        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)*),
+
+            opal_pallets($($opal_pallets)*),
+            quartz_pallets($($quartz_pallets)*),
+            unique_pallets($($unique_pallets)*),
+        }
+    };
+}