mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 09:01:08 +00:00
Rename pallet trait Trait to Config (#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
This commit is contained in:
committed by
GitHub
parent
dd3c84c362
commit
1cbfc9257f
@@ -181,12 +181,12 @@ macro_rules! impl_outer_origin {
|
||||
index { $( $index:tt )? },
|
||||
)*
|
||||
) => {
|
||||
// WARNING: All instance must hold the filter `frame_system::Trait::BaseCallFilter`, except
|
||||
// WARNING: All instance must hold the filter `frame_system::Config::BaseCallFilter`, except
|
||||
// when caller is system Root. One can use `OriginTrait::reset_filter` to do so.
|
||||
#[derive(Clone)]
|
||||
pub struct $name {
|
||||
caller: $caller_name,
|
||||
filter: $crate::sp_std::rc::Rc<Box<dyn Fn(&<$runtime as $system::Trait>::Call) -> bool>>,
|
||||
filter: $crate::sp_std::rc::Rc<Box<dyn Fn(&<$runtime as $system::Config>::Call) -> bool>>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
@@ -213,9 +213,9 @@ macro_rules! impl_outer_origin {
|
||||
}
|
||||
|
||||
impl $crate::traits::OriginTrait for $name {
|
||||
type Call = <$runtime as $system::Trait>::Call;
|
||||
type Call = <$runtime as $system::Config>::Call;
|
||||
type PalletsOrigin = $caller_name;
|
||||
type AccountId = <$runtime as $system::Trait>::AccountId;
|
||||
type AccountId = <$runtime as $system::Config>::AccountId;
|
||||
|
||||
fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static) {
|
||||
let f = self.filter.clone();
|
||||
@@ -227,8 +227,8 @@ macro_rules! impl_outer_origin {
|
||||
|
||||
fn reset_filter(&mut self) {
|
||||
let filter = <
|
||||
<$runtime as $system::Trait>::BaseCallFilter
|
||||
as $crate::traits::Filter<<$runtime as $system::Trait>::Call>
|
||||
<$runtime as $system::Config>::BaseCallFilter
|
||||
as $crate::traits::Filter<<$runtime as $system::Config>::Call>
|
||||
>::filter;
|
||||
|
||||
self.filter = $crate::sp_std::rc::Rc::new(Box::new(filter));
|
||||
@@ -246,7 +246,7 @@ macro_rules! impl_outer_origin {
|
||||
&self.caller
|
||||
}
|
||||
|
||||
/// Create with system none origin and `frame-system::Trait::BaseCallFilter`.
|
||||
/// Create with system none origin and `frame-system::Config::BaseCallFilter`.
|
||||
fn none() -> Self {
|
||||
$system::RawOrigin::None.into()
|
||||
}
|
||||
@@ -254,8 +254,8 @@ macro_rules! impl_outer_origin {
|
||||
fn root() -> Self {
|
||||
$system::RawOrigin::Root.into()
|
||||
}
|
||||
/// Create with system signed origin and `frame-system::Trait::BaseCallFilter`.
|
||||
fn signed(by: <$runtime as $system::Trait>::AccountId) -> Self {
|
||||
/// Create with system signed origin and `frame-system::Config::BaseCallFilter`.
|
||||
fn signed(by: <$runtime as $system::Config>::AccountId) -> Self {
|
||||
$system::RawOrigin::Signed(by).into()
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ macro_rules! impl_outer_origin {
|
||||
// For backwards compatibility and ease of accessing these functions.
|
||||
#[allow(dead_code)]
|
||||
impl $name {
|
||||
/// Create with system none origin and `frame-system::Trait::BaseCallFilter`.
|
||||
/// Create with system none origin and `frame-system::Config::BaseCallFilter`.
|
||||
pub fn none() -> Self {
|
||||
<$name as $crate::traits::OriginTrait>::none()
|
||||
}
|
||||
@@ -288,8 +288,8 @@ macro_rules! impl_outer_origin {
|
||||
pub fn root() -> Self {
|
||||
<$name as $crate::traits::OriginTrait>::root()
|
||||
}
|
||||
/// Create with system signed origin and `frame-system::Trait::BaseCallFilter`.
|
||||
pub fn signed(by: <$runtime as $system::Trait>::AccountId) -> Self {
|
||||
/// Create with system signed origin and `frame-system::Config::BaseCallFilter`.
|
||||
pub fn signed(by: <$runtime as $system::Config>::AccountId) -> Self {
|
||||
<$name as $crate::traits::OriginTrait>::signed(by)
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ macro_rules! impl_outer_origin {
|
||||
impl From<$system::Origin<$runtime>> for $name {
|
||||
/// Convert to runtime origin:
|
||||
/// * root origin is built with no filter
|
||||
/// * others use `frame-system::Trait::BaseCallFilter`
|
||||
/// * others use `frame-system::Config::BaseCallFilter`
|
||||
fn from(x: $system::Origin<$runtime>) -> Self {
|
||||
let o: $caller_name = x.into();
|
||||
o.into()
|
||||
@@ -335,10 +335,10 @@ macro_rules! impl_outer_origin {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<Option<<$runtime as $system::Trait>::AccountId>> for $name {
|
||||
impl From<Option<<$runtime as $system::Config>::AccountId>> for $name {
|
||||
/// Convert to runtime origin with caller being system signed or none and use filter
|
||||
/// `frame-system::Trait::BaseCallFilter`.
|
||||
fn from(x: Option<<$runtime as $system::Trait>::AccountId>) -> Self {
|
||||
/// `frame-system::Config::BaseCallFilter`.
|
||||
fn from(x: Option<<$runtime as $system::Config>::AccountId>) -> Self {
|
||||
<$system::Origin<$runtime>>::from(x).into()
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ macro_rules! impl_outer_origin {
|
||||
}
|
||||
|
||||
impl From<$module::Origin < $( $generic )? $(, $module::$generic_instance )? > > for $name {
|
||||
/// Convert to runtime origin using `frame-system::Trait::BaseCallFilter`.
|
||||
/// Convert to runtime origin using `frame-system::Config::BaseCallFilter`.
|
||||
fn from(x: $module::Origin < $( $generic )? $(, $module::$generic_instance )? >) -> Self {
|
||||
let x: $caller_name = x.into();
|
||||
x.into()
|
||||
@@ -388,7 +388,7 @@ mod tests {
|
||||
mod frame_system {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait {
|
||||
pub trait Config {
|
||||
type AccountId;
|
||||
type Call;
|
||||
type BaseCallFilter;
|
||||
@@ -410,7 +410,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
}
|
||||
|
||||
mod origin_without_generic {
|
||||
@@ -439,7 +439,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_system::Trait for TestRuntime {
|
||||
impl frame_system::Config for TestRuntime {
|
||||
type AccountId = u32;
|
||||
type Call = u32;
|
||||
type BaseCallFilter = BaseCallFilter;
|
||||
|
||||
Reference in New Issue
Block a user