mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51: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:
@@ -2188,10 +2188,80 @@ pub mod pallet_macros {
|
||||
pub use frame_support_procedural::{
|
||||
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, no_default_bounds, origin, pallet_section, storage, storage_prefix,
|
||||
storage_version, type_value, unbounded, validate_unsigned, weight, whitelist_storage,
|
||||
generate_store, getter, hooks, import_section, inherent, no_default, no_default_bounds,
|
||||
origin, pallet_section, storage, storage_prefix, storage_version, type_value, unbounded,
|
||||
validate_unsigned, weight, whitelist_storage,
|
||||
};
|
||||
|
||||
/// 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 [`frame_support::traits::BuildGenesisConfig`].
|
||||
///
|
||||
/// See [`genesis_build`] for an example.
|
||||
pub use frame_support_procedural::genesis_config;
|
||||
|
||||
/// Allows you to define how the state of your pallet at genesis is built. This
|
||||
/// takes as input the `GenesisConfig` type (as `self`) and constructs the pallet's initial
|
||||
/// state.
|
||||
///
|
||||
/// The fields of the `GenesisConfig` can in turn be populated by the chain-spec.
|
||||
///
|
||||
/// ## Example:
|
||||
///
|
||||
/// ```
|
||||
/// #[frame_support::pallet]
|
||||
/// pub mod pallet {
|
||||
/// # #[pallet::config]
|
||||
/// # pub trait Config: frame_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # use frame_support::traits::BuildGenesisConfig;
|
||||
/// #[pallet::genesis_config]
|
||||
/// #[derive(frame_support::DefaultNoBound)]
|
||||
/// pub struct GenesisConfig<T: Config> {
|
||||
/// foo: Vec<T::AccountId>
|
||||
/// }
|
||||
///
|
||||
/// #[pallet::genesis_build]
|
||||
/// impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
|
||||
/// fn build(&self) {
|
||||
/// // use &self to access fields.
|
||||
/// let foo = &self.foo;
|
||||
/// todo!()
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ## Former Usage
|
||||
///
|
||||
/// Prior to <https://github.com/paritytech/substrate/pull/14306>, the following syntax was used.
|
||||
/// This is deprecated and will soon be removed.
|
||||
///
|
||||
/// ```
|
||||
/// #[frame_support::pallet]
|
||||
/// pub mod pallet {
|
||||
/// # #[pallet::config]
|
||||
/// # pub trait Config: frame_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// # use frame_support::traits::GenesisBuild;
|
||||
/// #[pallet::genesis_config]
|
||||
/// #[derive(frame_support::DefaultNoBound)]
|
||||
/// pub struct GenesisConfig<T: Config> {
|
||||
/// foo: Vec<T::AccountId>
|
||||
/// }
|
||||
///
|
||||
/// #[pallet::genesis_build]
|
||||
/// impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
|
||||
/// fn build(&self) {
|
||||
/// todo!()
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub use frame_support_procedural::genesis_build;
|
||||
}
|
||||
|
||||
#[deprecated(note = "Will be removed after July 2023; Use `sp_runtime::traits` directly instead.")]
|
||||
|
||||
Reference in New Issue
Block a user