-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metadata V16 (unstable): Enrich metadata with associated types of con…
…fig traits (#5274) This feature is part of the upcoming metadata V16. The associated types of the `Config` trait that require the `TypeInfo` or `Parameter` bounds are included in the metadata of the pallet. The metadata is not yet exposed to the end-user, however the metadata intermediate representation (IR) contains these types. Developers can opt out of metadata collection of the associated types by specifying `without_metadata` optional attribute to the `#[pallet::config]`. Furthermore, the `without_metadata` argument can be used in combination with the newly added `#[pallet::include_metadata]` attribute to selectively include only certain associated types in the metadata collection. ### API Design - There is nothing to collect from the associated types: ```rust #[pallet::config] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; // Constants are already propagated. #[pallet::constant] type MyGetParam2: Get<u32>; } ``` - Default automatic collection of associated types that require TypeInfo or Parameter bounds: ```rust #[pallet::config] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; // Constants are already propagated. #[pallet::constant] type MyGetParam2: Get<u32>; // Associated type included by default, because it requires TypeInfo bound. /// Nonce doc. type Nonce: TypeInfo; // Associated type included by default, because it requires // Parameter bound (indirect TypeInfo). type AccountData: Parameter; // Associated type without metadata bounds, not included. type NotIncluded: From<u8>; } ``` - Disable automatic collection ```rust // Associated types are not collected by default. #[pallet::config(without_metadata)] pub trait Config: frame_system::Config { // Runtime events already propagated to the metadata. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; // Constants are already propagated. #[pallet::constant] type MyGetParam2: Get<u32>; // Explicitly include associated types. #[pallet::include_metadata] type Nonce: TypeInfo; type AccountData: Parameter; type NotIncluded: From<u8>; } ``` Builds on top of the PoC: #4358 Closes: #4519 cc @paritytech/subxt-team --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Guillaume Thiolliere <[email protected]> Co-authored-by: Shawn Tabrizi <[email protected]>
- Loading branch information
1 parent
2c41656
commit b649f4a
Showing
23 changed files
with
917 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
title: Enrich metadata IR with associated types of config traits | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
This feature is part of the upcoming metadata V16. The associated types of the `Config` trait that require the `TypeInfo` | ||
or `Parameter` bounds are included in the metadata of the pallet. The metadata is not yet exposed to the end-user, however | ||
the metadata intermediate representation (IR) contains these types. | ||
|
||
Developers can opt out of metadata collection of the associated types by specifying `without_metadata` optional attribute | ||
to the `#[pallet::config]`. | ||
|
||
Furthermore, the `without_metadata` argument can be used in combination with the newly added `#[pallet::include_metadata]` | ||
attribute to selectively include only certain associated types in the metadata collection. | ||
|
||
crates: | ||
- name: frame-support | ||
bump: patch | ||
- name: frame-support-procedural | ||
bump: patch | ||
- name: frame-support-procedural-tools | ||
bump: patch | ||
- name: sp-metadata-ir | ||
bump: major |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.