diff --git a/rpcs/src/methods/chain_head.rs b/rpcs/src/methods/chain_head.rs index 5aba9f8dbb..faf7053fff 100644 --- a/rpcs/src/methods/chain_head.rs +++ b/rpcs/src/methods/chain_head.rs @@ -394,7 +394,7 @@ impl ChainHeadRpcMethods { .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(); diff --git a/subxt/src/backend/archive.rs b/subxt/src/backend/archive.rs index 3051e32f7f..155b8d24ba 100644 --- a/subxt/src/backend/archive.rs +++ b/subxt/src/backend/archive.rs @@ -50,7 +50,7 @@ impl Backend for ArchiveBackend { let queries = keys .into_iter() .map(|key| ArchiveStorageQuery { - key: key, + key, query_type: StorageQueryType::Value, pagination_start_key: None, }) @@ -77,7 +77,7 @@ impl Backend for ArchiveBackend { at: HashFor, ) -> Result>, 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 Backend for ArchiveBackend { at: HashFor, ) -> Result, BackendError> { let queries = std::iter::once(ArchiveStorageQuery { - key: key, + key, query_type: StorageQueryType::DescendantsValues, pagination_start_key: None, }) diff --git a/subxt/src/backend/combined.rs b/subxt/src/backend/combined.rs index a835822549..6930a5710e 100644 --- a/subxt/src/backend/combined.rs +++ b/subxt/src/backend/combined.rs @@ -31,6 +31,12 @@ enum BackendChoice { UseDefault, } +impl Default for CombinedBackendBuilder { + fn default() -> Self { + Self::new() + } +} + impl CombinedBackendBuilder { /// 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, diff --git a/subxt/src/backend/legacy.rs b/subxt/src/backend/legacy.rs index d7aadf4989..86e5e8a665 100644 --- a/subxt/src/backend/legacy.rs +++ b/subxt/src/backend/legacy.rs @@ -286,7 +286,7 @@ impl Backend for LegacyBackend { 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); diff --git a/subxt/src/client/online_client.rs b/subxt/src/client/online_client.rs index dc02d251b8..81cdd7eb89 100644 --- a/subxt/src/client/online_client.rs +++ b/subxt/src/client/online_client.rs @@ -120,7 +120,7 @@ impl OnlineClient { inner: Arc::new(OnlineClientInner { config, genesis_hash, - backend: backend.into(), + backend, }), }) } diff --git a/subxt/src/config/polkadot.rs b/subxt/src/config/polkadot.rs index a6d2a8fb27..3d480ef3db 100644 --- a/subxt/src/config/polkadot.rs +++ b/subxt/src/config/polkadot.rs @@ -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 { diff --git a/subxt/src/config/substrate.rs b/subxt/src/config/substrate.rs index 54b825cf51..68903e5216 100644 --- a/subxt/src/config/substrate.rs +++ b/subxt/src/config/substrate.rs @@ -135,6 +135,12 @@ struct SubstrateConfigInner { metadata_for_spec_version: Mutex>, } +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: Encode + Decode, { fn number(&self) -> u64 { - self.number.into() + self.number } } diff --git a/subxt/src/extrinsics.rs b/subxt/src/extrinsics.rs index e62841a9fe..c40726e57e 100644 --- a/subxt/src/extrinsics.rs +++ b/subxt/src/extrinsics.rs @@ -134,7 +134,7 @@ impl<'atblock, T: Config, C: OfflineClientAtBlockT> 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, } })?; diff --git a/subxt/src/storage.rs b/subxt/src/storage.rs index 9edbb47acf..f0b5fbbf31 100644 --- a/subxt/src/storage.rs +++ b/subxt/src/storage.rs @@ -211,7 +211,7 @@ where pub fn entry( &self, ) -> Result, 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) } } diff --git a/subxt/src/transactions.rs b/subxt/src/transactions.rs index 4afef1c08b..6647f8c7fb 100644 --- a/subxt/src/transactions.rs +++ b/subxt/src/transactions.rs @@ -587,7 +587,7 @@ impl<'atblock, T: Config, Client: OfflineClientAtBlockT> // "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); diff --git a/subxt/src/transactions/payload.rs b/subxt/src/transactions/payload.rs index debd6c438b..3ce32b661c 100644 --- a/subxt/src/transactions/payload.rs +++ b/subxt/src/transactions/payload.rs @@ -206,7 +206,7 @@ pub fn dynamic( call_name: impl Into, call_data: CallData, ) -> DynamicPayload { - StaticPayload::new(pallet_name, call_name, call_data.into()) + StaticPayload::new(pallet_name, call_name, call_data) } #[cfg(test)] diff --git a/subxt/src/transactions/transaction_progress.rs b/subxt/src/transactions/transaction_progress.rs index b32ee2756c..00d764c952 100644 --- a/subxt/src/transactions/transaction_progress.rs +++ b/subxt/src/transactions/transaction_progress.rs @@ -323,7 +323,7 @@ impl<'atblock, T: Config, C: OnlineClientAtBlockT> 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 diff --git a/subxt/src/view_functions.rs b/subxt/src/view_functions.rs index 985a800fa6..9def3409ac 100644 --- a/subxt/src/view_functions.rs +++ b/subxt/src/view_functions.rs @@ -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, ViewFunctionError> { let client = &self.client; let block_hash = client.block_hash(); diff --git a/utils/accountid32/src/lib.rs b/utils/accountid32/src/lib.rs index debe4fc04c..0510dfe90c 100644 --- a/utils/accountid32/src/lib.rs +++ b/utils/accountid32/src/lib.rs @@ -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 { + fn from_ss58(s: &str) -> Result { 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 { 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 { - 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 ); }