mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 04:31:02 +00:00
update genesis_config related docs and tests and error messages (#1642)
Follow-up to https://github.com/paritytech/substrate/pull/14306. I hope this also showcases the important message of: **It is really not that hard to make the examples codes in rust-docs compile, and therefore remain correct. Please embrace this :)** It moves the documentation of proc macros to their re-export, such that can link other items in frame-support. This is a patter that we should embrace for all of macro docs, and apply in PRs like https://github.com/paritytech/substrate/pull/13987 as well. --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: command-bot <>
This commit is contained in:
@@ -1417,57 +1417,11 @@ pub fn type_value(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
/// The `#[pallet::genesis_config]` attribute allows you to define the genesis configuration
|
||||
/// for the pallet.
|
||||
///
|
||||
/// Item is defined as either an enum or a struct. It needs to be public and implement the
|
||||
/// trait `GenesisBuild` with [`#[pallet::genesis_build]`](`macro@genesis_build`). The type
|
||||
/// generics are constrained to be either none, or `T` or `T: Config`.
|
||||
///
|
||||
/// E.g:
|
||||
///
|
||||
/// ```ignore
|
||||
/// #[pallet::genesis_config]
|
||||
/// pub struct GenesisConfig<T: Config> {
|
||||
/// _myfield: BalanceOf<T>,
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro_attribute]
|
||||
pub fn genesis_config(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
/// The `#[pallet::genesis_build]` attribute allows you to define how `genesis_configuration`
|
||||
/// is built. This takes as input the `GenesisConfig` type (as `self`) and constructs the pallet's
|
||||
/// initial state.
|
||||
///
|
||||
/// The impl must be defined as:
|
||||
///
|
||||
/// ```ignore
|
||||
/// #[pallet::genesis_build]
|
||||
/// impl<T: Config> GenesisBuild<T> for GenesisConfig<$maybe_generics> {
|
||||
/// fn build(&self) { $expr }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// I.e. a trait implementation with generic `T: Config`, of trait `GenesisBuild<T>` on
|
||||
/// type `GenesisConfig` with generics none or `T`.
|
||||
///
|
||||
/// E.g.:
|
||||
///
|
||||
/// ```ignore
|
||||
/// #[pallet::genesis_build]
|
||||
/// impl<T: Config> GenesisBuild<T> for GenesisConfig {
|
||||
/// fn build(&self) {}
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ## Macro expansion
|
||||
///
|
||||
/// The macro will add the following attribute:
|
||||
/// * `#[cfg(feature = "std")]`
|
||||
///
|
||||
/// The macro will implement `sp_runtime::BuildStorage`.
|
||||
#[proc_macro_attribute]
|
||||
pub fn genesis_build(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
|
||||
Reference in New Issue
Block a user