Allow pallet's info to be enumerated (#10053)

* Allow pallet's info to be enumerated

* Fixes

* Formatting

* Flat tuple for getting all pallet instances

* Renaming and fixing reversedness

* Formatting

* Fixes

* Back to nesting

* Back to nestingx

* Revert executive lib

* Reversions

* Reversions

* Fixes

* Fixes

* Formatting

* Fixes

* Spelling

* Comments
This commit is contained in:
Gavin Wood
2021-10-21 10:29:10 +02:00
committed by GitHub
parent 1660bc8cf2
commit 1dc753eb08
9 changed files with 187 additions and 7 deletions
@@ -217,6 +217,7 @@ fn decl_all_pallets<'a>(
quote!(
#types
/// All pallets included in the runtime as a nested tuple of types.
/// Excludes the System pallet.
pub type AllPallets = ( #all_pallets );
@@ -233,6 +233,25 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
}
}
impl<#type_impl_gen> #frame_support::traits::PalletsInfoAccess
for #pallet_ident<#type_use_gen>
#config_where_clause
{
fn count() -> usize { 1 }
fn accumulate(
acc: &mut #frame_support::sp_std::vec::Vec<#frame_support::traits::PalletInfoData>
) {
use #frame_support::traits::PalletInfoAccess;
let item = #frame_support::traits::PalletInfoData {
index: Self::index(),
name: Self::name(),
module_name: Self::module_name(),
crate_version: Self::crate_version(),
};
acc.push(item);
}
}
#storage_info
)
}