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
@@ -42,7 +42,7 @@ impl system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -181,7 +181,7 @@ impl frame_system::Trait for Runtime {
/// Converts a module to the index of the module in `construct_runtime!`.
///
/// This type is being generated by `construct_runtime!`.
type ModuleToIndex = ModuleToIndex;
type PalletInfo = PalletInfo;
/// What to do if a new account is created.
type OnNewAccount = ();
/// What to do if an account is fully reaped from the system.
+1 -1
View File
@@ -179,7 +179,7 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
type ModuleToIndex = ModuleToIndex;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -319,7 +319,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -45,7 +45,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -66,7 +66,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -164,7 +164,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -438,7 +438,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -86,7 +86,7 @@ impl frame_system::Trait for Test {
type MaximumExtrinsicWeight = MaximumBlockWeight;
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -902,7 +902,7 @@ impl<T: Subtrait<I>, I: Instance> frame_system::Trait for ElevatedTrait<T, I> {
type MaximumBlockLength = T::MaximumBlockLength;
type AvailableBlockRatio = T::AvailableBlockRatio;
type Version = T::Version;
type ModuleToIndex = T::ModuleToIndex;
type PalletInfo = T::PalletInfo;
type OnNewAccount = T::OnNewAccount;
type OnKilledAccount = T::OnKilledAccount;
type AccountData = T::AccountData;
@@ -87,7 +87,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = super::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -87,7 +87,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = super::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = Module<Test>;
+1 -1
View File
@@ -93,7 +93,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = ();
type AvailableBlockRatio = ();
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -985,7 +985,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -137,7 +137,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -112,7 +112,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -1113,7 +1113,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -59,7 +59,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -52,7 +52,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -74,7 +74,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -764,7 +764,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -591,7 +591,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = RuntimeVersion;
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -273,7 +273,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -100,7 +100,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -63,7 +63,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -130,7 +130,7 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -70,7 +70,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -320,7 +320,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -80,7 +80,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -283,7 +283,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -474,7 +474,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -59,7 +59,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = ();
type MaximumBlockLength = ();
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = (Balances,);
+1 -1
View File
@@ -116,7 +116,7 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -82,7 +82,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -178,7 +178,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -79,7 +79,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -735,7 +735,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -70,7 +70,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -78,7 +78,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = ();
type MaximumBlockLength = ();
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = Balances;
+1 -1
View File
@@ -193,7 +193,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -81,7 +81,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type AccountData = pallet_balances::AccountData<u64>;
+1 -1
View File
@@ -77,7 +77,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = ();
type MaximumBlockLength = ();
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = (Balances,);
+1 -1
View File
@@ -220,7 +220,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -139,7 +139,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -52,6 +52,8 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
..
} = definition;
let modules = modules.into_pairs().map(|v| v.into_value()).collect::<Vec<_>>();
// Assert we have system module declared
let system_module = match find_system_module(modules.iter()) {
Some(sm) => sm,
@@ -82,7 +84,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
&scrate,
)?;
let all_modules = decl_all_modules(&name, modules.iter());
let module_to_index = decl_module_to_index(modules.iter(), modules.len(), &scrate);
let module_to_index = decl_pallet_runtime_setup(&modules, &scrate);
let dispatch = decl_outer_dispatch(&name, modules.iter(), &scrate);
let metadata = decl_runtime_metadata(&name, modules.iter(), &scrate, &unchecked_extrinsic);
@@ -376,22 +378,23 @@ fn decl_all_modules<'a>(
)
}
fn decl_module_to_index<'a>(
module_declarations: impl Iterator<Item = &'a ModuleDeclaration>,
num_modules: usize,
fn decl_pallet_runtime_setup(
module_declarations: &[ModuleDeclaration],
scrate: &TokenStream2,
) -> TokenStream2 {
let names = module_declarations.map(|d| &d.name);
let indices = 0..num_modules;
let names = module_declarations.iter().map(|d| &d.name);
let names2 = module_declarations.iter().map(|d| &d.name);
let name_strings = module_declarations.iter().map(|d| d.name.to_string());
let indices = 0..module_declarations.len();
quote!(
/// Provides an implementation of `ModuleToIndex` to map a module
/// to its index in the runtime.
pub struct ModuleToIndex;
/// Provides an implementation of `PalletInfo` to provide information
/// about the pallet setup in the runtime.
pub struct PalletInfo;
impl #scrate::traits::ModuleToIndex for ModuleToIndex {
fn module_to_index<M: 'static>() -> Option<usize> {
let type_id = #scrate::sp_std::any::TypeId::of::<M>();
impl #scrate::traits::PalletInfo for PalletInfo {
fn index<P: 'static>() -> Option<usize> {
let type_id = #scrate::sp_std::any::TypeId::of::<P>();
#(
if type_id == #scrate::sp_std::any::TypeId::of::<#names>() {
return Some(#indices)
@@ -400,6 +403,17 @@ fn decl_module_to_index<'a>(
None
}
fn name<P: 'static>() -> Option<&'static str> {
let type_id = #scrate::sp_std::any::TypeId::of::<P>();
#(
if type_id == #scrate::sp_std::any::TypeId::of::<#names2>() {
return Some(#name_strings)
}
)*
None
}
}
)
}
+2 -2
View File
@@ -140,8 +140,8 @@ macro_rules! decl_error {
for $crate::sp_runtime::DispatchError
{
fn from(err: $error<$generic $(, $inst_generic)?>) -> Self {
let index = <$generic::ModuleToIndex as $crate::traits::ModuleToIndex>
::module_to_index::<$module<$generic $(, $inst_generic)?>>()
let index = <$generic::PalletInfo as $crate::traits::PalletInfo>
::index::<$module<$generic $(, $inst_generic)?>>()
.expect("Every active module has an index in the runtime; qed") as u8;
$crate::sp_runtime::DispatchError::Module {
+2 -2
View File
@@ -297,7 +297,7 @@ mod tests {
type AccountId: From<u32> + Encode;
type BlockNumber: From<u32> + Encode;
type SomeValue: Get<u32>;
type ModuleToIndex: crate::traits::ModuleToIndex;
type PalletInfo: crate::traits::PalletInfo;
type Call;
}
@@ -443,7 +443,7 @@ mod tests {
type AccountId = u32;
type BlockNumber = u32;
type SomeValue = SystemValue;
type ModuleToIndex = ();
type PalletInfo = ();
type Call = Call;
}
+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.
@@ -24,13 +24,14 @@
use sp_runtime::{generic, traits::{BlakeTwo256, Block as _, Verify}, DispatchError};
use sp_core::{H256, sr25519};
use sp_std::cell::RefCell;
use frame_support::traits::PalletInfo as _;
mod system;
pub trait Currency {}
thread_local! {
pub static INTEGRITY_TEST_EXEC: RefCell<u32> = RefCell::new(0);
pub static INTEGRITY_TEST_EXEC: RefCell<u32> = RefCell::new(0);
}
mod module1 {
@@ -107,7 +108,7 @@ impl system::Trait for Runtime {
type BlockNumber = BlockNumber;
type AccountId = AccountId;
type Event = Event;
type ModuleToIndex = ModuleToIndex;
type PalletInfo = PalletInfo;
type Call = Call;
}
@@ -157,3 +158,15 @@ fn integrity_test_works() {
__construct_runtime_integrity_test::runtime_integrity_tests();
assert_eq!(INTEGRITY_TEST_EXEC.with(|i| *i.borrow()), 1);
}
#[test]
fn pallet_in_runtime_is_correct() {
assert_eq!(PalletInfo::index::<System>().unwrap(), 0);
assert_eq!(PalletInfo::name::<System>().unwrap(), "System");
assert_eq!(PalletInfo::index::<Module1_2>().unwrap(), 3);
assert_eq!(PalletInfo::name::<Module1_2>().unwrap(), "Module1_2");
assert_eq!(PalletInfo::index::<Module2>().unwrap(), 2);
assert_eq!(PalletInfo::name::<Module2>().unwrap(), "Module2");
}
@@ -241,7 +241,7 @@ impl system::Trait for Runtime {
type BlockNumber = BlockNumber;
type AccountId = AccountId;
type Event = Event;
type ModuleToIndex = ();
type PalletInfo = ();
type Call = Call;
}
@@ -164,7 +164,7 @@ impl system::Trait for Runtime {
type BlockNumber = BlockNumber;
type AccountId = AccountId;
type Event = Event;
type ModuleToIndex = ();
type PalletInfo = ();
type Call = Call;
}
+1 -1
View File
@@ -27,7 +27,7 @@ pub trait Trait: 'static + Eq + Clone {
type AccountId: Encode + EncodeLike + Decode;
type Call;
type Event: From<Event<Self>>;
type ModuleToIndex: frame_support::traits::ModuleToIndex;
type PalletInfo: frame_support::traits::PalletInfo;
}
frame_support::decl_module! {
+1 -1
View File
@@ -81,7 +81,7 @@ impl system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -71,7 +71,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = ();
type MaximumBlockLength = ();
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
+7 -5
View File
@@ -117,7 +117,7 @@ use frame_support::{
decl_module, decl_event, decl_storage, decl_error, Parameter, ensure, debug,
storage,
traits::{
Contains, Get, ModuleToIndex, OnNewAccount, OnKilledAccount, IsDeadAccount, Happened,
Contains, Get, PalletInfo, OnNewAccount, OnKilledAccount, IsDeadAccount, Happened,
StoredMap, EnsureOrigin, OriginTrait, Filter,
},
weights::{
@@ -256,11 +256,13 @@ pub trait Trait: 'static + Eq + Clone {
/// Get the chain's current version.
type Version: Get<RuntimeVersion>;
/// Convert a module to its index in the runtime.
/// Provides information about the pallet setup in the runtime.
///
/// Expects the `ModuleToIndex` type that is being generated by `construct_runtime!` in the
/// runtime. For tests it is okay to use `()` as type (returns `0` for each input).
type ModuleToIndex: ModuleToIndex;
/// Expects the `PalletInfo` type that is being generated by `construct_runtime!` in the
/// runtime.
///
/// For tests it is okay to use `()` as type, however it will provide "useless" data.
type PalletInfo: PalletInfo;
/// Data to be associated with an account (other than nonce/transaction counter, which this
/// module does regardless).
+1 -1
View File
@@ -101,7 +101,7 @@ impl Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = Version;
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = u32;
type OnNewAccount = ();
type OnKilledAccount = RecordKilled;
+1 -1
View File
@@ -339,7 +339,7 @@ mod tests {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -654,7 +654,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -80,7 +80,7 @@ impl frame_system::Trait for Test {
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -79,7 +79,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -444,7 +444,7 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
+1 -1
View File
@@ -453,7 +453,7 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();