mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 14:18:03 +00:00
Clippy fixes (#2033)
* clippy fixed * wasm clippy * clippy fixes * post clippy fmt * last clippy fix
This commit is contained in:
@@ -239,7 +239,7 @@ fn pallets_as_string(metadata: &Metadata) -> String {
|
||||
let mut strings: Vec<_> = metadata.pallets().map(|p| p.name()).collect();
|
||||
strings.sort();
|
||||
for pallet in strings {
|
||||
write!(output, "\n {}", pallet).unwrap();
|
||||
write!(output, "\n {pallet}").unwrap();
|
||||
}
|
||||
output
|
||||
}
|
||||
@@ -254,7 +254,7 @@ pub fn runtime_apis_as_string(metadata: &Metadata) -> String {
|
||||
let mut strings: Vec<_> = metadata.runtime_api_traits().map(|p| p.name()).collect();
|
||||
strings.sort();
|
||||
for api in strings {
|
||||
write!(output, "\n {}", api).unwrap();
|
||||
write!(output, "\n {api}").unwrap();
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
@@ -206,10 +206,8 @@ fn storage_entries_string(storage_metadata: &StorageMetadata, pallet_name: &str)
|
||||
if storage_metadata.entries().is_empty() {
|
||||
format!("No {storage_entry_placeholder}'s available in the \"{pallet_name}\" pallet.")
|
||||
} else {
|
||||
let mut output = format!(
|
||||
"Available {storage_entry_placeholder}'s in the \"{}\" pallet:",
|
||||
pallet_name
|
||||
);
|
||||
let mut output =
|
||||
format!("Available {storage_entry_placeholder}'s in the \"{pallet_name}\" pallet:");
|
||||
let mut strings: Vec<_> = storage_metadata
|
||||
.entries()
|
||||
.iter()
|
||||
@@ -217,7 +215,7 @@ fn storage_entries_string(storage_metadata: &StorageMetadata, pallet_name: &str)
|
||||
.collect();
|
||||
strings.sort();
|
||||
for entry in strings {
|
||||
write!(output, "\n {}", entry).unwrap();
|
||||
write!(output, "\n {entry}").unwrap();
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
@@ -50,20 +50,20 @@ fn generate_pallet_view_function(
|
||||
// just be an underscore, so fix any such names we find to work in structs.
|
||||
let mut name = input.name.trim_start_matches('_').to_string();
|
||||
if name.is_empty() {
|
||||
name = format!("_{}", idx);
|
||||
name = format!("_{idx}");
|
||||
}
|
||||
while !unique_names.insert(name.clone()) {
|
||||
name = format!("{}_param{}", name, idx);
|
||||
name = format!("{name}_param{idx}");
|
||||
}
|
||||
|
||||
// The alias type name is based on the name, above.
|
||||
let mut alias = name.to_upper_camel_case();
|
||||
// Note: name is not empty.
|
||||
if alias.as_bytes()[0].is_ascii_digit() {
|
||||
alias = format!("Param{}", alias);
|
||||
alias = format!("Param{alias}");
|
||||
}
|
||||
while !unique_aliases.insert(alias.clone()) {
|
||||
alias = format!("{}Param{}", alias, idx);
|
||||
alias = format!("{alias}Param{idx}");
|
||||
}
|
||||
|
||||
// Path to the actual type we'll have generated for this input.
|
||||
|
||||
@@ -57,20 +57,20 @@ fn generate_runtime_api(
|
||||
// just be an underscore, so fix any such names we find to work in structs.
|
||||
let mut name = input.name.trim_start_matches('_').to_string();
|
||||
if name.is_empty() {
|
||||
name = format!("_{}", idx);
|
||||
name = format!("_{idx}");
|
||||
}
|
||||
while !unique_names.insert(name.clone()) {
|
||||
// Name is already used, append the index until it is unique.
|
||||
name = format!("{}_param{}", name, idx);
|
||||
name = format!("{name}_param{idx}");
|
||||
}
|
||||
|
||||
let mut alias = name.to_upper_camel_case();
|
||||
// Note: name is not empty.
|
||||
if alias.as_bytes()[0].is_ascii_digit() {
|
||||
alias = format!("Param{}", alias);
|
||||
alias = format!("Param{alias}");
|
||||
}
|
||||
while !unique_aliases.insert(alias.clone()) {
|
||||
alias = format!("{}Param{}", alias, idx);
|
||||
alias = format!("{alias}Param{idx}");
|
||||
}
|
||||
|
||||
let (alias_name, name) = (format_ident!("{alias}"), format_ident!("{name}"));
|
||||
|
||||
@@ -93,7 +93,7 @@ impl<T> EncodeAsType for WrapperKeepOpaque<T> {
|
||||
|
||||
types
|
||||
.resolve_type(type_id.clone(), visitor)
|
||||
.map_err(|_| Error::new(ErrorKind::TypeNotFound(format!("{:?}", type_id))))?
|
||||
.map_err(|_| Error::new(ErrorKind::TypeNotFound(format!("{type_id:?}"))))?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,8 +278,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTaskData<TPlatform, TChain> {
|
||||
None => "null",
|
||||
};
|
||||
let request = format!(
|
||||
r#"{{"jsonrpc":"2.0","id":"{}", "method":"{}","params":{}}}"#,
|
||||
id, method, params
|
||||
r#"{{"jsonrpc":"2.0","id":"{id}", "method":"{method}","params":{params}}}"#
|
||||
);
|
||||
|
||||
self.requests.insert(id, sender);
|
||||
@@ -328,8 +327,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTaskData<TPlatform, TChain> {
|
||||
None => "null",
|
||||
};
|
||||
let request = format!(
|
||||
r#"{{"jsonrpc":"2.0","id":"{}", "method":"{}","params":{}}}"#,
|
||||
id, method, params
|
||||
r#"{{"jsonrpc":"2.0","id":"{id}", "method":"{method}","params":{params}}}"#
|
||||
);
|
||||
|
||||
tracing::trace!(target: LOG_TARGET, "Tracking subscription request id={id} chain={chain_id:?}");
|
||||
|
||||
@@ -114,28 +114,28 @@ impl PlatformRef for SubxtPlatform {
|
||||
port,
|
||||
secure: true,
|
||||
} => {
|
||||
format!("wss://{}:{}", hostname, port)
|
||||
format!("wss://{hostname}:{port}")
|
||||
}
|
||||
Address::WebSocketDns {
|
||||
hostname,
|
||||
port,
|
||||
secure: false,
|
||||
} => {
|
||||
format!("ws://{}:{}", hostname, port)
|
||||
format!("ws://{hostname}:{port}")
|
||||
}
|
||||
Address::WebSocketIp {
|
||||
ip: IpAddr::V4(ip),
|
||||
port,
|
||||
} => {
|
||||
let addr = SocketAddr::from((ip, port));
|
||||
format!("ws://{}", addr)
|
||||
format!("ws://{addr}")
|
||||
}
|
||||
Address::WebSocketIp {
|
||||
ip: IpAddr::V6(ip),
|
||||
port,
|
||||
} => {
|
||||
let addr = SocketAddr::from((ip, port));
|
||||
format!("ws://{}", addr)
|
||||
format!("ws://{addr}")
|
||||
}
|
||||
|
||||
// The API user of the `PlatformRef` trait is never supposed to open connections of
|
||||
@@ -212,15 +212,15 @@ impl PlatformRef for SubxtPlatform {
|
||||
} else {
|
||||
let _ = write!(message_build, ", ");
|
||||
}
|
||||
let _ = write!(message_build, "{}={}", key, value);
|
||||
let _ = write!(message_build, "{key}={value}");
|
||||
}
|
||||
|
||||
match log_level {
|
||||
LogLevel::Error => tracing::error!("target={} {}", log_target, message_build),
|
||||
LogLevel::Warn => tracing::warn!("target={} {}", log_target, message_build),
|
||||
LogLevel::Info => tracing::info!("target={} {}", log_target, message_build),
|
||||
LogLevel::Debug => tracing::debug!("target={} {}", log_target, message_build),
|
||||
LogLevel::Trace => tracing::trace!("target={} {}", log_target, message_build),
|
||||
LogLevel::Error => tracing::error!("target={log_target} {message_build}"),
|
||||
LogLevel::Warn => tracing::warn!("target={log_target} {message_build}"),
|
||||
LogLevel::Info => tracing::info!("target={log_target} {message_build}"),
|
||||
LogLevel::Debug => tracing::debug!("target={log_target} {message_build}"),
|
||||
LogLevel::Trace => tracing::trace!("target={log_target} {message_build}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ impl WasmSocket {
|
||||
pub fn new(addr: &str) -> Result<Self, Error> {
|
||||
let socket = match web_sys::WebSocket::new(addr) {
|
||||
Ok(socket) => socket,
|
||||
Err(err) => return Err(Error::ConnectionError(format!("{:?}", err))),
|
||||
Err(err) => return Err(Error::ConnectionError(format!("{err:?}"))),
|
||||
};
|
||||
|
||||
socket.set_binary_type(web_sys::BinaryType::Arraybuffer);
|
||||
|
||||
@@ -584,10 +584,11 @@ impl<'a> MetadataHasher<'a> {
|
||||
|
||||
let extrinsic_hash = get_extrinsic_hash(&metadata.types, &metadata.extrinsic);
|
||||
|
||||
let custom_values_hash = self
|
||||
.include_custom_values
|
||||
.then(|| get_custom_metadata_hash(&metadata.custom()))
|
||||
.unwrap_or_default();
|
||||
let custom_values_hash = if self.include_custom_values {
|
||||
get_custom_metadata_hash(&metadata.custom())
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
concat_and_hash5(
|
||||
&pallet_hash,
|
||||
|
||||
@@ -243,7 +243,7 @@ async fn run_server_with_settings(
|
||||
drop(server_handle);
|
||||
});
|
||||
|
||||
Ok((tx, format!("ws://{}", addr)))
|
||||
Ok((tx, format!("ws://{addr}")))
|
||||
}
|
||||
|
||||
async fn serve_with_graceful_shutdown<S, B, I>(
|
||||
|
||||
@@ -35,7 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
println!(" Fields:");
|
||||
println!(" {}\n", fields);
|
||||
println!(" {fields}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let event_values = evt.field_values()?;
|
||||
|
||||
println!(" {pallet_name}_{event_name}");
|
||||
println!(" {}", event_values);
|
||||
println!(" {event_values}");
|
||||
}
|
||||
|
||||
println!(" Transaction Extensions:");
|
||||
|
||||
@@ -23,6 +23,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.call(runtime_api_call)
|
||||
.await;
|
||||
|
||||
println!("AccountNonceApi_account_nonce for Alice: {:?}", nonce);
|
||||
println!("AccountNonceApi_account_nonce for Alice: {nonce:?}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl std::str::FromStr for MetadataVersion {
|
||||
version => {
|
||||
let num: u32 = version
|
||||
.parse()
|
||||
.map_err(|_| format!("Invalid metadata version specified {:?}", version))?;
|
||||
.map_err(|_| format!("Invalid metadata version specified {version:?}"))?;
|
||||
|
||||
Ok(MetadataVersion::Version(num))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user