Skip to content

Commit

Permalink
change: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed Oct 7, 2024
1 parent 1b1d41d commit ee0a030
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 39 deletions.
8 changes: 8 additions & 0 deletions pallets/gas-transaction-payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ sp-io = {workspace = true}

[features]
default = ["std"]
runtime-benchmarks=[
"fc-traits-gas-tank/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"fc-traits-gas-tank/std",
Expand Down
12 changes: 4 additions & 8 deletions pallets/gas-transaction-payment/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> frame_support::pallet_prelude::TransactionValidity {
if let Some(_) = T::GasBurner::check_available_gas(who, &info.weight) {
if T::GasBurner::check_available_gas(who, &info.weight).is_some() {
Ok(ValidTransaction::default())
} else {
self.0.validate(who, call, info, len)
Expand All @@ -115,13 +115,9 @@ where
) -> Result<(), frame_support::pallet_prelude::TransactionValidityError> {
if let Some((who, pre)) = pre {
match pre {
Pre::Inner(inner_pre) => S::post_dispatch(
Some(inner_pre),
&info.clone().into(),
post_info,
len,
result,
)?,
Pre::Inner(inner_pre) => {
S::post_dispatch(Some(inner_pre), info, post_info, len, result)?
}
Pre::Burner(expected_remaining) => {
let used_gas = post_info.actual_weight.unwrap_or(info.weight);
let should_burn_gas = post_info.pays_fee == Pays::Yes;
Expand Down
5 changes: 1 addition & 4 deletions pallets/pass/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use crate::Pallet;
use frame_benchmarking::v2::*;
Expand Down Expand Up @@ -29,7 +27,6 @@ where

#[instance_benchmarks(
where
T: frame_system::Config + crate::Config<I>,
OriginFor<T>: From<frame_system::Origin<T>>,
T::Hash: Into<HashedUserId>,
RuntimeEventFor<T, I>: From<frame_system::Event<T>>,
Expand All @@ -41,7 +38,7 @@ mod benchmarks {
pub fn register() -> Result<(), BenchmarkError> {
// Setup code
let origin = T::BenchmarkHelper::register_origin();
let user_id = hash::<T>(&*b"my-account");
let user_id = hash::<T>(b"my-account");
let account_id = Pallet::<T, I>::account_id_for(user_id)?;
let device_id = [0u8; 32];

Expand Down
27 changes: 9 additions & 18 deletions pallets/pass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ pub mod pallet {
}

#[pallet::call_index(3)]
// #[pallet::feeless_if(
// |_: &OriginFor<T>, _: &DeviceId, _: &CredentialOf<T, I>, _: &Option<BlockNumberFor<T>>| true
// )]
pub fn authenticate(
origin: OriginFor<T>,
device_id: DeviceId,
Expand All @@ -166,7 +163,7 @@ pub mod pallet {
Error::<T, I>::AccountNotFound
);

let device = Devices::<T, I>::get(&account_id, &device_id)
let device = Devices::<T, I>::get(&account_id, device_id)
.ok_or(Error::<T, I>::DeviceNotFound)?;
device
.verify_user(&credential)
Expand Down Expand Up @@ -259,13 +256,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
.ok_or(Error::<T, I>::DeviceAttestationInvalid)?;

Devices::<T, I>::insert(who, device_id, device);
Self::deposit_event(
Event::<T, I>::AddedDevice {
who: who.clone(),
device_id: device_id.clone(),
}
.into(),
);
Self::deposit_event(Event::<T, I>::AddedDevice {
who: who.clone(),
device_id: *device_id,
});

Ok(())
}
Expand Down Expand Up @@ -315,12 +309,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {

Sessions::<T, I>::insert(session_key.clone(), (account_id.clone(), until));

Self::deposit_event(
Event::<T, I>::SessionCreated {
session_key: session_key.clone(),
until,
}
.into(),
);
Self::deposit_event(Event::<T, I>::SessionCreated {
session_key: session_key.clone(),
until,
});
}
}
6 changes: 2 additions & 4 deletions pallets/referenda-tracks/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

//! Benchmarks for remarks pallet
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use crate::{Event, OriginToTrackId, Pallet as ReferendaTracks, Tracks, TracksIds};
use frame_benchmarking::v2::*;
Expand Down Expand Up @@ -82,8 +80,8 @@ fn prepare_tracks<T: Config<I>, I: 'static>(full: bool) {
*tracks_ids = BoundedVec::truncate_from(ids.clone());
});
ids.iter().for_each(|id| {
Tracks::<T, I>::insert(id.clone(), track.clone());
OriginToTrackId::<T, I>::insert(origin.clone(), id.clone());
Tracks::<T, I>::insert(id, track.clone());
OriginToTrackId::<T, I>::insert(origin.clone(), id);
});

if full {
Expand Down
4 changes: 2 additions & 2 deletions pallets/referenda-tracks/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<T: Config<I>, I> fc_traits_tracks::MutateTracks<BalanceOf<T, I>, BlockNumbe
origin: Self::RuntimeOrigin,
) -> DispatchResult {
ensure!(
Tracks::<T, I>::get(id) == None,
Tracks::<T, I>::get(id).is_none(),
Error::<T, I>::TrackIdAlreadyExisting
);

Expand Down Expand Up @@ -93,6 +93,6 @@ impl<T: Config<I>, I> fc_traits_tracks::MutateTracks<BalanceOf<T, I>, BlockNumbe
})?;

Self::deposit_event(Event::Removed { id });
Ok(().into())
Ok(())
}
}
2 changes: 1 addition & 1 deletion pallets/referenda-tracks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub mod pallet {
type TrackId: Parameter + Member + Copy + MaxEncodedLen + Ord;

type MaxTracks: Get<u32>;
///

type WeightInfo: WeightInfo;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
2 changes: 0 additions & 2 deletions pallets/template/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use crate::Pallet;
use frame_benchmarking::v2::*;
Expand Down
7 changes: 7 additions & 0 deletions traits/gas-tank/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ sp-io.workspace = true

[features]
default = ["std"]
runtime-benchmarks=[
"pallet-balances/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"pallet-balances/std",
Expand Down

0 comments on commit ee0a030

Please sign in to comment.