mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -39,11 +39,7 @@ fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
|
||||
let registrar: T::AccountId = account("registrar", i, SEED);
|
||||
let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::<T>::max_value());
|
||||
Identity::<T>::add_registrar(RawOrigin::Root.into(), registrar.clone())?;
|
||||
Identity::<T>::set_fee(
|
||||
RawOrigin::Signed(registrar.clone()).into(),
|
||||
i.into(),
|
||||
10u32.into(),
|
||||
)?;
|
||||
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?;
|
||||
let fields =
|
||||
IdentityFields(
|
||||
IdentityField::Display |
|
||||
@@ -52,7 +48,7 @@ fn add_registrars<T: Config>(r: u32) -> Result<(), &'static str> {
|
||||
IdentityField::PgpFingerprint |
|
||||
IdentityField::Image | IdentityField::Twitter,
|
||||
);
|
||||
Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), i.into(), fields)?;
|
||||
Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), i, fields)?;
|
||||
}
|
||||
|
||||
assert_eq!(Registrars::<T>::get().len(), r as usize);
|
||||
@@ -75,9 +71,9 @@ fn create_sub_accounts<T: Config>(
|
||||
}
|
||||
|
||||
// Set identity so `set_subs` does not fail.
|
||||
let _ = T::Currency::make_free_balance_be(&who, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
let _ = T::Currency::make_free_balance_be(who, BalanceOf::<T>::max_value() / 2u32.into());
|
||||
let info = create_identity_info::<T>(1);
|
||||
Identity::<T>::set_identity(who_origin.clone().into(), Box::new(info))?;
|
||||
Identity::<T>::set_identity(who_origin.into(), Box::new(info))?;
|
||||
|
||||
Ok(subs)
|
||||
}
|
||||
@@ -101,7 +97,7 @@ fn add_sub_accounts<T: Config>(
|
||||
fn create_identity_info<T: Config>(num_fields: u32) -> IdentityInfo<T::MaxAdditionalFields> {
|
||||
let data = Data::Raw(vec![0; 32].try_into().unwrap());
|
||||
|
||||
let info = IdentityInfo {
|
||||
IdentityInfo {
|
||||
additional: vec![(data.clone(), data.clone()); num_fields as usize].try_into().unwrap(),
|
||||
display: data.clone(),
|
||||
legal: data.clone(),
|
||||
@@ -110,10 +106,8 @@ fn create_identity_info<T: Config>(num_fields: u32) -> IdentityInfo<T::MaxAdditi
|
||||
email: data.clone(),
|
||||
pgp_fingerprint: Some([0; 20]),
|
||||
image: data.clone(),
|
||||
twitter: data.clone(),
|
||||
};
|
||||
|
||||
return info
|
||||
twitter: data,
|
||||
}
|
||||
}
|
||||
|
||||
benchmarks! {
|
||||
@@ -282,7 +276,7 @@ benchmarks! {
|
||||
|
||||
Identity::<T>::add_registrar(RawOrigin::Root.into(), caller.clone())?;
|
||||
let registrars = Registrars::<T>::get();
|
||||
ensure!(registrars[r as usize].as_ref().unwrap().account == caller.clone(), "id not set.");
|
||||
ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set.");
|
||||
}: _(RawOrigin::Signed(caller), r, account("new", 0, SEED))
|
||||
verify {
|
||||
let registrars = Registrars::<T>::get();
|
||||
@@ -325,7 +319,7 @@ benchmarks! {
|
||||
};
|
||||
|
||||
Identity::<T>::add_registrar(RawOrigin::Root.into(), caller.clone())?;
|
||||
Identity::<T>::request_judgement(user_origin.clone(), r, 10u32.into())?;
|
||||
Identity::<T>::request_judgement(user_origin, r, 10u32.into())?;
|
||||
}: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::JudgementGiven { target: user, registrar_index: r }.into())
|
||||
|
||||
@@ -324,8 +324,8 @@ pub mod pallet {
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[pallet::weight( T::WeightInfo::set_identity(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn set_identity(
|
||||
origin: OriginFor<T>,
|
||||
@@ -416,7 +416,7 @@ pub mod pallet {
|
||||
let new_deposit = T::SubAccountDeposit::get() * <BalanceOf<T>>::from(subs.len() as u32);
|
||||
|
||||
let not_other_sub =
|
||||
subs.iter().filter_map(|i| SuperOf::<T>::get(&i.0)).all(|i| &i.0 == &sender);
|
||||
subs.iter().filter_map(|i| SuperOf::<T>::get(&i.0)).all(|i| i.0 == sender);
|
||||
ensure!(not_other_sub, Error::<T>::AlreadyClaimed);
|
||||
|
||||
if old_deposit < new_deposit {
|
||||
@@ -470,9 +470,9 @@ pub mod pallet {
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::clear_identity(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxSubAccounts::get().into(), // S
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxSubAccounts::get(), // S
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn clear_identity(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
let sender = ensure_signed(origin)?;
|
||||
@@ -484,7 +484,7 @@ pub mod pallet {
|
||||
<SuperOf<T>>::remove(sub);
|
||||
}
|
||||
|
||||
let err_amount = T::Currency::unreserve(&sender, deposit.clone());
|
||||
let err_amount = T::Currency::unreserve(&sender, deposit);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
|
||||
Self::deposit_event(Event::IdentityCleared { who: sender, deposit });
|
||||
@@ -521,8 +521,8 @@ pub mod pallet {
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::request_judgement(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn request_judgement(
|
||||
origin: OriginFor<T>,
|
||||
@@ -542,7 +542,7 @@ pub mod pallet {
|
||||
match id.judgements.binary_search_by_key(®_index, |x| x.0) {
|
||||
Ok(i) =>
|
||||
if id.judgements[i].1.is_sticky() {
|
||||
Err(Error::<T>::StickyJudgement)?
|
||||
return Err(Error::<T>::StickyJudgement.into())
|
||||
} else {
|
||||
id.judgements[i] = item
|
||||
},
|
||||
@@ -583,8 +583,8 @@ pub mod pallet {
|
||||
/// - One event
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::cancel_request(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn cancel_request(
|
||||
origin: OriginFor<T>,
|
||||
@@ -600,7 +600,7 @@ pub mod pallet {
|
||||
let fee = if let Judgement::FeePaid(fee) = id.judgements.remove(pos).1 {
|
||||
fee
|
||||
} else {
|
||||
Err(Error::<T>::JudgementGiven)?
|
||||
return Err(Error::<T>::JudgementGiven.into())
|
||||
};
|
||||
|
||||
let err_amount = T::Currency::unreserve(&sender, fee);
|
||||
@@ -754,8 +754,8 @@ pub mod pallet {
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::provide_judgement(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn provide_judgement(
|
||||
origin: OriginFor<T>,
|
||||
@@ -821,9 +821,9 @@ pub mod pallet {
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[pallet::weight(T::WeightInfo::kill_identity(
|
||||
T::MaxRegistrars::get().into(), // R
|
||||
T::MaxSubAccounts::get().into(), // S
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
T::MaxRegistrars::get(), // R
|
||||
T::MaxSubAccounts::get(), // S
|
||||
T::MaxAdditionalFields::get(), // X
|
||||
))]
|
||||
pub fn kill_identity(
|
||||
origin: OriginFor<T>,
|
||||
|
||||
@@ -217,20 +217,14 @@ impl<Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + Part
|
||||
/// Returns `true` if this judgement is indicative of a deposit being currently held. This means
|
||||
/// it should not be cleared or replaced except by an operation which utilizes the deposit.
|
||||
pub(crate) fn has_deposit(&self) -> bool {
|
||||
match self {
|
||||
Judgement::FeePaid(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Judgement::FeePaid(_))
|
||||
}
|
||||
|
||||
/// Returns `true` if this judgement is one that should not be generally be replaced outside
|
||||
/// of specialized handlers. Examples include "malicious" judgements and deposit-holding
|
||||
/// judgements.
|
||||
pub(crate) fn is_sticky(&self) -> bool {
|
||||
match self {
|
||||
Judgement::FeePaid(_) | Judgement::Erroneous => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Judgement::FeePaid(_) | Judgement::Erroneous)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user