Adds instance support for composite enums (#1857)

Fixes https://github.com/paritytech/polkadot-sdk/issues/1839

Currently, `composite_enum`s do not support pallet instances. This PR
allows the following:
```rust
	#[pallet::composite_enum]
	pub enum HoldReason<I: 'static = ()> {
		SomeHoldReason
	}
```

### Todo

- [x]  UI Test
This commit is contained in:
gupnik
2023-10-13 07:48:51 +02:00
committed by GitHub
parent d2fc1d7c91
commit 6b27dad359
11 changed files with 264 additions and 93 deletions
+15 -2
View File
@@ -1646,8 +1646,7 @@ pub mod pallet_prelude {
/// the enum:
///
/// ```ignore
/// Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo,
/// RuntimeDebug
/// Copy, Clone, Eq, PartialEq, Encode, Decode, MaxEncodedLen, TypeInfo, RuntimeDebug
/// ```
///
/// The inverse is also true: if there are any #[derive] attributes present for the enum, then
@@ -1815,6 +1814,15 @@ pub mod pallet_prelude {
/// #[pallet::origin]
/// pub struct Origin<T>(PhantomData<T>);
///
/// // Declare a hold reason (this is optional).
/// //
/// // Creates a hold reason for this pallet that is aggregated by `construct_runtime`.
/// // A similar enum can be defined for `FreezeReason`, `LockId` or `SlashReason`.
/// #[pallet::composite_enum]
/// pub enum HoldReason {
/// SomeHoldReason
/// }
///
/// // Declare validate_unsigned implementation (this is optional).
/// #[pallet::validate_unsigned]
/// impl<T: Config> ValidateUnsigned for Pallet<T> {
@@ -1949,6 +1957,11 @@ pub mod pallet_prelude {
/// #[pallet::origin]
/// pub struct Origin<T, I = ()>(PhantomData<(T, I)>);
///
/// #[pallet::composite_enum]
/// pub enum HoldReason<I: 'static = ()> {
/// SomeHoldReason
/// }
///
/// #[pallet::validate_unsigned]
/// impl<T: Config<I>, I: 'static> ValidateUnsigned for Pallet<T, I> {
/// type Call = Call<T, I>;