mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 15:51:04 +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();
|
let mut strings: Vec<_> = metadata.pallets().map(|p| p.name()).collect();
|
||||||
strings.sort();
|
strings.sort();
|
||||||
for pallet in strings {
|
for pallet in strings {
|
||||||
write!(output, "\n {}", pallet).unwrap();
|
write!(output, "\n {pallet}").unwrap();
|
||||||
}
|
}
|
||||||
output
|
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();
|
let mut strings: Vec<_> = metadata.runtime_api_traits().map(|p| p.name()).collect();
|
||||||
strings.sort();
|
strings.sort();
|
||||||
for api in strings {
|
for api in strings {
|
||||||
write!(output, "\n {}", api).unwrap();
|
write!(output, "\n {api}").unwrap();
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,10 +206,8 @@ fn storage_entries_string(storage_metadata: &StorageMetadata, pallet_name: &str)
|
|||||||
if storage_metadata.entries().is_empty() {
|
if storage_metadata.entries().is_empty() {
|
||||||
format!("No {storage_entry_placeholder}'s available in the \"{pallet_name}\" pallet.")
|
format!("No {storage_entry_placeholder}'s available in the \"{pallet_name}\" pallet.")
|
||||||
} else {
|
} else {
|
||||||
let mut output = format!(
|
let mut output =
|
||||||
"Available {storage_entry_placeholder}'s in the \"{}\" pallet:",
|
format!("Available {storage_entry_placeholder}'s in the \"{pallet_name}\" pallet:");
|
||||||
pallet_name
|
|
||||||
);
|
|
||||||
let mut strings: Vec<_> = storage_metadata
|
let mut strings: Vec<_> = storage_metadata
|
||||||
.entries()
|
.entries()
|
||||||
.iter()
|
.iter()
|
||||||
@@ -217,7 +215,7 @@ fn storage_entries_string(storage_metadata: &StorageMetadata, pallet_name: &str)
|
|||||||
.collect();
|
.collect();
|
||||||
strings.sort();
|
strings.sort();
|
||||||
for entry in strings {
|
for entry in strings {
|
||||||
write!(output, "\n {}", entry).unwrap();
|
write!(output, "\n {entry}").unwrap();
|
||||||
}
|
}
|
||||||
output
|
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.
|
// 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();
|
let mut name = input.name.trim_start_matches('_').to_string();
|
||||||
if name.is_empty() {
|
if name.is_empty() {
|
||||||
name = format!("_{}", idx);
|
name = format!("_{idx}");
|
||||||
}
|
}
|
||||||
while !unique_names.insert(name.clone()) {
|
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.
|
// The alias type name is based on the name, above.
|
||||||
let mut alias = name.to_upper_camel_case();
|
let mut alias = name.to_upper_camel_case();
|
||||||
// Note: name is not empty.
|
// Note: name is not empty.
|
||||||
if alias.as_bytes()[0].is_ascii_digit() {
|
if alias.as_bytes()[0].is_ascii_digit() {
|
||||||
alias = format!("Param{}", alias);
|
alias = format!("Param{alias}");
|
||||||
}
|
}
|
||||||
while !unique_aliases.insert(alias.clone()) {
|
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.
|
// 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.
|
// 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();
|
let mut name = input.name.trim_start_matches('_').to_string();
|
||||||
if name.is_empty() {
|
if name.is_empty() {
|
||||||
name = format!("_{}", idx);
|
name = format!("_{idx}");
|
||||||
}
|
}
|
||||||
while !unique_names.insert(name.clone()) {
|
while !unique_names.insert(name.clone()) {
|
||||||
// Name is already used, append the index until it is unique.
|
// 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();
|
let mut alias = name.to_upper_camel_case();
|
||||||
// Note: name is not empty.
|
// Note: name is not empty.
|
||||||
if alias.as_bytes()[0].is_ascii_digit() {
|
if alias.as_bytes()[0].is_ascii_digit() {
|
||||||
alias = format!("Param{}", alias);
|
alias = format!("Param{alias}");
|
||||||
}
|
}
|
||||||
while !unique_aliases.insert(alias.clone()) {
|
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}"));
|
let (alias_name, name) = (format_ident!("{alias}"), format_ident!("{name}"));
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ impl<T> EncodeAsType for WrapperKeepOpaque<T> {
|
|||||||
|
|
||||||
types
|
types
|
||||||
.resolve_type(type_id.clone(), visitor)
|
.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",
|
None => "null",
|
||||||
};
|
};
|
||||||
let request = format!(
|
let request = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":"{}", "method":"{}","params":{}}}"#,
|
r#"{{"jsonrpc":"2.0","id":"{id}", "method":"{method}","params":{params}}}"#
|
||||||
id, method, params
|
|
||||||
);
|
);
|
||||||
|
|
||||||
self.requests.insert(id, sender);
|
self.requests.insert(id, sender);
|
||||||
@@ -328,8 +327,7 @@ impl<TPlatform: PlatformRef, TChain> BackgroundTaskData<TPlatform, TChain> {
|
|||||||
None => "null",
|
None => "null",
|
||||||
};
|
};
|
||||||
let request = format!(
|
let request = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":"{}", "method":"{}","params":{}}}"#,
|
r#"{{"jsonrpc":"2.0","id":"{id}", "method":"{method}","params":{params}}}"#
|
||||||
id, method, params
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tracing::trace!(target: LOG_TARGET, "Tracking subscription request id={id} chain={chain_id:?}");
|
tracing::trace!(target: LOG_TARGET, "Tracking subscription request id={id} chain={chain_id:?}");
|
||||||
|
|||||||
@@ -114,28 +114,28 @@ impl PlatformRef for SubxtPlatform {
|
|||||||
port,
|
port,
|
||||||
secure: true,
|
secure: true,
|
||||||
} => {
|
} => {
|
||||||
format!("wss://{}:{}", hostname, port)
|
format!("wss://{hostname}:{port}")
|
||||||
}
|
}
|
||||||
Address::WebSocketDns {
|
Address::WebSocketDns {
|
||||||
hostname,
|
hostname,
|
||||||
port,
|
port,
|
||||||
secure: false,
|
secure: false,
|
||||||
} => {
|
} => {
|
||||||
format!("ws://{}:{}", hostname, port)
|
format!("ws://{hostname}:{port}")
|
||||||
}
|
}
|
||||||
Address::WebSocketIp {
|
Address::WebSocketIp {
|
||||||
ip: IpAddr::V4(ip),
|
ip: IpAddr::V4(ip),
|
||||||
port,
|
port,
|
||||||
} => {
|
} => {
|
||||||
let addr = SocketAddr::from((ip, port));
|
let addr = SocketAddr::from((ip, port));
|
||||||
format!("ws://{}", addr)
|
format!("ws://{addr}")
|
||||||
}
|
}
|
||||||
Address::WebSocketIp {
|
Address::WebSocketIp {
|
||||||
ip: IpAddr::V6(ip),
|
ip: IpAddr::V6(ip),
|
||||||
port,
|
port,
|
||||||
} => {
|
} => {
|
||||||
let addr = SocketAddr::from((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
|
// The API user of the `PlatformRef` trait is never supposed to open connections of
|
||||||
@@ -212,15 +212,15 @@ impl PlatformRef for SubxtPlatform {
|
|||||||
} else {
|
} else {
|
||||||
let _ = write!(message_build, ", ");
|
let _ = write!(message_build, ", ");
|
||||||
}
|
}
|
||||||
let _ = write!(message_build, "{}={}", key, value);
|
let _ = write!(message_build, "{key}={value}");
|
||||||
}
|
}
|
||||||
|
|
||||||
match log_level {
|
match log_level {
|
||||||
LogLevel::Error => tracing::error!("target={} {}", log_target, message_build),
|
LogLevel::Error => tracing::error!("target={log_target} {message_build}"),
|
||||||
LogLevel::Warn => tracing::warn!("target={} {}", log_target, message_build),
|
LogLevel::Warn => tracing::warn!("target={log_target} {message_build}"),
|
||||||
LogLevel::Info => tracing::info!("target={} {}", log_target, message_build),
|
LogLevel::Info => tracing::info!("target={log_target} {message_build}"),
|
||||||
LogLevel::Debug => tracing::debug!("target={} {}", log_target, message_build),
|
LogLevel::Debug => tracing::debug!("target={log_target} {message_build}"),
|
||||||
LogLevel::Trace => tracing::trace!("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> {
|
pub fn new(addr: &str) -> Result<Self, Error> {
|
||||||
let socket = match web_sys::WebSocket::new(addr) {
|
let socket = match web_sys::WebSocket::new(addr) {
|
||||||
Ok(socket) => socket,
|
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);
|
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 extrinsic_hash = get_extrinsic_hash(&metadata.types, &metadata.extrinsic);
|
||||||
|
|
||||||
let custom_values_hash = self
|
let custom_values_hash = if self.include_custom_values {
|
||||||
.include_custom_values
|
get_custom_metadata_hash(&metadata.custom())
|
||||||
.then(|| get_custom_metadata_hash(&metadata.custom()))
|
} else {
|
||||||
.unwrap_or_default();
|
Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
concat_and_hash5(
|
concat_and_hash5(
|
||||||
&pallet_hash,
|
&pallet_hash,
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ async fn run_server_with_settings(
|
|||||||
drop(server_handle);
|
drop(server_handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok((tx, format!("ws://{}", addr)))
|
Ok((tx, format!("ws://{addr}")))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn serve_with_graceful_shutdown<S, B, I>(
|
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!(" 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()?;
|
let event_values = evt.field_values()?;
|
||||||
|
|
||||||
println!(" {pallet_name}_{event_name}");
|
println!(" {pallet_name}_{event_name}");
|
||||||
println!(" {}", event_values);
|
println!(" {event_values}");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(" Transaction Extensions:");
|
println!(" Transaction Extensions:");
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.call(runtime_api_call)
|
.call(runtime_api_call)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
println!("AccountNonceApi_account_nonce for Alice: {:?}", nonce);
|
println!("AccountNonceApi_account_nonce for Alice: {nonce:?}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ impl std::str::FromStr for MetadataVersion {
|
|||||||
version => {
|
version => {
|
||||||
let num: u32 = version
|
let num: u32 = version
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| format!("Invalid metadata version specified {:?}", version))?;
|
.map_err(|_| format!("Invalid metadata version specified {version:?}"))?;
|
||||||
|
|
||||||
Ok(MetadataVersion::Version(num))
|
Ok(MetadataVersion::Version(num))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user