Adds ability to provide defaults for types provided by construct_runtime (#14682)

* Adds ability to use defaults for verbatim types

* Adds RuntimeOrigin and PalletInfo in DefaultConfig

* Adds RuntimeEvent in DefaultConfig

* Adds RuntimeEvent in DefaultConfig

* Minor fix

* Minor fix

* Everything in frame_system can now have a default

* Adds docs

* Adds UI Test for no_bounds

* Updates docs

* Adds UI tests for verbatim

* Minor update

* Minor updates

* Minor updates

* Addresses review comments

* Fixes test

* Update frame/support/procedural/src/derive_impl.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Minor fix

* Minor

* Fixes build

* Uses runtime_type

* Fixes comment

* Fixes comment

* Fixes test

* Uses no_aggregated_types as an option in derive_impl

* Uses specific imports

* Fmt

* Updates doc

* Update frame/support/procedural/src/derive_impl.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update frame/support/procedural/src/derive_impl.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Addresses review comment

* Addresses review comment

* fmt

* Renames test files

* Adds docs using docify

* Fixes test

* Fixes UI tests

---------

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
gupnik
2023-08-25 13:22:22 +05:30
committed by GitHub
parent 32541bde15
commit 83ae018087
21 changed files with 409 additions and 41 deletions
+17 -2
View File
@@ -830,6 +830,21 @@ pub mod pallet_prelude {
};
pub use codec::{Decode, Encode, MaxEncodedLen};
pub use frame_support::pallet_macros::*;
/// The optional attribute `#[inject_runtime_type]` can be attached to `RuntimeCall`,
/// `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo` in an impl statement that has
/// `#[register_default_impl]` attached to indicate that this item is generated by
/// `construct_runtime`.
///
/// Attaching this attribute to such an item ensures that the combined impl generated via
/// [`#[derive_impl(..)]`](`macro@super::derive_impl`) will use the correct type
/// auto-generated by `construct_runtime!`.
#[doc = docify::embed!("src/tests/inject_runtime_type.rs", derive_impl_works_with_runtime_type_injection)]
///
/// However, if `no_aggregated_types` is specified while using
/// `[`#[derive_impl(..)]`](`macro@super::derive_impl`)`, then these items are attached
/// verbatim to the combined impl.
#[doc = docify::embed!("src/tests/inject_runtime_type.rs", derive_impl_works_with_no_aggregated_types)]
pub use frame_support_procedural::inject_runtime_type;
pub use frame_support_procedural::register_default_impl;
pub use scale_info::TypeInfo;
pub use sp_inherents::MakeFatalError;
@@ -2176,8 +2191,8 @@ pub mod pallet_macros {
call_index, compact, composite_enum, config, constant,
disable_frame_system_supertrait_check, error, event, extra_constants, generate_deposit,
generate_store, genesis_build, genesis_config, getter, hooks, import_section, inherent,
no_default, origin, pallet_section, storage, storage_prefix, storage_version, type_value,
unbounded, validate_unsigned, weight, whitelist_storage,
no_default, no_default_bounds, origin, pallet_section, storage, storage_prefix,
storage_version, type_value, unbounded, validate_unsigned, weight, whitelist_storage,
};
}