From 86182cda5e1be58569a251b65e2356ad643ea6c6 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Tue, 16 Mar 2021 16:03:54 +1300 Subject: [PATCH 01/12] Use 'Pallet' struct in construct_runtime. --- .../procedural/src/construct_runtime/mod.rs | 322 +++++++++--------- .../procedural/src/construct_runtime/parse.rs | 72 ++-- frame/support/src/dispatch.rs | 2 + 3 files changed, 199 insertions(+), 197 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index abd68e4425d89..cf4231de0b050 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -19,90 +19,90 @@ mod parse; use frame_support_procedural_tools::syn_ext as ext; use frame_support_procedural_tools::{generate_crate_access, generate_hidden_includes}; -use parse::{ModuleDeclaration, RuntimeDefinition, WhereSection, ModulePart}; +use parse::{PalletDeclaration, RuntimeDefinition, WhereSection, PalletPart}; use proc_macro::TokenStream; use proc_macro2::{TokenStream as TokenStream2}; use quote::quote; use syn::{Ident, Result, TypePath}; use std::collections::HashMap; -/// The fixed name of the system module. -const SYSTEM_MODULE_NAME: &str = "System"; +/// The fixed name of the system pallet. +const SYSTEM_PALLET_NAME: &str = "System"; -/// The complete definition of a module with the resulting fixed index. +/// The complete definition of a pallet with the resulting fixed index. #[derive(Debug, Clone)] -pub struct Module { +pub struct Pallet { pub name: Ident, pub index: u8, - pub module: Ident, + pub pallet: Ident, pub instance: Option, - pub module_parts: Vec, + pub pallet_parts: Vec, } -impl Module { - /// Get resolved module parts - fn module_parts(&self) -> &[ModulePart] { - &self.module_parts +impl Pallet { + /// Get resolved pallet parts + fn pallet_parts(&self) -> &[PalletPart] { + &self.pallet_parts } /// Find matching parts - fn find_part(&self, name: &str) -> Option<&ModulePart> { - self.module_parts.iter().find(|part| part.name() == name) + fn find_part(&self, name: &str) -> Option<&PalletPart> { + self.pallet_parts.iter().find(|part| part.name() == name) } - /// Return whether module contains part + /// Return whether pallet contains part fn exists_part(&self, name: &str) -> bool { self.find_part(name).is_some() } } -/// Convert from the parsed module to their final information. -/// Assign index to each modules using same rules as rust for fieldless enum. +/// Convert from the parsed pallet to their final information. +/// Assign index to each pallet using same rules as rust for fieldless enum. /// I.e. implicit are assigned number incrementedly from last explicit or 0. -fn complete_modules(decl: impl Iterator) -> syn::Result> { +fn complete_pallets(decl: impl Iterator) -> syn::Result> { let mut indices = HashMap::new(); let mut last_index: Option = None; let mut names = HashMap::new(); decl - .map(|module| { - let final_index = match module.index { + .map(|pallet| { + let final_index = match pallet.index { Some(i) => i, None => last_index.map_or(Some(0), |i| i.checked_add(1)) .ok_or_else(|| { - let msg = "Module index doesn't fit into u8, index is 256"; - syn::Error::new(module.name.span(), msg) + let msg = "Pallet index doesn't fit into u8, index is 256"; + syn::Error::new(pallet.name.span(), msg) })?, }; last_index = Some(final_index); - if let Some(used_module) = indices.insert(final_index, module.name.clone()) { + if let Some(used_pallet) = indices.insert(final_index, pallet.name.clone()) { let msg = format!( - "Module indices are conflicting: Both modules {} and {} are at index {}", - used_module, - module.name, + "Pallet indices are conflicting: Both pallets {} and {} are at index {}", + used_pallet, + pallet.name, final_index, ); - let mut err = syn::Error::new(used_module.span(), &msg); - err.combine(syn::Error::new(module.name.span(), msg)); + let mut err = syn::Error::new(used_pallet.span(), &msg); + err.combine(syn::Error::new(pallet.name.span(), msg)); return Err(err); } - if let Some(used_module) = names.insert(module.name.clone(), module.name.span()) { - let msg = "Two modules with the same name!"; + if let Some(used_pallet) = names.insert(pallet.name.clone(), pallet.name.span()) { + let msg = "Two pallets with the same name!"; - let mut err = syn::Error::new(used_module, &msg); - err.combine(syn::Error::new(module.name.span(), &msg)); + let mut err = syn::Error::new(used_pallet, &msg); + err.combine(syn::Error::new(pallet.name.span(), &msg)); return Err(err); } - Ok(Module { - name: module.name, + Ok(Pallet { + name: pallet.name, index: final_index, - module: module.module, - instance: module.instance, - module_parts: module.module_parts, + pallet: pallet.pallet, + instance: pallet.instance, + pallet_parts: pallet.pallet_parts, }) }) .collect() @@ -124,55 +124,55 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result},`", + pallets_token.span, + "`System` pallet declaration is missing. \ + Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},`", ))?; let hidden_crate_name = "construct_runtime"; let scrate = generate_crate_access(&hidden_crate_name, "frame-support"); let scrate_decl = generate_hidden_includes(&hidden_crate_name, "frame-support"); - let all_but_system_modules = modules.iter().filter(|module| module.name != SYSTEM_MODULE_NAME); + let all_but_system_pallets = pallets.iter().filter(|pallet| pallet.name != SYSTEM_PALLET_NAME); let outer_event = decl_outer_event( &name, - modules.iter(), + pallets.iter(), &scrate, )?; let outer_origin = decl_outer_origin( &name, - all_but_system_modules, - &system_module, + all_but_system_pallets, + &system_pallet, &scrate, )?; - let all_modules = decl_all_modules(&name, modules.iter()); - let module_to_index = decl_pallet_runtime_setup(&modules, &scrate); + let all_pallets = decl_all_pallets(&name, pallets.iter()); + let pallet_to_index = decl_pallet_runtime_setup(&pallets, &scrate); - let dispatch = decl_outer_dispatch(&name, modules.iter(), &scrate); - let metadata = decl_runtime_metadata(&name, modules.iter(), &scrate, &unchecked_extrinsic); - let outer_config = decl_outer_config(&name, modules.iter(), &scrate); + let dispatch = decl_outer_dispatch(&name, pallets.iter(), &scrate); + let metadata = decl_runtime_metadata(&name, pallets.iter(), &scrate, &unchecked_extrinsic); + let outer_config = decl_outer_config(&name, pallets.iter(), &scrate); let inherent = decl_outer_inherent( &block, &unchecked_extrinsic, - modules.iter(), + pallets.iter(), &scrate, ); - let validate_unsigned = decl_validate_unsigned(&name, modules.iter(), &scrate); + let validate_unsigned = decl_validate_unsigned(&name, pallets.iter(), &scrate); let integrity_test = decl_integrity_test(&scrate); let res = quote!( @@ -197,9 +197,9 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result Result( runtime: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, ) -> TokenStream2 { - let modules_tokens = module_declarations - .filter(|module_declaration| module_declaration.exists_part("ValidateUnsigned")) - .map(|module_declaration| &module_declaration.name); + let pallets_tokens = pallet_declarations + .filter(|pallet_declaration| pallet_declaration.exists_part("ValidateUnsigned")) + .map(|pallet_declaration| &pallet_declaration.name); quote!( #scrate::impl_outer_validate_unsigned!( impl ValidateUnsigned for #runtime { - #( #modules_tokens )* + #( #pallets_tokens )* } ); ) @@ -237,13 +237,13 @@ fn decl_validate_unsigned<'a>( fn decl_outer_inherent<'a>( block: &'a syn::TypePath, unchecked_extrinsic: &'a syn::TypePath, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, ) -> TokenStream2 { - let modules_tokens = module_declarations.filter_map(|module_declaration| { - let maybe_config_part = module_declaration.find_part("Inherent"); + let pallets_tokens = pallet_declarations.filter_map(|pallet_declaration| { + let maybe_config_part = pallet_declaration.find_part("Inherent"); maybe_config_part.map(|_| { - let name = &module_declaration.name; + let name = &pallet_declaration.name; quote!(#name,) }) }); @@ -253,7 +253,7 @@ fn decl_outer_inherent<'a>( Block = #block, UncheckedExtrinsic = #unchecked_extrinsic { - #(#modules_tokens)* + #(#pallets_tokens)* } ); ) @@ -261,37 +261,37 @@ fn decl_outer_inherent<'a>( fn decl_outer_config<'a>( runtime: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, ) -> TokenStream2 { - let modules_tokens = module_declarations - .filter_map(|module_declaration| { - module_declaration.find_part("Config").map(|part| { + let pallets_tokens = pallet_declarations + .filter_map(|pallet_declaration| { + pallet_declaration.find_part("Config").map(|part| { let transformed_generics: Vec<_> = part .generics .params .iter() .map(|param| quote!(<#param>)) .collect(); - (module_declaration, transformed_generics) + (pallet_declaration, transformed_generics) }) }) - .map(|(module_declaration, generics)| { - let module = &module_declaration.module; + .map(|(pallet_declaration, generics)| { + let pallet = &pallet_declaration.pallet; let name = Ident::new( - &format!("{}Config", module_declaration.name), - module_declaration.name.span(), + &format!("{}Config", pallet_declaration.name), + pallet_declaration.name.span(), ); - let instance = module_declaration.instance.as_ref().into_iter(); + let instance = pallet_declaration.instance.as_ref().into_iter(); quote!( #name => - #module #(#instance)* #(#generics)*, + #pallet #(#instance)* #(#generics)*, ) }); quote!( #scrate::impl_outer_config! { - pub struct GenesisConfig for #runtime where AllModulesWithSystem = AllModulesWithSystem { - #(#modules_tokens)* + pub struct GenesisConfig for #runtime where AllPalletsWithSystem = AllPalletsWithSystem { + #(#pallets_tokens)* } } ) @@ -299,63 +299,63 @@ fn decl_outer_config<'a>( fn decl_runtime_metadata<'a>( runtime: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, extrinsic: &TypePath, ) -> TokenStream2 { - let modules_tokens = module_declarations - .filter_map(|module_declaration| { - module_declaration.find_part("Module").map(|_| { - let filtered_names: Vec<_> = module_declaration - .module_parts() + let pallets_tokens = pallet_declarations + .filter_map(|pallet_declaration| { + pallet_declaration.find_part("Pallet").map(|_| { + let filtered_names: Vec<_> = pallet_declaration + .pallet_parts() .iter() - .filter(|part| part.name() != "Module") + .filter(|part| part.name() != "Pallet") .map(|part| part.ident()) .collect(); - (module_declaration, filtered_names) + (pallet_declaration, filtered_names) }) }) - .map(|(module_declaration, filtered_names)| { - let module = &module_declaration.module; - let name = &module_declaration.name; - let instance = module_declaration + .map(|(pallet_declaration, filtered_names)| { + let pallet = &pallet_declaration.pallet; + let name = &pallet_declaration.name; + let instance = pallet_declaration .instance .as_ref() .map(|name| quote!(<#name>)) .into_iter(); - let index = module_declaration.index; + let index = pallet_declaration.index; quote!( - #module::Module #(#instance)* as #name { index #index } with #(#filtered_names)*, + #pallet::Pallet #(#instance)* as #name { index #index } with #(#filtered_names)*, ) }); quote!( #scrate::impl_runtime_metadata!{ - for #runtime with modules where Extrinsic = #extrinsic - #(#modules_tokens)* + for #runtime with pallets where Extrinsic = #extrinsic + #(#pallets_tokens)* } ) } fn decl_outer_dispatch<'a>( runtime: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, ) -> TokenStream2 { - let modules_tokens = module_declarations - .filter(|module_declaration| module_declaration.exists_part("Call")) - .map(|module_declaration| { - let module = &module_declaration.module; - let name = &module_declaration.name; - let index = module_declaration.index; - quote!(#[codec(index = #index)] #module::#name) + let pallets_tokens = pallet_declarations + .filter(|pallet_declaration| pallet_declaration.exists_part("Call")) + .map(|pallet_declaration| { + let pallet = &pallet_declaration.pallet; + let name = &pallet_declaration.name; + let index = pallet_declaration.index; + quote!(#[codec(index = #index)] #pallet::#name) }); quote!( #scrate::impl_outer_dispatch! { pub enum Call for #runtime where origin: Origin { - #(#modules_tokens,)* + #(#pallets_tokens,)* } } ) @@ -363,32 +363,32 @@ fn decl_outer_dispatch<'a>( fn decl_outer_origin<'a>( runtime_name: &'a Ident, - modules_except_system: impl Iterator, - system_module: &'a Module, + pallets_except_system: impl Iterator, + system_pallet: &'a Pallet, scrate: &'a TokenStream2, ) -> syn::Result { - let mut modules_tokens = TokenStream2::new(); - for module_declaration in modules_except_system { - if let Some(module_entry) = module_declaration.find_part("Origin") { - let module = &module_declaration.module; - let instance = module_declaration.instance.as_ref(); - let generics = &module_entry.generics; + let mut pallets_tokens = TokenStream2::new(); + for pallet_declaration in pallets_except_system { + if let Some(pallet_entry) = pallet_declaration.find_part("Origin") { + let pallet = &pallet_declaration.pallet; + let instance = pallet_declaration.instance.as_ref(); + let generics = &pallet_entry.generics; if instance.is_some() && generics.params.is_empty() { let msg = format!( - "Instantiable module with no generic `Origin` cannot \ - be constructed: module `{}` must have generic `Origin`", - module_declaration.name + "Instantiable pallet with no generic `Origin` cannot \ + be constructed: pallet `{}` must have generic `Origin`", + pallet_declaration.name ); - return Err(syn::Error::new(module_declaration.name.span(), msg)); + return Err(syn::Error::new(pallet_declaration.name.span(), msg)); } - let index = module_declaration.index; - let tokens = quote!(#[codec(index = #index)] #module #instance #generics,); - modules_tokens.extend(tokens); + let index = pallet_declaration.index; + let tokens = quote!(#[codec(index = #index)] #pallet #instance #generics,); + pallets_tokens.extend(tokens); } } - let system_name = &system_module.module; - let system_index = system_module.index; + let system_name = &system_pallet.pallet; + let system_index = system_pallet.index; Ok(quote!( #scrate::impl_outer_origin! { @@ -396,7 +396,7 @@ fn decl_outer_origin<'a>( system = #system_name, system_index = #system_index { - #modules_tokens + #pallets_tokens } } )) @@ -404,89 +404,89 @@ fn decl_outer_origin<'a>( fn decl_outer_event<'a>( runtime_name: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, scrate: &'a TokenStream2, ) -> syn::Result { - let mut modules_tokens = TokenStream2::new(); - for module_declaration in module_declarations { - if let Some(module_entry) = module_declaration.find_part("Event") { - let module = &module_declaration.module; - let instance = module_declaration.instance.as_ref(); - let generics = &module_entry.generics; + let mut pallets_tokens = TokenStream2::new(); + for pallet_declaration in pallet_declarations { + if let Some(pallet_entry) = pallet_declaration.find_part("Event") { + let pallet = &pallet_declaration.pallet; + let instance = pallet_declaration.instance.as_ref(); + let generics = &pallet_entry.generics; if instance.is_some() && generics.params.is_empty() { let msg = format!( - "Instantiable module with no generic `Event` cannot \ - be constructed: module `{}` must have generic `Event`", - module_declaration.name, + "Instantiable pallet with no generic `Event` cannot \ + be constructed: pallet `{}` must have generic `Event`", + pallet_declaration.name, ); - return Err(syn::Error::new(module_declaration.name.span(), msg)); + return Err(syn::Error::new(pallet_declaration.name.span(), msg)); } - let index = module_declaration.index; - let tokens = quote!(#[codec(index = #index)] #module #instance #generics,); - modules_tokens.extend(tokens); + let index = pallet_declaration.index; + let tokens = quote!(#[codec(index = #index)] #pallet #instance #generics,); + pallets_tokens.extend(tokens); } } Ok(quote!( #scrate::impl_outer_event! { pub enum Event for #runtime_name { - #modules_tokens + #pallets_tokens } } )) } -fn decl_all_modules<'a>( +fn decl_all_pallets<'a>( runtime: &'a Ident, - module_declarations: impl Iterator, + pallet_declarations: impl Iterator, ) -> TokenStream2 { let mut types = TokenStream2::new(); let mut names = Vec::new(); - for module_declaration in module_declarations { - let type_name = &module_declaration.name; - let module = &module_declaration.module; + for pallet_declaration in pallet_declarations { + let type_name = &pallet_declaration.name; + let pallet = &pallet_declaration.pallet; let mut generics = vec![quote!(#runtime)]; generics.extend( - module_declaration + pallet_declaration .instance .iter() - .map(|name| quote!(#module::#name)), + .map(|name| quote!(#pallet::#name)), ); let type_decl = quote!( - pub type #type_name = #module::Module <#(#generics),*>; + pub type #type_name = #pallet::Pallet <#(#generics),*>; ); types.extend(type_decl); - names.push(&module_declaration.name); + names.push(&pallet_declaration.name); } // Make nested tuple structure like (((Babe, Consensus), Grandpa), ...) - // But ignore the system module. - let all_modules = names.iter() - .filter(|n| **n != SYSTEM_MODULE_NAME) + // But ignore the system pallet. + let all_pallets = names.iter() + .filter(|n| **n != SYSTEM_PALLET_NAME) .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); - let all_modules_with_system = names.iter() + let all_pallets_with_system = names.iter() .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); quote!( #types /// All pallets included in the runtime as a nested tuple of types. /// Excludes the System pallet. - pub type AllModules = ( #all_modules ); + pub type AllPallets = ( #all_pallets ); /// All pallets included in the runtime as a nested tuple of types. - pub type AllModulesWithSystem = ( #all_modules_with_system ); + pub type AllPalletsWithSystem = ( #all_pallets_with_system ); ) } fn decl_pallet_runtime_setup( - module_declarations: &[Module], + pallet_declarations: &[Pallet], scrate: &TokenStream2, ) -> TokenStream2 { - 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 = module_declarations.iter() - .map(|module| module.index as usize); + let names = pallet_declarations.iter().map(|d| &d.name); + let names2 = pallet_declarations.iter().map(|d| &d.name); + let name_strings = pallet_declarations.iter().map(|d| d.name.to_string()); + let indices = pallet_declarations.iter() + .map(|pallet| pallet.index as usize); quote!( /// Provides an implementation of `PalletInfo` to provide information @@ -527,7 +527,7 @@ fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 { #[test] pub fn runtime_integrity_tests() { - ::integrity_test(); + ::integrity_test(); } } ) diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 6d4ba6cdbf743..def207439b536 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -28,7 +28,7 @@ mod keyword { syn::custom_keyword!(Block); syn::custom_keyword!(NodeBlock); syn::custom_keyword!(UncheckedExtrinsic); - syn::custom_keyword!(Module); + syn::custom_keyword!(Pallet); syn::custom_keyword!(Call); syn::custom_keyword!(Storage); syn::custom_keyword!(Event); @@ -44,7 +44,7 @@ pub struct RuntimeDefinition { pub enum_token: Token![enum], pub name: Ident, pub where_section: WhereSection, - pub modules: ext::Braces>, + pub pallets: ext::Braces>, } impl Parse for RuntimeDefinition { @@ -54,7 +54,7 @@ impl Parse for RuntimeDefinition { enum_token: input.parse()?, name: input.parse()?, where_section: input.parse()?, - modules: input.parse()?, + pallets: input.parse()?, }) } } @@ -150,20 +150,20 @@ impl Parse for WhereDefinition { } #[derive(Debug, Clone)] -pub struct ModuleDeclaration { +pub struct PalletDeclaration { pub name: Ident, /// Optional fixed index (e.g. `MyPallet ... = 3,`) pub index: Option, - pub module: Ident, + pub pallet: Ident, pub instance: Option, - pub module_parts: Vec, + pub pallet_parts: Vec, } -impl Parse for ModuleDeclaration { +impl Parse for PalletDeclaration { fn parse(input: ParseStream) -> Result { let name = input.parse()?; let _: Token![:] = input.parse()?; - let module = input.parse()?; + let pallet = input.parse()?; let instance = if input.peek(Token![::]) && input.peek3(Token![<]) { let _: Token![::] = input.parse()?; let _: Token![<] = input.parse()?; @@ -175,7 +175,7 @@ impl Parse for ModuleDeclaration { }; let _: Token![::] = input.parse()?; - let module_parts = parse_module_parts(input)?; + let pallet_parts = parse_pallet_parts(input)?; let index = if input.peek(Token![=]) { input.parse::()?; @@ -188,9 +188,9 @@ impl Parse for ModuleDeclaration { let parsed = Self { name, - module, + pallet, instance, - module_parts, + pallet_parts, index, }; @@ -198,14 +198,14 @@ impl Parse for ModuleDeclaration { } } -/// Parse [`ModulePart`]'s from a braces enclosed list that is split by commas, e.g. +/// Parse [`PalletPart`]'s from a braces enclosed list that is split by commas, e.g. /// /// `{ Call, Event }` -fn parse_module_parts(input: ParseStream) -> Result> { - let module_parts :ext::Braces> = input.parse()?; +fn parse_pallet_parts(input: ParseStream) -> Result> { + let pallet_parts :ext::Braces> = input.parse()?; let mut resolved = HashSet::new(); - for part in module_parts.content.inner.iter() { + for part in pallet_parts.content.inner.iter() { if !resolved.insert(part.name()) { let msg = format!( "`{}` was already declared before. Please remove the duplicate declaration", @@ -215,12 +215,12 @@ fn parse_module_parts(input: ParseStream) -> Result> { } } - Ok(module_parts.content.inner.into_iter().collect()) + Ok(pallet_parts.content.inner.into_iter().collect()) } #[derive(Debug, Clone)] -pub enum ModulePartKeyword { - Module(keyword::Module), +pub enum PalletPartKeyword { + Pallet(keyword::Pallet), Call(keyword::Call), Storage(keyword::Storage), Event(keyword::Event), @@ -230,12 +230,12 @@ pub enum ModulePartKeyword { ValidateUnsigned(keyword::ValidateUnsigned), } -impl Parse for ModulePartKeyword { +impl Parse for PalletPartKeyword { fn parse(input: ParseStream) -> Result { let lookahead = input.lookahead1(); - if lookahead.peek(keyword::Module) { - Ok(Self::Module(input.parse()?)) + if lookahead.peek(keyword::Pallet) { + Ok(Self::Pallet(input.parse()?)) } else if lookahead.peek(keyword::Call) { Ok(Self::Call(input.parse()?)) } else if lookahead.peek(keyword::Storage) { @@ -256,11 +256,11 @@ impl Parse for ModulePartKeyword { } } -impl ModulePartKeyword { +impl PalletPartKeyword { /// Returns the name of `Self`. fn name(&self) -> &'static str { match self { - Self::Module(_) => "Module", + Self::Pallet(_) => "Pallet", Self::Call(_) => "Call", Self::Storage(_) => "Storage", Self::Event(_) => "Event", @@ -276,21 +276,21 @@ impl ModulePartKeyword { Ident::new(self.name(), self.span()) } - /// Returns `true` if this module part is allowed to have generic arguments. + /// Returns `true` if this pallet part is allowed to have generic arguments. fn allows_generic(&self) -> bool { Self::all_generic_arg().iter().any(|n| *n == self.name()) } - /// Returns the names of all module parts that allow to have a generic argument. + /// Returns the names of all pallet parts that allow to have a generic argument. fn all_generic_arg() -> &'static [&'static str] { &["Event", "Origin", "Config"] } } -impl Spanned for ModulePartKeyword { +impl Spanned for PalletPartKeyword { fn span(&self) -> Span { match self { - Self::Module(inner) => inner.span(), + Self::Pallet(inner) => inner.span(), Self::Call(inner) => inner.span(), Self::Storage(inner) => inner.span(), Self::Event(inner) => inner.span(), @@ -303,21 +303,21 @@ impl Spanned for ModulePartKeyword { } #[derive(Debug, Clone)] -pub struct ModulePart { - pub keyword: ModulePartKeyword, +pub struct PalletPart { + pub keyword: PalletPartKeyword, pub generics: syn::Generics, } -impl Parse for ModulePart { +impl Parse for PalletPart { fn parse(input: ParseStream) -> Result { - let keyword: ModulePartKeyword = input.parse()?; + let keyword: PalletPartKeyword = input.parse()?; let generics: syn::Generics = input.parse()?; if !generics.params.is_empty() && !keyword.allows_generic() { - let valid_generics = ModulePart::format_names(ModulePartKeyword::all_generic_arg()); + let valid_generics = PalletPart::format_names(PalletPartKeyword::all_generic_arg()); let msg = format!( "`{}` is not allowed to have generics. \ - Only the following modules are allowed to have generics: {}.", + Only the following pallets are allowed to have generics: {}.", keyword.name(), valid_generics, ); @@ -331,18 +331,18 @@ impl Parse for ModulePart { } } -impl ModulePart { +impl PalletPart { pub fn format_names(names: &[&'static str]) -> String { let res: Vec<_> = names.iter().map(|s| format!("`{}`", s)).collect(); res.join(", ") } - /// The name of this module part. + /// The name of this pallet part. pub fn name(&self) -> &'static str { self.keyword.name() } - /// The name of this module part as `Ident`. + /// The name of this pallet part as `Ident`. pub fn ident(&self) -> Ident { self.keyword.ident() } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 64b7b7a8e2180..a61e11a9dcac8 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1858,6 +1858,8 @@ macro_rules! decl_module { $(, $instance: $instantiable $( = $module_default_instance)?)? >($crate::sp_std::marker::PhantomData<($trait_instance, $( $instance)?)>) where $( $other_where_bounds )*; + /// The `Pallet` alias, to make `decl_module` compatible with new pallet attribute macro. + pub type Pallet<$trait_instance> = $mod_type<$trait_instance>; $crate::decl_module! { @impl_on_initialize From 2607a4a7769c2603d4c234a8f557ae58ce405770 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Tue, 16 Mar 2021 16:46:24 +1300 Subject: [PATCH 02/12] Fix genesis and metadata macro. --- frame/support/src/genesis_config.rs | 6 +++--- frame/support/src/metadata.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/support/src/genesis_config.rs b/frame/support/src/genesis_config.rs index 8f915082e8bb0..3f7f943603e42 100644 --- a/frame/support/src/genesis_config.rs +++ b/frame/support/src/genesis_config.rs @@ -56,7 +56,7 @@ macro_rules! __impl_outer_config_types { /// specific genesis configuration. /// /// ```ignore -/// pub struct GenesisConfig for Runtime where AllModulesWithSystem = AllModulesWithSystem { +/// pub struct GenesisConfig for Runtime where AllPalletsWithSystem = AllPalletsWithSystem { /// rust_module_one: Option, /// ... /// } @@ -65,7 +65,7 @@ macro_rules! __impl_outer_config_types { macro_rules! impl_outer_config { ( pub struct $main:ident for $concrete:ident where - AllModulesWithSystem = $all_modules_with_system:ident + AllPalletsWithSystem = $all_pallets_with_system:ident { $( $config:ident => $snake:ident $( $instance:ident )? $( <$generic:ident> )*, )* @@ -103,7 +103,7 @@ macro_rules! impl_outer_config { )* $crate::BasicExternalities::execute_with_storage(storage, || { - <$all_modules_with_system as $crate::traits::OnGenesis>::on_genesis(); + <$all_pallets_with_system as $crate::traits::OnGenesis>::on_genesis(); }); Ok(()) diff --git a/frame/support/src/metadata.rs b/frame/support/src/metadata.rs index 2edaba1cb47e9..06d334ab8e5af 100644 --- a/frame/support/src/metadata.rs +++ b/frame/support/src/metadata.rs @@ -69,7 +69,7 @@ pub use frame_metadata::{ #[macro_export] macro_rules! impl_runtime_metadata { ( - for $runtime:ident with modules where Extrinsic = $ext:ident + for $runtime:ident with pallets where Extrinsic = $ext:ident $( $rest:tt )* ) => { impl $runtime { From ef0c40e71881518ba208889079ae1d3399e5bb78 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Tue, 16 Mar 2021 22:33:50 +1300 Subject: [PATCH 03/12] Fix 'Pallet' type alias. --- frame/support/src/dispatch.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index a61e11a9dcac8..7b526e305b7be 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1858,8 +1858,10 @@ macro_rules! decl_module { $(, $instance: $instantiable $( = $module_default_instance)?)? >($crate::sp_std::marker::PhantomData<($trait_instance, $( $instance)?)>) where $( $other_where_bounds )*; - /// The `Pallet` alias, to make `decl_module` compatible with new pallet attribute macro. - pub type Pallet<$trait_instance> = $mod_type<$trait_instance>; + + /// Type alias to `Module`, to be used by `construct_runtime`. + pub type Pallet<$trait_instance $(, $instance $( = $module_default_instance)?)?> + = $mod_type<$trait_instance $(, $instance)?>; $crate::decl_module! { @impl_on_initialize From e1aa8401a286f533b9c863162b86d30777a251ab Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Tue, 16 Mar 2021 23:27:28 +1300 Subject: [PATCH 04/12] Replace 'Module' with 'Pallet' for all construct_runtime use cases. --- .../pallets/template/src/mock.rs | 6 +- bin/node-template/runtime/src/lib.rs | 22 +-- bin/node/executor/tests/basic.rs | 4 +- bin/node/runtime/src/lib.rs | 84 ++++++------ frame/assets/src/benchmarking.rs | 4 +- frame/assets/src/lib.rs | 8 +- frame/assets/src/mock.rs | 6 +- frame/assets/src/tests.rs | 2 +- frame/atomic-swap/src/lib.rs | 6 +- frame/atomic-swap/src/tests.rs | 6 +- frame/aura/src/lib.rs | 4 +- frame/aura/src/mock.rs | 6 +- frame/authority-discovery/src/lib.rs | 6 +- frame/authorship/src/lib.rs | 14 +- frame/babe/src/lib.rs | 6 +- frame/babe/src/mock.rs | 18 +-- frame/babe/src/randomness.rs | 2 +- frame/balances/src/lib.rs | 2 +- frame/balances/src/tests.rs | 2 +- frame/balances/src/tests_composite.rs | 8 +- frame/balances/src/tests_local.rs | 8 +- frame/balances/src/tests_reentrancy.rs | 10 +- frame/benchmarking/src/lib.rs | 8 +- frame/benchmarking/src/tests.rs | 4 +- frame/bounties/src/benchmarking.rs | 6 +- frame/bounties/src/lib.rs | 10 +- frame/bounties/src/tests.rs | 10 +- frame/collective/src/benchmarking.rs | 2 +- frame/collective/src/lib.rs | 12 +- frame/contracts/COMPLEXITY.md | 2 +- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/exec.rs | 8 +- frame/contracts/src/lib.rs | 18 +-- frame/contracts/src/rent.rs | 14 +- frame/contracts/src/storage.rs | 4 +- frame/contracts/src/tests.rs | 50 +++---- frame/contracts/src/wasm/code_cache.rs | 2 +- frame/contracts/src/wasm/mod.rs | 2 +- frame/democracy/src/benchmarking.rs | 2 +- frame/democracy/src/lib.rs | 22 +-- frame/democracy/src/tests.rs | 10 +- .../src/benchmarking.rs | 2 +- .../election-provider-multi-phase/src/mock.rs | 6 +- frame/elections-phragmen/src/lib.rs | 8 +- frame/elections/src/lib.rs | 8 +- frame/elections/src/mock.rs | 6 +- frame/example-offchain-worker/src/tests.rs | 4 +- frame/example-parallel/src/tests.rs | 4 +- frame/example/src/lib.rs | 6 +- frame/executive/README.md | 4 +- frame/executive/src/lib.rs | 128 +++++++++--------- frame/gilt/src/lib.rs | 4 +- frame/gilt/src/mock.rs | 6 +- frame/grandpa/src/lib.rs | 8 +- frame/grandpa/src/mock.rs | 18 +-- frame/identity/src/benchmarking.rs | 2 +- frame/identity/src/tests.rs | 6 +- frame/im-online/src/lib.rs | 2 +- frame/im-online/src/mock.rs | 8 +- frame/indices/src/mock.rs | 6 +- frame/lottery/src/lib.rs | 4 +- frame/lottery/src/mock.rs | 6 +- frame/membership/src/lib.rs | 4 +- .../primitives/src/lib.rs | 4 +- frame/merkle-mountain-range/src/mock.rs | 6 +- frame/merkle-mountain-range/src/tests.rs | 4 +- frame/multisig/src/lib.rs | 4 +- frame/multisig/src/tests.rs | 8 +- frame/nicks/src/lib.rs | 6 +- frame/node-authorization/src/lib.rs | 4 +- frame/offences/benchmarking/src/lib.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 16 +-- frame/offences/src/mock.rs | 4 +- frame/proxy/src/benchmarking.rs | 6 +- frame/proxy/src/lib.rs | 8 +- frame/proxy/src/tests.rs | 16 +-- frame/randomness-collective-flip/src/lib.rs | 8 +- frame/recovery/src/lib.rs | 8 +- frame/recovery/src/mock.rs | 6 +- frame/scheduler/src/benchmarking.rs | 2 +- frame/scheduler/src/lib.rs | 8 +- frame/scored-pool/src/mock.rs | 6 +- frame/scored-pool/src/tests.rs | 4 +- frame/session/benchmarking/src/mock.rs | 10 +- frame/session/src/historical/mod.rs | 2 +- frame/session/src/historical/offchain.rs | 4 +- frame/session/src/historical/onchain.rs | 2 +- frame/session/src/lib.rs | 8 +- frame/session/src/mock.rs | 16 +-- frame/society/src/lib.rs | 6 +- frame/society/src/mock.rs | 8 +- frame/staking/fuzzer/src/mock.rs | 12 +- frame/staking/src/lib.rs | 10 +- frame/staking/src/mock.rs | 10 +- frame/sudo/src/mock.rs | 6 +- frame/support/procedural/src/lib.rs | 14 +- .../src/pallet/expand/pallet_struct.rs | 2 + frame/support/src/dispatch.rs | 5 +- frame/support/src/metadata.rs | 8 +- frame/support/test/src/lib.rs | 2 +- frame/support/test/tests/construct_runtime.rs | 22 +-- .../conflicting_module_name.rs | 6 +- .../conflicting_module_name.stderr | 4 +- .../double_module_parts.rs | 2 +- .../generics_in_invalid_module.rs | 2 +- .../invalid_module_entry.rs | 2 +- ...g_event_generic_on_module_with_instance.rs | 2 +- ..._origin_generic_on_module_with_instance.rs | 2 +- .../missing_system_module.stderr | 2 +- frame/support/test/tests/instance.rs | 16 +-- frame/support/test/tests/issue2219.rs | 4 +- frame/support/test/tests/pallet.rs | 12 +- .../test/tests/pallet_compatibility.rs | 6 +- .../tests/pallet_compatibility_instance.rs | 14 +- frame/support/test/tests/pallet_instance.rs | 38 +++--- frame/support/test/tests/pallet_version.rs | 22 +-- .../tests/pallet_with_name_trait_is_valid.rs | 4 +- frame/system/README.md | 4 +- frame/system/benches/bench.rs | 4 +- frame/system/benchmarking/src/lib.rs | 2 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/extensions/check_genesis.rs | 4 +- .../system/src/extensions/check_mortality.rs | 8 +- .../src/extensions/check_spec_version.rs | 4 +- .../system/src/extensions/check_tx_version.rs | 4 +- frame/system/src/extensions/check_weight.rs | 6 +- frame/system/src/lib.rs | 24 ++-- frame/system/src/mock.rs | 2 +- frame/timestamp/src/lib.rs | 4 +- frame/tips/src/lib.rs | 4 +- frame/tips/src/tests.rs | 10 +- frame/transaction-payment/src/lib.rs | 10 +- frame/treasury/src/tests.rs | 8 +- frame/utility/src/benchmarking.rs | 2 +- frame/utility/src/tests.rs | 10 +- frame/vesting/src/benchmarking.rs | 2 +- frame/vesting/src/lib.rs | 10 +- .../runtime/src/offchain/storage_lock.rs | 4 +- test-utils/runtime/src/lib.rs | 8 +- utils/frame/remote-externalities/src/lib.rs | 2 +- 140 files changed, 614 insertions(+), 611 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index d33670f2e9cb0..1ebe3bee6090c 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -7,7 +7,7 @@ use sp_runtime::{ use frame_system as system; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( @@ -16,8 +16,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - TemplateModule: pallet_template::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + TemplateModule: pallet_template::{Pallet, Call, Storage, Event}, } ); diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 0f026db5735cc..251fe4d298139 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -270,16 +270,16 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Config, Storage, Event}, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Aura: pallet_aura::{Module, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, - Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Aura: pallet_aura::{Pallet, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, + Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, // Include the custom logic from the template pallet in the runtime. - TemplateModule: template::{Module, Call, Storage, Event}, + TemplateModule: template::{Pallet, Call, Storage, Event}, } ); @@ -313,7 +313,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllModules, + AllPallets, >; impl_runtime_apis! { @@ -453,7 +453,7 @@ impl_runtime_apis! { ) -> Result, sp_runtime::RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; - use frame_system_benchmarking::Module as SystemBench; + use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} let whitelist: Vec = vec![ diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 279b6a776031a..0d228678aeecd 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -600,13 +600,13 @@ fn deploying_wasm_contract_should_work() { let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap(); let transfer_ch = ::Hashing::hash(&transfer_code); - let addr = pallet_contracts::Module::::contract_address( + let addr = pallet_contracts::Pallet::::contract_address( &charlie(), &transfer_ch, &[], ); - let subsistence = pallet_contracts::Module::::subsistence_threshold(); + let subsistence = pallet_contracts::Pallet::::subsistence_threshold(); let time = 42 * 1000; let b = construct_block( diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index bb372f31c73b9..bd50ed367879c 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -379,7 +379,7 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Module; + type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; } @@ -1005,7 +1005,7 @@ impl pallet_mmr::Config for Runtime { const INDEXING_PREFIX: &'static [u8] = b"mmr"; type Hashing = ::Hashing; type Hash = ::Hash; - type LeafData = frame_system::Module; + type LeafData = frame_system::Pallet; type OnNewRoot = (); type WeightInfo = (); } @@ -1085,44 +1085,44 @@ construct_runtime!( NodeBlock = node_primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Config, Storage, Event}, - Utility: pallet_utility::{Module, Call, Event}, - Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, - Indices: pallet_indices::{Module, Call, Storage, Config, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, - ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Module, Call, Storage, Event, ValidateUnsigned}, - Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - Democracy: pallet_democracy::{Module, Call, Storage, Config, Event}, - Council: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, - TechnicalCommittee: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, - Elections: pallet_elections_phragmen::{Module, Call, Storage, Event, Config}, - TechnicalMembership: pallet_membership::::{Module, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, - Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, - Contracts: pallet_contracts::{Module, Call, Config, Storage, Event}, - Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, - ImOnline: pallet_im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, - AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, - Offences: pallet_offences::{Module, Call, Storage, Event}, - Historical: pallet_session_historical::{Module}, - RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Identity: pallet_identity::{Module, Call, Storage, Event}, - Society: pallet_society::{Module, Call, Storage, Event, Config}, - Recovery: pallet_recovery::{Module, Call, Storage, Event}, - Vesting: pallet_vesting::{Module, Call, Storage, Event, Config}, - Scheduler: pallet_scheduler::{Module, Call, Storage, Event}, - Proxy: pallet_proxy::{Module, Call, Storage, Event}, - Multisig: pallet_multisig::{Module, Call, Storage, Event}, - Bounties: pallet_bounties::{Module, Call, Storage, Event}, - Tips: pallet_tips::{Module, Call, Storage, Event}, - Assets: pallet_assets::{Module, Call, Storage, Event}, - Mmr: pallet_mmr::{Module, Storage}, - Lottery: pallet_lottery::{Module, Call, Storage, Event}, - Gilt: pallet_gilt::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Utility: pallet_utility::{Pallet, Call, Event}, + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, + Indices: pallet_indices::{Pallet, Call, Storage, Config, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, + ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned}, + Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event}, + Council: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config}, + TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config}, + Elections: pallet_elections_phragmen::{Pallet, Call, Storage, Event, Config}, + TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + Contracts: pallet_contracts::{Pallet, Call, Config, Storage, Event}, + Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config}, + Offences: pallet_offences::{Pallet, Call, Storage, Event}, + Historical: pallet_session_historical::{Pallet}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, + Identity: pallet_identity::{Pallet, Call, Storage, Event}, + Society: pallet_society::{Pallet, Call, Storage, Event, Config}, + Recovery: pallet_recovery::{Pallet, Call, Storage, Event}, + Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config}, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event}, + Proxy: pallet_proxy::{Pallet, Call, Storage, Event}, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event}, + Bounties: pallet_bounties::{Pallet, Call, Storage, Event}, + Tips: pallet_tips::{Pallet, Call, Storage, Event}, + Assets: pallet_assets::{Pallet, Call, Storage, Event}, + Mmr: pallet_mmr::{Pallet, Storage}, + Lottery: pallet_lottery::{Pallet, Call, Storage, Event}, + Gilt: pallet_gilt::{Pallet, Call, Storage, Event, Config}, } ); @@ -1162,7 +1162,7 @@ pub type Executive = frame_executive::Executive< Block, frame_system::ChainContext, Runtime, - AllModules, + AllPallets, (), >; @@ -1436,7 +1436,7 @@ impl_runtime_apis! { // which is why we need these two lines below. use pallet_session_benchmarking::Module as SessionBench; use pallet_offences_benchmarking::Module as OffencesBench; - use frame_system_benchmarking::Module as SystemBench; + use frame_system_benchmarking::Pallet as SystemBench; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 42f876ff7f3de..99ee5e99d1cf3 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -120,7 +120,7 @@ fn add_approvals(minter: T::AccountId, n: u32) { } fn assert_last_event(generic_event: ::Event) { - let events = frame_system::Module::::events(); + let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; @@ -193,7 +193,7 @@ benchmarks! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) verify { - assert!(frame_system::Module::::account_exists(&caller)); + assert!(frame_system::Pallet::::account_exists(&caller)); assert_last_event::(Event::Transferred(Default::default(), caller, target, amount).into()); } diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index e5cb39db2b8e5..b8d436f106bbb 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -1375,11 +1375,11 @@ impl Pallet { ) -> Result { let accounts = d.accounts.checked_add(1).ok_or(Error::::Overflow)?; let is_sufficient = if d.is_sufficient { - frame_system::Module::::inc_sufficients(who); + frame_system::Pallet::::inc_sufficients(who); d.sufficients += 1; true } else { - frame_system::Module::::inc_consumers(who).map_err(|_| Error::::NoProvider)?; + frame_system::Pallet::::inc_consumers(who).map_err(|_| Error::::NoProvider)?; false }; d.accounts = accounts; @@ -1393,9 +1393,9 @@ impl Pallet { ) { if sufficient { d.sufficients = d.sufficients.saturating_sub(1); - frame_system::Module::::dec_sufficients(who); + frame_system::Pallet::::dec_sufficients(who); } else { - frame_system::Module::::dec_consumers(who); + frame_system::Pallet::::dec_consumers(who); } d.accounts = d.accounts.saturating_sub(1); } diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 434a7ccce0757..806d85ce71947 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -33,9 +33,9 @@ construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Assets: pallet_assets::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Assets: pallet_assets::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/assets/src/tests.rs b/frame/assets/src/tests.rs index 89173b64d5898..1fe9358dcbff7 100644 --- a/frame/assets/src/tests.rs +++ b/frame/assets/src/tests.rs @@ -23,7 +23,7 @@ use frame_support::{assert_ok, assert_noop, traits::Currency}; use pallet_balances::Error as BalancesError; fn last_event() -> mock::Event { - frame_system::Module::::events().pop().expect("Event expected").event + frame_system::Pallet::::events().pop().expect("Event expected").event } #[test] diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index e6d44d73c40d2..536a452c115dc 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -191,7 +191,7 @@ decl_event!( { /// Swap created. \[account, proof, swap\] NewSwap(AccountId, HashedProof, PendingSwap), - /// Swap claimed. The last parameter indicates whether the execution succeeds. + /// Swap claimed. The last parameter indicates whether the execution succeeds. /// \[account, proof, success\] SwapClaimed(AccountId, HashedProof, bool), /// Swap cancelled. \[account, proof\] @@ -237,7 +237,7 @@ decl_module! { let swap = PendingSwap { source, action, - end_block: frame_system::Module::::block_number() + duration, + end_block: frame_system::Pallet::::block_number() + duration, }; PendingSwaps::::insert(target.clone(), hashed_proof.clone(), swap.clone()); @@ -307,7 +307,7 @@ decl_module! { Error::::SourceMismatch, ); ensure!( - frame_system::Module::::block_number() >= swap.end_block, + frame_system::Pallet::::block_number() >= swap.end_block, Error::::DurationNotPassed, ); diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 977b17f8710e3..baa9a08957d4a 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -19,9 +19,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - AtomicSwap: pallet_atomic_swap::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event}, } ); diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 17484461cdeff..40d17115412fe 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -130,7 +130,7 @@ impl Pallet { AURA_ENGINE_ID, ConsensusLog::AuthoritiesChange(new).encode() ); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } fn initialize_authorities(authorities: &[T::AuthorityId]) { @@ -194,7 +194,7 @@ impl OneSessionHandler for Pallet { ConsensusLog::::OnDisabled(i as AuthorityIndex).encode(), ); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index a5ef12f5935f1..481edbaff487f 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -34,9 +34,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Aura: pallet_aura::{Module, Call, Storage, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Aura: pallet_aura::{Pallet, Call, Storage, Config}, } ); diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index cc3f41f59ed89..ca8f3eeff3d68 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -136,9 +136,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config}, } ); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 3d89ab24d01cf..286abc721cbba 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -234,7 +234,7 @@ impl Module { return author; } - let digest = >::digest(); + let digest = >::digest(); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) { ::Author::put(&author); @@ -245,7 +245,7 @@ impl Module { } fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::DispatchResult { - let now = >::block_number(); + let now = >::block_number(); let mut uncles = ::Uncles::get(); uncles.push(UncleEntryItem::InclusionHeight(now)); @@ -278,7 +278,7 @@ impl Module { accumulator: &mut >::Accumulator, ) -> Result, dispatch::DispatchError> { - let now = >::block_number(); + let now = >::block_number(); let (minimum_height, maximum_height) = { let uncle_generations = T::UncleGenerations::get(); @@ -303,7 +303,7 @@ impl Module { { let parent_number = uncle.number().clone() - One::one(); - let parent_hash = >::block_hash(&parent_number); + let parent_hash = >::block_hash(&parent_number); if &parent_hash != uncle.parent_hash() { return Err(Error::::InvalidUncleParent.into()); } @@ -314,7 +314,7 @@ impl Module { } let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some(); - let in_chain = >::block_hash(uncle.number()) == hash; + let in_chain = >::block_hash(uncle.number()) == hash; if duplicate || in_chain { return Err(Error::::UncleAlreadyIncluded.into()) @@ -413,8 +413,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, } ); diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 00bfa4f2656c9..ad38c34589af3 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -480,7 +480,7 @@ impl Module { // Update the start blocks of the previous and new current epoch. >::mutate(|(previous_epoch_start_block, current_epoch_start_block)| { *previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block); - *current_epoch_start_block = >::block_number(); + *current_epoch_start_block = >::block_number(); }); // After we update the current epoch, we signal the *next* epoch change @@ -560,7 +560,7 @@ impl Module { fn deposit_consensus(new: U) { let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode()); - >::deposit_log(log.into()) + >::deposit_log(log.into()) } fn deposit_randomness(randomness: &schnorrkel::Randomness) { @@ -586,7 +586,7 @@ impl Module { return; } - let maybe_pre_digest: Option = >::digest() + let maybe_pre_digest: Option = >::digest() .logs .iter() .filter_map(|s| s.as_pre_runtime()) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c46b55c2c4ace..31a26c6291b0c 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -51,14 +51,14 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Historical: pallet_session_historical::{Module}, - Offences: pallet_offences::{Module, Call, Storage, Event}, - Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned}, - Staking: pallet_staking::{Module, Call, Storage, Config, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Historical: pallet_session_historical::{Pallet}, + Offences: pallet_offences::{Pallet, Call, Storage, Event}, + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, + Staking: pallet_staking::{Pallet, Call, Storage, Config, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, } ); @@ -203,7 +203,7 @@ impl pallet_staking::Config for Test { type SlashDeferDuration = SlashDeferDuration; type SlashCancelOrigin = frame_system::EnsureRoot; type SessionInterface = Self; - type UnixTime = pallet_timestamp::Module; + type UnixTime = pallet_timestamp::Pallet; type RewardCurve = RewardCurve; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type NextNewSession = Session; diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index 71412a962becf..7c5c4aadf1823 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -143,6 +143,6 @@ impl RandomnessT, T::BlockNumber> for CurrentBlockRan T::Hashing::hash(&subject[..]) }); - (random, >::block_number()) + (random, >::block_number()) } } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index cc7b6351c2584..8908f4c097750 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -624,7 +624,7 @@ pub struct DustCleaner, I: 'static = ()>(Option<(T::AccountId, Nega impl, I: 'static> Drop for DustCleaner { fn drop(&mut self) { if let Some((who, dust)) = self.0.take() { - Module::::deposit_event(Event::DustLost(who, dust.peek())); + Pallet::::deposit_event(Event::DustLost(who, dust.peek())); T::DustRemoval::on_unbalanced(dust); } } diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 776cda140efb8..da6c99d46ced8 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -55,7 +55,7 @@ macro_rules! decl_tests { } fn last_event() -> Event { - system::Module::::events().pop().expect("Event expected").event + system::Pallet::::events().pop().expect("Event expected").event } #[test] diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 14dfd0c4b33d6..90bcaf1a480ad 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -30,7 +30,7 @@ use frame_support::weights::{Weight, DispatchInfo, IdentityFee}; use pallet_transaction_payment::CurrencyAdapter; use crate::{ self as pallet_balances, - Module, Config, decl_tests, + Pallet, Config, decl_tests, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -41,8 +41,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } ); @@ -80,7 +80,7 @@ parameter_types! { pub const TransactionByteFee: u64 = 1; } impl pallet_transaction_payment::Config for Test { - type OnChargeTransaction = CurrencyAdapter, ()>; + type OnChargeTransaction = CurrencyAdapter, ()>; type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 02088e88b98ec..10ea74d8887bc 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim; use frame_support::weights::{Weight, DispatchInfo, IdentityFee}; use crate::{ self as pallet_balances, - Module, Config, decl_tests, + Pallet, Config, decl_tests, }; use pallet_transaction_payment::CurrencyAdapter; @@ -43,8 +43,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } ); @@ -82,7 +82,7 @@ parameter_types! { pub const TransactionByteFee: u64 = 1; } impl pallet_transaction_payment::Config for Test { - type OnChargeTransaction = CurrencyAdapter, ()>; + type OnChargeTransaction = CurrencyAdapter, ()>; type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 020c514b6317c..547c7dd7cfb72 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim; use frame_support::weights::{IdentityFee}; use crate::{ self as pallet_balances, - Module, Config, + Pallet, Config, }; use pallet_transaction_payment::CurrencyAdapter; @@ -47,7 +47,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; fn last_event() -> Event { - system::Module::::events().pop().expect("Event expected").event + system::Pallet::::events().pop().expect("Event expected").event } frame_support::construct_runtime!( @@ -56,8 +56,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, } ); @@ -95,7 +95,7 @@ parameter_types! { pub const TransactionByteFee: u64 = 1; } impl pallet_transaction_payment::Config for Test { - type OnChargeTransaction = CurrencyAdapter, ()>; + type OnChargeTransaction = CurrencyAdapter, ()>; type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index c2f60a5e13c41..b7f8303cb2609 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -744,8 +744,8 @@ macro_rules! impl_benchmark { >::instance(&selected_benchmark, c, verify)?; // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Module::::block_number()) { - frame_system::Module::::set_block_number(1u32.into()); + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); } // Commit the externalities to the database, flushing the DB cache. @@ -915,8 +915,8 @@ macro_rules! impl_benchmark_test { >::instance(&selected_benchmark, &c, true)?; // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Module::::block_number()) { - frame_system::Module::::set_block_number(1u32.into()); + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); } // Run execution + verification diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 8431f3e46c277..7b872e52941e6 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -76,8 +76,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - TestPallet: pallet_test::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + TestPallet: pallet_test::{Pallet, Call, Storage}, } ); diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 632f951f05e19..cb7933079763a 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -84,7 +84,7 @@ fn setup_pot_account() { } fn assert_last_event(generic_event: ::Event) { - let events = frame_system::Module::::events(); + let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len() - 1]; @@ -122,7 +122,7 @@ benchmarks! { let (curator_lookup, bounty_id) = create_bounty::()?; Bounties::::on_initialize(T::BlockNumber::zero()); let bounty_id = BountyCount::get() - 1; - frame_system::Module::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); + frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), bounty_id) @@ -159,7 +159,7 @@ benchmarks! { let beneficiary = T::Lookup::unlookup(beneficiary_account.clone()); Bounties::::award_bounty(RawOrigin::Signed(curator.clone()).into(), bounty_id, beneficiary)?; - frame_system::Module::::set_block_number(T::BountyDepositPayoutDelay::get()); + frame_system::Pallet::::set_block_number(T::BountyDepositPayoutDelay::get()); ensure!(T::Currency::free_balance(&beneficiary_account).is_zero(), "Beneficiary already has balance"); }: _(RawOrigin::Signed(curator), bounty_id) diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index ba0d4a5b16cb4..7d6cd6fc1439c 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -424,7 +424,7 @@ decl_module! { // If the sender is not the curator, and the curator is inactive, // slash the curator. if sender != *curator { - let block_number = system::Module::::block_number(); + let block_number = system::Pallet::::block_number(); if *update_due < block_number { slash_curator(curator, &mut bounty.curator_deposit); // Continue to change bounty status below... @@ -479,7 +479,7 @@ decl_module! { T::Currency::reserve(curator, deposit)?; bounty.curator_deposit = deposit; - let update_due = system::Module::::block_number() + T::BountyUpdatePeriod::get(); + let update_due = system::Pallet::::block_number() + T::BountyUpdatePeriod::get(); bounty.status = BountyStatus::Active { curator: curator.clone(), update_due }; Ok(()) @@ -518,7 +518,7 @@ decl_module! { bounty.status = BountyStatus::PendingPayout { curator: signer, beneficiary: beneficiary.clone(), - unlock_at: system::Module::::block_number() + T::BountyDepositPayoutDelay::get(), + unlock_at: system::Pallet::::block_number() + T::BountyDepositPayoutDelay::get(), }; Ok(()) @@ -543,7 +543,7 @@ decl_module! { Bounties::::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult { let bounty = maybe_bounty.take().ok_or(Error::::InvalidIndex)?; if let BountyStatus::PendingPayout { curator, beneficiary, unlock_at } = bounty.status { - ensure!(system::Module::::block_number() >= unlock_at, Error::::Premature); + ensure!(system::Pallet::::block_number() >= unlock_at, Error::::Premature); let bounty_account = Self::bounty_account_id(bounty_id); let balance = T::Currency::free_balance(&bounty_account); let fee = bounty.fee.min(balance); // just to be safe @@ -649,7 +649,7 @@ decl_module! { match bounty.status { BountyStatus::Active { ref curator, ref mut update_due } => { ensure!(*curator == signer, Error::::RequireCurator); - *update_due = (system::Module::::block_number() + T::BountyUpdatePeriod::get()).max(*update_due); + *update_due = (system::Pallet::::block_number() + T::BountyUpdatePeriod::get()).max(*update_due); }, _ => return Err(Error::::UnexpectedStatus.into()), } diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index cbff502daa65e..617f186975269 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -43,10 +43,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Bounties: pallet_bounties::{Module, Call, Storage, Event}, - Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Bounties: pallet_bounties::{Pallet, Call, Storage, Event}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, } ); @@ -107,7 +107,7 @@ parameter_types! { // impl pallet_treasury::Config for Test { impl pallet_treasury::Config for Test { type ModuleId = TreasuryModuleId; - type Currency = pallet_balances::Module; + type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; type Event = Event; diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 1afdd14b1ad38..cd4fcfba5fe1e 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -31,7 +31,7 @@ use sp_runtime::traits::Bounded; use sp_std::mem::size_of; use frame_system::Call as SystemCall; -use frame_system::Module as System; +use frame_system::Pallet as System; use crate::Module as Collective; const SEED: u32 = 0; diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 6d9066bca241c..28c2ff77b81fe 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -472,7 +472,7 @@ decl_module! { let index = Self::proposal_count(); >::mutate(|i| *i += 1); >::insert(proposal_hash, *proposal); - let end = system::Module::::block_number() + T::MotionDuration::get(); + let end = system::Pallet::::block_number() + T::MotionDuration::get(); let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end }; >::insert(proposal_hash, votes); @@ -647,7 +647,7 @@ decl_module! { } // Only allow actual closing of the proposal after the voting period has ended. - ensure!(system::Module::::block_number() >= voting.end, Error::::TooEarly); + ensure!(system::Pallet::::block_number() >= voting.end, Error::::TooEarly); let prime_vote = Self::prime().map(|who| voting.ayes.iter().any(|a| a == &who)); @@ -1045,10 +1045,10 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, - Collective: collective::::{Module, Call, Event, Origin, Config}, - CollectiveMajority: collective::::{Module, Call, Event, Origin, Config}, - DefaultCollective: collective::{Module, Call, Event, Origin, Config}, + System: system::{Pallet, Call, Event}, + Collective: collective::::{Pallet, Call, Event, Origin, Config}, + CollectiveMajority: collective::::{Pallet, Call, Event, Origin, Config}, + DefaultCollective: collective::{Pallet, Call, Event, Origin, Config}, } ); diff --git a/frame/contracts/COMPLEXITY.md b/frame/contracts/COMPLEXITY.md index 32f6f84b89b6a..f0e5a035586bc 100644 --- a/frame/contracts/COMPLEXITY.md +++ b/frame/contracts/COMPLEXITY.md @@ -176,7 +176,7 @@ Before a call or instantiate can be performed the execution context must be init For the first call or instantiation in the handling of an extrinsic, this involves two calls: 1. `>::now()` -2. `>::block_number()` +2. `>::block_number()` The complexity of initialization depends on the complexity of these functions. In the current implementation they just involve a DB read. diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index d41154e995a67..dd313e98ef4c8 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -37,7 +37,7 @@ use self::{ sandbox::Sandbox, }; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; -use frame_system::{Module as System, RawOrigin}; +use frame_system::{Pallet as System, RawOrigin}; use parity_wasm::elements::{Instruction, ValueType, BlockType}; use sp_runtime::traits::{Hash, Bounded, Zero}; use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec}; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 427cf1ada5ad5..a0752d9e05d6f 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -16,7 +16,7 @@ // limitations under the License. use crate::{ - CodeHash, Event, Config, Module as Contracts, + CodeHash, Event, Config, Pallet as Contracts, TrieId, BalanceOf, ContractInfo, gas::GasMeter, rent::Rent, storage::{self, Storage}, Error, ContractInfoOf, Schedule, AliveContractInfo, }; @@ -384,7 +384,7 @@ where depth: 0, schedule, timestamp: T::Time::now(), - block_number: >::block_number(), + block_number: >::block_number(), _phantom: Default::default(), } } @@ -909,7 +909,7 @@ fn deposit_event( topics: Vec, event: Event, ) { - >::deposit_event_indexed( + >::deposit_event_indexed( &*topics, ::Event::from(event).into(), ) @@ -961,7 +961,7 @@ mod tests { } fn events() -> Vec> { - >::events() + >::events() .into_iter() .filter_map(|meta| match meta.event { MetaEvent::pallet_contracts(contract_event) => Some(contract_event), diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 5453e079e3ae4..b12bb9214576c 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! # Contract Module +//! # Contract Pallet //! //! The Contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts. //! @@ -124,7 +124,7 @@ use frame_support::{ traits::{OnUnbalanced, Currency, Get, Time, Randomness}, weights::{Weight, PostDispatchInfo, WithPostDispatchInfo}, }; -use frame_system::Module as System; +use frame_system::Pallet as System; use pallet_contracts_primitives::{ RentProjectionResult, GetStorageResult, ContractAccessError, ContractExecResult, }; @@ -290,7 +290,7 @@ pub mod pallet { schedule: Schedule ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - if >::current_schedule().version > schedule.version { + if >::current_schedule().version > schedule.version { Err(Error::::InvalidScheduleVersion)? } Self::deposit_event(Event::ScheduleUpdated(schedule.version)); @@ -316,7 +316,7 @@ pub mod pallet { let origin = ensure_signed(origin)?; let dest = T::Lookup::lookup(dest)?; let mut gas_meter = GasMeter::new(gas_limit); - let schedule = >::current_schedule(); + let schedule = >::current_schedule(); let mut ctx = ExecutionContext::>::top_level(origin, &schedule); let (result, code_len) = match ctx.call(dest, value, &mut gas_meter, data) { Ok((output, len)) => (Ok(output), len), @@ -365,7 +365,7 @@ pub mod pallet { let code_len = code.len() as u32; ensure!(code_len <= T::MaxCodeSize::get(), Error::::CodeTooLarge); let mut gas_meter = GasMeter::new(gas_limit); - let schedule = >::current_schedule(); + let schedule = >::current_schedule(); let executable = PrefabWasmModule::from_code(code, &schedule)?; let code_len = executable.code_len(); ensure!(code_len <= T::MaxCodeSize::get(), Error::::CodeTooLarge); @@ -397,7 +397,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let origin = ensure_signed(origin)?; let mut gas_meter = GasMeter::new(gas_limit); - let schedule = >::current_schedule(); + let schedule = >::current_schedule(); let executable = PrefabWasmModule::from_storage(code_hash, &schedule, &mut gas_meter)?; let mut ctx = ExecutionContext::>::top_level(origin, &schedule); let code_len = executable.code_len(); @@ -665,7 +665,7 @@ pub mod pallet { } } -impl Module +impl Pallet where T::AccountId: UncheckedFrom + AsRef<[u8]>, { @@ -683,7 +683,7 @@ where input_data: Vec, ) -> ContractExecResult { let mut gas_meter = GasMeter::new(gas_limit); - let schedule = >::current_schedule(); + let schedule = >::current_schedule(); let mut ctx = ExecutionContext::>::top_level(origin, &schedule); let result = ctx.call(dest, value, &mut gas_meter, input_data); let gas_consumed = gas_meter.gas_spent(); @@ -746,7 +746,7 @@ where /// Store code for benchmarks which does not check nor instrument the code. #[cfg(feature = "runtime-benchmarks")] fn store_code_raw(code: Vec) -> frame_support::dispatch::DispatchResult { - let schedule = >::current_schedule(); + let schedule = >::current_schedule(); PrefabWasmModule::store_code_unchecked(code, &schedule)?; Ok(()) } diff --git a/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs index e9befeee2d370..9b3a3f731a2a4 100644 --- a/frame/contracts/src/rent.rs +++ b/frame/contracts/src/rent.rs @@ -18,7 +18,7 @@ //! A module responsible for computing the right amount of weight and charging it. use crate::{ - AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Module, Event, + AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Pallet, Event, TombstoneContractInfo, Config, CodeHash, Error, storage::Storage, wasm::PrefabWasmModule, exec::Executable, }; @@ -124,7 +124,7 @@ where free_balance: &BalanceOf, contract: &AliveContractInfo, ) -> Option> { - let subsistence_threshold = Module::::subsistence_threshold(); + let subsistence_threshold = Pallet::::subsistence_threshold(); // Reserved balance contributes towards the subsistence threshold to stay consistent // with the existential deposit where the reserved balance is also counted. if *total_balance < subsistence_threshold { @@ -268,7 +268,7 @@ where let tombstone_info = ContractInfo::Tombstone(tombstone); >::insert(account, &tombstone_info); code.drop_from_storage(); - >::deposit_event(Event::Evicted(account.clone())); + >::deposit_event(Event::Evicted(account.clone())); Ok(None) } (Verdict::Evict { amount: _ }, None) => { @@ -298,7 +298,7 @@ where contract: AliveContractInfo, code_size: u32, ) -> Result>, DispatchError> { - let current_block_number = >::block_number(); + let current_block_number = >::block_number(); let verdict = Self::consider_case( account, current_block_number, @@ -333,7 +333,7 @@ where }; let module = PrefabWasmModule::::from_storage_noinstr(contract.code_hash)?; let code_len = module.code_len(); - let current_block_number = >::block_number(); + let current_block_number = >::block_number(); let verdict = Self::consider_case( account, current_block_number, @@ -384,7 +384,7 @@ where let module = PrefabWasmModule::from_storage_noinstr(alive_contract_info.code_hash) .map_err(|_| IsTombstone)?; let code_size = module.occupied_storage(); - let current_block_number = >::block_number(); + let current_block_number = >::block_number(); let verdict = Self::consider_case( account, current_block_number, @@ -465,7 +465,7 @@ where let child_trie_info = origin_contract.child_trie_info(); - let current_block = >::block_number(); + let current_block = >::block_number(); if origin_contract.last_write == Some(current_block) { return Err((Error::::InvalidContractOrigin.into(), 0, 0)); diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 970eec2003668..a73569a886280 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -117,7 +117,7 @@ where .and_then(|val| val.checked_add(new_value_len)) .ok_or_else(|| Error::::StorageExhausted)?; - new_info.last_write = Some(>::block_number()); + new_info.last_write = Some(>::block_number()); >::insert(&account, ContractInfo::Alive(new_info)); // Finally, perform the change on the storage. @@ -176,7 +176,7 @@ where // We want to charge rent for the first block in advance. Therefore we // treat the contract as if it was created in the last block and then // charge rent for it during instantiation. - >::block_number().saturating_sub(1u32.into()), + >::block_number().saturating_sub(1u32.into()), rent_allowance: >::max_value(), rent_payed: >::zero(), pair_count: 0, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 2fa09e3405c1c..d35cf7bb1d8dc 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -16,7 +16,7 @@ // limitations under the License. use crate::{ - BalanceOf, ContractInfo, ContractInfoOf, Module, + BalanceOf, ContractInfo, ContractInfoOf, Pallet, RawAliveContractInfo, Config, Schedule, Error, storage::Storage, chain_extension::{ @@ -57,11 +57,11 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Randomness: pallet_randomness_collective_flip::{Module, Call, Storage}, - Contracts: pallet_contracts::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Randomness: pallet_randomness_collective_flip::{Pallet, Call, Storage}, + Contracts: pallet_contracts::{Pallet, Call, Config, Storage, Event}, } ); @@ -72,7 +72,7 @@ pub mod test_utils { ContractInfoOf, CodeHash, storage::Storage, exec::{StorageKey, AccountIdOf}, - Module as Contracts, + Pallet as Contracts, }; use frame_support::traits::Currency; @@ -457,7 +457,7 @@ fn instantiate_and_call_and_deposit_event() { .build() .execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); // Check at the end to get hash on error easily let creation = Contracts::instantiate_with_code( @@ -572,7 +572,7 @@ fn deposit_event_max_value_limit() { #[test] fn run_out_of_gas() { let (wasm, code_hash) = compile_module::("run_out_of_gas").unwrap(); - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); ExtBuilder::default() .existential_deposit(50) @@ -908,7 +908,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf) -> bool) { .unwrap().get_alive().unwrap().rent_allowance; let balance = Balances::free_balance(&addr); - let subsistence_threshold = Module::::subsistence_threshold(); + let subsistence_threshold = Pallet::::subsistence_threshold(); // Trigger rent must have no effect assert!(!trigger_call(addr.clone())); @@ -997,7 +997,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf) -> bool) { .build() .execute_with(|| { // Create - let subsistence_threshold = Module::::subsistence_threshold(); + let subsistence_threshold = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, subsistence_threshold * 1000); assert_ok!(Contracts::instantiate_with_code( Origin::signed(ALICE), @@ -1878,7 +1878,7 @@ fn crypto_hashes() { // We offset data in the contract tables by 1. let mut params = vec![(n + 1) as u8]; params.extend_from_slice(input); - let result = >::bare_call( + let result = >::bare_call( ALICE, addr.clone(), 0, @@ -1896,7 +1896,7 @@ fn crypto_hashes() { fn transfer_return_code() { let (wasm, code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -1943,7 +1943,7 @@ fn call_return_code() { let (caller_code, caller_hash) = compile_module::("call_return_code").unwrap(); let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence); @@ -2036,7 +2036,7 @@ fn instantiate_return_code() { let (caller_code, caller_hash) = compile_module::("instantiate_return_code").unwrap(); let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence); let callee_hash = callee_hash.as_ref().to_vec(); @@ -2127,7 +2127,7 @@ fn instantiate_return_code() { fn disabled_chain_extension_wont_deploy() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); TestExtension::disable(); assert_err_ignore_postinfo!( @@ -2148,7 +2148,7 @@ fn disabled_chain_extension_wont_deploy() { fn disabled_chain_extension_errors_on_call() { let (code, hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( Contracts::instantiate_with_code( @@ -2179,7 +2179,7 @@ fn disabled_chain_extension_errors_on_call() { fn chain_extension_works() { let (code, hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( Contracts::instantiate_with_code( @@ -2248,7 +2248,7 @@ fn chain_extension_works() { fn lazy_removal_works() { let (code, hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -2308,7 +2308,7 @@ fn lazy_removal_partial_remove_works() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let trie = ext.execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -2389,7 +2389,7 @@ fn lazy_removal_partial_remove_works() { fn lazy_removal_does_no_run_on_full_block() { let (code, hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -2473,7 +2473,7 @@ fn lazy_removal_does_no_run_on_full_block() { fn lazy_removal_does_not_use_all_weight() { let (code, hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -2543,7 +2543,7 @@ fn lazy_removal_does_not_use_all_weight() { fn deletion_queue_full() { let (code, hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); assert_ok!( @@ -2669,7 +2669,7 @@ fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); // Create two contracts with the same code and check that they do in fact share it. assert_ok!(Contracts::instantiate_with_code( @@ -2741,7 +2741,7 @@ fn reinstrument_does_charge() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let subsistence = Module::::subsistence_threshold(); + let subsistence = Pallet::::subsistence_threshold(); let zero = 0u32.to_le_bytes().encode(); let code_len = wasm.len() as u32; diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 0b2512f17f594..f9513afe51f4f 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -29,7 +29,7 @@ use crate::{ CodeHash, CodeStorage, PristineCode, Schedule, Config, Error, Weight, - wasm::{prepare, PrefabWasmModule}, Module as Contracts, Event, + wasm::{prepare, PrefabWasmModule}, Pallet as Contracts, Event, gas::{GasMeter, Token}, weights::WeightInfo, }; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 6fc6bc1764e4a..fc442473ff0f1 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -245,7 +245,7 @@ where mod tests { use super::*; use crate::{ - CodeHash, BalanceOf, Error, Module as Contracts, + CodeHash, BalanceOf, Error, Pallet as Contracts, exec::{Ext, StorageKey, AccountIdOf, Executable, RentParams}, gas::GasMeter, tests::{Test, Call, ALICE, BOB}, diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 57447944d22a7..73275fa7cb612 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -24,7 +24,7 @@ use frame_support::{ IterableStorageMap, traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime}, }; -use frame_system::{RawOrigin, Module as System, self, EventRecord}; +use frame_system::{RawOrigin, Pallet as System, self, EventRecord}; use sp_runtime::traits::{Bounded, One}; use crate::Module as Democracy; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index a7dd2d5bd9297..8790e0e487bb8 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -596,7 +596,7 @@ decl_module! { if let Some((until, _)) = >::get(proposal_hash) { ensure!( - >::block_number() >= until, + >::block_number() >= until, Error::::ProposalBlacklisted, ); } @@ -688,7 +688,7 @@ decl_module! { ensure!(!>::exists(), Error::::DuplicateProposal); if let Some((until, _)) = >::get(proposal_hash) { ensure!( - >::block_number() >= until, + >::block_number() >= until, Error::::ProposalBlacklisted, ); } @@ -776,7 +776,7 @@ decl_module! { ensure!(proposal_hash == e_proposal_hash, Error::::InvalidHash); >::kill(); - let now = >::block_number(); + let now = >::block_number(); Self::inject_referendum(now + voting_period, proposal_hash, threshold, delay); } @@ -806,7 +806,7 @@ decl_module! { .err().ok_or(Error::::AlreadyVetoed)?; existing_vetoers.insert(insert_position, who.clone()); - let until = >::block_number() + T::CooloffPeriod::get(); + let until = >::block_number() + T::CooloffPeriod::get(); >::insert(&proposal_hash, (until, existing_vetoers)); Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until)); @@ -1004,7 +1004,7 @@ decl_module! { _ => None, }).ok_or(Error::::PreimageMissing)?; - let now = >::block_number(); + let now = >::block_number(); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let additional = if who == provider { Zero::zero() } else { enactment }; ensure!(now >= since + voting + additional, Error::::TooEarly); @@ -1209,7 +1209,7 @@ impl Module { delay: T::BlockNumber ) -> ReferendumIndex { >::inject_referendum( - >::block_number() + T::VotingPeriod::get(), + >::block_number() + T::VotingPeriod::get(), proposal_hash, threshold, delay @@ -1308,7 +1308,7 @@ impl Module { Some(ReferendumInfo::Finished{end, approved}) => if let Some((lock_periods, balance)) = votes[i].1.locked_if(approved) { let unlock_at = end + T::EnactmentPeriod::get() * lock_periods.into(); - let now = system::Module::::block_number(); + let now = system::Pallet::::block_number(); if now < unlock_at { ensure!(matches!(scope, UnvoteScope::Any), Error::::NoPermission); prior.accumulate(unlock_at, balance) @@ -1435,7 +1435,7 @@ impl Module { } => { // remove any delegation votes to our current target. let votes = Self::reduce_upstream_delegation(&target, conviction.votes(balance)); - let now = system::Module::::block_number(); + let now = system::Pallet::::block_number(); let lock_periods = conviction.lock_periods().into(); prior.accumulate(now + T::EnactmentPeriod::get() * lock_periods, balance); voting.set_common(delegations, prior); @@ -1455,7 +1455,7 @@ impl Module { /// a security hole) but may be reduced from what they are currently. fn update_lock(who: &T::AccountId) { let lock_needed = VotingOf::::mutate(who, |voting| { - voting.rejig(system::Module::::block_number()); + voting.rejig(system::Pallet::::block_number()); voting.locked_balance() }); if lock_needed.is_zero() { @@ -1716,7 +1716,7 @@ impl Module { .saturating_mul(T::PreimageByteDeposit::get()); T::Currency::reserve(&who, deposit)?; - let now = >::block_number(); + let now = >::block_number(); let a = PreimageStatus::Available { data: encoded_proposal, provider: who.clone(), @@ -1738,7 +1738,7 @@ impl Module { let status = Preimages::::get(&proposal_hash).ok_or(Error::::NotImminent)?; let expiry = status.to_missing_expiry().ok_or(Error::::DuplicatePreimage)?; - let now = >::block_number(); + let now = >::block_number(); let free = >::zero(); let a = PreimageStatus::Available { data: encoded_proposal, diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 291cfa33b5224..57e845ace9f24 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -60,10 +60,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Scheduler: pallet_scheduler::{Module, Call, Storage, Config, Event}, - Democracy: pallet_democracy::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Config, Event}, + Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event}, } ); @@ -161,7 +161,7 @@ impl Contains for OneToFive { impl Config for Test { type Proposal = Call; type Event = Event; - type Currency = pallet_balances::Module; + type Currency = pallet_balances::Pallet; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index 74db28c6e3929..c62d80653379c 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Two phase election pallet benchmarking. use super::*; -use crate::Module as MultiPhase; +use crate::Pallet as MultiPhase; pub use frame_benchmarking::{account, benchmarks, whitelist_account, whitelisted_caller}; use frame_support::{assert_ok, traits::OnInitialize}; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index e7a2924fd2aa6..1fa1f0084b769 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -52,9 +52,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event, Config}, - Balances: pallet_balances::{Module, Call, Event, Config}, - MultiPhase: multi_phase::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Event, Config}, + Balances: pallet_balances::{Pallet, Call, Event, Config}, + MultiPhase: multi_phase::{Pallet, Call, Event}, } ); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 779570ca633ee..26b9c9190a965 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1096,7 +1096,7 @@ mod tests { type Event = Event; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Module; + type AccountStore = frame_system::Pallet; type MaxLocks = (); type WeightInfo = (); } @@ -1187,9 +1187,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Balances: pallet_balances::{Module, Call, Event, Config}, - Elections: elections_phragmen::{Module, Call, Event, Config}, + System: frame_system::{Pallet, Call, Event}, + Balances: pallet_balances::{Pallet, Call, Event, Config}, + Elections: elections_phragmen::{Pallet, Call, Event, Config}, } ); diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index 6eaa2dfad3732..d6b68bbf5a043 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -713,7 +713,7 @@ decl_event!( BadReaperSlashed(AccountId), /// A tally (for approval votes of \[seats\]) has started. TallyStarted(u32), - /// A tally (for approval votes of seat(s)) has ended (with one or more new members). + /// A tally (for approval votes of seat(s)) has ended (with one or more new members). /// \[incoming, outgoing\] TallyFinalized(Vec, Vec), } @@ -759,7 +759,7 @@ impl Module { // if there's a tally in progress, then next tally can begin immediately afterwards (tally_end, c.len() - leavers.len() + comers as usize, comers) } else { - (>::block_number(), c.len(), 0) + (>::block_number(), c.len(), 0) }; if count < desired_seats as usize { Some(next_possible) @@ -914,7 +914,7 @@ impl Module { fn start_tally() { let members = Self::members(); let desired_seats = Self::desired_seats() as usize; - let number = >::block_number(); + let number = >::block_number(); let expiring = members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::>(); let retaining_seats = members.len() - expiring.len(); @@ -942,7 +942,7 @@ impl Module { .ok_or("finalize can only be called after a tally is started.")?; let leaderboard: Vec<(BalanceOf, T::AccountId)> = >::take() .unwrap_or_default(); - let new_expiry = >::block_number() + Self::term_duration(); + let new_expiry = >::block_number() + Self::term_duration(); // return bond to winners. let candidacy_bond = T::CandidacyBond::get(); diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 31d3f5a1c28a5..287eaa27b196a 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -135,9 +135,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, - Balances: pallet_balances::{Module, Call, Event, Config}, - Elections: elections::{Module, Call, Event, Config}, + System: system::{Pallet, Call, Event}, + Balances: pallet_balances::{Pallet, Call, Event, Config}, + Elections: elections::{Pallet, Call, Event, Config}, } ); diff --git a/frame/example-offchain-worker/src/tests.rs b/frame/example-offchain-worker/src/tests.rs index 7707e7d61e629..e91b374adbe1d 100644 --- a/frame/example-offchain-worker/src/tests.rs +++ b/frame/example-offchain-worker/src/tests.rs @@ -49,8 +49,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Example: example_offchain_worker::{Module, Call, Storage, Event, ValidateUnsigned}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Example: example_offchain_worker::{Pallet, Call, Storage, Event, ValidateUnsigned}, } ); diff --git a/frame/example-parallel/src/tests.rs b/frame/example-parallel/src/tests.rs index da2892c67d42a..e82d75e632068 100644 --- a/frame/example-parallel/src/tests.rs +++ b/frame/example-parallel/src/tests.rs @@ -33,8 +33,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Example: pallet_example_parallel::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Example: pallet_example_parallel::{Pallet, Call, Storage}, } ); diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index 7a537f4522abf..86e9b7fdc0c18 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -758,9 +758,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Example: pallet_example::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Example: pallet_example::{Pallet, Call, Storage, Config, Event}, } ); diff --git a/frame/executive/README.md b/frame/executive/README.md index 183e32b2ff8a9..ae3bbf1a9d994 100644 --- a/frame/executive/README.md +++ b/frame/executive/README.md @@ -35,7 +35,7 @@ The default Substrate node template declares the [`Executive`](https://docs.rs/f ```rust # /// Executive: handles dispatch to the various modules. -pub type Executive = executive::Executive; +pub type Executive = executive::Executive; ``` ### Custom `OnRuntimeUpgrade` logic @@ -54,7 +54,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { } } -pub type Executive = executive::Executive; +pub type Executive = executive::Executive; ``` License: Apache-2.0 diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index f48fda4841d26..277b20cf20bfa 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -59,7 +59,7 @@ //! # type Context = frame_system::ChainContext; //! # pub type Block = generic::Block; //! # pub type Balances = u64; -//! # pub type AllModules = u64; +//! # pub type AllPallets = u64; //! # pub enum Runtime {}; //! # use sp_runtime::transaction_validity::{ //! # TransactionValidity, UnknownTransaction, TransactionSource, @@ -73,7 +73,7 @@ //! # } //! # } //! /// Executive: handles dispatch to the various modules. -//! pub type Executive = executive::Executive; +//! pub type Executive = executive::Executive; //! ``` //! //! ### Custom `OnRuntimeUpgrade` logic @@ -90,7 +90,7 @@ //! # type Context = frame_system::ChainContext; //! # pub type Block = generic::Block; //! # pub type Balances = u64; -//! # pub type AllModules = u64; +//! # pub type AllPallets = u64; //! # pub enum Runtime {}; //! # use sp_runtime::transaction_validity::{ //! # TransactionValidity, UnknownTransaction, TransactionSource, @@ -111,7 +111,7 @@ //! } //! } //! -//! pub type Executive = executive::Executive; +//! pub type Executive = executive::Executive; //! ``` #![cfg_attr(not(feature = "std"), no_std)] @@ -144,12 +144,12 @@ pub type OriginOf = as Dispatchable>::Origin; /// - `Block`: The block type of the runtime /// - `Context`: The context that is used when checking an extrinsic. /// - `UnsignedValidator`: The unsigned transaction validator of the runtime. -/// - `AllModules`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`. +/// - `AllPallets`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`. /// - `OnRuntimeUpgrade`: Custom logic that should be called after a runtime upgrade. Modules are -/// already called by `AllModules`. It will be called before all modules will +/// already called by `AllPallets`. It will be called before all modules will /// be called. -pub struct Executive( - PhantomData<(System, Block, Context, UnsignedValidator, AllModules, OnRuntimeUpgrade)> +pub struct Executive( + PhantomData<(System, Block, Context, UnsignedValidator, AllPallets, OnRuntimeUpgrade)> ); impl< @@ -157,7 +157,7 @@ impl< Block: traits::Block, Context: Default, UnsignedValidator, - AllModules: + AllPallets: OnRuntimeUpgrade + OnInitialize + OnIdle + @@ -165,7 +165,7 @@ impl< OffchainWorker, COnRuntimeUpgrade: OnRuntimeUpgrade, > ExecuteBlock for - Executive + Executive where Block::Extrinsic: Checkable + Codec, CheckedOf: @@ -176,7 +176,7 @@ where UnsignedValidator: ValidateUnsigned>, { fn execute_block(block: Block) { - Executive::::execute_block(block); + Executive::::execute_block(block); } } @@ -185,13 +185,13 @@ impl< Block: traits::Block
, Context: Default, UnsignedValidator, - AllModules: OnRuntimeUpgrade + AllPallets: OnRuntimeUpgrade + OnInitialize + OnIdle + OnFinalize + OffchainWorker, COnRuntimeUpgrade: OnRuntimeUpgrade, - > Executive + > Executive where Block::Extrinsic: Checkable + Codec, CheckedOf: Applyable + GetDispatchInfo, @@ -204,10 +204,10 @@ where pub fn execute_on_runtime_upgrade() -> frame_support::weights::Weight { let mut weight = 0; weight = weight.saturating_add( - as OnRuntimeUpgrade>::on_runtime_upgrade(), + as OnRuntimeUpgrade>::on_runtime_upgrade(), ); weight = weight.saturating_add(COnRuntimeUpgrade::on_runtime_upgrade()); - weight = weight.saturating_add(::on_runtime_upgrade()); + weight = weight.saturating_add(::on_runtime_upgrade()); weight } @@ -218,7 +218,7 @@ where #[cfg(feature = "try-runtime")] pub fn try_runtime_upgrade() -> Result { < - (frame_system::Module::, COnRuntimeUpgrade, AllModules) + (frame_system::Pallet::, COnRuntimeUpgrade, AllPallets) as OnRuntimeUpgrade >::pre_upgrade()?; @@ -226,7 +226,7 @@ where let weight = Self::execute_on_runtime_upgrade(); < - (frame_system::Module::, COnRuntimeUpgrade, AllModules) + (frame_system::Pallet::, COnRuntimeUpgrade, AllPallets) as OnRuntimeUpgrade >::post_upgrade()?; @@ -265,24 +265,24 @@ where if Self::runtime_upgraded() { weight = weight.saturating_add(Self::execute_on_runtime_upgrade()); } - >::initialize( + >::initialize( block_number, parent_hash, digest, frame_system::InitKind::Full, ); weight = weight.saturating_add( - as OnInitialize>::on_initialize(*block_number) + as OnInitialize>::on_initialize(*block_number) ); weight = weight.saturating_add( - >::on_initialize(*block_number) + >::on_initialize(*block_number) ); weight = weight.saturating_add( >::get().base_block ); - >::register_extra_weight_unchecked(weight, DispatchClass::Mandatory); + >::register_extra_weight_unchecked(weight, DispatchClass::Mandatory); - frame_system::Module::::note_finished_initialize(); + frame_system::Pallet::::note_finished_initialize(); } /// Returns if the runtime was upgraded since the last time this function was called. @@ -308,7 +308,7 @@ where let n = header.number().clone(); assert!( n > System::BlockNumber::zero() - && >::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(), + && >::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(), "Parent hash should be valid.", ); } @@ -350,7 +350,7 @@ where }); // post-extrinsics book-keeping - >::note_finished_extrinsics(); + >::note_finished_extrinsics(); Self::idle_and_finalize_hook(block_number); } @@ -360,36 +360,36 @@ where pub fn finalize_block() -> System::Header { sp_io::init_tracing(); sp_tracing::enter_span!( sp_tracing::Level::TRACE, "finalize_block" ); - >::note_finished_extrinsics(); - let block_number = >::block_number(); + >::note_finished_extrinsics(); + let block_number = >::block_number(); Self::idle_and_finalize_hook(block_number); - >::finalize() + >::finalize() } fn idle_and_finalize_hook(block_number: NumberFor) { - let weight = >::block_weight(); + let weight = >::block_weight(); let max_weight = >::get().max_block; let mut remaining_weight = max_weight.saturating_sub(weight.total()); if remaining_weight > 0 { let mut used_weight = - as OnIdle>::on_idle( + as OnIdle>::on_idle( block_number, remaining_weight ); remaining_weight = remaining_weight.saturating_sub(used_weight); - used_weight = >::on_idle( + used_weight = >::on_idle( block_number, remaining_weight ) .saturating_add(used_weight); - >::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory); + >::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory); } - as OnFinalize>::on_finalize(block_number); - >::on_finalize(block_number); + as OnFinalize>::on_finalize(block_number); + >::on_finalize(block_number); } /// Apply extrinsic outside of the block execution function. @@ -419,7 +419,7 @@ where // We don't need to make sure to `note_extrinsic` only after we know it's going to be // executed to prevent it from leaking in storage since at this point, it will either // execute or panic (and revert storage changes). - >::note_extrinsic(to_note); + >::note_extrinsic(to_note); // AUDIT: Under no circumstances may this function panic from here onwards. @@ -427,7 +427,7 @@ where let dispatch_info = xt.get_dispatch_info(); let r = Applyable::apply::(xt, &dispatch_info, encoded_len)?; - >::note_applied_extrinsic(&r, dispatch_info); + >::note_applied_extrinsic(&r, dispatch_info); Ok(r.map(|_| ()).map_err(|e| e.error)) } @@ -435,7 +435,7 @@ where fn final_checks(header: &System::Header) { sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks"); // remove temporaries - let new_header = >::finalize(); + let new_header = >::finalize(); // check digest assert_eq!( @@ -499,7 +499,7 @@ where // OffchainWorker RuntimeApi should skip initialization. let digests = header.digest().clone(); - >::initialize( + >::initialize( header.number(), header.parent_hash(), &digests, @@ -511,7 +511,7 @@ where // as well. frame_system::BlockHash::::insert(header.number(), header.hash()); - >::offchain_worker(*header.number()) + >::offchain_worker(*header.number()) } } @@ -628,9 +628,9 @@ mod tests { NodeBlock = TestBlock, UncheckedExtrinsic = TestUncheckedExtrinsic { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Custom: custom::{Module, Call, ValidateUnsigned}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Custom: custom::{Pallet, Call, ValidateUnsigned}, } ); @@ -741,7 +741,7 @@ mod tests { Block, ChainContext, Runtime, - AllModules, + AllPallets, CustomOnRuntimeUpgrade >; @@ -780,8 +780,8 @@ mod tests { )); let r = Executive::apply_extrinsic(xt); assert!(r.is_ok()); - assert_eq!(>::total_balance(&1), 142 - fee); - assert_eq!(>::total_balance(&2), 69); + assert_eq!(>::total_balance(&1), 142 - fee); + assert_eq!(>::total_balance(&2), 69); }); } @@ -857,7 +857,7 @@ mod tests { Digest::default(), )); assert!(Executive::apply_extrinsic(xt).is_err()); - assert_eq!(>::extrinsic_index(), Some(0)); + assert_eq!(>::extrinsic_index(), Some(0)); }); } @@ -883,7 +883,7 @@ mod tests { Digest::default(), )); // Base block execution weight + `on_initialize` weight from the custom module. - assert_eq!(>::block_weight().total(), base_block_weight); + assert_eq!(>::block_weight().total(), base_block_weight); for nonce in 0..=num_to_exhaust_block { let xt = TestXt::new( @@ -893,11 +893,11 @@ mod tests { if nonce != num_to_exhaust_block { assert!(res.is_ok()); assert_eq!( - >::block_weight().total(), + >::block_weight().total(), //--------------------- on_initialize + block_execution + extrinsic_base weight (encoded_len + 5) * (nonce + 1) + base_block_weight, ); - assert_eq!(>::extrinsic_index(), Some(nonce as u32 + 1)); + assert_eq!(>::extrinsic_index(), Some(nonce as u32 + 1)); } else { assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into())); } @@ -924,8 +924,8 @@ mod tests { Digest::default(), )); - assert_eq!(>::block_weight().total(), base_block_weight); - assert_eq!(>::all_extrinsics_len(), 0); + assert_eq!(>::block_weight().total(), base_block_weight); + assert_eq!(>::all_extrinsics_len(), 0); assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok()); assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok()); @@ -935,14 +935,14 @@ mod tests { let extrinsic_weight = len as Weight + ::BlockWeights ::get().get(DispatchClass::Normal).base_extrinsic; assert_eq!( - >::block_weight().total(), + >::block_weight().total(), base_block_weight + 3 * extrinsic_weight, ); - assert_eq!(>::all_extrinsics_len(), 3 * len); + assert_eq!(>::all_extrinsics_len(), 3 * len); - let _ = >::finalize(); + let _ = >::finalize(); // All extrinsics length cleaned on `System::finalize` - assert_eq!(>::all_extrinsics_len(), 0); + assert_eq!(>::all_extrinsics_len(), 0); // New Block Executive::initialize_block(&Header::new( @@ -954,7 +954,7 @@ mod tests { )); // Block weight cleaned up on `System::initialize` - assert_eq!(>::block_weight().total(), base_block_weight); + assert_eq!(>::block_weight().total(), base_block_weight); }); } @@ -989,7 +989,7 @@ mod tests { let execute_with_lock = |lock: WithdrawReasons| { let mut t = new_test_ext(1); t.execute_with(|| { - as LockableCurrency>::set_lock( + as LockableCurrency>::set_lock( id, &1, 110, @@ -1017,13 +1017,13 @@ mod tests { if lock == WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT) { assert!(Executive::apply_extrinsic(xt).unwrap().is_ok()); // tx fee has been deducted. - assert_eq!(>::total_balance(&1), 111 - fee); + assert_eq!(>::total_balance(&1), 111 - fee); } else { assert_eq!( Executive::apply_extrinsic(xt), Err(InvalidTransaction::Payment.into()), ); - assert_eq!(>::total_balance(&1), 111); + assert_eq!(>::total_balance(&1), 111); } }); }; @@ -1041,7 +1041,7 @@ mod tests { // NOTE: might need updates over time if new weights are introduced. // For now it only accounts for the base block execution weight and // the `on_initialize` weight defined in the custom test module. - assert_eq!(>::block_weight().total(), 175 + 175 + 10); + assert_eq!(>::block_weight().total(), 175 + 175 + 10); }) } @@ -1159,16 +1159,16 @@ mod tests { )); // All weights that show up in the `initialize_block_impl` - let frame_system_upgrade_weight = frame_system::Module::::on_runtime_upgrade(); + let frame_system_upgrade_weight = frame_system::Pallet::::on_runtime_upgrade(); let custom_runtime_upgrade_weight = CustomOnRuntimeUpgrade::on_runtime_upgrade(); - let runtime_upgrade_weight = ::on_runtime_upgrade(); - let frame_system_on_initialize_weight = frame_system::Module::::on_initialize(block_number); - let on_initialize_weight = >::on_initialize(block_number); + let runtime_upgrade_weight = ::on_runtime_upgrade(); + let frame_system_on_initialize_weight = frame_system::Pallet::::on_initialize(block_number); + let on_initialize_weight = >::on_initialize(block_number); let base_block_weight = ::BlockWeights::get().base_block; // Weights are recorded correctly assert_eq!( - frame_system::Module::::block_weight().total(), + frame_system::Pallet::::block_weight().total(), frame_system_upgrade_weight + custom_runtime_upgrade_weight + runtime_upgrade_weight + diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index ab35ce76742bc..bc99630993de2 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -440,7 +440,7 @@ pub mod pallet { let gilt = Active::::get(index).ok_or(Error::::Unknown)?; // If found, check the owner is `who`. ensure!(gilt.who == who, Error::::NotOwner); - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); ensure!(now >= gilt.expiry, Error::::NotExpired); // Remove it Active::::remove(index); @@ -525,7 +525,7 @@ pub mod pallet { let mut remaining = amount; let mut bids_taken = 0; let mut queues_hit = 0; - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); ActiveTotal::::mutate(|totals| { QueueTotals::::mutate(|qs| { diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index ca4ccaff73c58..5e736fe8e55b5 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -36,9 +36,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Config, Storage, Event}, - Gilt: pallet_gilt::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, + Gilt: pallet_gilt::{Pallet, Call, Config, Storage, Event}, } ); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index b68624df7b5dc..eb3dc4f110acb 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -390,7 +390,7 @@ impl Module { /// Cannot be done when already paused. pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult { if let StoredState::Live = >::get() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at, @@ -405,7 +405,7 @@ impl Module { /// Schedule a resume of GRANDPA after pausing. pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult { if let StoredState::Paused = >::get() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at, @@ -437,7 +437,7 @@ impl Module { forced: Option, ) -> DispatchResult { if !>::exists() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); if let Some(_) = forced { if Self::next_forced().map_or(false, |next| next > scheduled_at) { @@ -465,7 +465,7 @@ impl Module { /// Deposit one of this module's logs. fn deposit_log(log: ConsensusLog) { let log: DigestItem = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } // Perform module initialization, abstracted so that it can be called either through genesis diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 0a24a2344547e..adc644a9fdab2 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -51,14 +51,14 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, - Offences: pallet_offences::{Module, Call, Storage, Event}, - Historical: pallet_session_historical::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned}, + Offences: pallet_offences::{Pallet, Call, Storage, Event}, + Historical: pallet_session_historical::{Pallet}, } ); @@ -209,7 +209,7 @@ impl pallet_staking::Config for Test { type SlashDeferDuration = SlashDeferDuration; type SlashCancelOrigin = frame_system::EnsureRoot; type SessionInterface = Self; - type UnixTime = pallet_timestamp::Module; + type UnixTime = pallet_timestamp::Pallet; type RewardCurve = RewardCurve; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type NextNewSession = Session; diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index 645b3817d6ec9..b567bde32cfbe 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -30,7 +30,7 @@ use crate::Module as Identity; const SEED: u32 = 0; fn assert_last_event(generic_event: ::Event) { - let events = frame_system::Module::::events(); + let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len() - 1]; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 230079a21ea0d..a996c989a9185 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -37,9 +37,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Identity: pallet_identity::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Identity: pallet_identity::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index e00b5aa9d1395..c913712ba15e2 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -672,7 +672,7 @@ impl OneSessionHandler for Module { // Tell the offchain worker to start making the next session's heartbeats. // Since we consider producing blocks as being online, // the heartbeat is deferred a bit to prevent spamming. - let block_number = >::block_number(); + let block_number = >::block_number(); let half_session = T::NextSessionRotation::average_session_length() / 2u32.into(); >::put(block_number + half_session); diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index f8346aa536248..35028dd89df4e 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -44,10 +44,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - ImOnline: imonline::{Module, Call, Storage, Config, Event}, - Historical: pallet_session_historical::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + ImOnline: imonline::{Pallet, Call, Storage, Config, Event}, + Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 06c73b1a9bc27..01db4b50f5085 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -33,9 +33,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Indices: pallet_indices::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Indices: pallet_indices::{Pallet, Call, Storage, Config, Event}, } ); diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 8248caa06708e..84b924c173805 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -277,7 +277,7 @@ decl_module! { ensure!(lottery.is_none(), Error::::InProgress); let index = LotteryIndex::get(); let new_index = index.checked_add(1).ok_or(Error::::Overflow)?; - let start = frame_system::Module::::block_number(); + let start = frame_system::Pallet::::block_number(); // Use new_index to more easily track everything with the current state. *lottery = Some(LotteryConfig { price, @@ -392,7 +392,7 @@ impl Module { fn do_buy_ticket(caller: &T::AccountId, call: &::Call) -> DispatchResult { // Check the call is valid lottery let config = Lottery::::get().ok_or(Error::::NotConfigured)?; - let block_number = frame_system::Module::::block_number(); + let block_number = frame_system::Pallet::::block_number(); ensure!(block_number < config.start.saturating_add(config.length), Error::::AlreadyEnded); ensure!(T::ValidateCall::validate_call(call), Error::::InvalidCall); let call_index = Self::call_to_index(call)?; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 44691427c8e59..a776896921a7f 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -42,9 +42,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Lottery: pallet_lottery::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Lottery: pallet_lottery::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index f080938095445..e26af3ce9b71a 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -293,8 +293,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Membership: pallet_membership::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Membership: pallet_membership::{Pallet, Call, Storage, Config, Event}, } ); diff --git a/frame/merkle-mountain-range/primitives/src/lib.rs b/frame/merkle-mountain-range/primitives/src/lib.rs index 0887535dca0ef..73d4d3ecc1fc3 100644 --- a/frame/merkle-mountain-range/primitives/src/lib.rs +++ b/frame/merkle-mountain-range/primitives/src/lib.rs @@ -51,10 +51,10 @@ impl LeafDataProvider for () { /// so that any point in time in the future we can receive a proof about some past /// blocks without using excessive on-chain storage. /// -/// Hence we implement the [LeafDataProvider] for [frame_system::Module]. Since the +/// Hence we implement the [LeafDataProvider] for [frame_system::Pallet]. Since the /// current block hash is not available (since the block is not finished yet), /// we use the `parent_hash` here along with parent block number. -impl LeafDataProvider for frame_system::Module { +impl LeafDataProvider for frame_system::Pallet { type LeafData = ( ::BlockNumber, ::Hash diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 0adb0294d5080..072724a58afe5 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -40,8 +40,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - MMR: pallet_mmr::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + MMR: pallet_mmr::{Pallet, Call, Storage}, } ); @@ -78,7 +78,7 @@ impl Config for Test { type Hashing = Keccak256; type Hash = H256; - type LeafData = Compact, LeafData)>; + type LeafData = Compact, LeafData)>; type OnNewRoot = (); type WeightInfo = (); } diff --git a/frame/merkle-mountain-range/src/tests.rs b/frame/merkle-mountain-range/src/tests.rs index ea522dc51cd03..dfaf60ef2eab6 100644 --- a/frame/merkle-mountain-range/src/tests.rs +++ b/frame/merkle-mountain-range/src/tests.rs @@ -39,11 +39,11 @@ fn register_offchain_ext(ext: &mut sp_io::TestExternalities) { } fn new_block() -> u64 { - let number = frame_system::Module::::block_number() + 1; + let number = frame_system::Pallet::::block_number() + 1; let hash = H256::repeat_byte(number as u8); LEAF_DATA.with(|r| r.borrow_mut().a = number); - frame_system::Module::::initialize( + frame_system::Pallet::::initialize( &number, &hash, &Default::default(), diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index aa72d2d1ad3ca..3b434ec484041 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -638,8 +638,8 @@ impl Module { /// The current `Timepoint`. pub fn timepoint() -> Timepoint { Timepoint { - height: >::block_number(), - index: >::extrinsic_index().unwrap_or_default(), + height: >::block_number(), + index: >::extrinsic_index().unwrap_or_default(), } } diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index a3f47a26e6422..a3a3edc34f1a9 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -37,9 +37,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Multisig: pallet_multisig::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event}, } ); @@ -124,7 +124,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn last_event() -> Event { - system::Module::::events().pop().map(|e| e.event).expect("Event expected") + system::Pallet::::events().pop().map(|e| e.event).expect("Event expected") } fn expect_event>(e: E) { diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 681a45626fbca..6dee9ba79a60f 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -257,9 +257,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Nicks: pallet_nicks::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Nicks: pallet_nicks::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 090be28492630..d467d41680a02 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -453,9 +453,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, NodeAuthorization: pallet_node_authorization::{ - Module, Call, Storage, Config, Event, + Pallet, Call, Storage, Config, Event, }, } ); diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 0ceebaecd91ae..b3dca22ca4721 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -24,7 +24,7 @@ mod mock; use sp_std::prelude::*; use sp_std::vec; -use frame_system::{RawOrigin, Module as System, Config as SystemConfig}; +use frame_system::{RawOrigin, Pallet as System, Config as SystemConfig}; use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite}; use frame_support::traits::{Currency, OnInitialize, ValidatorSet, ValidatorSetWithIdentification}; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 54d649381eea6..df7b84ec07eac 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -158,7 +158,7 @@ impl onchain::Config for Test { impl pallet_staking::Config for Test { type Currency = Balances; - type UnixTime = pallet_timestamp::Module; + type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); type Event = Event; @@ -219,13 +219,13 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - ImOnline: pallet_im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, - Offences: pallet_offences::{Module, Call, Storage, Event}, - Historical: pallet_session_historical::{Module}, + System: system::{Pallet, Call, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config}, + Offences: pallet_offences::{Pallet, Call, Storage, Event}, + Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index c47a9cf943c18..ab45bb0837b56 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -91,8 +91,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Offences: offences::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Offences: offences::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 130c980011871..5372f8ee0288e 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -28,7 +28,7 @@ use crate::Module as Proxy; const SEED: u32 = 0; fn assert_last_event(generic_event: ::Event) { - let events = frame_system::Module::::events(); + let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len() - 1]; @@ -239,8 +239,8 @@ benchmarks! { T::BlockNumber::zero(), 0 )?; - let height = system::Module::::block_number(); - let ext_index = system::Module::::extrinsic_index().unwrap_or(0); + let height = system::Pallet::::block_number(); + let ext_index = system::Pallet::::extrinsic_index().unwrap_or(0); let anon = Module::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); add_proxies::(p, Some(anon.clone()))?; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 1e5aaadcc62d3..85561f593903d 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -420,7 +420,7 @@ decl_module! { let announcement = Announcement { real: real.clone(), call_hash: call_hash.clone(), - height: system::Module::::block_number(), + height: system::Pallet::::block_number(), }; Announcements::::try_mutate(&who, |(ref mut pending, ref mut deposit)| { @@ -517,7 +517,7 @@ decl_module! { let def = Self::find_proxy(&real, &delegate, force_proxy_type)?; let call_hash = T::CallHasher::hash_of(&call); - let now = system::Module::::block_number(); + let now = system::Pallet::::block_number(); Self::edit_announcements(&delegate, |ann| ann.real != real || ann.call_hash != call_hash || now.saturating_sub(ann.height) < def.delay ).map_err(|_| Error::::Unannounced)?; @@ -547,8 +547,8 @@ impl Module { maybe_when: Option<(T::BlockNumber, u32)>, ) -> T::AccountId { let (height, ext_index) = maybe_when.unwrap_or_else(|| ( - system::Module::::block_number(), - system::Module::::extrinsic_index().unwrap_or_default() + system::Pallet::::block_number(), + system::Pallet::::extrinsic_index().unwrap_or_default() )); let entropy = (b"modlpy/proxy____", who, height, ext_index, proxy_type, index) .using_encoded(blake2_256); diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index b31ef1dfdb2fe..8923246fb83f2 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -38,10 +38,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Proxy: proxy::{Module, Call, Storage, Event}, - Utility: pallet_utility::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Proxy: proxy::{Pallet, Call, Storage, Event}, + Utility: pallet_utility::{Pallet, Call, Event}, } ); @@ -163,7 +163,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn last_event() -> Event { - system::Module::::events().pop().expect("Event expected").event + system::Pallet::::events().pop().expect("Event expected").event } fn expect_event>(e: E) { @@ -171,7 +171,7 @@ fn expect_event>(e: E) { } fn last_events(n: usize) -> Vec { - system::Module::::events().into_iter().rev().take(n).rev().map(|e| e.event).collect() + system::Pallet::::events().into_iter().rev().take(n).rev().map(|e| e.event).collect() } fn expect_events(e: Vec) { @@ -270,7 +270,7 @@ fn delayed_requires_pre_announcement() { assert_noop!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()), e); let call_hash = BlakeTwo256::hash_of(&call); assert_ok!(Proxy::announce(Origin::signed(2), 1, call_hash)); - system::Module::::set_block_number(2); + system::Pallet::::set_block_number(2); assert_ok!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone())); }); } @@ -288,7 +288,7 @@ fn proxy_announced_removes_announcement_and_returns_deposit() { let e = Error::::Unannounced; assert_noop!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()), e); - system::Module::::set_block_number(2); + system::Pallet::::set_block_number(2); assert_ok!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone())); assert_eq!(Announcements::::get(3), (vec![Announcement { real: 2, diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 57e95ccb141df..3e37a03b2e2fa 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -76,7 +76,7 @@ fn block_number_to_index(block_number: T::BlockNumber) -> usize { decl_module! { pub struct Module for enum Call where origin: T::Origin { fn on_initialize(block_number: T::BlockNumber) -> Weight { - let parent_hash = >::parent_hash(); + let parent_hash = >::parent_hash(); >::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize { values.push(parent_hash) @@ -111,7 +111,7 @@ impl Randomness for Module { /// and mean that all bits of the resulting value are entirely manipulatable by the author of /// the parent block, who can determine the value of `parent_hash`. fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { - let block_number = >::block_number(); + let block_number = >::block_number(); let index = block_number_to_index::(block_number); let hash_series = >::get(); @@ -157,8 +157,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - CollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + CollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, } ); diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 00cd6ff2a7f79..20e984c98d0f5 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -496,7 +496,7 @@ decl_module! { T::Currency::reserve(&who, recovery_deposit)?; // Create an active recovery status let recovery_status = ActiveRecovery { - created: >::block_number(), + created: >::block_number(), deposit: recovery_deposit, friends: vec![], }; @@ -578,7 +578,7 @@ decl_module! { let active_recovery = Self::active_recovery(&account, &who).ok_or(Error::::NotStarted)?; ensure!(!Proxy::::contains_key(&who), Error::::AlreadyProxy); // Make sure the delay period has passed - let current_block_number = >::block_number(); + let current_block_number = >::block_number(); let recoverable_block_number = active_recovery.created .checked_add(&recovery_config.delay_period) .ok_or(Error::::Overflow)?; @@ -588,7 +588,7 @@ decl_module! { recovery_config.threshold as usize <= active_recovery.friends.len(), Error::::Threshold ); - system::Module::::inc_consumers(&who).map_err(|_| Error::::BadState)?; + system::Pallet::::inc_consumers(&who).map_err(|_| Error::::BadState)?; // Create the recovery storage item Proxy::::insert(&who, &account); Self::deposit_event(RawEvent::AccountRecovered(account, who)); @@ -677,7 +677,7 @@ decl_module! { // Check `who` is allowed to make a call on behalf of `account` ensure!(Self::proxy(&who) == Some(account), Error::::NotAllowed); Proxy::::remove(&who); - system::Module::::dec_consumers(&who); + system::Pallet::::dec_consumers(&who); } } } diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index ee38b0e24cc60..301dd8dba8ddd 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -35,9 +35,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Recovery: recovery::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Recovery: recovery::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index 37ccb900a824a..563a1ba89c86f 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_support::{ensure, traits::OnInitialize}; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use crate::Module as Scheduler; -use frame_system::Module as System; +use frame_system::Pallet as System; const BLOCK_NUMBER: u32 = 2; diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 5cab10b0aff38..abce8504e5a52 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -465,7 +465,7 @@ impl Module { } fn resolve_time(when: DispatchTime) -> Result { - let now = frame_system::Module::::block_number(); + let now = frame_system::Pallet::::block_number(); let when = match when { DispatchTime::At(x) => x, @@ -793,9 +793,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Logger: logger::{Module, Call, Event}, - Scheduler: scheduler::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Logger: logger::{Pallet, Call, Event}, + Scheduler: scheduler::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 3c4263b813e41..76f9dd848d6c0 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -37,9 +37,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - ScoredPool: pallet_scored_pool::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + ScoredPool: pallet_scored_pool::{Pallet, Call, Storage, Config, Event}, } ); diff --git a/frame/scored-pool/src/tests.rs b/frame/scored-pool/src/tests.rs index 8f33f30f6ed8e..e24ee91164973 100644 --- a/frame/scored-pool/src/tests.rs +++ b/frame/scored-pool/src/tests.rs @@ -24,8 +24,8 @@ use frame_support::{assert_ok, assert_noop, traits::OnInitialize}; use sp_runtime::traits::BadOrigin; type ScoredPool = Module; -type System = frame_system::Module; -type Balances = pallet_balances::Module; +type System = frame_system::Pallet; +type Balances = pallet_balances::Pallet; #[test] fn query_membership_works() { diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 0eba5452b28d0..dbf6584b6ea20 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -37,10 +37,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); @@ -163,7 +163,7 @@ impl onchain::Config for Test { impl pallet_staking::Config for Test { type Currency = Balances; - type UnixTime = pallet_timestamp::Module; + type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); type Event = Event; diff --git a/frame/session/src/historical/mod.rs b/frame/session/src/historical/mod.rs index 9b4d2704cf456..8902ebe551f6c 100644 --- a/frame/session/src/historical/mod.rs +++ b/frame/session/src/historical/mod.rs @@ -358,7 +358,7 @@ pub(crate) mod tests { ); BasicExternalities::execute_with_storage(&mut t, || { for (ref k, ..) in &keys { - frame_system::Module::::inc_providers(k); + frame_system::Pallet::::inc_providers(k); } }); crate::GenesisConfig:: { keys }.assimilate_storage(&mut t).unwrap(); diff --git a/frame/session/src/historical/offchain.rs b/frame/session/src/historical/offchain.rs index f095be9e44e24..f675d878c1e28 100644 --- a/frame/session/src/historical/offchain.rs +++ b/frame/session/src/historical/offchain.rs @@ -28,7 +28,7 @@ use sp_runtime::{offchain::storage::StorageValueRef, KeyTypeId}; use sp_session::MembershipProof; -use super::super::{Module as SessionModule, SessionIndex}; +use super::super::{Pallet as SessionModule, SessionIndex}; use super::{IdentificationTuple, ProvingTrie, Config}; use super::shared; @@ -167,7 +167,7 @@ mod tests { ); BasicExternalities::execute_with_storage(&mut t, || { for (ref k, ..) in &keys { - frame_system::Module::::inc_providers(k); + frame_system::Pallet::::inc_providers(k); } }); diff --git a/frame/session/src/historical/onchain.rs b/frame/session/src/historical/onchain.rs index 3b933bf262a00..8fe63a79e1c59 100644 --- a/frame/session/src/historical/onchain.rs +++ b/frame/session/src/historical/onchain.rs @@ -21,7 +21,7 @@ use codec::Encode; use sp_runtime::traits::Convert; use super::super::Config as SessionConfig; -use super::super::{Module as SessionModule, SessionIndex}; +use super::super::{Pallet as SessionModule, SessionIndex}; use super::Config as HistoricalConfig; use super::shared; diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 45f3ae9dfce47..a66ea587a1306 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -442,7 +442,7 @@ decl_storage! { for (account, val, keys) in config.keys.iter().cloned() { >::inner_set_keys(&val, keys) .expect("genesis config must not contain duplicates; qed"); - assert!(frame_system::Module::::inc_consumers(&account).is_ok()); + assert!(frame_system::Pallet::::inc_consumers(&account).is_ok()); } let initial_validators_0 = T::SessionManager::new_session(0) @@ -746,10 +746,10 @@ impl Module { let who = T::ValidatorIdOf::convert(account.clone()) .ok_or(Error::::NoAssociatedValidatorId)?; - frame_system::Module::::inc_consumers(&account).map_err(|_| Error::::NoAccount)?; + frame_system::Pallet::::inc_consumers(&account).map_err(|_| Error::::NoAccount)?; let old_keys = Self::inner_set_keys(&who, keys)?; if old_keys.is_some() { - let _ = frame_system::Module::::dec_consumers(&account); + let _ = frame_system::Pallet::::dec_consumers(&account); // ^^^ Defensive only; Consumers were incremented just before, so should never fail. } @@ -798,7 +798,7 @@ impl Module { let key_data = old_keys.get_raw(*id); Self::clear_key_owner(*id, key_data); } - frame_system::Module::::dec_consumers(&account); + frame_system::Pallet::::dec_consumers(&account); Ok(()) } diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 73499bf739b87..b64359fccee32 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -78,9 +78,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, - Historical: pallet_session_historical::{Module}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Historical: pallet_session_historical::{Pallet}, } ); @@ -91,8 +91,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); @@ -210,11 +210,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ); BasicExternalities::execute_with_storage(&mut t, || { for (ref k, ..) in &keys { - frame_system::Module::::inc_providers(k); + frame_system::Pallet::::inc_providers(k); } - frame_system::Module::::inc_providers(&4); + frame_system::Pallet::::inc_providers(&4); // An additional identity that we use. - frame_system::Module::::inc_providers(&69); + frame_system::Pallet::::inc_providers(&69); }); pallet_session::GenesisConfig:: { keys }.assimilate_storage(&mut t).unwrap(); sp_io::TestExternalities::new(t) diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 66d89d67dd6e7..3546ea68d4dca 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -793,7 +793,7 @@ decl_module! { let mut payouts = >::get(&who); if let Some((when, amount)) = payouts.first() { - if when <= &>::block_number() { + if when <= &>::block_number() { T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?; payouts.remove(0); if payouts.is_empty() { @@ -981,7 +981,7 @@ decl_module! { // Reduce next pot by payout >::put(pot - value); // Add payout for new candidate - let maturity = >::block_number() + let maturity = >::block_number() + Self::lock_duration(Self::members().len() as u32); Self::pay_accepted_candidate(&who, value, kind, maturity); } @@ -1324,7 +1324,7 @@ impl, I: Instance> Module { // critical issues or side-effects. This is auto-correcting as members fall out of society. members.reserve(candidates.len()); - let maturity = >::block_number() + let maturity = >::block_number() + Self::lock_duration(members.len() as u32); let mut rewardees = Vec::new(); diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 0a684b2a8dc89..53d999e37e628 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -41,9 +41,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Society: pallet_society::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Society: pallet_society::{Pallet, Call, Storage, Event, Config}, } ); @@ -104,7 +104,7 @@ impl pallet_balances::Config for Test { impl Config for Test { type Event = Event; - type Currency = pallet_balances::Module; + type Currency = pallet_balances::Pallet; type Randomness = TestRandomness; type CandidateDeposit = CandidateDeposit; type WrongSideDeduction = WrongSideDeduction; diff --git a/frame/staking/fuzzer/src/mock.rs b/frame/staking/fuzzer/src/mock.rs index 05d001d23858e..ef4a719713e34 100644 --- a/frame/staking/fuzzer/src/mock.rs +++ b/frame/staking/fuzzer/src/mock.rs @@ -33,11 +33,11 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Staking: pallet_staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Indices: pallet_indices::{Module, Call, Storage, Config, Event}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Staking: pallet_staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Indices: pallet_indices::{Pallet, Call, Storage, Config, Event}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); @@ -169,7 +169,7 @@ impl sp_election_providers::ElectionProvider for MockEle impl pallet_staking::Config for Test { type Currency = Balances; - type UnixTime = pallet_timestamp::Module; + type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); type Event = Event; diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index c57fac43c5600..92d1b2a30864d 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1505,7 +1505,7 @@ decl_module! { Err(Error::::InsufficientValue)? } - system::Module::::inc_consumers(&stash).map_err(|_| Error::::BadState)?; + system::Pallet::::inc_consumers(&stash).map_err(|_| Error::::BadState)?; // You're auto-bonded forever, here. We might improve this by only bonding when // you actually validate/nominate and remove once you unbond __everything__. @@ -3212,7 +3212,7 @@ impl Module { >::remove(stash); >::remove(stash); - system::Module::::dec_consumers(stash); + system::Pallet::::dec_consumers(stash); Ok(()) } @@ -3418,7 +3418,7 @@ impl pallet_session::SessionManager for Module { log!( trace, "[{:?}] planning new_session({})", - >::block_number(), + >::block_number(), new_index, ); CurrentPlannedSession::put(new_index); @@ -3428,7 +3428,7 @@ impl pallet_session::SessionManager for Module { log!( trace, "[{:?}] starting start_session({})", - >::block_number(), + >::block_number(), start_index, ); Self::start_session(start_index) @@ -3437,7 +3437,7 @@ impl pallet_session::SessionManager for Module { log!( trace, "[{:?}] ending end_session({})", - >::block_number(), + >::block_number(), end_index, ); Self::end_session(end_index) diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 0d6701c48b894..824c6cb087217 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -98,11 +98,11 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Staking: staking::{Module, Call, Config, Storage, Event, ValidateUnsigned}, - Session: pallet_session::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Staking: staking::{Pallet, Call, Config, Storage, Event, ValidateUnsigned}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 91cd03ac4756a..cd242d491dae2 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -82,9 +82,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Sudo: sudo::{Module, Call, Config, Storage, Event}, - Logger: logger::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Sudo: sudo::{Pallet, Call, Config, Storage, Event}, + Logger: logger::{Pallet, Call, Storage, Event}, } ); diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index e64a364d2951e..2aecc5b993928 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -192,7 +192,7 @@ use proc_macro::TokenStream; /// construct_runtime!( /// pub enum Runtime with ... { /// ..., -/// Example: example::{Module, Storage, ..., Config}, +/// Example: example::{Pallet, Storage, ..., Config}, /// ..., /// } /// ); @@ -258,13 +258,13 @@ pub fn decl_storage(input: TokenStream) -> TokenStream { /// NodeBlock = runtime::Block, /// UncheckedExtrinsic = UncheckedExtrinsic /// { -/// System: system::{Module, Call, Event, Config} = 0, -/// Test: test::{Module, Call} = 1, -/// Test2: test_with_long_module::{Module, Event}, +/// System: system::{Pallet, Call, Event, Config} = 0, +/// Test: test::{Pallet, Call} = 1, +/// Test2: test_with_long_module::{Pallet, Event}, /// /// // Module with instances -/// Test3_Instance1: test3::::{Module, Call, Storage, Event, Config, Origin}, -/// Test3_DefaultInstance: test3::{Module, Call, Storage, Event, Config, Origin} = 4, +/// Test3_Instance1: test3::::{Pallet, Call, Storage, Event, Config, Origin}, +/// Test3_DefaultInstance: test3::{Pallet, Call, Storage, Event, Config, Origin} = 4, /// } /// ) /// ``` @@ -306,7 +306,7 @@ pub fn decl_storage(input: TokenStream) -> TokenStream { /// # Type definitions /// /// * The macro generates a type alias for each pallet to their `Module` (or `Pallet`). -/// E.g. `type System = frame_system::Module` +/// E.g. `type System = frame_system::Pallet` #[proc_macro] pub fn construct_runtime(input: TokenStream) -> TokenStream { construct_runtime::construct_runtime(input) diff --git a/frame/support/procedural/src/pallet/expand/pallet_struct.rs b/frame/support/procedural/src/pallet/expand/pallet_struct.rs index 47e4344c50d8e..fd3230edd1e74 100644 --- a/frame/support/procedural/src/pallet/expand/pallet_struct.rs +++ b/frame/support/procedural/src/pallet/expand/pallet_struct.rs @@ -102,6 +102,8 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { /// Type alias to `Pallet`, to be used by `construct_runtime`. /// /// Generated by `pallet` attribute macro. + #[deprecated(note = "use `Pallet` instead")] + #[allow(dead_code)] pub type Module<#type_decl_gen> = #pallet_ident<#type_use_gen>; // Implement `GetPalletVersion` for `Pallet` diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 7b526e305b7be..aede0404da19c 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1375,11 +1375,11 @@ macro_rules! decl_module { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $module<$trait_instance $(, $instance)?> where $( $other_where_bounds )* { - /// Deposits an event using `frame_system::Module::deposit_event`. + /// Deposits an event using `frame_system::Pallet::deposit_event`. $vis fn deposit_event( event: impl Into<< $trait_instance as $trait_name $(<$instance>)? >::Event> ) { - <$system::Module<$trait_instance>>::deposit_event(event.into()) + <$system::Pallet<$trait_instance>>::deposit_event(event.into()) } } }; @@ -1860,6 +1860,7 @@ macro_rules! decl_module { $( $other_where_bounds )*; /// Type alias to `Module`, to be used by `construct_runtime`. + #[allow(dead_code)] pub type Pallet<$trait_instance $(, $instance $( = $module_default_instance)?)?> = $mod_type<$trait_instance $(, $instance)?>; diff --git a/frame/support/src/metadata.rs b/frame/support/src/metadata.rs index 06d334ab8e5af..a253dabce85b2 100644 --- a/frame/support/src/metadata.rs +++ b/frame/support/src/metadata.rs @@ -421,7 +421,7 @@ mod tests { impl crate::traits::PalletInfo for TestRuntime { fn index() -> Option { let type_id = sp_std::any::TypeId::of::

(); - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some(0) } if type_id == sp_std::any::TypeId::of::() { @@ -435,7 +435,7 @@ mod tests { } fn name() -> Option<&'static str> { let type_id = sp_std::any::TypeId::of::

(); - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some("System") } if type_id == sp_std::any::TypeId::of::() { @@ -492,8 +492,8 @@ mod tests { } impl_runtime_metadata!( - for TestRuntime with modules where Extrinsic = TestExtrinsic - system::Module as System { index 0 } with Event, + for TestRuntime with pallets where Extrinsic = TestExtrinsic + system::Pallet as System { index 0 } with Event, event_module::Module as Module { index 1 } with Event Call, event_module2::Module as Module2 { index 2 } with Event Storage Call, ); diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index ae3efdf57aa22..d40031c149d90 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -67,7 +67,7 @@ where ( Output::decode(&mut TrailingZeroInput::new(subject)).unwrap_or_default(), - frame_system::Module::::block_number(), + frame_system::Pallet::::block_number(), ) } } diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 8dc44c2024adc..a1ec744e42733 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -138,17 +138,17 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event, Origin} = 30, - Module1_1: module1::::{Module, Call, Storage, Event, Origin}, - Module2: module2::{Module, Call, Storage, Event, Origin}, - Module1_2: module1::::{Module, Call, Storage, Event, Origin}, - Module1_3: module1::::{Module, Storage} = 6, - Module1_4: module1::::{Module, Call} = 3, - Module1_5: module1::::{Module, Event}, - Module1_6: module1::::{Module, Call, Storage, Event, Origin} = 1, - Module1_7: module1::::{Module, Call, Storage, Event, Origin}, - Module1_8: module1::::{Module, Call, Storage, Event, Origin} = 12, - Module1_9: module1::::{Module, Call, Storage, Event, Origin}, + System: system::{Pallet, Call, Event, Origin} = 30, + Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, + Module2: module2::{Pallet, Call, Storage, Event, Origin}, + Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, + Module1_3: module1::::{Pallet, Storage} = 6, + Module1_4: module1::::{Pallet, Call} = 3, + Module1_5: module1::::{Pallet, Event}, + Module1_6: module1::::{Pallet, Call, Storage, Event, Origin} = 1, + Module1_7: module1::::{Pallet, Call, Storage, Event, Origin}, + Module1_8: module1::::{Pallet, Call, Storage, Event, Origin} = 12, + Module1_9: module1::::{Pallet, Call, Storage, Event, Origin}, } ); diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs index bc242a57a41e5..7cc6cbd6bd6e2 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs @@ -6,9 +6,9 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, - Balance: balances::{Module}, - Balance: balances::{Module}, + System: system::{Pallet}, + Balance: balances::{Pallet}, + Balance: balances::{Pallet}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr index f5b999db66a41..89c6b9e054131 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr @@ -1,11 +1,11 @@ error: Two modules with the same name! --> $DIR/conflicting_module_name.rs:10:3 | -10 | Balance: balances::{Module}, +10 | Balance: balances::{Pallet}, | ^^^^^^^ error: Two modules with the same name! --> $DIR/conflicting_module_name.rs:11:3 | -11 | Balance: balances::{Module}, +11 | Balance: balances::{Pallet}, | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs index ec37456e58e79..836af597851d8 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, + System: system::{Pallet}, Balance: balances::{Config, Call, Config, Origin}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs index b79d73ff5c022..b3f0d340d671f 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, + System: system::{Pallet}, Balance: balances::::{Call, Origin}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs index 3754d41d6e81c..e7d32559a6cc6 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, + System: system::{Pallet}, Balance: balances::{Error}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs index 5eb7df5d18c20..f748e643aa18a 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, + System: system::{Pallet}, Balance: balances::::{Event}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs index 5e44ae84d87c6..7053acc185900 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs @@ -6,7 +6,7 @@ construct_runtime! { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module}, + System: system::{Pallet}, Balance: balances::::{Origin}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index 2ebe0721eb381..a57eac19194cd 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,4 +1,4 @@ -error: `System` module declaration is missing. Please add this line: `System: frame_system::{Module, Call, Storage, Config, Event},` +error: `System` module declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` --> $DIR/missing_system_module.rs:8:2 | 8 | { diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 42cc2af19c655..e0dd1d1891d26 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -264,24 +264,24 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, + System: system::{Pallet, Call, Event}, Module1_1: module1::::{ - Module, Call, Storage, Event, Config, Origin, Inherent + Pallet, Call, Storage, Event, Config, Origin, Inherent }, Module1_2: module1::::{ - Module, Call, Storage, Event, Config, Origin, Inherent + Pallet, Call, Storage, Event, Config, Origin, Inherent }, - Module2: module2::{Module, Call, Storage, Event, Config, Origin, Inherent}, + Module2: module2::{Pallet, Call, Storage, Event, Config, Origin, Inherent}, Module2_1: module2::::{ - Module, Call, Storage, Event, Config, Origin, Inherent + Pallet, Call, Storage, Event, Config, Origin, Inherent }, Module2_2: module2::::{ - Module, Call, Storage, Event, Config, Origin, Inherent + Pallet, Call, Storage, Event, Config, Origin, Inherent }, Module2_3: module2::::{ - Module, Call, Storage, Event, Config, Origin, Inherent + Pallet, Call, Storage, Event, Config, Origin, Inherent }, - Module3: module3::{Module, Call}, + Module3: module3::{Pallet, Call}, } ); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 9ad9b8be7f415..4525e8c1a1fe2 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -177,8 +177,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Event}, - Module: module::{Module, Call, Storage, Config}, + System: system::{Pallet, Call, Event}, + Module: module::{Pallet, Call, Storage, Config}, } ); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index a31ce9d91ae2d..5f54f81cfb842 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -396,9 +396,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Example: pallet::{Module, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned}, - Example2: pallet2::{Module, Call, Event, Config, Storage}, + System: frame_system::{Pallet, Call, Event}, + Example: pallet::{Pallet, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned}, + Example2: pallet2::{Pallet, Call, Event, Config, Storage}, } ); @@ -530,11 +530,11 @@ fn pallet_hooks_expand() { TestExternalities::default().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_eq!(AllModules::on_initialize(1), 10); - AllModules::on_finalize(1); + assert_eq!(AllPallets::on_initialize(1), 10); + AllPallets::on_finalize(1); assert_eq!(pallet::Pallet::::storage_version(), None); - assert_eq!(AllModules::on_runtime_upgrade(), 30); + assert_eq!(AllPallets::on_runtime_upgrade(), 30); assert_eq!( pallet::Pallet::::storage_version(), Some(pallet::Pallet::::current_version()), diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 5b9001e0475fe..95e1c027eb3fa 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -247,10 +247,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Event}, // NOTE: name Example here is needed in order to have same module prefix - Example: pallet::{Module, Call, Event, Config, Storage}, - PalletOld: pallet_old::{Module, Call, Event, Config, Storage}, + Example: pallet::{Pallet, Call, Event, Config, Storage}, + PalletOld: pallet_old::{Pallet, Call, Event, Config, Storage}, } ); diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index d7de03ea46cfd..603c583ae217f 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -259,13 +259,13 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Example: pallet::{Module, Call, Event, Config, Storage}, - PalletOld: pallet_old::{Module, Call, Event, Config, Storage}, - Instance2Example: pallet::::{Module, Call, Event, Config, Storage}, - PalletOld2: pallet_old::::{Module, Call, Event, Config, Storage}, - Instance3Example: pallet::::{Module, Call, Event, Config, Storage}, - PalletOld3: pallet_old::::{Module, Call, Event, Config, Storage}, + System: frame_system::{Pallet, Call, Event}, + Example: pallet::{Pallet, Call, Event, Config, Storage}, + PalletOld: pallet_old::{Pallet, Call, Event, Config, Storage}, + Instance2Example: pallet::::{Pallet, Call, Event, Config, Storage}, + PalletOld2: pallet_old::::{Pallet, Call, Event, Config, Storage}, + Instance3Example: pallet::::{Pallet, Call, Event, Config, Storage}, + PalletOld3: pallet_old::::{Pallet, Call, Event, Config, Storage}, } ); diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 62654d53e19d7..1bf4c1af09280 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -288,13 +288,13 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Example: pallet::{Module, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned}, + System: frame_system::{Pallet, Call, Event}, + Example: pallet::{Pallet, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned}, Instance1Example: pallet::::{ - Module, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned + Pallet, Call, Event, Config, Storage, Inherent, Origin, ValidateUnsigned }, - Example2: pallet2::{Module, Call, Event, Config, Storage}, - Instance1Example2: pallet2::::{Module, Call, Event, Config, Storage}, + Example2: pallet2::{Pallet, Call, Event, Config, Storage}, + Instance1Example2: pallet2::::{Pallet, Call, Event, Config, Storage}, } ); @@ -377,19 +377,19 @@ fn instance_expand() { #[test] fn pallet_expand_deposit_event() { TestExternalities::default().execute_with(|| { - frame_system::Module::::set_block_number(1); + frame_system::Pallet::::set_block_number(1); pallet::Call::::foo(3).dispatch_bypass_filter(None.into()).unwrap(); assert_eq!( - frame_system::Module::::events()[0].event, + frame_system::Pallet::::events()[0].event, Event::pallet(pallet::Event::Something(3)), ); }); TestExternalities::default().execute_with(|| { - frame_system::Module::::set_block_number(1); + frame_system::Pallet::::set_block_number(1); pallet::Call::::foo(3).dispatch_bypass_filter(None.into()).unwrap(); assert_eq!( - frame_system::Module::::events()[0].event, + frame_system::Pallet::::events()[0].event, Event::pallet_Instance1(pallet::Event::Something(3)), ); }); @@ -480,14 +480,14 @@ fn storage_expand() { #[test] fn pallet_hooks_expand() { TestExternalities::default().execute_with(|| { - frame_system::Module::::set_block_number(1); + frame_system::Pallet::::set_block_number(1); - assert_eq!(AllModules::on_initialize(1), 21); - AllModules::on_finalize(1); + assert_eq!(AllPallets::on_initialize(1), 21); + AllPallets::on_finalize(1); assert_eq!(pallet::Pallet::::storage_version(), None); assert_eq!(pallet::Pallet::::storage_version(), None); - assert_eq!(AllModules::on_runtime_upgrade(), 61); + assert_eq!(AllPallets::on_runtime_upgrade(), 61); assert_eq!( pallet::Pallet::::storage_version(), Some(pallet::Pallet::::current_version()), @@ -499,27 +499,27 @@ fn pallet_hooks_expand() { // The order is indeed reversed due to https://github.com/paritytech/substrate/issues/6280 assert_eq!( - frame_system::Module::::events()[0].event, + frame_system::Pallet::::events()[0].event, Event::pallet_Instance1(pallet::Event::Something(11)), ); assert_eq!( - frame_system::Module::::events()[1].event, + frame_system::Pallet::::events()[1].event, Event::pallet(pallet::Event::Something(10)), ); assert_eq!( - frame_system::Module::::events()[2].event, + frame_system::Pallet::::events()[2].event, Event::pallet_Instance1(pallet::Event::Something(21)), ); assert_eq!( - frame_system::Module::::events()[3].event, + frame_system::Pallet::::events()[3].event, Event::pallet(pallet::Event::Something(20)), ); assert_eq!( - frame_system::Module::::events()[4].event, + frame_system::Pallet::::events()[4].event, Event::pallet_Instance1(pallet::Event::Something(31)), ); assert_eq!( - frame_system::Module::::events()[5].event, + frame_system::Pallet::::events()[5].event, Event::pallet(pallet::Event::Something(30)), ); }) diff --git a/frame/support/test/tests/pallet_version.rs b/frame/support/test/tests/pallet_version.rs index 4cc93d395db2a..b3436b7baed9a 100644 --- a/frame/support/test/tests/pallet_version.rs +++ b/frame/support/test/tests/pallet_version.rs @@ -174,15 +174,15 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: frame_system::{Module, Call, Event}, - Module1: module1::{Module, Call}, - Module2: module2::{Module, Call}, - Module2_1: module2::::{Module, Call}, - Module2_2: module2::::{Module, Call}, - Pallet3: pallet3::{Module, Call}, - Pallet4: pallet4::{Module, Call}, - Pallet4_1: pallet4::::{Module, Call}, - Pallet4_2: pallet4::::{Module, Call}, + System: frame_system::{Pallet, Call, Event}, + Module1: module1::{Pallet, Call}, + Module2: module2::{Pallet, Call}, + Module2_1: module2::::{Pallet, Call}, + Module2_2: module2::::{Pallet, Call}, + Pallet3: pallet3::{Pallet, Call}, + Pallet4: pallet4::{Pallet, Call}, + Pallet4_1: pallet4::::{Pallet, Call}, + Pallet4_2: pallet4::::{Pallet, Call}, } ); @@ -218,7 +218,7 @@ fn check_pallet_version(pallet: &str) { #[test] fn on_runtime_upgrade_sets_the_pallet_versions_in_storage() { sp_io::TestExternalities::new_empty().execute_with(|| { - AllModules::on_runtime_upgrade(); + AllPallets::on_runtime_upgrade(); check_pallet_version("Module1"); check_pallet_version("Module2"); @@ -237,7 +237,7 @@ fn on_runtime_upgrade_overwrites_old_version() { let key = get_pallet_version_storage_key_for_pallet("Module2"); sp_io::storage::set(&key, &SOME_TEST_VERSION.encode()); - AllModules::on_runtime_upgrade(); + AllPallets::on_runtime_upgrade(); check_pallet_version("Module1"); check_pallet_version("Module2"); diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index b09beb04cd17c..05cedbdb91a07 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -109,8 +109,8 @@ mod tests { NodeBlock = TestBlock, UncheckedExtrinsic = TestUncheckedExtrinsic { - System: frame_system::{Module, Call, Config, Storage, Event}, - PalletTest: pallet_test::{Module, Call, Storage, Event, Config, ValidateUnsigned, Inherent}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + PalletTest: pallet_test::{Pallet, Call, Storage, Event, Config, ValidateUnsigned, Inherent}, } ); diff --git a/frame/system/README.md b/frame/system/README.md index 106a16bc209d6..a6da7c3816d22 100644 --- a/frame/system/README.md +++ b/frame/system/README.md @@ -64,8 +64,8 @@ decl_module! { #[weight = 0] pub fn system_module_example(origin) -> dispatch::DispatchResult { let _sender = ensure_signed(origin)?; - let _extrinsic_count = >::extrinsic_count(); - let _parent_hash = >::parent_hash(); + let _extrinsic_count = >::extrinsic_count(); + let _parent_hash = >::parent_hash(); Ok(()) } } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 6ed3d456826c2..3ebee534a64e1 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -50,8 +50,8 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Module: module::{Module, Call, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Module: module::{Pallet, Call, Event}, } ); diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index bdb34e7944db5..80789c5b550f6 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -30,7 +30,7 @@ use frame_support::{ traits::Get, weights::DispatchClass, }; -use frame_system::{Module as System, Call, RawOrigin, DigestItemOf}; +use frame_system::{Pallet as System, Call, RawOrigin, DigestItemOf}; mod mock; diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index edc5dfebbd106..23da1fee5617a 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -34,7 +34,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, } ); diff --git a/frame/system/src/extensions/check_genesis.rs b/frame/system/src/extensions/check_genesis.rs index de635b4fb91a6..aa6c1358790a4 100644 --- a/frame/system/src/extensions/check_genesis.rs +++ b/frame/system/src/extensions/check_genesis.rs @@ -16,7 +16,7 @@ // limitations under the License. use codec::{Encode, Decode}; -use crate::{Config, Module}; +use crate::{Config, Pallet}; use sp_runtime::{ traits::{SignedExtension, Zero}, transaction_validity::TransactionValidityError, @@ -53,6 +53,6 @@ impl SignedExtension for CheckGenesis { const IDENTIFIER: &'static str = "CheckGenesis"; fn additional_signed(&self) -> Result { - Ok(>::block_hash(T::BlockNumber::zero())) + Ok(>::block_hash(T::BlockNumber::zero())) } } diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 1e8eb32a3d3c2..b3e4c4ecfda86 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -16,7 +16,7 @@ // limitations under the License. use codec::{Encode, Decode}; -use crate::{Config, Module, BlockHash}; +use crate::{Config, Pallet, BlockHash}; use sp_runtime::{ generic::Era, traits::{SignedExtension, DispatchInfoOf, SaturatedConversion}, @@ -62,7 +62,7 @@ impl SignedExtension for CheckMortality { _info: &DispatchInfoOf, _len: usize, ) -> TransactionValidity { - let current_u64 = >::block_number().saturated_into::(); + let current_u64 = >::block_number().saturated_into::(); let valid_till = self.0.death(current_u64); Ok(ValidTransaction { longevity: valid_till.saturating_sub(current_u64), @@ -71,12 +71,12 @@ impl SignedExtension for CheckMortality { } fn additional_signed(&self) -> Result { - let current_u64 = >::block_number().saturated_into::(); + let current_u64 = >::block_number().saturated_into::(); let n = self.0.birth(current_u64).saturated_into::(); if !>::contains_key(n) { Err(InvalidTransaction::AncientBirthBlock.into()) } else { - Ok(>::block_hash(n)) + Ok(>::block_hash(n)) } } } diff --git a/frame/system/src/extensions/check_spec_version.rs b/frame/system/src/extensions/check_spec_version.rs index 1fd8376d342b2..e41ce1725a549 100644 --- a/frame/system/src/extensions/check_spec_version.rs +++ b/frame/system/src/extensions/check_spec_version.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Config, Module}; +use crate::{Config, Pallet}; use codec::{Encode, Decode}; use sp_runtime::{ traits::SignedExtension, @@ -53,6 +53,6 @@ impl SignedExtension for CheckSpecVersion { const IDENTIFIER: &'static str = "CheckSpecVersion"; fn additional_signed(&self) -> Result { - Ok(>::runtime_version().spec_version) + Ok(>::runtime_version().spec_version) } } diff --git a/frame/system/src/extensions/check_tx_version.rs b/frame/system/src/extensions/check_tx_version.rs index fa11a0a5727f1..ad23dc7e9dd05 100644 --- a/frame/system/src/extensions/check_tx_version.rs +++ b/frame/system/src/extensions/check_tx_version.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Config, Module}; +use crate::{Config, Pallet}; use codec::{Encode, Decode}; use sp_runtime::{ traits::SignedExtension, @@ -53,6 +53,6 @@ impl SignedExtension for CheckTxVersion { const IDENTIFIER: &'static str = "CheckTxVersion"; fn additional_signed(&self) -> Result { - Ok(>::runtime_version().transaction_version) + Ok(>::runtime_version().transaction_version) } } diff --git a/frame/system/src/extensions/check_weight.rs b/frame/system/src/extensions/check_weight.rs index 70116f4b6524b..fc9898b778b8d 100644 --- a/frame/system/src/extensions/check_weight.rs +++ b/frame/system/src/extensions/check_weight.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{limits::BlockWeights, Config, Module}; +use crate::{limits::BlockWeights, Config, Pallet}; use codec::{Encode, Decode}; use sp_runtime::{ traits::{SignedExtension, DispatchInfoOf, Dispatchable, PostDispatchInfoOf, Printable}, @@ -58,7 +58,7 @@ impl CheckWeight where info: &DispatchInfoOf, ) -> Result { let maximum_weight = T::BlockWeights::get(); - let all_weight = Module::::block_weight(); + let all_weight = Pallet::::block_weight(); calculate_consumed_weight::(maximum_weight, all_weight, info) } @@ -70,7 +70,7 @@ impl CheckWeight where len: usize, ) -> Result { let length_limit = T::BlockLength::get(); - let current_len = Module::::all_extrinsics_len(); + let current_len = Pallet::::all_extrinsics_len(); let added_len = len as u32; let next_len = current_len.saturating_add(added_len); if next_len > *length_limit.max.get(info.class) { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 6ea2a62f05ba2..ebf9eb38375bb 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1022,7 +1022,7 @@ pub enum IncRefError { NoProviders, } -impl Module { +impl Pallet { pub fn account_exists(who: &T::AccountId) -> bool { Account::::contains_key(who) } @@ -1083,7 +1083,7 @@ impl Module { (1, 0, 0) => { // No providers left (and no consumers) and no sufficients. Account dead. - Module::::on_killed_account(who.clone()); + Pallet::::on_killed_account(who.clone()); Ok(DecRefStatus::Reaped) } (1, c, _) if c > 0 => { @@ -1136,7 +1136,7 @@ impl Module { } match (account.sufficients, account.providers) { (0, 0) | (1, 0) => { - Module::::on_killed_account(who.clone()); + Pallet::::on_killed_account(who.clone()); DecRefStatus::Reaped } (x, _) => { @@ -1450,9 +1450,9 @@ impl Module { Ok(_) => Event::ExtrinsicSuccess(info), Err(err) => { log::trace!( - target: "runtime::system", - "Extrinsic failed at block({:?}): {:?}", - Self::block_number(), + target: "runtime::system", + "Extrinsic failed at block({:?}): {:?}", + Self::block_number(), err, ); Event::ExtrinsicFailed(err.error, info) @@ -1520,11 +1520,11 @@ impl Module { pub struct Provider(PhantomData); impl HandleLifetime for Provider { fn created(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::inc_providers(t); + Pallet::::inc_providers(t); Ok(()) } fn killed(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::dec_providers(t) + Pallet::::dec_providers(t) .map(|_| ()) .or_else(|e| match e { DecRefError::ConsumerRemaining => Err(StoredMapError::ConsumerRemaining), @@ -1536,11 +1536,11 @@ impl HandleLifetime for Provider { pub struct SelfSufficient(PhantomData); impl HandleLifetime for SelfSufficient { fn created(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::inc_sufficients(t); + Pallet::::inc_sufficients(t); Ok(()) } fn killed(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::dec_sufficients(t); + Pallet::::dec_sufficients(t); Ok(()) } } @@ -1549,13 +1549,13 @@ impl HandleLifetime for SelfSufficient { pub struct Consumer(PhantomData); impl HandleLifetime for Consumer { fn created(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::inc_consumers(t) + Pallet::::inc_consumers(t) .map_err(|e| match e { IncRefError::NoProviders => StoredMapError::NoProviders }) } fn killed(t: &T::AccountId) -> Result<(), StoredMapError> { - Module::::dec_consumers(t); + Pallet::::dec_consumers(t); Ok(()) } } diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 2b31929b5da81..43c7d8d252774 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -33,7 +33,7 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, } ); diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 2ef24a696ade9..002a8d1c989b0 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -319,8 +319,8 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, } ); diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 442df89428fcc..88cb65963af8f 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -401,7 +401,7 @@ decl_module! { let tip = Tips::::get(hash).ok_or(Error::::UnknownTip)?; let n = tip.closes.as_ref().ok_or(Error::::StillOpen)?; - ensure!(system::Module::::block_number() >= *n, Error::::Premature); + ensure!(system::Pallet::::block_number() >= *n, Error::::Premature); // closed. Reasons::::remove(&tip.reason); Tips::::remove(hash); @@ -463,7 +463,7 @@ impl Module { Self::retain_active_tips(&mut tip.tips); let threshold = (T::Tippers::count() + 1) / 2; if tip.tips.len() >= threshold && tip.closes.is_none() { - tip.closes = Some(system::Module::::block_number() + T::TipCountdown::get()); + tip.closes = Some(system::Pallet::::block_number() + T::TipCountdown::get()); true } else { false diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 413e2dd9437e2..ef30962fc846f 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -40,10 +40,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, - TipsModTestInst: tips::{Module, Call, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + TipsModTestInst: tips::{Pallet, Call, Storage, Event}, } ); @@ -125,7 +125,7 @@ parameter_types! { } impl pallet_treasury::Config for Test { type ModuleId = TreasuryModuleId; - type Currency = pallet_balances::Module; + type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; type Event = Event; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 709a8f69a487d..b2dc2c9859e0b 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -178,7 +178,7 @@ impl Convert for TargetedFeeAdjustment>::block_weight(); + let current_block_weight = >::block_weight(); let normal_block_weight = *current_block_weight .get(DispatchClass::Normal) .min(&normal_max_weight); @@ -303,7 +303,7 @@ decl_module! { target += addition; sp_io::TestExternalities::new_empty().execute_with(|| { - >::set_block_consumed_resources(target, 0); + >::set_block_consumed_resources(target, 0); let next = T::FeeMultiplierUpdate::convert(min_value); assert!(next > min_value, "The minimum bound of the multiplier is too low. When \ block saturation is more than target by 1% and multiplier is minimal then \ @@ -630,9 +630,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Module, Storage}, + System: system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, } ); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 3c70099843ea8..45fc3e629fb0b 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -43,9 +43,9 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Treasury: treasury::{Module, Call, Storage, Config, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Treasury: treasury::{Pallet, Call, Storage, Config, Event}, } ); @@ -105,7 +105,7 @@ parameter_types! { } impl Config for Test { type ModuleId = TreasuryModuleId; - type Currency = pallet_balances::Module; + type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; type Event = Event; diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index 79fb569c77a5c..b05b97d1d497a 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark const SEED: u32 = 0; fn assert_last_event(generic_event: ::Event) { - let events = frame_system::Module::::events(); + let events = frame_system::Pallet::::events(); let system_event: ::Event = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len() - 1]; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index af31bbe96cbc4..739ad74d6576b 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -75,10 +75,10 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Utility: utility::{Module, Call, Event}, - Example: example::{Module, Call}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Utility: utility::{Pallet, Call, Event}, + Example: example::{Pallet, Call}, } ); @@ -170,7 +170,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn last_event() -> Event { - frame_system::Module::::events().pop().map(|e| e.event).expect("Event expected") + frame_system::Pallet::::events().pop().map(|e| e.event).expect("Event expected") } fn expect_event>(e: E) { diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 937f2b033d847..0a882157ab38a 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_system::{RawOrigin, Module as System}; +use frame_system::{RawOrigin, Pallet as System}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use sp_runtime::traits::Bounded; diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 9cf9166b37c0c..7b725f7486dfd 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -314,7 +314,7 @@ impl Module { /// current unvested amount. fn update_lock(who: T::AccountId) -> DispatchResult { let vesting = Self::vesting(&who).ok_or(Error::::NotVesting)?; - let now = >::block_number(); + let now = >::block_number(); let locked_now = vesting.locked_at::(now); if locked_now.is_zero() { @@ -339,7 +339,7 @@ impl VestingSchedule for Module where /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { if let Some(v) = Self::vesting(who) { - let now = >::block_number(); + let now = >::block_number(); let locked_now = v.locked_at::(now); Some(T::Currency::free_balance(who).min(locked_now)) } else { @@ -408,9 +408,9 @@ mod tests { NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Module, Call, Config, Storage, Event}, - Balances: pallet_balances::{Module, Call, Storage, Config, Event}, - Vesting: pallet_vesting::{Module, Call, Storage, Event, Config}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config}, } ); diff --git a/primitives/runtime/src/offchain/storage_lock.rs b/primitives/runtime/src/offchain/storage_lock.rs index 4c66db6c385c0..1529de4ab591a 100644 --- a/primitives/runtime/src/offchain/storage_lock.rs +++ b/primitives/runtime/src/offchain/storage_lock.rs @@ -439,11 +439,11 @@ pub trait BlockNumberProvider { /// /// In case of using crate `sp_runtime` without the crate `frame` /// system, it is already implemented for - /// `frame_system::Module` as: + /// `frame_system::Pallet` as: /// /// ```ignore /// fn current_block_number() -> Self { - /// frame_system::Module::block_number() + /// frame_system::Pallet::block_number() /// } /// ``` /// . diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 5f80dc93a95f2..a3acea164ad9c 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -451,10 +451,10 @@ impl From> for Event { impl frame_support::traits::PalletInfo for Runtime { fn index() -> Option { let type_id = sp_std::any::TypeId::of::

(); - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some(0) } - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some(1) } if type_id == sp_std::any::TypeId::of::>() { @@ -465,10 +465,10 @@ impl frame_support::traits::PalletInfo for Runtime { } fn name() -> Option<&'static str> { let type_id = sp_std::any::TypeId::of::

(); - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some("System") } - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some("Timestamp") } if type_id == sp_std::any::TypeId::of::>() { diff --git a/utils/frame/remote-externalities/src/lib.rs b/utils/frame/remote-externalities/src/lib.rs index 8211274c46298..a5687f42337f9 100644 --- a/utils/frame/remote-externalities/src/lib.rs +++ b/utils/frame/remote-externalities/src/lib.rs @@ -76,7 +76,7 @@ //! assert_eq!( //! // note: the hash corresponds to 3098546. We can check only the parent. //! // https://polkascan.io/kusama/block/3098546 -//! >::block_hash(3098545u32), +//! >::block_hash(3098545u32), //! parent, //! ) //! }); From c1da4af8a72a48372c5a14493c1c50c64cb147f1 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 01:05:45 +1300 Subject: [PATCH 05/12] Replace more deprecated 'Module' struct. --- bin/node/runtime/src/lib.rs | 4 ++-- frame/assets/src/benchmarking.rs | 2 +- frame/balances/src/benchmarking.rs | 2 +- frame/benchmarking/src/lib.rs | 10 +++++----- frame/benchmarking/src/tests.rs | 2 +- frame/contracts/src/benchmarking/code.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/offences/benchmarking/src/lib.rs | 4 ++-- frame/session/benchmarking/src/lib.rs | 8 ++++---- frame/system/benchmarking/src/lib.rs | 4 ++-- frame/timestamp/src/benchmarking.rs | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index bd50ed367879c..12e7c265bf598 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1434,8 +1434,8 @@ impl_runtime_apis! { // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // issues. To get around that, we separated the Session benchmarks into its own crate, // which is why we need these two lines below. - use pallet_session_benchmarking::Module as SessionBench; - use pallet_offences_benchmarking::Module as OffencesBench; + use pallet_session_benchmarking::Pallet as SessionBench; + use pallet_offences_benchmarking::Pallet as OffencesBench; use frame_system_benchmarking::Pallet as SystemBench; impl pallet_session_benchmarking::Config for Runtime {} diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 99ee5e99d1cf3..37300bf221ded 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -29,7 +29,7 @@ use frame_benchmarking::{ use frame_support::traits::Get; use frame_support::{traits::EnsureOrigin, dispatch::UnfilteredDispatchable}; -use crate::Module as Assets; +use crate::Pallet as Assets; const SEED: u32 = 0; diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index c7cb67403d749..62959c4f1dc4a 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -25,7 +25,7 @@ use frame_system::RawOrigin; use frame_benchmarking::{benchmarks_instance_pallet, account, whitelisted_caller, impl_benchmark_test_suite}; use sp_runtime::traits::Bounded; -use crate::Module as Balances; +use crate::Pallet as Balances; const SEED: u32 = 0; // existential deposit multiplier diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index b7f8303cb2609..b134e79ca2450 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -676,7 +676,7 @@ macro_rules! impl_benchmark { ( $( $name_extra:ident ),* ) ) => { impl, $instance: $instance_bound )? > - $crate::Benchmarking<$crate::BenchmarkResults> for Module + $crate::Benchmarking<$crate::BenchmarkResults> for Pallet where T: frame_system::Config, $( $where_clause )* { fn benchmarks(extra: bool) -> $crate::Vec<&'static [u8]> { @@ -961,7 +961,7 @@ macro_rules! impl_benchmark_test { /// When called in `pallet_example` as /// /// ```rust,ignore -/// impl_benchmark_test_suite!(Module, crate::tests::new_test_ext(), crate::tests::Test); +/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); /// ``` /// /// It expands to the equivalent of: @@ -1019,11 +1019,11 @@ macro_rules! impl_benchmark_test { /// } /// /// mod tests { -/// // because of macro syntax limitations, neither Module nor benches can be paths, but both have +/// // because of macro syntax limitations, neither Pallet nor benches can be paths, but both have /// // to be idents in the scope of `impl_benchmark_test_suite`. -/// use crate::{benches, Module}; +/// use crate::{benches, Pallet}; /// -/// impl_benchmark_test_suite!(Module, new_test_ext(), Test, benchmarks_path = benches); +/// impl_benchmark_test_suite!(Pallet, new_test_ext(), Test, benchmarks_path = benches); /// /// // new_test_ext and the Test item are defined later in this module /// } diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 7b872e52941e6..ac0a208543058 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -133,7 +133,7 @@ mod benchmarks { use crate::{BenchmarkingSetup, BenchmarkParameter, account}; // Additional used internally by the benchmark macro. - use super::pallet_test::{Call, Config, Module}; + use super::pallet_test::{Call, Config, Pallet}; crate::benchmarks!{ where_clause { diff --git a/frame/contracts/src/benchmarking/code.rs b/frame/contracts/src/benchmarking/code.rs index 64d2a0cf011d9..de1ef72d1b559 100644 --- a/frame/contracts/src/benchmarking/code.rs +++ b/frame/contracts/src/benchmarking/code.rs @@ -25,7 +25,7 @@ //! compiles it down into a `WasmModule` that can be used as a contract's code. use crate::Config; -use crate::Module as Contracts; +use crate::Pallet as Contracts; use parity_wasm::elements::{ Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection, diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index dd313e98ef4c8..81419781bf85f 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -23,7 +23,7 @@ mod code; mod sandbox; use crate::{ - *, Module as Contracts, + *, Pallet as Contracts, exec::StorageKey, rent::Rent, schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE}, diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index b3dca22ca4721..f430330f767b9 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -50,7 +50,7 @@ const MAX_OFFENDERS: u32 = 100; const MAX_NOMINATORS: u32 = 100; const MAX_DEFERRED_OFFENCES: u32 = 100; -pub struct Module(Offences); +pub struct Pallet(Offences); pub trait Config: SessionConfig @@ -421,7 +421,7 @@ benchmarks! { } impl_benchmark_test_suite!( - Module, + Pallet, crate::mock::new_test_ext(), crate::mock::Test, ); diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index 8546800ee4fdc..696a86166c1d7 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -41,10 +41,10 @@ use sp_runtime::traits::{One, StaticLookup}; const MAX_VALIDATORS: u32 = 1000; -pub struct Module(pallet_session::Module); +pub struct Pallet(pallet_session::Module); pub trait Config: pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config {} -impl OnInitialize for Module { +impl OnInitialize for Pallet { fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight { pallet_session::Module::::on_initialize(n) } @@ -157,7 +157,7 @@ fn check_membership_proof_setup( Session::::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap(); } - Module::::on_initialize(T::BlockNumber::one()); + Pallet::::on_initialize(T::BlockNumber::one()); // skip sessions until the new validator set is enacted while Session::::validators().len() < n as usize { @@ -170,7 +170,7 @@ fn check_membership_proof_setup( } impl_benchmark_test_suite!( - Module, + Pallet, crate::mock::new_test_ext(), crate::mock::Test, extra = false, diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index 80789c5b550f6..7146bcd60645b 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -34,7 +34,7 @@ use frame_system::{Pallet as System, Call, RawOrigin, DigestItemOf}; mod mock; -pub struct Module(System); +pub struct Pallet(System); pub trait Config: frame_system::Config {} benchmarks! { @@ -145,7 +145,7 @@ benchmarks! { } impl_benchmark_test_suite!( - Module, + Pallet, crate::mock::new_test_ext(), crate::mock::Test, ); diff --git a/frame/timestamp/src/benchmarking.rs b/frame/timestamp/src/benchmarking.rs index b3e8eca889cb0..d64fa8dc691c7 100644 --- a/frame/timestamp/src/benchmarking.rs +++ b/frame/timestamp/src/benchmarking.rs @@ -24,7 +24,7 @@ use frame_system::RawOrigin; use frame_support::{ensure, traits::OnFinalize}; use frame_benchmarking::{benchmarks, TrackedStorageKey, impl_benchmark_test_suite}; -use crate::Module as Timestamp; +use crate::Pallet as Timestamp; const MAX_TIME: u32 = 100; From 0454cded07c8f489e1630729bb88a0c3ad61f6ee Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 01:21:05 +1300 Subject: [PATCH 06/12] Bring back AllModules and AllPalletsWithSystem type, but deprecate them. --- frame/democracy/src/benchmarking.rs | 2 +- frame/identity/src/benchmarking.rs | 2 +- frame/support/procedural/src/construct_runtime/mod.rs | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 73275fa7cb612..40bc99ec12e01 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -27,7 +27,7 @@ use frame_support::{ use frame_system::{RawOrigin, Pallet as System, self, EventRecord}; use sp_runtime::traits::{Bounded, One}; -use crate::Module as Democracy; +use crate::Pallet as Democracy; const SEED: u32 = 0; const MAX_REFERENDUMS: u32 = 99; diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index b567bde32cfbe..372abc72a97dd 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -25,7 +25,7 @@ use frame_system::{EventRecord, RawOrigin}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use sp_runtime::traits::Bounded; -use crate::Module as Identity; +use crate::Pallet as Identity; const SEED: u32 = 0; diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index cf4231de0b050..bcaf9fe871649 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -475,6 +475,16 @@ fn decl_all_pallets<'a>( pub type AllPallets = ( #all_pallets ); /// All pallets included in the runtime as a nested tuple of types. pub type AllPalletsWithSystem = ( #all_pallets_with_system ); + + /// All modules included in the runtime as a nested tuple of types. + /// Excludes the System pallet. + #[deprecated(note = "use `AllPallets` instead")] + #[allow(dead_code)] + pub type AllModules = ( #all_pallets ); + /// All modules included in the runtime as a nested tuple of types. + #[deprecated(note = "use `AllModulesWithSystem` instead")] + #[allow(dead_code)] + pub type AllModulesWithSystem = ( #all_pallets_with_system ); ) } From 5612fa9c6e38355e46fcb1ad7b94ea60dec6fd80 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 01:40:25 +1300 Subject: [PATCH 07/12] Replace deprecated 'Module' struct from merge master. --- frame/election-provider-multi-phase/src/helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/src/helpers.rs b/frame/election-provider-multi-phase/src/helpers.rs index 41d17e6aa9a2b..425fcb2effe78 100644 --- a/frame/election-provider-multi-phase/src/helpers.rs +++ b/frame/election-provider-multi-phase/src/helpers.rs @@ -25,7 +25,7 @@ macro_rules! log { ($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => { log::$level!( target: $crate::LOG_TARGET, - concat!("[#{:?}] 🗳 ", $pattern), >::block_number() $(, $values)* + concat!("[#{:?}] 🗳 ", $pattern), >::block_number() $(, $values)* ) }; } From 43989faf7fb702c0a29b8701ca264c6a12c59d99 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 01:42:23 +1300 Subject: [PATCH 08/12] Minor fix. --- frame/support/procedural/src/construct_runtime/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index bcaf9fe871649..0951dbdea987d 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -482,7 +482,7 @@ fn decl_all_pallets<'a>( #[allow(dead_code)] pub type AllModules = ( #all_pallets ); /// All modules included in the runtime as a nested tuple of types. - #[deprecated(note = "use `AllModulesWithSystem` instead")] + #[deprecated(note = "use `AllPalletsWithSystem` instead")] #[allow(dead_code)] pub type AllModulesWithSystem = ( #all_pallets_with_system ); ) From 9f9d5741210578f25ff1b4717b5fdd423243a11b Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 14:01:49 +1300 Subject: [PATCH 09/12] Fix UI tests. --- frame/support/src/metadata.rs | 2 +- .../test/tests/construct_runtime_ui/conflicting_index.stderr | 4 ++-- .../tests/construct_runtime_ui/conflicting_index_2.stderr | 4 ++-- .../construct_runtime_ui/conflicting_module_name.stderr | 4 ++-- .../construct_runtime_ui/generics_in_invalid_module.stderr | 2 +- .../invalid_module_details_keyword.stderr | 2 +- .../tests/construct_runtime_ui/invalid_module_entry.stderr | 2 +- .../missing_event_generic_on_module_with_instance.stderr | 2 +- .../missing_origin_generic_on_module_with_instance.stderr | 2 +- .../tests/construct_runtime_ui/missing_system_module.stderr | 2 +- .../tests/construct_runtime_ui/more_than_256_modules.stderr | 2 +- frame/support/test/tests/derive_no_bound_ui/eq.stderr | 5 +++++ 12 files changed, 19 insertions(+), 14 deletions(-) diff --git a/frame/support/src/metadata.rs b/frame/support/src/metadata.rs index a253dabce85b2..d0c59a0dfdc1d 100644 --- a/frame/support/src/metadata.rs +++ b/frame/support/src/metadata.rs @@ -58,7 +58,7 @@ pub use frame_metadata::{ /// /// struct Runtime; /// frame_support::impl_runtime_metadata! { -/// for Runtime with modules where Extrinsic = UncheckedExtrinsic +/// for Runtime with pallets where Extrinsic = UncheckedExtrinsic /// module0::Module as Module0 { index 0 } with, /// module1::Module as Module1 { index 1 } with, /// module2::Module as Module2 { index 2 } with Storage, diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_index.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_index.stderr index 65368666c88fe..2e2028fd1b862 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_index.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_index.stderr @@ -1,10 +1,10 @@ -error: Module indices are conflicting: Both modules System and Pallet1 are at index 0 +error: Pallet indices are conflicting: Both pallets System and Pallet1 are at index 0 --> $DIR/conflicting_index.rs:9:3 | 9 | System: system::{}, | ^^^^^^ -error: Module indices are conflicting: Both modules System and Pallet1 are at index 0 +error: Pallet indices are conflicting: Both pallets System and Pallet1 are at index 0 --> $DIR/conflicting_index.rs:10:3 | 10 | Pallet1: pallet1::{} = 0, diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_index_2.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_index_2.stderr index b792ff5d2a541..bfa3706a456a4 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_index_2.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_index_2.stderr @@ -1,10 +1,10 @@ -error: Module indices are conflicting: Both modules System and Pallet3 are at index 5 +error: Pallet indices are conflicting: Both pallets System and Pallet3 are at index 5 --> $DIR/conflicting_index_2.rs:9:3 | 9 | System: system::{} = 5, | ^^^^^^ -error: Module indices are conflicting: Both modules System and Pallet3 are at index 5 +error: Pallet indices are conflicting: Both pallets System and Pallet3 are at index 5 --> $DIR/conflicting_index_2.rs:12:3 | 12 | Pallet3: pallet3::{}, diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr index 89c6b9e054131..27c5644e0d736 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr @@ -1,10 +1,10 @@ -error: Two modules with the same name! +error: Two pallets with the same name! --> $DIR/conflicting_module_name.rs:10:3 | 10 | Balance: balances::{Pallet}, | ^^^^^^^ -error: Two modules with the same name! +error: Two pallets with the same name! --> $DIR/conflicting_module_name.rs:11:3 | 11 | Balance: balances::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr index fe880549211bc..06caa036b91ff 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr @@ -1,4 +1,4 @@ -error: `Call` is not allowed to have generics. Only the following modules are allowed to have generics: `Event`, `Origin`, `Config`. +error: `Call` is not allowed to have generics. Only the following pallets are allowed to have generics: `Event`, `Origin`, `Config`. --> $DIR/generics_in_invalid_module.rs:10:36 | 10 | Balance: balances::::{Call, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr index 66c9fc95cb546..29df6e4bd8cb5 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr @@ -1,4 +1,4 @@ -error: expected one of: `Module`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned` +error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned` --> $DIR/invalid_module_details_keyword.rs:9:20 | 9 | system: System::{enum}, diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr index 7442c6be3a9a3..bd3e672dc8b40 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr @@ -1,4 +1,4 @@ -error: expected one of: `Module`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned` +error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned` --> $DIR/invalid_module_entry.rs:10:23 | 10 | Balance: balances::{Error}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr index f80b4bd66abdd..b1aa9b86cd0d6 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr @@ -1,4 +1,4 @@ -error: Instantiable module with no generic `Event` cannot be constructed: module `Balance` must have generic `Event` +error: Instantiable pallet with no generic `Event` cannot be constructed: pallet `Balance` must have generic `Event` --> $DIR/missing_event_generic_on_module_with_instance.rs:10:3 | 10 | Balance: balances::::{Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr index 0f7d36aafb863..63bb7442a8576 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr @@ -1,4 +1,4 @@ -error: Instantiable module with no generic `Origin` cannot be constructed: module `Balance` must have generic `Origin` +error: Instantiable pallet with no generic `Origin` cannot be constructed: pallet `Balance` must have generic `Origin` --> $DIR/missing_origin_generic_on_module_with_instance.rs:10:3 | 10 | Balance: balances::::{Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index a57eac19194cd..c5319da851078 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,4 +1,4 @@ -error: `System` module declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` +error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` --> $DIR/missing_system_module.rs:8:2 | 8 | { diff --git a/frame/support/test/tests/construct_runtime_ui/more_than_256_modules.stderr b/frame/support/test/tests/construct_runtime_ui/more_than_256_modules.stderr index c0ef5c8e60b9e..2e055f5d3726a 100644 --- a/frame/support/test/tests/construct_runtime_ui/more_than_256_modules.stderr +++ b/frame/support/test/tests/construct_runtime_ui/more_than_256_modules.stderr @@ -1,4 +1,4 @@ -error: Module index doesn't fit into u8, index is 256 +error: Pallet index doesn't fit into u8, index is 256 --> $DIR/more_than_256_modules.rs:10:3 | 10 | Pallet256: pallet256::{}, diff --git a/frame/support/test/tests/derive_no_bound_ui/eq.stderr b/frame/support/test/tests/derive_no_bound_ui/eq.stderr index bbd907adecb33..36384178d469b 100644 --- a/frame/support/test/tests/derive_no_bound_ui/eq.stderr +++ b/frame/support/test/tests/derive_no_bound_ui/eq.stderr @@ -4,4 +4,9 @@ error[E0277]: can't compare `Foo` with `Foo` 6 | struct Foo { | ^^^ no implementation for `Foo == Foo` | + ::: $RUST/core/src/cmp.rs + | + | pub trait Eq: PartialEq { + | --------------- required by this bound in `Eq` + | = help: the trait `PartialEq` is not implemented for `Foo` From 3ebcb3e80cefaf56c32ab4c865691420e17fd7dc Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Wed, 17 Mar 2021 15:45:41 +1300 Subject: [PATCH 10/12] Revert UI override in derive_no_bound. --- frame/support/test/tests/derive_no_bound_ui/eq.stderr | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frame/support/test/tests/derive_no_bound_ui/eq.stderr b/frame/support/test/tests/derive_no_bound_ui/eq.stderr index 36384178d469b..bbd907adecb33 100644 --- a/frame/support/test/tests/derive_no_bound_ui/eq.stderr +++ b/frame/support/test/tests/derive_no_bound_ui/eq.stderr @@ -4,9 +4,4 @@ error[E0277]: can't compare `Foo` with `Foo` 6 | struct Foo { | ^^^ no implementation for `Foo == Foo` | - ::: $RUST/core/src/cmp.rs - | - | pub trait Eq: PartialEq { - | --------------- required by this bound in `Eq` - | = help: the trait `PartialEq` is not implemented for `Foo` From 71e85fabdb64b10b219200b6703610b75520034a Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Thu, 18 Mar 2021 12:15:29 +1300 Subject: [PATCH 11/12] Fix more deprecated 'Module' use from master branch. --- frame/babe/src/mock.rs | 2 +- frame/proxy/src/benchmarking.rs | 8 ++++---- frame/proxy/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index e85786e630088..0029b51abf399 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -104,7 +104,7 @@ where impl_opaque_keys! { pub struct MockSessionKeys { - pub babe_authority: super::Module, + pub babe_authority: super::Pallet, } } diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 377eda17e8c1f..4027fcbafa0d6 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -23,7 +23,7 @@ use super::*; use frame_system::{RawOrigin, EventRecord}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use sp_runtime::traits::Bounded; -use crate::Module as Proxy; +use crate::Pallet as Proxy; const SEED: u32 = 0; @@ -219,7 +219,7 @@ benchmarks! { 0 ) verify { - let anon_account = Module::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); + let anon_account = Pallet::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); assert_last_event::(Event::AnonymousCreated( anon_account, caller, @@ -233,7 +233,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); - Module::::anonymous( + Pallet::::anonymous( RawOrigin::Signed(whitelisted_caller()).into(), T::ProxyType::default(), T::BlockNumber::zero(), @@ -241,7 +241,7 @@ benchmarks! { )?; let height = system::Pallet::::block_number(); let ext_index = system::Pallet::::extrinsic_index().unwrap_or(0); - let anon = Module::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); + let anon = Pallet::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); add_proxies::(p, Some(anon.clone()))?; ensure!(Proxies::::contains_key(&anon), "anon proxy not created"); diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 0093bf011f1f6..5600fb6ea806a 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -584,7 +584,7 @@ pub mod pallet { } -impl Module { +impl Pallet { /// Calculate the address of an anonymous account. /// From 8d9b4db05c0392784851f36f7e9f05af1c1965d6 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Thu, 18 Mar 2021 13:37:07 +1300 Subject: [PATCH 12/12] Fix more deprecated 'Module' use from master branch. --- test-utils/runtime/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index a3acea164ad9c..4caee01fba68d 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -457,7 +457,7 @@ impl frame_support::traits::PalletInfo for Runtime { if type_id == sp_std::any::TypeId::of::>() { return Some(1) } - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some(2) } @@ -471,7 +471,7 @@ impl frame_support::traits::PalletInfo for Runtime { if type_id == sp_std::any::TypeId::of::>() { return Some("Timestamp") } - if type_id == sp_std::any::TypeId::of::>() { + if type_id == sp_std::any::TypeId::of::>() { return Some("Babe") } @@ -779,21 +779,21 @@ cfg_if! { c: (3, 10), genesis_authorities: system::authorities() .into_iter().map(|x|(x, 1)).collect(), - randomness: >::randomness(), + randomness: >::randomness(), allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots, } } fn current_epoch_start() -> Slot { - >::current_epoch_start() + >::current_epoch_start() } fn current_epoch() -> sp_consensus_babe::Epoch { - >::current_epoch() + >::current_epoch() } fn next_epoch() -> sp_consensus_babe::Epoch { - >::next_epoch() + >::next_epoch() } fn submit_report_equivocation_unsigned_extrinsic( @@ -1037,21 +1037,21 @@ cfg_if! { c: (3, 10), genesis_authorities: system::authorities() .into_iter().map(|x|(x, 1)).collect(), - randomness: >::randomness(), + randomness: >::randomness(), allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots, } } fn current_epoch_start() -> Slot { - >::current_epoch_start() + >::current_epoch_start() } fn current_epoch() -> sp_consensus_babe::Epoch { - >::current_epoch() + >::current_epoch() } fn next_epoch() -> sp_consensus_babe::Epoch { - >::next_epoch() + >::next_epoch() } fn submit_report_equivocation_unsigned_extrinsic(