mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +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
@@ -281,7 +281,7 @@ benchmarks_instance_pallet! {
|
||||
let target0 = T::Lookup::unlookup(account("target", 0, SEED));
|
||||
let target1 = T::Lookup::unlookup(account("target", 1, SEED));
|
||||
let target2 = T::Lookup::unlookup(account("target", 2, SEED));
|
||||
}: _(SystemOrigin::Signed(caller), Default::default(), target0.clone(), target1.clone(), target2.clone())
|
||||
}: _(SystemOrigin::Signed(caller), Default::default(), target0, target1, target2)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::TeamChanged {
|
||||
asset_id: Default::default(),
|
||||
@@ -346,7 +346,7 @@ benchmarks_instance_pallet! {
|
||||
let (caller, _) = create_default_asset::<T, I>(true);
|
||||
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
|
||||
let dummy = vec![0u8; T::StringLimit::get() as usize];
|
||||
let origin = SystemOrigin::Signed(caller.clone()).into();
|
||||
let origin = SystemOrigin::Signed(caller).into();
|
||||
Assets::<T, I>::set_metadata(origin, Default::default(), dummy.clone(), dummy, 12)?;
|
||||
|
||||
let origin = T::ForceOrigin::successful_origin();
|
||||
@@ -365,7 +365,7 @@ benchmarks_instance_pallet! {
|
||||
owner: caller_lookup.clone(),
|
||||
issuer: caller_lookup.clone(),
|
||||
admin: caller_lookup.clone(),
|
||||
freezer: caller_lookup.clone(),
|
||||
freezer: caller_lookup,
|
||||
min_balance: 100u32.into(),
|
||||
is_sufficient: true,
|
||||
is_frozen: false,
|
||||
@@ -398,7 +398,7 @@ benchmarks_instance_pallet! {
|
||||
let delegate_lookup = T::Lookup::unlookup(delegate.clone());
|
||||
let amount = 100u32.into();
|
||||
let origin = SystemOrigin::Signed(owner.clone()).into();
|
||||
Assets::<T, I>::approve_transfer(origin, id, delegate_lookup.clone(), amount)?;
|
||||
Assets::<T, I>::approve_transfer(origin, id, delegate_lookup, amount)?;
|
||||
|
||||
let dest: T::AccountId = account("dest", 0, SEED);
|
||||
let dest_lookup = T::Lookup::unlookup(dest.clone());
|
||||
|
||||
@@ -204,7 +204,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
who: &T::AccountId,
|
||||
keep_alive: bool,
|
||||
) -> Result<T::Balance, DispatchError> {
|
||||
let details = Asset::<T, I>::get(id).ok_or_else(|| Error::<T, I>::Unknown)?;
|
||||
let details = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(!details.is_frozen, Error::<T, I>::Frozen);
|
||||
|
||||
let account = Account::<T, I>::get(id, who).ok_or(Error::<T, I>::NoAccount)?;
|
||||
@@ -258,7 +258,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(dust) => actual.saturating_add(dust), //< guaranteed by reducible_balance
|
||||
Err(e) => {
|
||||
debug_assert!(false, "passed from reducible_balance; qed");
|
||||
return Err(e.into())
|
||||
return Err(e)
|
||||
},
|
||||
};
|
||||
|
||||
@@ -291,7 +291,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
(true, Some(dust)) => (amount, Some(dust)),
|
||||
_ => (debit, None),
|
||||
};
|
||||
Self::can_increase(id, &dest, credit, false).into_result()?;
|
||||
Self::can_increase(id, dest, credit, false).into_result()?;
|
||||
Ok((credit, maybe_burn))
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
) -> DispatchResult {
|
||||
Self::increase_balance(id, beneficiary, amount, |details| -> DispatchResult {
|
||||
if let Some(check_issuer) = maybe_check_issuer {
|
||||
ensure!(&check_issuer == &details.issuer, Error::<T, I>::NoPermission);
|
||||
ensure!(check_issuer == details.issuer, Error::<T, I>::NoPermission);
|
||||
}
|
||||
debug_assert!(
|
||||
T::Balance::max_value() - details.supply >= amount,
|
||||
@@ -433,7 +433,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
let actual = Self::decrease_balance(id, target, amount, f, |actual, details| {
|
||||
// Check admin rights.
|
||||
if let Some(check_admin) = maybe_check_admin {
|
||||
ensure!(&check_admin == &details.admin, Error::<T, I>::NoPermission);
|
||||
ensure!(check_admin == details.admin, Error::<T, I>::NoPermission);
|
||||
}
|
||||
|
||||
debug_assert!(details.supply >= actual, "checked in prep; qed");
|
||||
@@ -471,7 +471,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
let mut target_died: Option<DeadConsequence> = None;
|
||||
|
||||
Asset::<T, I>::try_mutate(id, |maybe_details| -> DispatchResult {
|
||||
let mut details = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
let details = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
|
||||
check(actual, details)?;
|
||||
|
||||
@@ -483,8 +483,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
account.balance = account.balance.saturating_sub(actual);
|
||||
if account.balance < details.min_balance {
|
||||
debug_assert!(account.balance.is_zero(), "checked in prep; qed");
|
||||
target_died =
|
||||
Some(Self::dead_account(target, &mut details, &account.reason, false));
|
||||
target_died = Some(Self::dead_account(target, details, &account.reason, false));
|
||||
if let Some(Remove) = target_died {
|
||||
return Ok(())
|
||||
}
|
||||
@@ -543,8 +542,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
}
|
||||
|
||||
// Figure out the debit and credit, together with side-effects.
|
||||
let debit = Self::prep_debit(id, &source, amount, f.into())?;
|
||||
let (credit, maybe_burn) = Self::prep_credit(id, &dest, amount, debit, f.burn_dust)?;
|
||||
let debit = Self::prep_debit(id, source, amount, f.into())?;
|
||||
let (credit, maybe_burn) = Self::prep_credit(id, dest, amount, debit, f.burn_dust)?;
|
||||
|
||||
let mut source_account =
|
||||
Account::<T, I>::get(id, &source).ok_or(Error::<T, I>::NoAccount)?;
|
||||
@@ -555,7 +554,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
// Check admin rights.
|
||||
if let Some(need_admin) = maybe_need_admin {
|
||||
ensure!(&need_admin == &details.admin, Error::<T, I>::NoPermission);
|
||||
ensure!(need_admin == details.admin, Error::<T, I>::NoPermission);
|
||||
}
|
||||
|
||||
// Skip if source == dest
|
||||
@@ -590,7 +589,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
*maybe_account = Some(AssetAccountOf::<T, I> {
|
||||
balance: credit,
|
||||
is_frozen: false,
|
||||
reason: Self::new_account(&dest, details, None)?,
|
||||
reason: Self::new_account(dest, details, None)?,
|
||||
extra: T::Extra::default(),
|
||||
});
|
||||
},
|
||||
@@ -602,7 +601,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
if source_account.balance < details.min_balance {
|
||||
debug_assert!(source_account.balance.is_zero(), "checked in prep; qed");
|
||||
source_died =
|
||||
Some(Self::dead_account(&source, details, &source_account.reason, false));
|
||||
Some(Self::dead_account(source, details, &source_account.reason, false));
|
||||
if let Some(Remove) = source_died {
|
||||
Account::<T, I>::remove(id, &source);
|
||||
return Ok(())
|
||||
@@ -746,7 +745,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
};
|
||||
let deposit_required = T::ApprovalDeposit::get();
|
||||
if approved.deposit < deposit_required {
|
||||
T::Currency::reserve(&owner, deposit_required - approved.deposit)?;
|
||||
T::Currency::reserve(owner, deposit_required - approved.deposit)?;
|
||||
approved.deposit = deposit_required;
|
||||
}
|
||||
approved.amount = approved.amount.saturating_add(amount);
|
||||
@@ -789,10 +788,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
approved.amount.checked_sub(&amount).ok_or(Error::<T, I>::Unapproved)?;
|
||||
|
||||
let f = TransferFlags { keep_alive: false, best_effort: false, burn_dust: false };
|
||||
owner_died = Self::transfer_and_die(id, &owner, &destination, amount, None, f)?.1;
|
||||
owner_died = Self::transfer_and_die(id, owner, destination, amount, None, f)?.1;
|
||||
|
||||
if remaining.is_zero() {
|
||||
T::Currency::unreserve(&owner, approved.deposit);
|
||||
T::Currency::unreserve(owner, approved.deposit);
|
||||
Asset::<T, I>::mutate(id, |maybe_details| {
|
||||
if let Some(details) = maybe_details {
|
||||
details.approvals.saturating_dec();
|
||||
|
||||
@@ -42,7 +42,7 @@ impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> f
|
||||
if let Some(ref mut account) = maybe_account {
|
||||
account.extra = extra;
|
||||
} else {
|
||||
Err(DispatchError::NoProviders)?;
|
||||
return Err(DispatchError::NoProviders.into())
|
||||
}
|
||||
} else {
|
||||
// They want to delete it. Let this pass if the item never existed anyway.
|
||||
|
||||
@@ -788,7 +788,7 @@ pub mod pallet {
|
||||
let origin = ensure_signed(origin)?;
|
||||
|
||||
let d = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &d.freezer, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == d.freezer, Error::<T, I>::NoPermission);
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
|
||||
Account::<T, I>::try_mutate(id, &who, |maybe_account| -> DispatchResult {
|
||||
@@ -819,7 +819,7 @@ pub mod pallet {
|
||||
let origin = ensure_signed(origin)?;
|
||||
|
||||
let details = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &details.admin, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == details.admin, Error::<T, I>::NoPermission);
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
|
||||
Account::<T, I>::try_mutate(id, &who, |maybe_account| -> DispatchResult {
|
||||
@@ -849,7 +849,7 @@ pub mod pallet {
|
||||
|
||||
Asset::<T, I>::try_mutate(id, |maybe_details| {
|
||||
let d = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &d.freezer, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == d.freezer, Error::<T, I>::NoPermission);
|
||||
|
||||
d.is_frozen = true;
|
||||
|
||||
@@ -876,7 +876,7 @@ pub mod pallet {
|
||||
|
||||
Asset::<T, I>::try_mutate(id, |maybe_details| {
|
||||
let d = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &d.admin, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == d.admin, Error::<T, I>::NoPermission);
|
||||
|
||||
d.is_frozen = false;
|
||||
|
||||
@@ -906,7 +906,7 @@ pub mod pallet {
|
||||
|
||||
Asset::<T, I>::try_mutate(id, |maybe_details| {
|
||||
let details = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &details.owner, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == details.owner, Error::<T, I>::NoPermission);
|
||||
if details.owner == owner {
|
||||
return Ok(())
|
||||
}
|
||||
@@ -951,7 +951,7 @@ pub mod pallet {
|
||||
|
||||
Asset::<T, I>::try_mutate(id, |maybe_details| {
|
||||
let details = maybe_details.as_mut().ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &details.owner, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == details.owner, Error::<T, I>::NoPermission);
|
||||
|
||||
details.issuer = issuer.clone();
|
||||
details.admin = admin.clone();
|
||||
@@ -1009,7 +1009,7 @@ pub mod pallet {
|
||||
let origin = ensure_signed(origin)?;
|
||||
|
||||
let d = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
|
||||
ensure!(&origin == &d.owner, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == d.owner, Error::<T, I>::NoPermission);
|
||||
|
||||
Metadata::<T, I>::try_mutate_exists(id, |metadata| {
|
||||
let deposit = metadata.take().ok_or(Error::<T, I>::Unknown)?.deposit;
|
||||
@@ -1241,7 +1241,7 @@ pub mod pallet {
|
||||
.map(|_| ())
|
||||
.or_else(|origin| -> DispatchResult {
|
||||
let origin = ensure_signed(origin)?;
|
||||
ensure!(&origin == &d.admin, Error::<T, I>::NoPermission);
|
||||
ensure!(origin == d.admin, Error::<T, I>::NoPermission);
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
|
||||
@@ -104,9 +104,9 @@ impl<Balance> ExistenceReason<Balance> {
|
||||
if let ExistenceReason::DepositHeld(deposit) =
|
||||
sp_std::mem::replace(self, ExistenceReason::DepositRefunded)
|
||||
{
|
||||
return Some(deposit)
|
||||
Some(deposit)
|
||||
} else {
|
||||
return None
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user