Tidy subxt-codegen crate interface (#1225)

* first pass tidying codegen crate interface

* fix a codegen test

* macro: keep error spans

* clippy

* fix doc example

* removecommented-out code
This commit is contained in:
James Wilson
2023-10-27 16:35:18 +01:00
committed by GitHub
parent 98170c8fdb
commit 2b21f8dc8c
29 changed files with 503 additions and 554 deletions
+5 -10
View File
@@ -8,7 +8,7 @@ use color_eyre::eyre;
use std::str::FromStr;
use std::{fs, io::Read, path::PathBuf};
use subxt_codegen::utils::{MetadataVersion, Url};
use subxt_codegen::fetch_metadata::{fetch_metadata_from_url, MetadataVersion, Url};
pub mod type_description;
pub mod type_example;
@@ -57,18 +57,13 @@ impl FileOrUrl {
eyre::bail!("`--file` is incompatible with `--version`")
}
// Fetch from --url
(None, Some(uri), version) => Ok(subxt_codegen::utils::fetch_metadata_bytes(
uri.clone(),
version.unwrap_or_default(),
)
.await?),
(None, Some(uri), version) => {
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(
subxt_codegen::utils::fetch_metadata_bytes(url, version.unwrap_or_default())
.await?,
)
Ok(fetch_metadata_from_url(url, version.unwrap_or_default()).await?)
}
}
}