mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 23:01:01 +00:00
metadata: Use v15 internally (#912)
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Improve documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * force CI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Address feedback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use HASH_LEN Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadta: Remove `LatestRuntimeMetadata` type alias Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove `metadata_to_latest` to avoid pancis Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -8,7 +8,7 @@ use color_eyre::eyre;
|
||||
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
|
||||
use scale::{Decode, Encode};
|
||||
use std::io::{self, Write};
|
||||
use subxt_metadata::retain_metadata_pallets;
|
||||
use subxt_metadata::{metadata_v14_to_latest, retain_metadata_pallets};
|
||||
|
||||
/// Download metadata from a substrate node, for use with `subxt` codegen.
|
||||
#[derive(Debug, ClapParser)]
|
||||
@@ -20,6 +20,9 @@ pub struct Opts {
|
||||
format: String,
|
||||
/// Generate a subset of the metadata that contains only the
|
||||
/// types needed to represent the provided pallets.
|
||||
///
|
||||
/// The returned metadata is updated to the latest available version
|
||||
/// when using the option.
|
||||
#[clap(long, use_value_delimiter = true, value_parser)]
|
||||
pallets: Option<Vec<String>>,
|
||||
}
|
||||
@@ -29,8 +32,9 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> {
|
||||
let mut metadata = <RuntimeMetadataPrefixed as Decode>::decode(&mut &bytes[..])?;
|
||||
|
||||
if let Some(pallets) = opts.pallets {
|
||||
let metadata_v14 = match &mut metadata.1 {
|
||||
RuntimeMetadata::V14(metadata_v14) => metadata_v14,
|
||||
let mut metadata_v15 = match metadata.1 {
|
||||
RuntimeMetadata::V14(metadata_v14) => metadata_v14_to_latest(metadata_v14),
|
||||
RuntimeMetadata::V15(metadata_v15) => metadata_v15,
|
||||
_ => {
|
||||
return Err(eyre::eyre!(
|
||||
"Unsupported metadata version {:?}, expected V14.",
|
||||
@@ -39,9 +43,10 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> {
|
||||
}
|
||||
};
|
||||
|
||||
retain_metadata_pallets(metadata_v14, |pallet_name| {
|
||||
retain_metadata_pallets(&mut metadata_v15, |pallet_name| {
|
||||
pallets.iter().any(|p| &**p == pallet_name)
|
||||
});
|
||||
metadata = metadata_v15.into();
|
||||
}
|
||||
|
||||
match opts.format.as_str() {
|
||||
|
||||
Reference in New Issue
Block a user