This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Metadata V15: Expose API to fetch metadata for version #13287
Merged
paritytech-processbot
merged 51 commits into
master
from
lexnv/md15_expose_md_at_versions
Mar 15, 2023
Merged
Changes from 41 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
a730fe1
impl_runtime_apis: Generate getters for `metadata_at` functions
lexnv bc1fed4
runtime: Implement new `Metadata` runtime trait
lexnv 46681dd
runtime: Move `metadata_at` functions to construct_runtime macro
lexnv d03dd7d
contruct_runtime: Use `OpaqueMetadata` from hidden imports
lexnv 441b7ad
Adjust testing
lexnv 555ccfb
frame/tests: Add tests for the new API
lexnv b43038f
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
f484197
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
f21f229
frame/tests: Adjust metdata naming
lexnv a5feff4
frame/support: Expose `metadata-v14` feature flag
lexnv 24e5033
frame/support: Expose metadata only under feature flags
lexnv caf5c96
frame/support: Expose v14 metadata by default
lexnv 0f88a88
frame/support: Expose metadata feature for testing
lexnv de27280
frame/support: Test metadata under different feature flags
lexnv dd09f0c
Update primitives/api/src/lib.rs
lexnv 0596269
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
f7c0493
Update primitives/api/src/lib.rs
lexnv 506799c
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
19900a5
client/tests: Adjust testing to reflect trait Metadata change
lexnv a2b1bd7
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
lexnv 485acef
frame/metadata-ir: Add intermediate representation types for metadata
lexnv 46b52cf
frame/metadata-ir: Convert metadata to V14
lexnv 3c171d9
frame/metadata-ir: Add API to convert metadata to multiple versions
lexnv d334a09
frame/metadata-ir: Expose V14 under feature flag
lexnv a68ba6b
frame/support: Adjust to metadata IR
lexnv 0064736
frame/support: More adjustments
lexnv ed5ce74
frame/support: Guard v14 details under feature flag
lexnv d96c2f1
frame/support: Adjust testing
lexnv 68e7c5b
CI: Ensure `quick-benchmarks` uses `metadata-v14`
lexnv ae4144e
frame/support: Use `metadata-v14` for benchmarks
lexnv 1a99c6e
Adjust cargo fmt
lexnv 475c5d8
kitchensink-runtime: Add feature flag for `metadata-v14`
lexnv d170a7a
frame/support/test: Adjust testing
lexnv 9194e52
frame/support/test: Check crates locally
lexnv bd9fcdb
Activate metadata-v14 for pallets
lexnv ede9a86
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
lexnv c4b7c5c
Remove metadata-v14 feature flag
lexnv 034241c
frame/metadata_ir: Move `api.rs` to `mod.rs`
lexnv 1225e77
frame/support: Handle latest metadata conversion via IR
lexnv 429a467
frame/tests: Add constant for metadata version 14
lexnv 8234488
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
290dff3
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
lexnv d99f1f8
frame/support/test: Fix merge conflict
lexnv 81c91ac
Update frame/support/Cargo.toml
lexnv 98fab89
Update frame/support/src/metadata_ir/mod.rs
lexnv 31d3483
Update frame/support/test/Cargo.toml
lexnv 63b3109
Update primitives/api/src/lib.rs
lexnv db4f553
frame/metadata: Collect pallet documentation for MetadataIR
lexnv a38ca53
frame/tests: Check pallet documentation is propagated to MetadataIR
lexnv 6208434
frame/support: Improve documentation
lexnv 9065690
Merge remote-tracking branch 'origin/master' into lexnv/md15_expose_m…
lexnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -59,25 +59,27 @@ pub fn expand_runtime_metadata( | |
|
|
||
| quote! { | ||
| #attr | ||
| #scrate::metadata::PalletMetadata { | ||
| #scrate::metadata_ir::PalletMetadataIR { | ||
| name: stringify!(#name), | ||
| index: #index, | ||
| storage: #storage, | ||
| calls: #calls, | ||
| event: #event, | ||
| constants: #constants, | ||
| error: #errors, | ||
| // No docs collected for now. | ||
| docs: Default::default(), | ||
|
||
| } | ||
| } | ||
| }) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| quote! { | ||
| impl #runtime { | ||
| pub fn metadata() -> #scrate::metadata::RuntimeMetadataPrefixed { | ||
| #scrate::metadata::RuntimeMetadataLastVersion::new( | ||
| #scrate::sp_std::vec![ #(#pallets),* ], | ||
| #scrate::metadata::ExtrinsicMetadata { | ||
| fn metadata_ir() -> #scrate::metadata_ir::MetadataIR { | ||
| #scrate::metadata_ir::MetadataIR { | ||
| pallets: #scrate::sp_std::vec![ #(#pallets),* ], | ||
| extrinsic: #scrate::metadata_ir::ExtrinsicMetadataIR { | ||
| ty: #scrate::scale_info::meta_type::<#extrinsic>(), | ||
| version: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSION, | ||
| signed_extensions: < | ||
|
|
@@ -86,15 +88,29 @@ pub fn expand_runtime_metadata( | |
| >::SignedExtensions as #scrate::sp_runtime::traits::SignedExtension | ||
| >::metadata() | ||
| .into_iter() | ||
| .map(|meta| #scrate::metadata::SignedExtensionMetadata { | ||
| .map(|meta| #scrate::metadata_ir::SignedExtensionMetadataIR { | ||
| identifier: meta.identifier, | ||
| ty: meta.ty, | ||
| additional_signed: meta.additional_signed, | ||
| }) | ||
| .collect(), | ||
| }, | ||
| #scrate::scale_info::meta_type::<#runtime>() | ||
| ).into() | ||
| ty: #scrate::scale_info::meta_type::<#runtime>() | ||
| } | ||
| } | ||
|
|
||
| pub fn metadata() -> #scrate::metadata::RuntimeMetadataPrefixed { | ||
| #scrate::metadata_ir::into_latest(#runtime::metadata_ir()) | ||
| } | ||
|
|
||
| pub fn metadata_at_version(version: u32) -> Option<#scrate::OpaqueMetadata> { | ||
| #scrate::metadata_ir::into_version(#runtime::metadata_ir(), version).map(|prefixed| { | ||
| #scrate::OpaqueMetadata::new(prefixed.into()) | ||
| }) | ||
| } | ||
|
|
||
| pub fn metadata_versions() -> #scrate::sp_std::vec::Vec<u32> { | ||
| #scrate::metadata_ir::supported_versions() | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -157,7 +173,7 @@ fn expand_pallet_metadata_events( | |
|
|
||
| quote! { | ||
| Some( | ||
| #scrate::metadata::PalletEventMetadata { | ||
| #scrate::metadata_ir::PalletEventMetadataIR { | ||
| ty: #scrate::scale_info::meta_type::<#pallet_event>() | ||
| } | ||
| ) | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.