mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
move fetch metadata to a separate crate subxt_utils_fetchmetadata (#1829)
* macros: feature-gate jsonrpsee/fetch metadata url * make CI happy * Update codegen/src/error.rs * extract `fetch-metdata` to separate crate * add missing license headers * introduce subxt-utils crate * add missing files * codegen: remove unused hex crate * fix test build * move subxt_utils -> subxt_utils_fetchmetadata * cargo fmt * runtime-path -> runtime-metadata-path * Update utils/fetch-metadata/src/lib.rs
This commit is contained in:
@@ -9,7 +9,7 @@ use jsonrpsee::{
|
||||
http_client::HttpClientBuilder,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use subxt_codegen::fetch_metadata::Url;
|
||||
use subxt_utils_fetchmetadata::Url;
|
||||
|
||||
/// Returns the node's chainSpec from the provided URL.
|
||||
pub async fn fetch_chain_spec(url: Url) -> Result<serde_json::Value, FetchSpecError> {
|
||||
|
||||
@@ -6,7 +6,7 @@ use clap::Parser as ClapParser;
|
||||
#[cfg(feature = "chain-spec-pruning")]
|
||||
use serde_json::Value;
|
||||
use std::{io::Write, path::PathBuf};
|
||||
use subxt_codegen::fetch_metadata::Url;
|
||||
use subxt_utils_fetchmetadata::Url;
|
||||
|
||||
mod fetch;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ use color_eyre::eyre::WrapErr;
|
||||
use jsonrpsee::client_transport::ws::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use subxt_codegen::fetch_metadata::MetadataVersion;
|
||||
use subxt_metadata::Metadata;
|
||||
use subxt_utils_fetchmetadata::MetadataVersion;
|
||||
|
||||
use crate::utils::validate_url_security;
|
||||
|
||||
@@ -137,7 +137,7 @@ async fn fetch_runtime_metadata(
|
||||
url: Url,
|
||||
version: MetadataVersion,
|
||||
) -> color_eyre::Result<Metadata> {
|
||||
let bytes = subxt_codegen::fetch_metadata::fetch_metadata_from_url(url, version).await?;
|
||||
let bytes = subxt_utils_fetchmetadata::from_url(url, version).await?;
|
||||
let metadata = Metadata::decode(&mut &bytes[..])?;
|
||||
Ok(metadata)
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ use std::{fs, io::Read, path::PathBuf};
|
||||
use subxt::{OnlineClient, PolkadotConfig};
|
||||
|
||||
use scale_value::Value;
|
||||
use subxt_codegen::fetch_metadata::{fetch_metadata_from_url, MetadataVersion, Url};
|
||||
use subxt_utils_fetchmetadata::{self as fetch_metadata, MetadataVersion, Url};
|
||||
|
||||
/// The source of the metadata.
|
||||
#[derive(Debug, Args, Clone)]
|
||||
@@ -117,12 +117,12 @@ impl FileOrUrl {
|
||||
}
|
||||
// Fetch from --url
|
||||
(None, Some(uri), version) => {
|
||||
Ok(fetch_metadata_from_url(uri.clone(), version.unwrap_or_default()).await?)
|
||||
Ok(fetch_metadata::from_url(uri.clone(), version.unwrap_or_default()).await?)
|
||||
}
|
||||
// Default if neither is provided; fetch from local url
|
||||
(None, None, version) => {
|
||||
let url = Url::parse("ws://localhost:9944").expect("Valid URL; qed");
|
||||
Ok(fetch_metadata_from_url(url, version.unwrap_or_default()).await?)
|
||||
Ok(fetch_metadata::from_url(url, version.unwrap_or_default()).await?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user