BREAKING: Rename Call & Event (#11981)

* rename Event to RuntimeEvent

* rename Call

* rename in runtimes

* small fix

* rename Event

* small fix & rename RuntimeCall back to Call for now

* small fixes

* more renaming

* a bit more renaming

* fmt

* small fix

* commit

* prep for renaming associated types

* fix

* rename associated Event type

* rename to RuntimeEvent

* commit

* merge conflict fixes & fmt

* additional renaming

* fix.

* fix decl_event

* rename in tests

* remove warnings

* remove accidental rename

* .

* commit

* update .stderr

* fix in test

* update .stderr

* TRYBUILD=overwrite

* docs

* fmt

* small change in docs

* rename PalletEvent to Event

* rename Call to RuntimeCall

* renamed at wrong places :P

* rename Call

* rename

* rename associated type

* fix

* fix & fmt

* commit

* frame-support-test

* passing tests

* update docs

* rustdoc fix

* update .stderr

* wrong code in docs

* merge fix

* fix in error message

* update .stderr

* docs & error message

* .

* merge fix

* merge fix

* fmt

* fmt

* merge fix

* more fixing

* fmt

* remove unused

* fmt

* fix

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Sergej Sakac
2022-09-13 00:03:31 +02:00
committed by GitHub
parent 472b5746e5
commit 6e8795afe6
228 changed files with 1791 additions and 1672 deletions
@@ -55,7 +55,7 @@ pub fn expand_outer_dispatch(
#[codec(index = #index)]
#name( #scrate::dispatch::CallableCallFor<#name, #runtime> ),
});
variant_patterns.push(quote!(Call::#name(call)));
variant_patterns.push(quote!(RuntimeCall::#name(call)));
pallet_names.push(name);
pallet_attrs.push(attr);
query_call_part_macros.push(quote! {
@@ -73,11 +73,11 @@ pub fn expand_outer_dispatch(
#scrate::scale_info::TypeInfo,
#scrate::RuntimeDebug,
)]
pub enum Call {
pub enum RuntimeCall {
#variant_defs
}
#[cfg(test)]
impl Call {
impl RuntimeCall {
/// Return a list of the module names together with their size in memory.
pub const fn sizes() -> &'static [( &'static str, usize )] {
use #scrate::dispatch::Callable;
@@ -86,7 +86,7 @@ pub fn expand_outer_dispatch(
#pallet_attrs
(
stringify!(#pallet_names),
size_of::< <#pallet_names as Callable<#runtime>>::Call >(),
size_of::< <#pallet_names as Callable<#runtime>>::RuntimeCall >(),
),
)*]
}
@@ -113,7 +113,7 @@ pub fn expand_outer_dispatch(
}
}
}
impl #scrate::dispatch::GetDispatchInfo for Call {
impl #scrate::dispatch::GetDispatchInfo for RuntimeCall {
fn get_dispatch_info(&self) -> #scrate::dispatch::DispatchInfo {
match self {
#(
@@ -123,7 +123,7 @@ pub fn expand_outer_dispatch(
}
}
}
impl #scrate::dispatch::GetCallMetadata for Call {
impl #scrate::dispatch::GetCallMetadata for RuntimeCall {
fn get_call_metadata(&self) -> #scrate::dispatch::CallMetadata {
use #scrate::dispatch::GetCallName;
match self {
@@ -151,16 +151,16 @@ pub fn expand_outer_dispatch(
#(
#pallet_attrs
stringify!(#pallet_names) =>
<<#pallet_names as Callable<#runtime>>::Call
<<#pallet_names as Callable<#runtime>>::RuntimeCall
as GetCallName>::get_call_names(),
)*
_ => unreachable!(),
}
}
}
impl #scrate::dispatch::Dispatchable for Call {
impl #scrate::dispatch::Dispatchable for RuntimeCall {
type Origin = Origin;
type Config = Call;
type Config = RuntimeCall;
type Info = #scrate::weights::DispatchInfo;
type PostInfo = #scrate::weights::PostDispatchInfo;
fn dispatch(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo {
@@ -173,7 +173,7 @@ pub fn expand_outer_dispatch(
#scrate::traits::UnfilteredDispatchable::dispatch_bypass_filter(self, origin)
}
}
impl #scrate::traits::UnfilteredDispatchable for Call {
impl #scrate::traits::UnfilteredDispatchable for RuntimeCall {
type Origin = Origin;
fn dispatch_bypass_filter(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo {
match self {
@@ -188,7 +188,7 @@ pub fn expand_outer_dispatch(
#(
#pallet_attrs
impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call {
impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall {
#[allow(unreachable_patterns)]
fn is_sub_type(&self) -> Option<&#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> {
match self {
@@ -200,7 +200,7 @@ pub fn expand_outer_dispatch(
}
#pallet_attrs
impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call {
impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall {
fn from(call: #scrate::dispatch::CallableCallFor<#pallet_names, #runtime>) -> Self {
#variant_patterns
}
@@ -80,7 +80,7 @@ pub fn expand_outer_event(
#scrate::RuntimeDebug,
)]
#[allow(non_camel_case_types)]
pub enum Event {
pub enum RuntimeEvent {
#event_variants
}
@@ -148,13 +148,13 @@ fn expand_event_conversion(
quote! {
#attr
impl From<#pallet_event> for Event {
impl From<#pallet_event> for RuntimeEvent {
fn from(x: #pallet_event) -> Self {
Event::#variant_name(x)
RuntimeEvent::#variant_name(x)
}
}
#attr
impl TryInto<#pallet_event> for Event {
impl TryInto<#pallet_event> for RuntimeEvent {
type Error = ();
fn try_into(self) -> #scrate::sp_std::result::Result<#pallet_event, Self::Error> {
@@ -105,7 +105,7 @@ pub fn expand_outer_origin(
#[derive(Clone)]
pub struct Origin {
caller: OriginCaller,
filter: #scrate::sp_std::rc::Rc<Box<dyn Fn(&<#runtime as #system_path::Config>::Call) -> bool>>,
filter: #scrate::sp_std::rc::Rc<Box<dyn Fn(&<#runtime as #system_path::Config>::RuntimeCall) -> bool>>,
}
#[cfg(not(feature = "std"))]
@@ -132,7 +132,7 @@ pub fn expand_outer_origin(
}
impl #scrate::traits::OriginTrait for Origin {
type Call = <#runtime as #system_path::Config>::Call;
type Call = <#runtime as #system_path::Config>::RuntimeCall;
type PalletsOrigin = OriginCaller;
type AccountId = <#runtime as #system_path::Config>::AccountId;
@@ -147,7 +147,7 @@ pub fn expand_outer_origin(
fn reset_filter(&mut self) {
let filter = <
<#runtime as #system_path::Config>::BaseCallFilter
as #scrate::traits::Contains<<#runtime as #system_path::Config>::Call>
as #scrate::traits::Contains<<#runtime as #system_path::Config>::RuntimeCall>
>::contains;
self.filter = #scrate::sp_std::rc::Rc::new(Box::new(filter));
@@ -55,14 +55,14 @@ pub fn expand_outer_validate_unsigned(
#( #query_validate_unsigned_part_macros )*
impl #scrate::unsigned::ValidateUnsigned for #runtime {
type Call = Call;
type Call = RuntimeCall;
fn pre_dispatch(call: &Self::Call) -> Result<(), #scrate::unsigned::TransactionValidityError> {
#[allow(unreachable_patterns)]
match call {
#(
#pallet_attrs
Call::#pallet_names(inner_call) => #pallet_names::pre_dispatch(inner_call),
RuntimeCall::#pallet_names(inner_call) => #pallet_names::pre_dispatch(inner_call),
)*
// pre-dispatch should not stop inherent extrinsics, validation should prevent
// including arbitrary (non-inherent) extrinsics to blocks.
@@ -79,7 +79,7 @@ pub fn expand_outer_validate_unsigned(
match call {
#(
#pallet_attrs
Call::#pallet_names(inner_call) => #pallet_names::validate_unsigned(source, inner_call),
RuntimeCall::#pallet_names(inner_call) => #pallet_names::validate_unsigned(source, inner_call),
)*
_ => #scrate::unsigned::UnknownTransaction::NoUnsignedValidator.into(),
}