Rename ModuleToIndex to PalletRuntimeSetup (#7148)

* Rename `ModuleToIndex` to `PalletRuntimeSetup`

Besides the renaming it also adds support getting the name of a pallet
as configured in the runtime.

* Rename it to `PalletInfo`

* Remove accidentally added files
This commit is contained in:
Bastian Köcher
2020-09-22 15:39:56 +02:00
committed by GitHub
parent 22632efc5f
commit 86594727d9
62 changed files with 119 additions and 88 deletions
+11 -9
View File
@@ -1313,8 +1313,6 @@ impl<T: Clone + Ord> ChangeMembers<T> for () {
fn set_prime(_: Option<T>) {}
}
/// Trait for type that can handle the initialization of account IDs at genesis.
pub trait InitializeMembers<AccountId> {
/// Initialize the members to the given `members`.
@@ -1380,16 +1378,20 @@ pub trait ValidatorRegistration<ValidatorId> {
fn is_registered(id: &ValidatorId) -> bool;
}
/// Something that can convert a given module into the index of the module in the runtime.
/// Provides information about the pallet setup in the runtime.
///
/// The index of a module is determined by the position it appears in `construct_runtime!`.
pub trait ModuleToIndex {
/// Convert the given module `M` into an index.
fn module_to_index<M: 'static>() -> Option<usize>;
/// An implementor should be able to provide information about each pallet that
/// is configured in `construct_runtime!`.
pub trait PalletInfo {
/// Convert the given pallet `P` into its index as configured in the runtime.
fn index<P: 'static>() -> Option<usize>;
/// Convert the given pallet `P` into its name as configured in the runtime.
fn name<P: 'static>() -> Option<&'static str>;
}
impl ModuleToIndex for () {
fn module_to_index<M: 'static>() -> Option<usize> { Some(0) }
impl PalletInfo for () {
fn index<P: 'static>() -> Option<usize> { Some(0) }
fn name<P: 'static>() -> Option<&'static str> { Some("test") }
}
/// The function and pallet name of the Call.