mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Implement #[pallet::composite_enum] (#13722)
* Implement #[pallet::hold_reason] * Appease clippy * cargo fmt * Update test expectations * Update test expectations * Support composite_enum attribute instead * Update test expectations * Change hold_reason to composite_enum * Add UI test for unsupported identifier when using composite_enum * Fix comment * Add documentation for pallet::composable_enum * More docs * cargo fmt
This commit is contained in:
@@ -1411,3 +1411,30 @@ pub fn validate_unsigned(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pub fn origin(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
/// The `#[pallet::composable_enum]` attribute allows you to define an enum that gets composed as an
|
||||
/// aggregate enum by `construct_runtime`. This is similar in principle with `#[pallet::event]` and
|
||||
/// `#[pallet::error]`.
|
||||
///
|
||||
/// The attribute currently only supports enum definitions, and identifiers that are named
|
||||
/// `FreezeReason`, `HoldReason`, `LockId` or `SlashReason`. Arbitrary identifiers for the enum are
|
||||
/// not supported. The aggregate enum generated by `construct_runtime` will have the name of
|
||||
/// `RuntimeFreezeReason`, `RuntimeHoldReason`, `RuntimeLockId` and `RuntimeSlashReason`
|
||||
/// respectively.
|
||||
///
|
||||
/// NOTE: The aggregate enum generated by `construct_runtime` generates a conversion function from
|
||||
/// the pallet enum to the aggregate enum, and automatically derives the following traits:
|
||||
///
|
||||
/// ```ignore
|
||||
/// Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo,
|
||||
/// RuntimeDebug
|
||||
/// ```
|
||||
///
|
||||
/// For ease of usage, when no `#[derive]` attributes are found for the enum under
|
||||
/// `#[pallet::composable_enum]`, the aforementioned traits are automatically derived for it. The
|
||||
/// inverse is also true: if there are any `#[derive]` attributes found for the enum, then no traits
|
||||
/// will automatically be derived for it.
|
||||
#[proc_macro_attribute]
|
||||
pub fn composable_enum(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user