Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docs #304

Merged
merged 1 commit into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/subalfred/src/command/check/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) struct RuntimeCmd {
#[arg(long, required = true, value_name = "PATH")]
executable: String,
/// Pass this name to `--chain` to launch the local chain.
#[arg(long, required = true, value_name = "NAME")]
#[arg(long, required = true, value_name = "CHAIN")]
chain: String,
/// Live chain's HTTP RPC endpoint.
#[arg(long, required = true, value_name = "URI")]
Expand Down
2 changes: 1 addition & 1 deletion bin/subalfred/src/command/convert/ascii2hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::prelude::*;
#[derive(Debug, Args)]
pub(crate) struct Ascii2HexCmd {
/// Ascii data input.
#[arg(required = true, value_name = "ASCII DATA")]
#[arg(required = true, value_name = "ASCII")]
data: String,
}
impl Ascii2HexCmd {
Expand Down
4 changes: 2 additions & 2 deletions bin/subalfred/src/command/convert/bytes_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub(crate) struct BytesStyleCmd {
#[arg(required = true, value_name = "BYTES")]
bytes: String,
/// Origin style.
#[arg(value_enum, long, required = true, value_name = "BYTES STYLE")]
#[arg(value_enum, long, required = true, value_name = "STYLE")]
from: BytesStringKind,
/// Target style.
#[arg(value_enum, long, required = true, value_name = "BYTES STYLE")]
#[arg(value_enum, long, required = true, value_name = "STYLE")]
to: BytesStringKind,
}
impl BytesStyleCmd {
Expand Down
4 changes: 2 additions & 2 deletions bin/subalfred/src/command/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn cmd(_: TokenStream, input: TokenStream) -> TokenStream {
let ItemEnum {
attrs: cmd_attrs, vis: cmd_vis, ident: cmd_name, variants: cmd_variants, ..
} = cmd_enum;
let cmd_variants_names =
let cmd_variant_names =
cmd_variants.iter().map(|variant| variant.ident.clone()).collect::<Vec<_>>();
let cmd_variants = cmd_variants
.into_iter()
Expand All @@ -42,7 +42,7 @@ pub fn cmd(_: TokenStream, input: TokenStream) -> TokenStream {
#cmd_vis fn run(&self) -> crate::prelude::Result<()> {
match self {
#(
Self::#cmd_variants_names(cmd) => cmd.run(),
Self::#cmd_variant_names(cmd) => cmd.run(),
)*
}
}
Expand Down
2 changes: 2 additions & 0 deletions bin/subalfred/src/command/state/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub(crate) struct ExportCmd {
#[arg(required = true, value_name = "URI")]
live: String,
/// Export the data starting from this block.
///
/// Accept block hash or block number.
#[arg(long, value_name = "HASH/NUM")]
at: Option<String>,
/// Timeout for the fetching.
Expand Down
4 changes: 2 additions & 2 deletions bin/subalfred/src/command/storage_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::prelude::*;
#[derive(Debug, Args)]
pub(crate) struct StorageKeyCmd {
/// Prefix of the storage.
#[arg(long, required = true, value_name = "PREFIX")]
#[arg(long, required = true, value_name = "NAME")]
pallet: String,
/// Name of the storage item.
#[arg(long, required = true, value_name = "ITEM")]
#[arg(long, required = true, value_name = "NAME")]
item: String,
}
impl StorageKeyCmd {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ pub async fn update_member_versions(to: &str, manifest_path: &str) -> Result<()>
};
let mut tasks = stream::iter(&members)
.map(|pkg| async {
let members_deps = pkg
let member_deps = pkg
.dependencies
.iter()
.filter(|dep| members.iter().any(|pkg| dep.name == pkg.name))
.collect::<Vec<_>>();
let content = system::read_file_to_string(&pkg.manifest_path)?;
let content = content.replacen(&pkg.version.to_string(), to, 1);
let content = if members_deps.is_empty() {
let content = if member_deps.is_empty() {
Cow::Owned(content)
} else {
util::find_member_dep_regex(&members_deps).replace_all(
util::find_member_dep_regex(&member_deps).replace_all(
&content,
|caps: &Captures| {
format!("{}\"{}\"", &caps[1], util::align_version(&caps[3], to))
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/cargo/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub fn find_package<'a>(metadata: &'a Metadata, id: &PackageId) -> Option<&'a Pa
metadata.packages.iter().find(|pkg| &pkg.id == id)
}

pub fn find_member_dep_regex(members_deps: &[&Dependency]) -> Regex {
pub fn find_member_dep_regex(member_deps: &[&Dependency]) -> Regex {
Regex::new(&format!(
"(({}) *?= *?\\{{ *?version *?= *?)\"(.+?)\"",
members_deps.iter().map(|dep| dep.name.replace('-', "\\-")).collect::<Vec<_>>().join("|"),
member_deps.iter().map(|dep| dep.name.replace('-', "\\-")).collect::<Vec<_>>().join("|"),
))
.expect("[core::cargo] build constant regex never fails; qed")
}
Expand Down
3 changes: 3 additions & 0 deletions lib/core/src/jsonrpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::prelude::*;
/// JSONRPC Id.
pub type Id = usize;

// TODO: doc
/// Generic JSONRPC request.
#[allow(missing_docs)]
#[derive(Debug, Serialize)]
Expand All @@ -27,6 +28,7 @@ pub struct Request<'a, P> {
pub method: &'a str,
pub params: P,
}
// TODO: doc
/// Raw JSONRPC request.
#[allow(missing_docs)]
#[derive(Debug)]
Expand All @@ -40,6 +42,7 @@ impl<'a, P> From<(&'a str, P)> for RawRequest<'a, P> {
}
}

// TODO: doc
/// Generic JSONRPC response.
#[allow(missing_docs)]
#[derive(Debug, Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions substrate-minimal/subrpcer/src/client/r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use once_cell::sync::Lazy;
use reqwest::{Client, Error, Response};
use serde_json::Value;

#[allow(unused)]
static CLIENT: Lazy<Arc<Client>> = Lazy::new(|| Arc::new(Client::new()));

/// A simple HTTP post helper which implements with [reqwest](https://crates.io/crates/reqwest).
#[allow(unused)]
pub async fn send_jsonrpc(uri: &str, json: &Value) -> Result<Response, Error> {
CLIENT.post(uri).json(json).send().await
}
1 change: 1 addition & 0 deletions substrate-minimal/subrpcer/src/client/u.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde_json::Value;
use ureq::{Error, Response};

/// A simple HTTP post helper which implements with [ureq](https://crates.io/crates/ureq).
#[allow(unused, clippy::result_large_err)]
pub fn send_jsonrpc(uri: &str, body: &Value) -> Result<Response, Error> {
ureq::post(uri)
.set("Content-Type", "application/json;charset=utf-8")
Expand Down