-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metadata: Retain a subset of metadata pallets (#879)
* Update cargo.lock to use scale-info v2.4.0 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only a subset of the metadata Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate top level Event Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Only retain DispatchError Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Export just the retain method Signed-off-by: Alexandru Vasile <[email protected]> * cli: Retain pallets Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Do not include extrinsic metadata Signed-off-by: Alexandru Vasile <[email protected]> * retain: Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * test-runtime: Generate per pallet metadata and rs file Signed-off-by: Alexandru Vasile <[email protected]> * ui-tests: Check per metadata generated files Signed-off-by: Alexandru Vasile <[email protected]> * Revert "test-runtime: Generate per pallet metadata and rs file" This reverts commit 725a2e5. Signed-off-by: Alexandru Vasile <[email protected]> * ui-tests: Adjust path to metadata file Signed-off-by: Alexandru Vasile <[email protected]> * ui-tests: Change drop order to keep `PalletMetadata` around Signed-off-by: Alexandru Vasile <[email protected]> * Update metadata/src/retain.rs Co-authored-by: James Wilson <[email protected]> * Address feedback Signed-off-by: Alexandru Vasile <[email protected]> * retain: Keep extrinsic type Signed-off-by: Alexandru Vasile <[email protected]> * cli: Introduce `MetadataSource` Signed-off-by: Alexandru Vasile <[email protected]> * cli: Use `MetadataSource` helper Signed-off-by: Alexandru Vasile <[email protected]> * cli: Use `FileOrUrl` flatten command argument Signed-off-by: Alexandru Vasile <[email protected]> * retain: Do not include generic type params in retained metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust subxt to scale-info v2.5.0 Signed-off-by: Alexandru Vasile <[email protected]> * Update scaleinfo to v2.5.0 Signed-off-by: Alexandru Vasile <[email protected]> * Remove deprecated fn Signed-off-by: Alexandru Vasile <[email protected]> * testing: Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * benches: Use inner fields of scale info Signed-off-by: Alexandru Vasile <[email protected]> * address nits, and strip RuntimeCall type instead of trying to filter out use of it for better overall wins/clarity * fix UI test * move utils out of commands folder and fix clippy etc * address nits --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
- Loading branch information
Showing
14 changed files
with
464 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2019-2023 Parity Technologies (UK) Ltd. | ||
// This file is dual-licensed as Apache-2.0 or GPL-3.0. | ||
// see LICENSE for license details. | ||
|
||
use clap::Args; | ||
use color_eyre::eyre; | ||
use std::{fs, io::Read, path::PathBuf}; | ||
use subxt_codegen::utils::Uri; | ||
|
||
/// The source of the metadata. | ||
#[derive(Debug, Args)] | ||
pub struct FileOrUrl { | ||
/// The url of the substrate node to query for metadata for codegen. | ||
#[clap(long, value_parser)] | ||
url: Option<Uri>, | ||
/// The path to the encoded metadata file. | ||
#[clap(long, value_parser)] | ||
file: Option<PathBuf>, | ||
} | ||
|
||
impl FileOrUrl { | ||
/// Fetch the metadata bytes. | ||
pub async fn fetch(&self) -> color_eyre::Result<Vec<u8>> { | ||
match (&self.file, &self.url) { | ||
// Can't provide both --file and --url | ||
(Some(_), Some(_)) => { | ||
eyre::bail!("specify one of `--url` or `--file` but not both") | ||
} | ||
// Load from --file path | ||
(Some(path), None) => { | ||
let mut file = fs::File::open(path)?; | ||
let mut bytes = Vec::new(); | ||
file.read_to_end(&mut bytes)?; | ||
Ok(bytes) | ||
} | ||
// Fetch from --url | ||
(None, Some(uri)) => Ok(subxt_codegen::utils::fetch_metadata_bytes(uri).await?), | ||
// Default if neither is provided; fetch from local url | ||
(None, None) => { | ||
let uri = Uri::from_static("http://localhost:9933"); | ||
Ok(subxt_codegen::utils::fetch_metadata_bytes(&uri).await?) | ||
} | ||
} | ||
} | ||
} |
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.