mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Fix clippy bits
This commit is contained in:
@@ -394,7 +394,7 @@ impl<T: RpcConfig> ChainHeadRpcMethods<T> {
|
||||
.map(|item| ArchiveStorageQuery {
|
||||
key: to_hex(item.key),
|
||||
query_type: item.query_type,
|
||||
pagination_start_key: item.pagination_start_key.map(|k| to_hex(k)),
|
||||
pagination_start_key: item.pagination_start_key.map(to_hex),
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ impl<T: Config> Backend<T> for ArchiveBackend<T> {
|
||||
let queries = keys
|
||||
.into_iter()
|
||||
.map(|key| ArchiveStorageQuery {
|
||||
key: key,
|
||||
key,
|
||||
query_type: StorageQueryType::Value,
|
||||
pagination_start_key: None,
|
||||
})
|
||||
@@ -77,7 +77,7 @@ impl<T: Config> Backend<T> for ArchiveBackend<T> {
|
||||
at: HashFor<T>,
|
||||
) -> Result<StreamOfResults<Vec<u8>>, BackendError> {
|
||||
let queries = std::iter::once(ArchiveStorageQuery {
|
||||
key: key,
|
||||
key,
|
||||
// Just ask for the hash and then ignore it and return keys
|
||||
query_type: StorageQueryType::DescendantsHashes,
|
||||
pagination_start_key: None,
|
||||
@@ -99,7 +99,7 @@ impl<T: Config> Backend<T> for ArchiveBackend<T> {
|
||||
at: HashFor<T>,
|
||||
) -> Result<StreamOfResults<StorageResponse>, BackendError> {
|
||||
let queries = std::iter::once(ArchiveStorageQuery {
|
||||
key: key,
|
||||
key,
|
||||
query_type: StorageQueryType::DescendantsValues,
|
||||
pagination_start_key: None,
|
||||
})
|
||||
|
||||
@@ -31,6 +31,12 @@ enum BackendChoice<V> {
|
||||
UseDefault,
|
||||
}
|
||||
|
||||
impl<T: Config> Default for CombinedBackendBuilder<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> CombinedBackendBuilder<T> {
|
||||
/// Create a new [`CombinedBackendBuilder`].
|
||||
pub fn new() -> Self {
|
||||
@@ -438,7 +444,7 @@ where
|
||||
"None of the configured backends are capable of handling this request";
|
||||
let mut err = BackendError::other(NO_AVAILABLE_BACKEND);
|
||||
|
||||
for backend in backends.into_iter().filter_map(|b| *b) {
|
||||
for backend in backends.iter().filter_map(|b| *b) {
|
||||
match f(backend).await {
|
||||
Ok(res) => return Ok(res),
|
||||
Err(e) => err = e,
|
||||
|
||||
@@ -286,7 +286,7 @@ impl<T: Config> Backend<T> for LegacyBackend<T> {
|
||||
let last_finalized_block_num = this
|
||||
.block_header(last_finalized_block_ref.hash())
|
||||
.await?
|
||||
.map(|h| h.number().into());
|
||||
.map(|h| h.number());
|
||||
|
||||
// Fill in any missing blocks, because the backend may not emit every finalized block; just the latest ones which
|
||||
// are finalized each time.
|
||||
@@ -408,7 +408,7 @@ where
|
||||
};
|
||||
|
||||
// We want all previous details up to, but not including this current block num.
|
||||
let end_block_num = header.number().into();
|
||||
let end_block_num = header.number();
|
||||
|
||||
// This is one after the last block we returned details for last time.
|
||||
let start_block_num = last_block_num.map(|n| n + 1).unwrap_or(end_block_num);
|
||||
|
||||
@@ -120,7 +120,7 @@ impl<T: Config> OnlineClient<T> {
|
||||
inner: Arc::new(OnlineClientInner {
|
||||
config,
|
||||
genesis_hash,
|
||||
backend: backend.into(),
|
||||
backend,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -81,6 +81,12 @@ impl PolkadotConfigBuilder {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PolkadotConfig(SubstrateConfig);
|
||||
|
||||
impl Default for PolkadotConfig {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl PolkadotConfig {
|
||||
/// Create a new, default, [`PolkadotConfig`].
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -135,6 +135,12 @@ struct SubstrateConfigInner {
|
||||
metadata_for_spec_version: Mutex<HashMap<u32, ArcMetadata>>,
|
||||
}
|
||||
|
||||
impl Default for SubstrateConfig {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SubstrateConfig {
|
||||
/// Create a new, default, [`SubstrateConfig`]. This does not
|
||||
/// support working with historic (pre-V14) types. If you want this,
|
||||
@@ -297,7 +303,7 @@ where
|
||||
SubstrateHeader<H>: Encode + Decode,
|
||||
{
|
||||
fn number(&self) -> u64 {
|
||||
self.number.into()
|
||||
self.number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ impl<'atblock, T: Config, C: OfflineClientAtBlockT<T>> Extrinsics<'atblock, T, C
|
||||
}
|
||||
|
||||
Ok(Extrinsic {
|
||||
client: client,
|
||||
client,
|
||||
index: extrinsic_index,
|
||||
info: Arc::new(info),
|
||||
extrinsics: Arc::clone(&all_extrinsic_bytes),
|
||||
@@ -306,7 +306,7 @@ where
|
||||
self.metadata.types(),
|
||||
)
|
||||
.map_err(|e| ExtrinsicError::CannotDecodeIntoRootExtrinsic {
|
||||
extrinsic_index: self.index as usize,
|
||||
extrinsic_index: self.index,
|
||||
error: e,
|
||||
})?;
|
||||
|
||||
@@ -347,7 +347,7 @@ where
|
||||
let decoded =
|
||||
E::decode_as_fields(bytes, &mut fields, self.metadata.types()).map_err(|e| {
|
||||
ExtrinsicError::CannotDecodeFields {
|
||||
extrinsic_index: self.index as usize,
|
||||
extrinsic_index: self.index,
|
||||
error: e,
|
||||
}
|
||||
})?;
|
||||
|
||||
@@ -211,7 +211,7 @@ where
|
||||
pub fn entry(
|
||||
&self,
|
||||
) -> Result<StorageEntry<'atblock, T, Client, address::DynamicAddress>, StorageError> {
|
||||
let addr = address::dynamic(self.pallet_name.to_owned(), self.entry_name.to_owned());
|
||||
let addr = address::dynamic(&*self.pallet_name, &*self.entry_name);
|
||||
StorageEntry::new(self.client, addr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT<T>>
|
||||
// "is general" + transaction protocol version (5)
|
||||
(0b01000000 + 5u8).encode_to(&mut encoded_inner);
|
||||
// Encode versions for the transaction extensions
|
||||
(tx_extensions_version as u8).encode_to(&mut encoded_inner);
|
||||
tx_extensions_version.encode_to(&mut encoded_inner);
|
||||
// Encode the actual transaction extensions values
|
||||
self.additional_and_extra_params
|
||||
.encode_value_to(&mut encoded_inner);
|
||||
|
||||
@@ -206,7 +206,7 @@ pub fn dynamic<CallData>(
|
||||
call_name: impl Into<String>,
|
||||
call_data: CallData,
|
||||
) -> DynamicPayload<CallData> {
|
||||
StaticPayload::new(pallet_name, call_name, call_data.into())
|
||||
StaticPayload::new(pallet_name, call_name, call_data)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -323,7 +323,7 @@ impl<'atblock, T: Config, C: OnlineClientAtBlockT<T>> TransactionInBlock<'atbloc
|
||||
.iter()
|
||||
.position(|ext| {
|
||||
use crate::config::Hasher;
|
||||
let hash = hasher.hash(&ext);
|
||||
let hash = hasher.hash(ext);
|
||||
hash == self.ext_hash
|
||||
})
|
||||
// If we successfully obtain the block hash we think contains our
|
||||
|
||||
@@ -103,9 +103,9 @@ where
|
||||
{
|
||||
/// Execute a raw View function API call. This returns the raw bytes representing the result
|
||||
/// of this call. The caller is responsible for decoding the result.
|
||||
pub async fn call_raw<'a>(
|
||||
pub async fn call_raw(
|
||||
&self,
|
||||
call_parameters: Option<&'a [u8]>,
|
||||
call_parameters: Option<&[u8]>,
|
||||
) -> Result<Vec<u8>, ViewFunctionError> {
|
||||
let client = &self.client;
|
||||
let block_hash = client.block_hash();
|
||||
|
||||
@@ -58,7 +58,7 @@ impl From<[u8; 32]> for AccountId32 {
|
||||
impl AccountId32 {
|
||||
// Return the ss58-check string for this key. Adapted from `sp_core::crypto`. We need this to
|
||||
// serialize our account appropriately but otherwise don't care.
|
||||
fn to_ss58check(&self) -> String {
|
||||
fn ss58(&self) -> String {
|
||||
// For serializing to a string to obtain the account nonce, we use the default substrate
|
||||
// prefix (since we have no way to otherwise pick one). It doesn't really matter, since when
|
||||
// it's deserialized back in system_accountNextIndex, we ignore this (so long as it's valid).
|
||||
@@ -78,7 +78,7 @@ impl AccountId32 {
|
||||
// This isn't strictly needed, but to give our AccountId32 a little more usefulness, we also
|
||||
// implement the logic needed to decode an AccountId32 from an SS58 encoded string. This is exposed
|
||||
// via a `FromStr` impl.
|
||||
fn from_ss58check(s: &str) -> Result<Self, FromSs58Error> {
|
||||
fn from_ss58(s: &str) -> Result<Self, FromSs58Error> {
|
||||
const CHECKSUM_LEN: usize = 2;
|
||||
let body_len = 32;
|
||||
|
||||
@@ -123,7 +123,7 @@ pub enum FromSs58Error {
|
||||
InvalidPrefix,
|
||||
}
|
||||
|
||||
// We do this just to get a checksum to help verify the validity of the address in to_ss58check
|
||||
// We do this just to get a checksum to help verify the validity of the address in ss58
|
||||
fn ss58hash(data: &[u8]) -> Vec<u8> {
|
||||
use blake2::{Blake2b512, Digest};
|
||||
const PREFIX: &[u8] = b"SS58PRE";
|
||||
@@ -138,7 +138,7 @@ impl Serialize for AccountId32 {
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_str(&self.to_ss58check())
|
||||
serializer.serialize_str(&self.ss58())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,21 +147,21 @@ impl<'de> Deserialize<'de> for AccountId32 {
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
AccountId32::from_ss58check(&String::deserialize(deserializer)?)
|
||||
AccountId32::from_ss58(&String::deserialize(deserializer)?)
|
||||
.map_err(|e| serde::de::Error::custom(format!("{e:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for AccountId32 {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{}", self.to_ss58check())
|
||||
write!(f, "{}", self.ss58())
|
||||
}
|
||||
}
|
||||
|
||||
impl core::str::FromStr for AccountId32 {
|
||||
type Err = FromSs58Error;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
AccountId32::from_ss58check(s)
|
||||
AccountId32::from_ss58(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,16 +180,16 @@ mod test {
|
||||
let local_account = AccountId32(substrate_account.clone().into());
|
||||
|
||||
// Both should encode to ss58 the same way:
|
||||
let substrate_ss58 = substrate_account.to_ss58check();
|
||||
assert_eq!(substrate_ss58, local_account.to_ss58check());
|
||||
let substrate_ss58 = substrate_account.ss58();
|
||||
assert_eq!(substrate_ss58, local_account.ss58());
|
||||
|
||||
// Both should decode from ss58 back to the same:
|
||||
assert_eq!(
|
||||
sp_core::crypto::AccountId32::from_ss58check(&substrate_ss58).unwrap(),
|
||||
sp_core::crypto::AccountId32::from_ss58(&substrate_ss58).unwrap(),
|
||||
substrate_account
|
||||
);
|
||||
assert_eq!(
|
||||
AccountId32::from_ss58check(&substrate_ss58).unwrap(),
|
||||
AccountId32::from_ss58(&substrate_ss58).unwrap(),
|
||||
local_account
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user