mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +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
@@ -35,7 +35,7 @@ use proc_macro::TokenStream;
|
||||
///
|
||||
/// ```nocompile
|
||||
/// decl_storage! {
|
||||
/// trait Store for Module<T: Trait> as Example {
|
||||
/// trait Store for Module<T: Config> as Example {
|
||||
/// Foo get(fn foo) config(): u32=12;
|
||||
/// Bar: map hasher(identity) u32 => u32;
|
||||
/// pub Zed build(|config| vec![(0, 0)]): map hasher(identity) u32 => u32;
|
||||
@@ -43,7 +43,7 @@ use proc_macro::TokenStream;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Declaration is set with the header `(pub) trait Store for Module<T: Trait> as Example`,
|
||||
/// Declaration is set with the header `(pub) trait Store for Module<T: Config> as Example`,
|
||||
/// with `Store` a (pub) trait generated associating each storage item to the `Module` and
|
||||
/// `as Example` setting the prefix used for storage items of this module. `Example` must be unique:
|
||||
/// another module with the same name and the same inner storage item name will conflict.
|
||||
@@ -169,7 +169,7 @@ use proc_macro::TokenStream;
|
||||
///
|
||||
/// ```nocompile
|
||||
/// decl_storage! {
|
||||
/// trait Store for Module<T: Trait> as Example {
|
||||
/// trait Store for Module<T: Config> as Example {
|
||||
///
|
||||
/// // Your storage items
|
||||
/// }
|
||||
@@ -202,7 +202,7 @@ use proc_macro::TokenStream;
|
||||
/// (`DefaultInstance` type is optional):
|
||||
///
|
||||
/// ```nocompile
|
||||
/// trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as Example {}
|
||||
/// trait Store for Module<T: Config<I>, I: Instance=DefaultInstance> as Example {}
|
||||
/// ```
|
||||
///
|
||||
/// Accessing the structure no requires the instance as generic parameter:
|
||||
@@ -214,7 +214,7 @@ use proc_macro::TokenStream;
|
||||
/// This macro supports a where clause which will be replicated to all generated types.
|
||||
///
|
||||
/// ```nocompile
|
||||
/// trait Store for Module<T: Trait> as Example where T::AccountId: std::fmt::Display {}
|
||||
/// trait Store for Module<T: Config> as Example where T::AccountId: std::fmt::Display {}
|
||||
/// ```
|
||||
///
|
||||
/// ## Limitations
|
||||
|
||||
@@ -33,11 +33,11 @@ pub struct GenesisConfigFieldDef {
|
||||
pub struct GenesisConfigDef {
|
||||
pub is_generic: bool,
|
||||
pub fields: Vec<GenesisConfigFieldDef>,
|
||||
/// For example: `<T: Trait<I>, I: Instance=DefaultInstance>`.
|
||||
/// For example: `<T: Config<I>, I: Instance=DefaultInstance>`.
|
||||
pub genesis_struct_decl: TokenStream,
|
||||
/// For example: `<T, I>`.
|
||||
pub genesis_struct: TokenStream,
|
||||
/// For example: `<T: Trait<I>, I: Instance>`.
|
||||
/// For example: `<T: Config<I>, I: Instance>`.
|
||||
pub genesis_impl: TokenStream,
|
||||
/// The where clause to use to constrain generics if genesis config is generic.
|
||||
pub genesis_where_clause: Option<syn::WhereClause>,
|
||||
|
||||
@@ -42,7 +42,7 @@ pub struct DeclStorageDef {
|
||||
module_name: syn::Ident,
|
||||
/// Usually `T`.
|
||||
module_runtime_generic: syn::Ident,
|
||||
/// Usually `Trait`
|
||||
/// Usually `Config`
|
||||
module_runtime_trait: syn::Path,
|
||||
/// For instantiable module: usually `I: Instance=DefaultInstance`.
|
||||
module_instance: Option<ModuleInstanceDef>,
|
||||
@@ -77,7 +77,7 @@ pub struct DeclStorageDefExt {
|
||||
module_name: syn::Ident,
|
||||
/// Usually `T`.
|
||||
module_runtime_generic: syn::Ident,
|
||||
/// Usually `Trait`.
|
||||
/// Usually `Config`.
|
||||
module_runtime_trait: syn::Path,
|
||||
/// For instantiable module: usually `I: Instance=DefaultInstance`.
|
||||
module_instance: Option<ModuleInstanceDef>,
|
||||
@@ -93,7 +93,7 @@ pub struct DeclStorageDefExt {
|
||||
crate_name: syn::Ident,
|
||||
/// Full struct expansion: `Module<T, I>`.
|
||||
module_struct: proc_macro2::TokenStream,
|
||||
/// Impl block for module: `<T: Trait, I: Instance>`.
|
||||
/// Impl block for module: `<T: Config, I: Instance>`.
|
||||
module_impl: proc_macro2::TokenStream,
|
||||
/// For instantiable: `I`.
|
||||
optional_instance: Option<proc_macro2::TokenStream>,
|
||||
@@ -212,7 +212,7 @@ pub struct StorageLineDefExt {
|
||||
storage_struct: proc_macro2::TokenStream,
|
||||
/// If storage is generic over runtime then `T`.
|
||||
optional_storage_runtime_comma: Option<proc_macro2::TokenStream>,
|
||||
/// If storage is generic over runtime then `T: Trait`.
|
||||
/// If storage is generic over runtime then `T: Config`.
|
||||
optional_storage_runtime_bound_comma: Option<proc_macro2::TokenStream>,
|
||||
/// The where clause to use to constrain generics if storage is generic over runtime.
|
||||
optional_storage_where_clause: Option<proc_macro2::TokenStream>,
|
||||
|
||||
@@ -72,9 +72,9 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_system::{Trait, ensure_signed};
|
||||
/// # use frame_system::{Config, ensure_signed};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
///
|
||||
/// // Private functions are dispatchable, but not available to other
|
||||
/// // FRAME pallets.
|
||||
@@ -98,7 +98,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
///
|
||||
/// The declaration is set with the header where:
|
||||
///
|
||||
/// * `Module`: The struct generated by the macro, with type `Trait`.
|
||||
/// * `Module`: The struct generated by the macro, with type `Config`.
|
||||
/// * `Call`: The enum generated for every pallet, which implements [`Callable`](./dispatch/trait.Callable.html).
|
||||
/// * `origin`: Alias of `T::Origin`, declared by the [`impl_outer_origin!`](./macro.impl_outer_origin.html) macro.
|
||||
/// * `Result`: The expected return type from pallet functions.
|
||||
@@ -114,9 +114,9 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_system::{Trait, ensure_signed};
|
||||
/// # use frame_system::{Config, ensure_signed};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// #[weight = 0]
|
||||
/// fn my_long_function(origin) -> dispatch::DispatchResult {
|
||||
/// // Your implementation
|
||||
@@ -149,9 +149,9 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo};
|
||||
/// # use frame_system::{Trait, ensure_signed};
|
||||
/// # use frame_system::{Config, ensure_signed};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// #[weight = 1_000_000]
|
||||
/// fn my_long_function(origin, do_expensive_calc: bool) -> DispatchResultWithPostInfo {
|
||||
/// ensure_signed(origin).map_err(|e| e.with_weight(100_000))?;
|
||||
@@ -178,9 +178,9 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::transactional;
|
||||
/// # use frame_system::Trait;
|
||||
/// # use frame_system::Config;
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// #[weight = 0]
|
||||
/// #[transactional]
|
||||
/// fn my_short_function(origin) {
|
||||
@@ -199,9 +199,9 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_system::{Trait, ensure_signed, ensure_root};
|
||||
/// # use frame_system::{Config, ensure_signed, ensure_root};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// #[weight = 0]
|
||||
/// fn my_privileged_function(origin) -> dispatch::DispatchResult {
|
||||
/// ensure_root(origin)?;
|
||||
@@ -236,10 +236,10 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # pub struct DefaultInstance;
|
||||
/// # pub trait Instance: 'static {}
|
||||
/// # impl Instance for DefaultInstance {}
|
||||
/// pub trait Trait<I: Instance=DefaultInstance>: frame_system::Trait {}
|
||||
/// pub trait Config<I: Instance=DefaultInstance>: frame_system::Config {}
|
||||
///
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config<I>, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {
|
||||
/// // Your implementation
|
||||
/// }
|
||||
/// }
|
||||
@@ -261,10 +261,10 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_system::{self as system, ensure_signed};
|
||||
/// pub trait Trait: system::Trait where Self::AccountId: From<u32> {}
|
||||
/// pub trait Config: system::Config where Self::AccountId: From<u32> {}
|
||||
///
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin, T::AccountId: From<u32> {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin, T::AccountId: From<u32> {
|
||||
/// // Your implementation
|
||||
/// }
|
||||
/// }
|
||||
@@ -1272,11 +1272,11 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_initialize() -> $return:ty { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) -> $return {
|
||||
fn on_initialize(_block_number_not_used: <$trait_instance as $system::Config>::BlockNumber) -> $return {
|
||||
$crate::sp_tracing::enter_span!($crate::sp_tracing::trace_span!("on_initialize"));
|
||||
{ $( $impl )* }
|
||||
}
|
||||
@@ -1289,8 +1289,8 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_initialize($param:ident : $param_ty:ty) -> $return:ty { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize($param: $param_ty) -> $return {
|
||||
@@ -1305,8 +1305,8 @@ macro_rules! decl_module {
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnInitialize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{}
|
||||
};
|
||||
@@ -1326,10 +1326,10 @@ macro_rules! decl_module {
|
||||
let result: $return = (|| { $( $impl )* })();
|
||||
|
||||
$crate::crate_to_pallet_version!()
|
||||
.put_into_storage::<<$trait_instance as $system::Trait>::PalletInfo, Self>();
|
||||
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
|
||||
|
||||
let additional_write = <
|
||||
<$trait_instance as $system::Trait>::DbWeight as $crate::traits::Get<_>
|
||||
<$trait_instance as $system::Config>::DbWeight as $crate::traits::Get<_>
|
||||
>::get().writes(1);
|
||||
|
||||
result.saturating_add(additional_write)
|
||||
@@ -1350,10 +1350,10 @@ macro_rules! decl_module {
|
||||
$crate::sp_tracing::enter_span!($crate::sp_tracing::trace_span!("on_runtime_upgrade"));
|
||||
|
||||
$crate::crate_to_pallet_version!()
|
||||
.put_into_storage::<<$trait_instance as $system::Trait>::PalletInfo, Self>();
|
||||
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
|
||||
|
||||
<
|
||||
<$trait_instance as $system::Trait>::DbWeight as $crate::traits::Get<_>
|
||||
<$trait_instance as $system::Config>::DbWeight as $crate::traits::Get<_>
|
||||
>::get().writes(1)
|
||||
}
|
||||
}
|
||||
@@ -1394,11 +1394,11 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_finalize() { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) {
|
||||
fn on_finalize(_block_number_not_used: <$trait_instance as $system::Config>::BlockNumber) {
|
||||
$crate::sp_tracing::enter_span!($crate::sp_tracing::trace_span!("on_finalize"));
|
||||
{ $( $impl )* }
|
||||
}
|
||||
@@ -1411,8 +1411,8 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn on_finalize($param:ident : $param_ty:ty) { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize($param: $param_ty) {
|
||||
@@ -1427,8 +1427,8 @@ macro_rules! decl_module {
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OnFinalize<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
}
|
||||
@@ -1440,11 +1440,11 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn offchain_worker() { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn offchain_worker(_block_number_not_used: <$trait_instance as $system::Trait>::BlockNumber) { $( $impl )* }
|
||||
fn offchain_worker(_block_number_not_used: <$trait_instance as $system::Config>::BlockNumber) { $( $impl )* }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1454,8 +1454,8 @@ macro_rules! decl_module {
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
fn offchain_worker($param:ident : $param_ty:ty) { $( $impl:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn offchain_worker($param: $param_ty) { $( $impl )* }
|
||||
@@ -1467,8 +1467,8 @@ macro_rules! decl_module {
|
||||
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
|
||||
{ $( $other_where_bounds:tt )* }
|
||||
) => {
|
||||
impl<$trait_instance: $system::Trait + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Trait>::BlockNumber>
|
||||
impl<$trait_instance: $system::Config + $trait_name$(<I>, $instance: $instantiable)?>
|
||||
$crate::traits::OffchainWorker<<$trait_instance as $system::Config>::BlockNumber>
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{}
|
||||
};
|
||||
@@ -1824,7 +1824,7 @@ macro_rules! decl_module {
|
||||
|
||||
fn storage_version() -> Option<$crate::traits::PalletVersion> {
|
||||
let key = $crate::traits::PalletVersion::storage_key::<
|
||||
<$trait_instance as $system::Trait>::PalletInfo, Self
|
||||
<$trait_instance as $system::Config>::PalletInfo, Self
|
||||
>().expect("Every active pallet has a name in the runtime; qed");
|
||||
|
||||
$crate::storage::unhashed::get(&key)
|
||||
@@ -1837,7 +1837,7 @@ macro_rules! decl_module {
|
||||
{
|
||||
fn on_genesis() {
|
||||
$crate::crate_to_pallet_version!()
|
||||
.put_into_storage::<<$trait_instance as $system::Trait>::PalletInfo, Self>();
|
||||
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2019,7 +2019,7 @@ macro_rules! impl_outer_dispatch {
|
||||
}
|
||||
impl $crate::dispatch::Dispatchable for $call_type {
|
||||
type Origin = $origin;
|
||||
type Trait = $call_type;
|
||||
type Config = $call_type;
|
||||
type Info = $crate::weights::DispatchInfo;
|
||||
type PostInfo = $crate::weights::PostDispatchInfo;
|
||||
fn dispatch(
|
||||
@@ -2412,12 +2412,12 @@ mod tests {
|
||||
IntegrityTest, Get,
|
||||
};
|
||||
|
||||
pub trait Trait: system::Trait + Sized where Self::AccountId: From<u32> { }
|
||||
pub trait Config: system::Config + Sized where Self::AccountId: From<u32> { }
|
||||
|
||||
pub mod system {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type AccountId;
|
||||
type Call;
|
||||
type BaseCallFilter;
|
||||
@@ -2443,11 +2443,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = system, T::AccountId: From<u32> {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system = system, T::AccountId: From<u32> {
|
||||
/// Hi, this is a comment.
|
||||
#[weight = 0]
|
||||
fn aux_0(_origin) -> DispatchResult { unreachable!() }
|
||||
@@ -2548,7 +2548,7 @@ mod tests {
|
||||
];
|
||||
|
||||
pub struct TraitImpl {}
|
||||
impl Trait for TraitImpl { }
|
||||
impl Config for TraitImpl { }
|
||||
|
||||
type Test = Module<TraitImpl>;
|
||||
|
||||
@@ -2562,7 +2562,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl system::Trait for TraitImpl {
|
||||
impl system::Config for TraitImpl {
|
||||
type Origin = OuterOrigin;
|
||||
type AccountId = u32;
|
||||
type Call = OuterCall;
|
||||
|
||||
@@ -39,7 +39,7 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent};
|
||||
/// #
|
||||
/// decl_error! {
|
||||
/// /// Errors that can occur in my module.
|
||||
/// pub enum MyError for Module<T: Trait> {
|
||||
/// pub enum MyError for Module<T: Config> {
|
||||
/// /// Hey this is an error message that indicates bla.
|
||||
/// MyCoolErrorMessage,
|
||||
/// /// You are just not cool enough for my module!
|
||||
@@ -47,13 +47,13 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent};
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// # use frame_system::Trait;
|
||||
/// # use frame_system::Config;
|
||||
///
|
||||
/// // You need to register the error type in `decl_module!` as well to make the error
|
||||
/// // exported in the metadata.
|
||||
///
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
/// type Error = MyError<T>;
|
||||
///
|
||||
/// #[weight = 0]
|
||||
|
||||
@@ -37,7 +37,7 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
/// # Generic Event Example:
|
||||
///
|
||||
/// ```rust
|
||||
/// trait Trait {
|
||||
/// trait Config {
|
||||
/// type Balance;
|
||||
/// type Token;
|
||||
/// }
|
||||
@@ -45,7 +45,7 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
/// mod event1 {
|
||||
/// // Event that specifies the generic parameter explicitly (`Balance`).
|
||||
/// frame_support::decl_event!(
|
||||
/// pub enum Event<T> where Balance = <T as super::Trait>::Balance {
|
||||
/// pub enum Event<T> where Balance = <T as super::Config>::Balance {
|
||||
/// Message(Balance),
|
||||
/// }
|
||||
/// );
|
||||
@@ -56,7 +56,7 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
/// // If no name for the generic parameter is specified explicitly,
|
||||
/// // the name will be taken from the type name of the trait.
|
||||
/// frame_support::decl_event!(
|
||||
/// pub enum Event<T> where <T as super::Trait>::Balance {
|
||||
/// pub enum Event<T> where <T as super::Config>::Balance {
|
||||
/// Message(Balance),
|
||||
/// }
|
||||
/// );
|
||||
@@ -65,7 +65,7 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
/// mod event3 {
|
||||
/// // And we even support declaring multiple generic parameters!
|
||||
/// frame_support::decl_event!(
|
||||
/// pub enum Event<T> where <T as super::Trait>::Balance, <T as super::Trait>::Token {
|
||||
/// pub enum Event<T> where <T as super::Config>::Balance, <T as super::Config>::Token {
|
||||
/// Message(Balance, Token),
|
||||
/// }
|
||||
/// );
|
||||
@@ -82,7 +82,7 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
///# struct DefaultInstance;
|
||||
///# trait Instance {}
|
||||
///# impl Instance for DefaultInstance {}
|
||||
/// trait Trait<I: Instance=DefaultInstance> {
|
||||
/// trait Config<I: Instance=DefaultInstance> {
|
||||
/// type Balance;
|
||||
/// type Token;
|
||||
/// }
|
||||
@@ -90,8 +90,8 @@ pub use frame_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnE
|
||||
/// // For module with instances, DefaultInstance is optional
|
||||
/// frame_support::decl_event!(
|
||||
/// pub enum Event<T, I: Instance = DefaultInstance> where
|
||||
/// <T as Trait>::Balance,
|
||||
/// <T as Trait>::Token
|
||||
/// <T as Config>::Balance,
|
||||
/// <T as Config>::Token
|
||||
/// {
|
||||
/// Message(Balance, Token),
|
||||
/// }
|
||||
@@ -258,10 +258,10 @@ macro_rules! __decl_generic_event {
|
||||
{ $( $events:tt )* };
|
||||
{ ,$( $generic_param:ident = $generic_type:ty ),* };
|
||||
) => {
|
||||
/// [`RawEvent`] specialized for the configuration [`Trait`]
|
||||
/// [`RawEvent`] specialized for the configuration [`Config`]
|
||||
///
|
||||
/// [`RawEvent`]: enum.RawEvent.html
|
||||
/// [`Trait`]: trait.Trait.html
|
||||
/// [`Config`]: trait.Config.html
|
||||
pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >;
|
||||
|
||||
#[derive(
|
||||
@@ -551,7 +551,7 @@ mod tests {
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
mod system {
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
@@ -559,7 +559,7 @@ mod tests {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
@@ -570,7 +570,7 @@ mod tests {
|
||||
}
|
||||
|
||||
mod system_renamed {
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
@@ -578,7 +578,7 @@ mod tests {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
@@ -591,17 +591,17 @@ mod tests {
|
||||
mod event_module {
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event without renaming the generic parameter `Balance` and `Origin`.
|
||||
pub enum Event<T> where <T as Trait>::Balance, <T as system::Trait>::Origin
|
||||
pub enum Event<T> where <T as Config>::Balance, <T as system::Config>::Origin
|
||||
{
|
||||
/// Hi, I am a comment.
|
||||
TestEvent(Balance, Origin),
|
||||
@@ -614,19 +614,19 @@ mod tests {
|
||||
mod event_module2 {
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event with renamed generic parameter
|
||||
pub enum Event<T> where
|
||||
BalanceRenamed = <T as Trait>::Balance,
|
||||
OriginRenamed = <T as system::Trait>::Origin
|
||||
BalanceRenamed = <T as Config>::Balance,
|
||||
OriginRenamed = <T as system::Config>::Origin
|
||||
{
|
||||
TestEvent(BalanceRenamed),
|
||||
TestOrigin(OriginRenamed),
|
||||
@@ -645,19 +645,19 @@ mod tests {
|
||||
mod event_module4 {
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event finish formatting on an unnamed one with trailing comma
|
||||
pub enum Event<T> where
|
||||
<T as Trait>::Balance,
|
||||
<T as system::Trait>::Origin,
|
||||
<T as Config>::Balance,
|
||||
<T as system::Config>::Origin,
|
||||
{
|
||||
TestEvent(Balance, Origin),
|
||||
}
|
||||
@@ -667,19 +667,19 @@ mod tests {
|
||||
mod event_module5 {
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
/// Event finish formatting on an named one with trailing comma
|
||||
pub enum Event<T> where
|
||||
BalanceRenamed = <T as Trait>::Balance,
|
||||
OriginRenamed = <T as system::Trait>::Origin,
|
||||
BalanceRenamed = <T as Config>::Balance,
|
||||
OriginRenamed = <T as system::Config>::Origin,
|
||||
{
|
||||
TestEvent(BalanceRenamed, OriginRenamed),
|
||||
TrailingCommaInArgs(
|
||||
@@ -714,37 +714,37 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl event_module::Trait for TestRuntime {
|
||||
impl event_module::Config for TestRuntime {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime {
|
||||
impl event_module2::Config for TestRuntime {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
impl system::Trait for TestRuntime {
|
||||
impl system::Config for TestRuntime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl event_module::Trait for TestRuntime2 {
|
||||
impl event_module::Config for TestRuntime2 {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime2 {
|
||||
impl event_module2::Config for TestRuntime2 {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
impl system_renamed::Trait for TestRuntime2 {
|
||||
impl system_renamed::Config for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl system::Trait for TestRuntime2 {
|
||||
impl system::Config for TestRuntime2 {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
|
||||
@@ -346,14 +346,14 @@ pub use frame_support_procedural::{
|
||||
/// This is useful for type generic over runtime:
|
||||
/// ```
|
||||
/// # use frame_support::CloneNoBound;
|
||||
/// trait Trait {
|
||||
/// trait Config {
|
||||
/// type C: Clone;
|
||||
/// }
|
||||
///
|
||||
/// // Foo implements [`Clone`] because `C` bounds [`Clone`].
|
||||
/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Clone`].
|
||||
/// #[derive(CloneNoBound)]
|
||||
/// struct Foo<T: Trait> {
|
||||
/// struct Foo<T: Config> {
|
||||
/// c: T::C,
|
||||
/// }
|
||||
/// ```
|
||||
@@ -364,14 +364,14 @@ pub use frame_support_procedural::CloneNoBound;
|
||||
/// This is useful for type generic over runtime:
|
||||
/// ```
|
||||
/// # use frame_support::{EqNoBound, PartialEqNoBound};
|
||||
/// trait Trait {
|
||||
/// trait Config {
|
||||
/// type C: Eq;
|
||||
/// }
|
||||
///
|
||||
/// // Foo implements [`Eq`] because `C` bounds [`Eq`].
|
||||
/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Eq`].
|
||||
/// #[derive(PartialEqNoBound, EqNoBound)]
|
||||
/// struct Foo<T: Trait> {
|
||||
/// struct Foo<T: Config> {
|
||||
/// c: T::C,
|
||||
/// }
|
||||
/// ```
|
||||
@@ -382,14 +382,14 @@ pub use frame_support_procedural::EqNoBound;
|
||||
/// This is useful for type generic over runtime:
|
||||
/// ```
|
||||
/// # use frame_support::PartialEqNoBound;
|
||||
/// trait Trait {
|
||||
/// trait Config {
|
||||
/// type C: PartialEq;
|
||||
/// }
|
||||
///
|
||||
/// // Foo implements [`PartialEq`] because `C` bounds [`PartialEq`].
|
||||
/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`PartialEq`].
|
||||
/// #[derive(PartialEqNoBound)]
|
||||
/// struct Foo<T: Trait> {
|
||||
/// struct Foo<T: Config> {
|
||||
/// c: T::C,
|
||||
/// }
|
||||
/// ```
|
||||
@@ -401,14 +401,14 @@ pub use frame_support_procedural::PartialEqNoBound;
|
||||
/// ```
|
||||
/// # use frame_support::DebugNoBound;
|
||||
/// # use core::fmt::Debug;
|
||||
/// trait Trait {
|
||||
/// trait Config {
|
||||
/// type C: Debug;
|
||||
/// }
|
||||
///
|
||||
/// // Foo implements [`Debug`] because `C` bounds [`Debug`].
|
||||
/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Debug`].
|
||||
/// #[derive(DebugNoBound)]
|
||||
/// struct Foo<T: Trait> {
|
||||
/// struct Foo<T: Config> {
|
||||
/// c: T::C,
|
||||
/// }
|
||||
/// ```
|
||||
@@ -565,7 +565,7 @@ mod tests {
|
||||
use sp_std::{marker::PhantomData, result};
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type BlockNumber: Codec + EncodeLike + Default;
|
||||
type Origin;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
@@ -575,16 +575,16 @@ mod tests {
|
||||
mod module {
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::Trait;
|
||||
use super::Config;
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
}
|
||||
use self::module::Module;
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
pub Data get(fn data) build(|_| vec![(15u32, 42u64)]):
|
||||
map hasher(twox_64_concat) u32 => u64;
|
||||
pub OptionLinkedMap: map hasher(blake2_128_concat) u32 => Option<u32>;
|
||||
@@ -606,7 +606,7 @@ mod tests {
|
||||
}
|
||||
|
||||
struct Test;
|
||||
impl Trait for Test {
|
||||
impl Config for Test {
|
||||
type BlockNumber = u32;
|
||||
type Origin = u32;
|
||||
type PalletInfo = ();
|
||||
|
||||
@@ -27,23 +27,23 @@ pub use frame_metadata::{
|
||||
/// Example:
|
||||
/// ```
|
||||
///# mod module0 {
|
||||
///# pub trait Trait: 'static {
|
||||
///# pub trait Config: 'static {
|
||||
///# type Origin;
|
||||
///# type BlockNumber;
|
||||
///# type PalletInfo: frame_support::traits::PalletInfo;
|
||||
///# type DbWeight: frame_support::traits::Get<frame_support::weights::RuntimeDbWeight>;
|
||||
///# }
|
||||
///# frame_support::decl_module! {
|
||||
///# pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
///# pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
///# }
|
||||
///#
|
||||
///# frame_support::decl_storage! {
|
||||
///# trait Store for Module<T: Trait> as TestStorage {}
|
||||
///# trait Store for Module<T: Config> as TestStorage {}
|
||||
///# }
|
||||
///# }
|
||||
///# use module0 as module1;
|
||||
///# use module0 as module2;
|
||||
///# impl module0::Trait for Runtime {
|
||||
///# impl module0::Config for Runtime {
|
||||
///# type Origin = u32;
|
||||
///# type BlockNumber = u32;
|
||||
///# type PalletInfo = ();
|
||||
@@ -297,7 +297,7 @@ mod tests {
|
||||
mod system {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type BaseCallFilter;
|
||||
const ASSOCIATED_CONST: u64 = 500;
|
||||
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
||||
@@ -311,7 +311,7 @@ mod tests {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
/// Hi, I am a comment.
|
||||
const BlockNumber: T::BlockNumber = 100.into();
|
||||
const GetType: T::AccountId = T::SomeValue::get().into();
|
||||
@@ -341,19 +341,19 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
}
|
||||
|
||||
mod event_module {
|
||||
use crate::dispatch::DispatchResult;
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where <T as Trait>::Balance
|
||||
pub enum Event<T> where <T as Config>::Balance
|
||||
{
|
||||
/// Hi, I am a comment.
|
||||
TestEvent(Balance),
|
||||
@@ -361,7 +361,7 @@ mod tests {
|
||||
);
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {
|
||||
type Error = Error<T>;
|
||||
|
||||
#[weight = 0]
|
||||
@@ -370,7 +370,7 @@ mod tests {
|
||||
}
|
||||
|
||||
crate::decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Some user input error
|
||||
UserInputError,
|
||||
/// Something bad happened
|
||||
@@ -383,23 +383,23 @@ mod tests {
|
||||
mod event_module2 {
|
||||
use super::system;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Config: system::Config {
|
||||
type Balance;
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where <T as Trait>::Balance
|
||||
pub enum Event<T> where <T as Config>::Balance
|
||||
{
|
||||
TestEvent(Balance),
|
||||
}
|
||||
);
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
trait Store for Module<T: Config> as TestStorage {
|
||||
StorageMethod : Option<u32>;
|
||||
}
|
||||
add_extra_genesis {
|
||||
@@ -433,11 +433,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl event_module::Trait for TestRuntime {
|
||||
impl event_module::Config for TestRuntime {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
impl event_module2::Trait for TestRuntime {
|
||||
impl event_module2::Config for TestRuntime {
|
||||
type Balance = u32;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ mod tests {
|
||||
pub const SystemValue: u32 = 600;
|
||||
}
|
||||
|
||||
impl system::Trait for TestRuntime {
|
||||
impl system::Config for TestRuntime {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type AccountId = u32;
|
||||
@@ -480,7 +480,7 @@ mod tests {
|
||||
struct ConstantAssociatedConstByteGetter;
|
||||
impl DefaultByte for ConstantAssociatedConstByteGetter {
|
||||
fn default_byte(&self) -> Vec<u8> {
|
||||
<TestRuntime as system::Trait>::ASSOCIATED_CONST.encode()
|
||||
<TestRuntime as system::Config>::ASSOCIATED_CONST.encode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -425,7 +425,7 @@ mod test_iterators {
|
||||
storage::{generator::StorageDoubleMap, IterableStorageDoubleMap, unhashed},
|
||||
};
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
@@ -433,14 +433,14 @@ mod test_iterators {
|
||||
}
|
||||
|
||||
crate::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
struct NoDef(u32);
|
||||
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
DoubleMap: double_map hasher(blake2_128_concat) u16, hasher(twox_64_concat) u32 => u64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ mod test_iterators {
|
||||
storage::{generator::StorageMap, IterableStorageMap, unhashed},
|
||||
};
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
@@ -333,14 +333,14 @@ mod test_iterators {
|
||||
}
|
||||
|
||||
crate::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
struct NoDef(u32);
|
||||
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
Map: map hasher(blake2_128_concat) u16 => u64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ mod tests {
|
||||
|
||||
struct Runtime;
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
type PalletInfo: crate::traits::PalletInfo;
|
||||
type DbWeight: crate::traits::Get<crate::weights::RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
impl Trait for Runtime {
|
||||
impl Config for Runtime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
@@ -57,11 +57,11 @@ mod tests {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Runtime {
|
||||
trait Store for Module<T: Config> as Runtime {
|
||||
Value get(fn value) config(): (u64, u64);
|
||||
NumberMap: map hasher(identity) u32 => u64;
|
||||
DoubleMap: double_map hasher(identity) u32, hasher(identity) u32 => u64;
|
||||
|
||||
@@ -1653,16 +1653,16 @@ pub trait EnsureOrigin<OuterOrigin> {
|
||||
/// Implemented for pallet dispatchable type by `decl_module` and for runtime dispatchable by
|
||||
/// `construct_runtime` and `impl_outer_dispatch`.
|
||||
pub trait UnfilteredDispatchable {
|
||||
/// The origin type of the runtime, (i.e. `frame_system::Trait::Origin`).
|
||||
/// The origin type of the runtime, (i.e. `frame_system::Config::Origin`).
|
||||
type Origin;
|
||||
|
||||
/// Dispatch this call but do not check the filter in origin.
|
||||
fn dispatch_bypass_filter(self, origin: Self::Origin) -> crate::dispatch::DispatchResultWithPostInfo;
|
||||
}
|
||||
|
||||
/// Methods available on `frame_system::Trait::Origin`.
|
||||
/// Methods available on `frame_system::Config::Origin`.
|
||||
pub trait OriginTrait: Sized {
|
||||
/// Runtime call type, as in `frame_system::Trait::Call`
|
||||
/// Runtime call type, as in `frame_system::Config::Call`
|
||||
type Call;
|
||||
|
||||
/// The caller origin, overarching type of all pallets origins.
|
||||
@@ -1674,7 +1674,7 @@ pub trait OriginTrait: Sized {
|
||||
/// Add a filter to the origin.
|
||||
fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static);
|
||||
|
||||
/// Reset origin filters to default one, i.e `frame_system::Trait::BaseCallFilter`.
|
||||
/// Reset origin filters to default one, i.e `frame_system::Config::BaseCallFilter`.
|
||||
fn reset_filter(&mut self);
|
||||
|
||||
/// Replace the caller with caller from the other origin
|
||||
@@ -1686,13 +1686,13 @@ pub trait OriginTrait: Sized {
|
||||
/// Get the caller.
|
||||
fn caller(&self) -> &Self::PalletsOrigin;
|
||||
|
||||
/// Create with system none origin and `frame-system::Trait::BaseCallFilter`.
|
||||
/// Create with system none origin and `frame-system::Config::BaseCallFilter`.
|
||||
fn none() -> Self;
|
||||
|
||||
/// Create with system root origin and no filter.
|
||||
fn root() -> Self;
|
||||
|
||||
/// Create with system signed origin and `frame-system::Trait::BaseCallFilter`.
|
||||
/// Create with system signed origin and `frame-system::Config::BaseCallFilter`.
|
||||
fn signed(by: Self::AccountId) -> Self;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
//! `Yes`**.
|
||||
//!
|
||||
//! ```
|
||||
//! # use frame_system::Trait;
|
||||
//! # use frame_system::Config;
|
||||
//! frame_support::decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
//! #[weight = 1000]
|
||||
//! fn dispatching(origin) { unimplemented!() }
|
||||
//! }
|
||||
@@ -52,10 +52,10 @@
|
||||
//! 2.1 Define weight and class, **in which case `PaysFee` would be `Yes`**.
|
||||
//!
|
||||
//! ```
|
||||
//! # use frame_system::Trait;
|
||||
//! # use frame_system::Config;
|
||||
//! # use frame_support::weights::DispatchClass;
|
||||
//! frame_support::decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
//! #[weight = (1000, DispatchClass::Operational)]
|
||||
//! fn dispatching(origin) { unimplemented!() }
|
||||
//! }
|
||||
@@ -66,10 +66,10 @@
|
||||
//! 2.2 Define weight and `PaysFee`, **in which case `ClassifyDispatch` would be `Normal`**.
|
||||
//!
|
||||
//! ```
|
||||
//! # use frame_system::Trait;
|
||||
//! # use frame_system::Config;
|
||||
//! # use frame_support::weights::Pays;
|
||||
//! frame_support::decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
//! #[weight = (1000, Pays::No)]
|
||||
//! fn dispatching(origin) { unimplemented!() }
|
||||
//! }
|
||||
@@ -80,10 +80,10 @@
|
||||
//! 3. Define all 3 parameters.
|
||||
//!
|
||||
//! ```
|
||||
//! # use frame_system::Trait;
|
||||
//! # use frame_system::Config;
|
||||
//! # use frame_support::weights::{DispatchClass, Pays};
|
||||
//! frame_support::decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
//! #[weight = (1000, DispatchClass::Operational, Pays::No)]
|
||||
//! fn dispatching(origin) { unimplemented!() }
|
||||
//! }
|
||||
@@ -100,10 +100,10 @@
|
||||
//! all 3 are static values, providing a raw tuple is easier.
|
||||
//!
|
||||
//! ```
|
||||
//! # use frame_system::Trait;
|
||||
//! # use frame_system::Config;
|
||||
//! # use frame_support::weights::{DispatchClass, FunctionOf, Pays};
|
||||
//! frame_support::decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
//! #[weight = FunctionOf(
|
||||
//! // weight, function.
|
||||
//! |args: (&u32, &u64)| *args.0 as u64 + args.1,
|
||||
@@ -701,7 +701,7 @@ mod tests {
|
||||
use crate::{decl_module, parameter_types, traits::Get};
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
type Origin;
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
@@ -718,7 +718,7 @@ mod tests {
|
||||
};
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
impl Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type Balance = u32;
|
||||
@@ -727,7 +727,7 @@ mod tests {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
// no arguments, fixed weight
|
||||
#[weight = 1000]
|
||||
fn f00(_origin) { unimplemented!(); }
|
||||
|
||||
@@ -25,6 +25,7 @@ trybuild = "1.0.33"
|
||||
pretty_assertions = "0.6.1"
|
||||
rustversion = "1.0.0"
|
||||
frame-metadata = { version = "12.0.0", default-features = false, path = "../../metadata" }
|
||||
frame-system = { version = "2.0.0", default-features = false, path = "../../system" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -33,6 +34,7 @@ std = [
|
||||
"codec/std",
|
||||
"sp-io/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"sp-inherents/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
mod pallet_version;
|
||||
|
||||
/// The configuration trait
|
||||
pub trait Trait: 'static {
|
||||
pub trait Config: 'static {
|
||||
/// The runtime origin type.
|
||||
type Origin: codec::Codec + codec::EncodeLike + Default;
|
||||
/// The block number type.
|
||||
@@ -39,5 +39,5 @@ pub trait Trait: 'static {
|
||||
|
||||
frame_support::decl_module! {
|
||||
/// Some test module
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ thread_local! {
|
||||
mod module1 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait<I>: system::Trait {}
|
||||
pub trait Config<I>: system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call
|
||||
where origin: <T as system::Trait>::Origin, system=system
|
||||
pub struct Module<T: Config<I>, I: Instance = DefaultInstance> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -55,31 +55,31 @@ mod module1 {
|
||||
|
||||
frame_support::decl_event! {
|
||||
pub enum Event<T, I: Instance = DefaultInstance> where
|
||||
<T as system::Trait>::AccountId
|
||||
<T as system::Config>::AccountId
|
||||
{
|
||||
A(AccountId),
|
||||
}
|
||||
}
|
||||
|
||||
frame_support::decl_error! {
|
||||
pub enum Error for Module<T: Trait<I>, I: Instance> {
|
||||
pub enum Error for Module<T: Config<I>, I: Instance> {
|
||||
Something
|
||||
}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as Module {}
|
||||
trait Store for Module<T: Config<I>, I: Instance=DefaultInstance> as Module {}
|
||||
}
|
||||
}
|
||||
|
||||
mod module2 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: system::Trait {}
|
||||
pub trait Config: system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call
|
||||
where origin: <T as system::Trait>::Origin, system=system
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where origin: <T as system::Config>::Origin, system=system
|
||||
{
|
||||
#[weight = 0]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
@@ -102,25 +102,25 @@ mod module2 {
|
||||
}
|
||||
|
||||
frame_support::decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
Something
|
||||
}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Module {}
|
||||
trait Store for Module<T: Config> as Module {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> module1::Trait<I> for Runtime {}
|
||||
impl module2::Trait for Runtime {}
|
||||
impl<I> module1::Config<I> for Runtime {}
|
||||
impl module2::Config for Runtime {}
|
||||
|
||||
pub type Signature = sr25519::Signature;
|
||||
pub type AccountId = <Signature as Verify>::Signer;
|
||||
pub type BlockNumber = u64;
|
||||
pub type Index = u64;
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter = ();
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
fn integrity_test() {}
|
||||
|
||||
fn integrity_test() {}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ error: `integrity_test` can only be passed once as input.
|
||||
--> $DIR/reserved_keyword_two_times_integrity_test.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
3 | | fn integrity_test() {}
|
||||
4 | |
|
||||
5 | | fn integrity_test() {}
|
||||
@@ -16,7 +16,7 @@ error[E0601]: `main` function not found in crate `$CRATE`
|
||||
--> $DIR/reserved_keyword_two_times_integrity_test.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
3 | | fn integrity_test() {}
|
||||
4 | |
|
||||
5 | | fn integrity_test() {}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
fn on_initialize() -> Weight {
|
||||
0
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ error: `on_initialize` can only be passed once as input.
|
||||
--> $DIR/reserved_keyword_two_times_on_initialize.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
3 | | fn on_initialize() -> Weight {
|
||||
4 | | 0
|
||||
... |
|
||||
@@ -16,7 +16,7 @@ error[E0601]: `main` function not found in crate `$CRATE`
|
||||
--> $DIR/reserved_keyword_two_times_on_initialize.rs:1:1
|
||||
|
|
||||
1 | / frame_support::decl_module! {
|
||||
2 | | pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
2 | | pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
3 | | fn on_initialize() -> Weight {
|
||||
4 | | 0
|
||||
... |
|
||||
|
||||
@@ -24,13 +24,13 @@ mod tests {
|
||||
use std::marker::PhantomData;
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
trait Store for Module<T: Config> as TestStorage {
|
||||
// non-getters: pub / $default
|
||||
|
||||
/// Hello, this is doc!
|
||||
@@ -81,14 +81,14 @@ mod tests {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
impl Config for TraitImpl {}
|
||||
|
||||
const EXPECTED_METADATA: StorageMetadata = StorageMetadata {
|
||||
prefix: DecodeDifferent::Encode("TestStorage"),
|
||||
@@ -414,16 +414,16 @@ mod tests {
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test2 {
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
type PairOf<T> = (T, T);
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
trait Store for Module<T: Config> as TestStorage {
|
||||
SingleDef : u32;
|
||||
PairDef : PairOf<u32>;
|
||||
Single : Option<u32>;
|
||||
@@ -438,26 +438,26 @@ mod test2 {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
impl Config for TraitImpl {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test3 {
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
Foo get(fn foo) config(initial_foo): u32;
|
||||
}
|
||||
}
|
||||
@@ -466,14 +466,14 @@ mod test3 {
|
||||
|
||||
struct TraitImpl {}
|
||||
|
||||
impl frame_support_test::Trait for TraitImpl {
|
||||
impl frame_support_test::Config for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {}
|
||||
impl Config for TraitImpl {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -482,17 +482,17 @@ mod test_append_and_len {
|
||||
use sp_io::TestExternalities;
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
struct NoDef(u32);
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
NoDefault: Option<NoDef>;
|
||||
|
||||
JustVec: Vec<u32>;
|
||||
@@ -511,14 +511,14 @@ mod test_append_and_len {
|
||||
|
||||
struct Test {}
|
||||
|
||||
impl frame_support_test::Trait for Test {
|
||||
impl frame_support_test::Config for Test {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for Test {}
|
||||
impl Config for Test {}
|
||||
|
||||
#[test]
|
||||
fn default_for_option() {
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait> as FinalKeysNone {
|
||||
trait Store for Module<T: Config> as FinalKeysNone {
|
||||
pub Value config(value): u32;
|
||||
pub Value2 config(value): u32;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait> as FinalKeysNone {
|
||||
trait Store for Module<T: Config> as FinalKeysNone {
|
||||
pub Value get(fn value) config(): u32;
|
||||
pub Value2 config(value): u32;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait> as FinalKeysNone {
|
||||
trait Store for Module<T: Config> as FinalKeysNone {
|
||||
pub Value get(fn value) config(): u32;
|
||||
pub Value2 get(fn value) config(): u32;
|
||||
}
|
||||
|
||||
@@ -28,19 +28,19 @@ fn runtime_debug_no_bound_display_correctly() {
|
||||
assert_eq!(format!("{:?}", Unnamed(1)), "Unnamed(1)");
|
||||
}
|
||||
|
||||
trait Trait {
|
||||
trait Config {
|
||||
type C: std::fmt::Debug + Clone + Eq + PartialEq;
|
||||
}
|
||||
|
||||
struct Runtime;
|
||||
struct ImplNone;
|
||||
|
||||
impl Trait for Runtime {
|
||||
impl Config for Runtime {
|
||||
type C = u32;
|
||||
}
|
||||
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound)]
|
||||
struct StructNamed<T: Trait, U, V> {
|
||||
struct StructNamed<T: Config, U, V> {
|
||||
a: u32,
|
||||
b: u64,
|
||||
c: T::C,
|
||||
@@ -77,7 +77,7 @@ fn test_struct_named() {
|
||||
}
|
||||
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound)]
|
||||
struct StructUnnamed<T: Trait, U, V>(u32, u64, T::C, core::marker::PhantomData<(U, V)>);
|
||||
struct StructUnnamed<T: Config, U, V>(u32, u64, T::C, core::marker::PhantomData<(U, V)>);
|
||||
|
||||
#[test]
|
||||
fn test_struct_unnamed() {
|
||||
@@ -109,7 +109,7 @@ fn test_struct_unnamed() {
|
||||
}
|
||||
|
||||
#[derive(DebugNoBound, CloneNoBound, EqNoBound, PartialEqNoBound)]
|
||||
enum Enum<T: Trait, U, V> {
|
||||
enum Enum<T: Config, U, V> {
|
||||
VariantUnnamed(u32, u64, T::C, core::marker::PhantomData<(U, V)>),
|
||||
VariantNamed {
|
||||
a: u32,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
trait Trait {
|
||||
trait Config {
|
||||
type C;
|
||||
}
|
||||
|
||||
#[derive(frame_support::CloneNoBound)]
|
||||
struct Foo<T: Trait> {
|
||||
struct Foo<T: Config> {
|
||||
c: T::C,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
error[E0277]: the trait bound `<T as Trait>::C: std::clone::Clone` is not satisfied
|
||||
error[E0277]: the trait bound `<T as Config>::C: std::clone::Clone` is not satisfied
|
||||
--> $DIR/clone.rs:7:2
|
||||
|
|
||||
7 | c: T::C,
|
||||
| ^ the trait `std::clone::Clone` is not implemented for `<T as Trait>::C`
|
||||
| ^ the trait `std::clone::Clone` is not implemented for `<T as Config>::C`
|
||||
|
|
||||
= note: required by `std::clone::Clone::clone`
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
trait Trait {
|
||||
trait Config {
|
||||
type C;
|
||||
}
|
||||
|
||||
#[derive(frame_support::DebugNoBound)]
|
||||
struct Foo<T: Trait> {
|
||||
struct Foo<T: Config> {
|
||||
c: T::C,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
error[E0277]: `<T as Trait>::C` doesn't implement `std::fmt::Debug`
|
||||
error[E0277]: `<T as Config>::C` doesn't implement `std::fmt::Debug`
|
||||
--> $DIR/debug.rs:7:2
|
||||
|
|
||||
7 | c: T::C,
|
||||
| ^ `<T as Trait>::C` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
||||
| ^ `<T as Config>::C` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
||||
|
|
||||
= help: the trait `std::fmt::Debug` is not implemented for `<T as Trait>::C`
|
||||
= help: the trait `std::fmt::Debug` is not implemented for `<T as Config>::C`
|
||||
= note: required for the cast to the object type `dyn std::fmt::Debug`
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
trait Trait {
|
||||
trait Config {
|
||||
type C;
|
||||
}
|
||||
|
||||
#[derive(frame_support::EqNoBound)]
|
||||
struct Foo<T: Trait> {
|
||||
struct Foo<T: Config> {
|
||||
c: T::C,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
error[E0277]: can't compare `Foo<T>` with `Foo<T>`
|
||||
--> $DIR/eq.rs:6:8
|
||||
|
|
||||
6 | struct Foo<T: Trait> {
|
||||
6 | struct Foo<T: Config> {
|
||||
| ^^^ no implementation for `Foo<T> == Foo<T>`
|
||||
|
|
||||
= help: the trait `std::cmp::PartialEq` is not implemented for `Foo<T>`
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
trait Trait {
|
||||
trait Config {
|
||||
type C;
|
||||
}
|
||||
|
||||
#[derive(frame_support::PartialEqNoBound)]
|
||||
struct Foo<T: Trait> {
|
||||
struct Foo<T: Config> {
|
||||
c: T::C,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
error[E0369]: binary operation `==` cannot be applied to type `<T as Trait>::C`
|
||||
error[E0369]: binary operation `==` cannot be applied to type `<T as Config>::C`
|
||||
--> $DIR/partial_eq.rs:7:2
|
||||
|
|
||||
7 | c: T::C,
|
||||
| ^
|
||||
|
|
||||
= note: the trait `std::cmp::PartialEq` is not implemented for `<T as Trait>::C`
|
||||
= note: the trait `std::cmp::PartialEq` is not implemented for `<T as Config>::C`
|
||||
|
||||
@@ -21,14 +21,14 @@ use frame_support::{StorageDoubleMap, StorageMap, StorageValue, StoragePrefixedM
|
||||
use sp_io::{TestExternalities, hashing::{twox_64, twox_128, blake2_128}};
|
||||
|
||||
mod no_instance {
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait> as FinalKeysNone {
|
||||
trait Store for Module<T: Config> as FinalKeysNone {
|
||||
pub Value config(value): u32;
|
||||
|
||||
pub Map: map hasher(blake2_128_concat) u32 => u32;
|
||||
@@ -45,15 +45,15 @@ mod no_instance {
|
||||
}
|
||||
|
||||
mod instance {
|
||||
pub trait Trait<I = DefaultInstance>: frame_support_test::Trait {}
|
||||
pub trait Config<I = DefaultInstance>: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance>
|
||||
pub struct Module<T: Config<I>, I: Instance = DefaultInstance>
|
||||
for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait<I>, I: Instance = DefaultInstance>
|
||||
trait Store for Module<T: Config<I>, I: Instance = DefaultInstance>
|
||||
as FinalKeysSome
|
||||
{
|
||||
pub Value config(value): u32;
|
||||
|
||||
@@ -15,28 +15,28 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {}
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
trait Store for Module<T: Config> as Test {
|
||||
pub AppendableDM config(t): double_map hasher(identity) u32, hasher(identity) T::BlockNumber => Vec<u32>;
|
||||
}
|
||||
}
|
||||
|
||||
struct Test;
|
||||
|
||||
impl frame_support_test::Trait for Test {
|
||||
impl frame_support_test::Config for Test {
|
||||
type BlockNumber = u32;
|
||||
type Origin = ();
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for Test {}
|
||||
impl Config for Test {}
|
||||
|
||||
#[test]
|
||||
fn init_genesis_config() {
|
||||
|
||||
@@ -41,16 +41,16 @@ mod module1 {
|
||||
use super::*;
|
||||
use sp_std::ops::Add;
|
||||
|
||||
pub trait Trait<I>: system::Trait where <Self as system::Trait>::BlockNumber: From<u32> {
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||
pub trait Config<I>: system::Config where <Self as system::Config>::BlockNumber: From<u32> {
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
type SomeParameter: Get<u32>;
|
||||
type GenericType: Default + Clone + Codec + EncodeLike;
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance> for enum Call where
|
||||
origin: <T as system::Trait>::Origin,
|
||||
pub struct Module<T: Config<I>, I: Instance> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
system = system,
|
||||
T::BlockNumber: From<u32>
|
||||
{
|
||||
@@ -67,7 +67,7 @@ mod module1 {
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance> as Module1 where
|
||||
trait Store for Module<T: Config<I>, I: Instance> as Module1 where
|
||||
T::BlockNumber: From<u32> + std::fmt::Display
|
||||
{
|
||||
pub Value config(value): T::GenericType;
|
||||
@@ -83,7 +83,7 @@ mod module1 {
|
||||
}
|
||||
|
||||
frame_support::decl_error! {
|
||||
pub enum Error for Module<T: Trait<I>, I: Instance> where
|
||||
pub enum Error for Module<T: Config<I>, I: Instance> where
|
||||
T::BlockNumber: From<u32>,
|
||||
T::BlockNumber: Add,
|
||||
T::AccountId: AsRef<[u8]>,
|
||||
@@ -101,14 +101,14 @@ mod module1 {
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
|
||||
pub enum Origin<T: Trait<I>, I> where T::BlockNumber: From<u32> {
|
||||
pub enum Origin<T: Config<I>, I> where T::BlockNumber: From<u32> {
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
}
|
||||
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678";
|
||||
|
||||
impl<T: Trait<I>, I: Instance> ProvideInherent for Module<T, I> where
|
||||
impl<T: Config<I>, I: Instance> ProvideInherent for Module<T, I> where
|
||||
T::BlockNumber: From<u32>
|
||||
{
|
||||
type Call = Call<T, I>;
|
||||
@@ -131,17 +131,17 @@ mod module1 {
|
||||
mod module2 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
pub trait Config<I=DefaultInstance>: system::Config {
|
||||
type Amount: Parameter + Default;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Config>::Event>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> Currency for Module<T, I> {}
|
||||
impl<T: Config<I>, I: Instance> Currency for Module<T, I> {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
origin: <T as system::Trait>::Origin,
|
||||
pub struct Module<T: Config<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
system = system
|
||||
{
|
||||
fn deposit_event() = default;
|
||||
@@ -149,7 +149,7 @@ mod module2 {
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as Module2 {
|
||||
trait Store for Module<T: Config<I>, I: Instance=DefaultInstance> as Module2 {
|
||||
pub Value config(value): T::Amount;
|
||||
pub Map config(map): map hasher(identity) u64 => u64;
|
||||
pub DoubleMap config(double_map): double_map hasher(identity) u64, hasher(identity) u64 => u64;
|
||||
@@ -157,20 +157,20 @@ mod module2 {
|
||||
}
|
||||
|
||||
frame_support::decl_event! {
|
||||
pub enum Event<T, I=DefaultInstance> where Amount = <T as Trait<I>>::Amount {
|
||||
pub enum Event<T, I=DefaultInstance> where Amount = <T as Config<I>>::Amount {
|
||||
Variant(Amount),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
|
||||
pub enum Origin<T: Trait<I>, I=DefaultInstance> {
|
||||
pub enum Origin<T: Config<I>, I=DefaultInstance> {
|
||||
Members(u32),
|
||||
_Phantom(std::marker::PhantomData<(T, I)>),
|
||||
}
|
||||
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678";
|
||||
|
||||
impl<T: Trait<I>, I: Instance> ProvideInherent for Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> ProvideInherent for Module<T, I> {
|
||||
type Call = Call<T, I>;
|
||||
type Error = MakeFatalError<sp_inherents::Error>;
|
||||
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
|
||||
@@ -190,13 +190,13 @@ mod module2 {
|
||||
mod module3 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: module2::Trait + module2::Trait<module2::Instance1> + system::Trait {
|
||||
pub trait Config: module2::Config + module2::Config<module2::Instance1> + system::Config {
|
||||
type Currency: Currency;
|
||||
type Currency2: Currency;
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: <T as system::Config>::Origin, system=system {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,39 +204,39 @@ parameter_types! {
|
||||
pub const SomeValue: u32 = 100;
|
||||
}
|
||||
|
||||
impl module1::Trait<module1::Instance1> for Runtime {
|
||||
impl module1::Config<module1::Instance1> for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type SomeParameter = SomeValue;
|
||||
type GenericType = u32;
|
||||
}
|
||||
impl module1::Trait<module1::Instance2> for Runtime {
|
||||
impl module1::Config<module1::Instance2> for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type SomeParameter = SomeValue;
|
||||
type GenericType = u32;
|
||||
}
|
||||
impl module2::Trait for Runtime {
|
||||
impl module2::Config for Runtime {
|
||||
type Amount = u16;
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
}
|
||||
impl module2::Trait<module2::Instance1> for Runtime {
|
||||
impl module2::Config<module2::Instance1> for Runtime {
|
||||
type Amount = u32;
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
}
|
||||
impl module2::Trait<module2::Instance2> for Runtime {
|
||||
impl module2::Config<module2::Instance2> for Runtime {
|
||||
type Amount = u32;
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
}
|
||||
impl module2::Trait<module2::Instance3> for Runtime {
|
||||
impl module2::Config<module2::Instance3> for Runtime {
|
||||
type Amount = u64;
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
}
|
||||
impl module3::Trait for Runtime {
|
||||
impl module3::Config for Runtime {
|
||||
type Currency = Module2_2;
|
||||
type Currency2 = Module2_3;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ pub type AccountId = <Signature as Verify>::Signer;
|
||||
pub type BlockNumber = u64;
|
||||
pub type Index = u64;
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter= ();
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
|
||||
@@ -27,9 +27,9 @@ mod module {
|
||||
use super::*;
|
||||
|
||||
pub type Request<T> = (
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as system::Config>::AccountId,
|
||||
Role,
|
||||
<T as system::Trait>::BlockNumber,
|
||||
<T as system::Config>::BlockNumber,
|
||||
);
|
||||
pub type Requests<T> = Vec<Request<T>>;
|
||||
|
||||
@@ -39,7 +39,7 @@ mod module {
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub struct RoleParameters<T: Trait> {
|
||||
pub struct RoleParameters<T: Config> {
|
||||
// minimum actors to maintain - if role is unstaking
|
||||
// and remaining actors would be less that this value - prevent or punish for unstaking
|
||||
pub min_actors: u32,
|
||||
@@ -65,7 +65,7 @@ mod module {
|
||||
pub startup_grace_period: T::BlockNumber,
|
||||
}
|
||||
|
||||
impl<T: Trait> Default for RoleParameters<T> {
|
||||
impl<T: Config> Default for RoleParameters<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
max_actors: 10,
|
||||
@@ -81,18 +81,18 @@ mod module {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: system::Trait {}
|
||||
pub trait Config: system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=system {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=system {}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Serialize, Deserialize)]
|
||||
pub struct Data<T: Trait> {
|
||||
pub struct Data<T: Config> {
|
||||
pub data: T::BlockNumber,
|
||||
}
|
||||
|
||||
impl<T: Trait> Default for Data<T> {
|
||||
impl<T: Config> Default for Data<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
data: T::BlockNumber::default(),
|
||||
@@ -101,7 +101,7 @@ mod module {
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Actors {
|
||||
trait Store for Module<T: Config> as Actors {
|
||||
/// requirements to enter and maintain status in roles
|
||||
pub Parameters get(fn parameters) build(|config: &GenesisConfig| {
|
||||
if config.enable_storage_role {
|
||||
@@ -157,7 +157,7 @@ pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, Call, Signature, ()>;
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter = ();
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
@@ -169,7 +169,7 @@ impl system::Trait for Runtime {
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl module::Trait for Runtime {}
|
||||
impl module::Config for Runtime {}
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Runtime where
|
||||
|
||||
@@ -37,11 +37,11 @@ const SOME_TEST_VERSION: PalletVersion = PalletVersion { major: 3000, minor: 30,
|
||||
mod module1 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait: system::Trait {}
|
||||
pub trait Config: system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where
|
||||
origin: <T as system::Trait>::Origin,
|
||||
pub struct Module<T: Config> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
system = system,
|
||||
{}
|
||||
}
|
||||
@@ -52,11 +52,11 @@ mod module1 {
|
||||
mod module2 {
|
||||
use super::*;
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: system::Trait {}
|
||||
pub trait Config<I=DefaultInstance>: system::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
origin: <T as system::Trait>::Origin,
|
||||
pub struct Module<T: Config<I>, I: Instance=DefaultInstance> for enum Call where
|
||||
origin: <T as system::Config>::Origin,
|
||||
system = system
|
||||
{
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
@@ -78,21 +78,21 @@ mod module2 {
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance=DefaultInstance> as Module2 {}
|
||||
trait Store for Module<T: Config<I>, I: Instance=DefaultInstance> as Module2 {}
|
||||
}
|
||||
}
|
||||
|
||||
impl module1::Trait for Runtime {}
|
||||
impl module2::Trait for Runtime {}
|
||||
impl module2::Trait<module2::Instance1> for Runtime {}
|
||||
impl module2::Trait<module2::Instance2> for Runtime {}
|
||||
impl module1::Config for Runtime {}
|
||||
impl module2::Config for Runtime {}
|
||||
impl module2::Config<module2::Instance1> for Runtime {}
|
||||
impl module2::Config<module2::Instance2> for Runtime {}
|
||||
|
||||
pub type Signature = sr25519::Signature;
|
||||
pub type AccountId = <Signature as Verify>::Signer;
|
||||
pub type BlockNumber = u64;
|
||||
pub type Index = u64;
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
impl system::Config for Runtime {
|
||||
type BaseCallFilter= ();
|
||||
type Hash = H256;
|
||||
type Origin = Origin;
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub trait Trait: frame_system::Config {
|
||||
type Balance: frame_support::dispatch::Parameter;
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Example {
|
||||
Dummy get(fn dummy) config(): Option<u32>;
|
||||
}
|
||||
}
|
||||
|
||||
frame_support::decl_event!(
|
||||
pub enum Event<T> where B = <T as Trait>::Balance {
|
||||
Dummy(B),
|
||||
}
|
||||
);
|
||||
|
||||
frame_support::decl_error!(
|
||||
pub enum Error for Module<T: Trait> {
|
||||
Dummy,
|
||||
}
|
||||
);
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn deposit_event() = default;
|
||||
type Error = Error<T>;
|
||||
const Foo: u32 = u32::max_value();
|
||||
|
||||
#[weight = 0]
|
||||
fn accumulate_dummy(origin, increase_by: T::Balance) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> sp_runtime::traits::ValidateUnsigned for Module<T> {
|
||||
type Call = Call<T>;
|
||||
|
||||
fn validate_unsigned(
|
||||
_source: sp_runtime::transaction_validity::TransactionSource,
|
||||
_call: &Self::Call,
|
||||
) -> sp_runtime::transaction_validity::TransactionValidity {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
pub const INHERENT_IDENTIFIER: sp_inherents::InherentIdentifier = *b"12345678";
|
||||
|
||||
impl<T: Trait> sp_inherents::ProvideInherent for Module<T> {
|
||||
type Call = Call<T>;
|
||||
type Error = sp_inherents::MakeFatalError<sp_inherents::Error>;
|
||||
const INHERENT_IDENTIFIER: sp_inherents::InherentIdentifier = INHERENT_IDENTIFIER;
|
||||
|
||||
fn create_inherent(_data: &sp_inherents::InherentData) -> Option<Self::Call> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn check_inherent(_: &Self::Call, _: &sp_inherents::InherentData) -> std::result::Result<(), Self::Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate as pallet_test;
|
||||
|
||||
use frame_support::parameter_types;
|
||||
use sp_runtime::traits::Block;
|
||||
|
||||
type SignedExtra = (
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
);
|
||||
type TestBlock = sp_runtime::generic::Block<TestHeader, TestUncheckedExtrinsic>;
|
||||
type TestHeader = sp_runtime::generic::Header<u64, sp_runtime::traits::BlakeTwo256>;
|
||||
type TestUncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<
|
||||
<Runtime as frame_system::Config>::AccountId,
|
||||
<Runtime as frame_system::Config>::Call,
|
||||
(),
|
||||
SignedExtra,
|
||||
>;
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Runtime where
|
||||
Block = TestBlock,
|
||||
NodeBlock = TestBlock,
|
||||
UncheckedExtrinsic = TestUncheckedExtrinsic
|
||||
{
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
PalletTest: pallet_test::{Module, Call, Storage, Event<T>, Config, ValidateUnsigned, Inherent},
|
||||
}
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const MaximumBlockWeight: frame_support::weights::Weight = 1024;
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: sp_runtime::Perbill = sp_runtime::Perbill::one();
|
||||
}
|
||||
|
||||
impl frame_system::Config for Runtime {
|
||||
type BaseCallFilter = ();
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = sp_core::H256;
|
||||
type Call = Call;
|
||||
type Hashing = sp_runtime::traits::BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
|
||||
type Header = TestHeader;
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type BlockExecutionWeight = ();
|
||||
type ExtrinsicBaseWeight = ();
|
||||
type MaximumExtrinsicWeight = MaximumBlockWeight;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_test::Trait for Runtime {
|
||||
type Balance = u32;
|
||||
type Event = ();
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ macro_rules! reserved {
|
||||
mod $reserved {
|
||||
pub use frame_support::dispatch;
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
pub mod system {
|
||||
use frame_support::dispatch;
|
||||
@@ -15,7 +15,7 @@ macro_rules! reserved {
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {
|
||||
#[weight = 0]
|
||||
fn $reserved(_origin) -> dispatch::DispatchResult { unreachable!() }
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ use frame_support::{
|
||||
use sp_io::TestExternalities;
|
||||
use sp_std::result;
|
||||
|
||||
pub trait Trait: frame_support_test::Trait {}
|
||||
pub trait Config: frame_support_test::Config {}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=frame_support_test {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=frame_support_test {
|
||||
#[weight = 0]
|
||||
#[transactional]
|
||||
fn value_commits(_origin, v: u32) {
|
||||
@@ -42,7 +42,7 @@ frame_support::decl_module! {
|
||||
}
|
||||
|
||||
frame_support::decl_storage!{
|
||||
trait Store for Module<T: Trait> as StorageTransactions {
|
||||
trait Store for Module<T: Config> as StorageTransactions {
|
||||
pub Value: u32;
|
||||
pub Map: map hasher(twox_64_concat) String => u32;
|
||||
}
|
||||
@@ -50,14 +50,14 @@ frame_support::decl_storage!{
|
||||
|
||||
struct Runtime;
|
||||
|
||||
impl frame_support_test::Trait for Runtime {
|
||||
impl frame_support_test::Config for Runtime {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type PalletInfo = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for Runtime {}
|
||||
impl Config for Runtime {}
|
||||
|
||||
#[test]
|
||||
fn storage_transaction_basic_commit() {
|
||||
|
||||
@@ -19,7 +19,7 @@ use frame_support::{
|
||||
codec::{Encode, Decode, EncodeLike}, traits::Get, weights::RuntimeDbWeight,
|
||||
};
|
||||
|
||||
pub trait Trait: 'static + Eq + Clone {
|
||||
pub trait Config: 'static + Eq + Clone {
|
||||
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
||||
+ From<RawOrigin<Self::AccountId>>;
|
||||
|
||||
@@ -34,18 +34,18 @@ pub trait Trait: 'static + Eq + Clone {
|
||||
}
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system=self {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin, system=self {
|
||||
#[weight = 0]
|
||||
fn noop(origin) {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
pub fn deposit_event(_event: impl Into<T::Event>) {}
|
||||
}
|
||||
|
||||
frame_support::decl_event!(
|
||||
pub enum Event<T> where BlockNumber = <T as Trait>::BlockNumber {
|
||||
pub enum Event<T> where BlockNumber = <T as Config>::BlockNumber {
|
||||
ExtrinsicSuccess,
|
||||
ExtrinsicFailed,
|
||||
Ignore(BlockNumber),
|
||||
@@ -53,7 +53,7 @@ frame_support::decl_event!(
|
||||
);
|
||||
|
||||
frame_support::decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Test error documentation
|
||||
TestError,
|
||||
/// Error documentation
|
||||
@@ -79,7 +79,7 @@ impl<AccountId> From<Option<AccountId>> for RawOrigin<AccountId> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
||||
pub type Origin<T> = RawOrigin<<T as Config>::AccountId>;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
|
||||
|
||||
Reference in New Issue
Block a user