Skip to content

Commit

Permalink
allow 'latest' metadata to be returned from the fallback code (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdw authored Aug 21, 2023
1 parent b763bf5 commit ab84228
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 4 additions & 8 deletions cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ pub struct FileOrUrl {
pub file: Option<PathBuf>,
/// Specify the metadata version.
///
/// - unstable:
/// - "latest": Use the latest stable version available.
/// - "unstable": Use the unstable metadata, if present.
/// - a number: Use a specific metadata version.
///
/// Use the latest unstable metadata of the node.
///
/// - number
///
/// Use this specific metadata version.
///
/// Defaults to 14.
/// Defaults to asking for the latest stable metadata version.
#[clap(long)]
pub version: Option<MetadataVersion>,
}
Expand Down
8 changes: 6 additions & 2 deletions codegen/src/utils/fetch_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,18 @@ async fn fetch_metadata(
client: &impl ClientT,
version: MetadataVersion,
) -> Result<Vec<u8>, FetchMetadataError> {
if !matches!(version, MetadataVersion::Version(14)) {
// If the user specifically asks for anything other than version 14 or "latest", error.
if !matches!(
version,
MetadataVersion::Latest | MetadataVersion::Version(14)
) {
return Err(FetchMetadataError::Other(
"The node can only return version 14 metadata using the legacy API but you've asked for something else"
.to_string(),
));
}

// Fetch the metadata at that version:
// Fetch the metadata.
let metadata_string: String = client
.request("state_call", rpc_params!["Metadata_metadata", "0x"])
.await?;
Expand Down

0 comments on commit ab84228

Please # to comment.