mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
Add documentation around FRAME Origin (#3362)
Does the following: - Add a reference doc page named `frame_runtime_types`, which explains what types like `RuntimeOrigin`, `RuntimeCall` etc are. - On top of it, it adds a reference doc page called `frame_origin` which explains a few important patterns that we use around origins - And finally brushes up `#[frame::origin]` docs. - Updates the theme, sidebar and favicon to look like: <img width="1728" alt="Screenshot 2024-02-20 at 12 16 00" src="https://github.com/paritytech/polkadot-sdk/assets/5588131/6d60a16b-2081-411b-8869-43b91920cca9"> All of this was inspired by https://substrate.stackexchange.com/questions/10992/how-do-you-find-the-public-key-for-the-medium-spender-track-origin/10993 closes https://github.com/paritytech/polkadot-sdk-docs/issues/45 closes https://github.com/paritytech/polkadot-sdk-docs/issues/43 contributes / overlaps with https://github.com/paritytech/polkadot-sdk/pull/2638 cc @liamaharon deprecation companion: https://github.com/substrate-developer-hub/substrate-docs/pull/2131 pba-content companion: https://github.com/Polkadot-Blockchain-Academy/pba-content/pull/977 --------- Co-authored-by: Radha <86818441+DrW3RK@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
@@ -2274,9 +2274,8 @@ pub mod pallet_macros {
|
||||
pub use frame_support_procedural::{
|
||||
composite_enum, config, disable_frame_system_supertrait_check, error, event,
|
||||
extra_constants, feeless_if, generate_deposit, generate_store, getter, hooks,
|
||||
import_section, inherent, no_default, no_default_bounds, origin, pallet_section,
|
||||
storage_prefix, storage_version, type_value, unbounded, validate_unsigned, weight,
|
||||
whitelist_storage,
|
||||
import_section, inherent, no_default, no_default_bounds, pallet_section, storage_prefix,
|
||||
storage_version, type_value, unbounded, validate_unsigned, weight, whitelist_storage,
|
||||
};
|
||||
|
||||
/// Allows a pallet to declare a set of functions as a *dispatchable extrinsic*. In
|
||||
@@ -2718,7 +2717,7 @@ pub mod pallet_macros {
|
||||
/// }
|
||||
/// ```
|
||||
pub use frame_support_procedural::storage;
|
||||
/// This attribute is attached to a function inside an `impl` block annoated with
|
||||
/// This attribute is attached to a function inside an `impl` block annotated with
|
||||
/// [`pallet::tasks_experimental`](`tasks_experimental`) to define the conditions for a
|
||||
/// given work item to be valid.
|
||||
///
|
||||
@@ -2726,21 +2725,21 @@ pub mod pallet_macros {
|
||||
/// should have the same signature as the function it is attached to, except that it should
|
||||
/// return a `bool` instead.
|
||||
pub use frame_support_procedural::task_condition;
|
||||
/// This attribute is attached to a function inside an `impl` block annoated with
|
||||
/// This attribute is attached to a function inside an `impl` block annotated with
|
||||
/// [`pallet::tasks_experimental`](`tasks_experimental`) to define the index of a given
|
||||
/// work item.
|
||||
///
|
||||
/// It takes an integer literal as input, which is then used to define the index. This
|
||||
/// index should be unique for each function in the `impl` block.
|
||||
pub use frame_support_procedural::task_index;
|
||||
/// This attribute is attached to a function inside an `impl` block annoated with
|
||||
/// This attribute is attached to a function inside an `impl` block annotated with
|
||||
/// [`pallet::tasks_experimental`](`tasks_experimental`) to define an iterator over the
|
||||
/// available work items for a task.
|
||||
///
|
||||
/// It takes an iterator as input that yields a tuple with same types as the function
|
||||
/// arguments.
|
||||
pub use frame_support_procedural::task_list;
|
||||
/// This attribute is attached to a function inside an `impl` block annoated with
|
||||
/// This attribute is attached to a function inside an `impl` block annotated with
|
||||
/// [`pallet::tasks_experimental`](`tasks_experimental`) define the weight of a given work
|
||||
/// item.
|
||||
///
|
||||
@@ -2773,6 +2772,61 @@ pub mod pallet_macros {
|
||||
/// Now, this can be executed as follows:
|
||||
#[doc = docify::embed!("src/tests/tasks.rs", tasks_work)]
|
||||
pub use frame_support_procedural::tasks_experimental;
|
||||
|
||||
/// Allows a pallet to declare a type as an origin.
|
||||
///
|
||||
/// If defined as such, this type will be amalgamated at the runtime level into
|
||||
/// `RuntimeOrigin`, very similar to [`call`], [`error`] and [`event`]. See
|
||||
/// [`composite_enum`] for similar cases.
|
||||
///
|
||||
/// Origin is a complex FRAME topics and is further explained in `polkadot_sdk_docs`.
|
||||
///
|
||||
/// ## Syntax Variants
|
||||
///
|
||||
/// ```
|
||||
/// #[frame_support::pallet]
|
||||
/// mod pallet {
|
||||
/// # use frame_support::pallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # pub trait Config: frame_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// /// On the spot declaration.
|
||||
/// #[pallet::origin]
|
||||
/// #[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
/// pub enum Origin {
|
||||
/// Foo,
|
||||
/// Bar,
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Or, more commonly used:/
|
||||
///
|
||||
/// ```
|
||||
/// #[frame_support::pallet]
|
||||
/// mod pallet {
|
||||
/// # use frame_support::pallet_prelude::*;
|
||||
/// # #[pallet::config]
|
||||
/// # pub trait Config: frame_system::Config {}
|
||||
/// # #[pallet::pallet]
|
||||
/// # pub struct Pallet<T>(_);
|
||||
/// #[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
/// pub enum RawOrigin {
|
||||
/// Foo,
|
||||
/// Bar,
|
||||
/// }
|
||||
///
|
||||
/// #[pallet::origin]
|
||||
/// pub type Origin = RawOrigin;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ## Warning
|
||||
///
|
||||
/// Modifying any pallet's origin type will cause the runtime level origin type to also
|
||||
/// change in encoding. If stored anywhere on-chain, this will require a data migration.
|
||||
pub use frame_support_procedural::origin;
|
||||
}
|
||||
|
||||
#[deprecated(note = "Will be removed after July 2023; Use `sp_runtime::traits` directly instead.")]
|
||||
|
||||
Reference in New Issue
Block a user