BREAKING: Rename Origin (#12258)

* BREAKING: Rename Origin

* more renaming

* a bit more renaming

* fix

* more fixing

* fix in frame_support

* even more fixes

* fix

* small fix

* ...

* update .stderr

* docs

* update docs

* update docs

* docs
This commit is contained in:
Sergej Sakac
2022-09-21 00:13:09 +02:00
committed by GitHub
parent 986d20b352
commit e4b6f4a66d
221 changed files with 5233 additions and 4200 deletions
@@ -162,12 +162,12 @@ pub fn expand_outer_dispatch(
}
}
impl #scrate::dispatch::Dispatchable for RuntimeCall {
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
type Config = RuntimeCall;
type Info = #scrate::dispatch::DispatchInfo;
type PostInfo = #scrate::dispatch::PostDispatchInfo;
fn dispatch(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo {
if !<Self::Origin as #scrate::traits::OriginTrait>::filter_call(&origin, &self) {
fn dispatch(self, origin: RuntimeOrigin) -> #scrate::dispatch::DispatchResultWithPostInfo {
if !<Self::RuntimeOrigin as #scrate::traits::OriginTrait>::filter_call(&origin, &self) {
return #scrate::sp_std::result::Result::Err(
#system_path::Error::<#runtime>::CallFiltered.into()
);
@@ -177,8 +177,8 @@ pub fn expand_outer_dispatch(
}
}
impl #scrate::traits::UnfilteredDispatchable for RuntimeCall {
type Origin = Origin;
fn dispatch_bypass_filter(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo {
type RuntimeOrigin = RuntimeOrigin;
fn dispatch_bypass_filter(self, origin: RuntimeOrigin) -> #scrate::dispatch::DispatchResultWithPostInfo {
match self {
#(
#pallet_attrs
@@ -103,13 +103,13 @@ pub fn expand_outer_origin(
///
#[doc = #doc_string]
#[derive(Clone)]
pub struct Origin {
pub struct RuntimeOrigin {
caller: OriginCaller,
filter: #scrate::sp_std::rc::Rc<Box<dyn Fn(&<#runtime as #system_path::Config>::RuntimeCall) -> bool>>,
}
#[cfg(not(feature = "std"))]
impl #scrate::sp_std::fmt::Debug for Origin {
impl #scrate::sp_std::fmt::Debug for RuntimeOrigin {
fn fmt(
&self,
fmt: &mut #scrate::sp_std::fmt::Formatter,
@@ -119,7 +119,7 @@ pub fn expand_outer_origin(
}
#[cfg(feature = "std")]
impl #scrate::sp_std::fmt::Debug for Origin {
impl #scrate::sp_std::fmt::Debug for RuntimeOrigin {
fn fmt(
&self,
fmt: &mut #scrate::sp_std::fmt::Formatter,
@@ -131,7 +131,7 @@ pub fn expand_outer_origin(
}
}
impl #scrate::traits::OriginTrait for Origin {
impl #scrate::traits::OriginTrait for RuntimeOrigin {
type Call = <#runtime as #system_path::Config>::RuntimeCall;
type PalletsOrigin = OriginCaller;
type AccountId = <#runtime as #system_path::Config>::AccountId;
@@ -214,21 +214,21 @@ pub fn expand_outer_origin(
// For backwards compatibility and ease of accessing these functions.
#[allow(dead_code)]
impl Origin {
impl RuntimeOrigin {
#[doc = #doc_string_none_origin]
pub fn none() -> Self {
<Origin as #scrate::traits::OriginTrait>::none()
<RuntimeOrigin as #scrate::traits::OriginTrait>::none()
}
#[doc = #doc_string_root_origin]
pub fn root() -> Self {
<Origin as #scrate::traits::OriginTrait>::root()
<RuntimeOrigin as #scrate::traits::OriginTrait>::root()
}
#[doc = #doc_string_signed_origin]
pub fn signed(by: <#runtime as #system_path::Config>::AccountId) -> Self {
<Origin as #scrate::traits::OriginTrait>::signed(by)
<RuntimeOrigin as #scrate::traits::OriginTrait>::signed(by)
}
}
@@ -251,7 +251,7 @@ pub fn expand_outer_origin(
}
}
impl From<#system_path::Origin<#runtime>> for Origin {
impl From<#system_path::Origin<#runtime>> for RuntimeOrigin {
#[doc = #doc_string_runtime_origin]
fn from(x: #system_path::Origin<#runtime>) -> Self {
@@ -260,9 +260,9 @@ pub fn expand_outer_origin(
}
}
impl From<OriginCaller> for Origin {
impl From<OriginCaller> for RuntimeOrigin {
fn from(x: OriginCaller) -> Self {
let mut o = Origin {
let mut o = RuntimeOrigin {
caller: x,
filter: #scrate::sp_std::rc::Rc::new(Box::new(|_| true)),
};
@@ -273,9 +273,9 @@ pub fn expand_outer_origin(
}
}
impl From<Origin> for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, Origin> {
impl From<RuntimeOrigin> for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> {
/// NOTE: converting to pallet origin loses the origin filter information.
fn from(val: Origin) -> Self {
fn from(val: RuntimeOrigin) -> Self {
if let OriginCaller::system(l) = val.caller {
Ok(l)
} else {
@@ -283,7 +283,7 @@ pub fn expand_outer_origin(
}
}
}
impl From<Option<<#runtime as #system_path::Config>::AccountId>> for Origin {
impl From<Option<<#runtime as #system_path::Config>::AccountId>> for RuntimeOrigin {
#[doc = #doc_string_runtime_origin_with_caller]
fn from(x: Option<<#runtime as #system_path::Config>::AccountId>) -> Self {
<#system_path::Origin<#runtime>>::from(x).into()
@@ -374,7 +374,7 @@ fn expand_origin_pallet_conversions(
}
#attr
impl From<#pallet_origin> for Origin {
impl From<#pallet_origin> for RuntimeOrigin {
#[doc = #doc_string]
fn from(x: #pallet_origin) -> Self {
let x: OriginCaller = x.into();
@@ -383,9 +383,9 @@ fn expand_origin_pallet_conversions(
}
#attr
impl From<Origin> for #scrate::sp_std::result::Result<#pallet_origin, Origin> {
impl From<RuntimeOrigin> for #scrate::sp_std::result::Result<#pallet_origin, RuntimeOrigin> {
/// NOTE: converting to pallet origin loses the origin filter information.
fn from(val: Origin) -> Self {
fn from(val: RuntimeOrigin) -> Self {
if let OriginCaller::#variant_name(l) = val.caller {
Ok(l)
} else {
@@ -278,10 +278,10 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
for #call_ident<#type_use_gen>
#where_clause
{
type Origin = #frame_system::pallet_prelude::OriginFor<T>;
type RuntimeOrigin = #frame_system::pallet_prelude::OriginFor<T>;
fn dispatch_bypass_filter(
self,
origin: Self::Origin
origin: Self::RuntimeOrigin
) -> #frame_support::dispatch::DispatchResultWithPostInfo {
match self {
#(
@@ -119,7 +119,7 @@ impl Def {
let g = genesis_build::GenesisBuildDef::try_from(span, index, item)?;
genesis_build = Some(g);
},
Some(PalletAttr::Origin(_)) if origin.is_none() =>
Some(PalletAttr::RuntimeOrigin(_)) if origin.is_none() =>
origin = Some(origin::OriginDef::try_from(index, item)?),
Some(PalletAttr::Inherent(_)) if inherent.is_none() =>
inherent = Some(inherent::InherentDef::try_from(index, item)?),
@@ -394,7 +394,7 @@ enum PalletAttr {
RuntimeCall(proc_macro2::Span),
Error(proc_macro2::Span),
RuntimeEvent(proc_macro2::Span),
Origin(proc_macro2::Span),
RuntimeOrigin(proc_macro2::Span),
Inherent(proc_macro2::Span),
Storage(proc_macro2::Span),
GenesisConfig(proc_macro2::Span),
@@ -413,7 +413,7 @@ impl PalletAttr {
Self::RuntimeCall(span) => *span,
Self::Error(span) => *span,
Self::RuntimeEvent(span) => *span,
Self::Origin(span) => *span,
Self::RuntimeOrigin(span) => *span,
Self::Inherent(span) => *span,
Self::Storage(span) => *span,
Self::GenesisConfig(span) => *span,
@@ -447,7 +447,7 @@ impl syn::parse::Parse for PalletAttr {
} else if lookahead.peek(keyword::event) {
Ok(PalletAttr::RuntimeEvent(content.parse::<keyword::event>()?.span()))
} else if lookahead.peek(keyword::origin) {
Ok(PalletAttr::Origin(content.parse::<keyword::origin>()?.span()))
Ok(PalletAttr::RuntimeOrigin(content.parse::<keyword::origin>()?.span()))
} else if lookahead.peek(keyword::inherent) {
Ok(PalletAttr::Inherent(content.parse::<keyword::inherent>()?.span()))
} else if lookahead.peek(keyword::storage) {