Skip to content

Commit

Permalink
chore: cargo clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Minh Huy Tran <huy@perun.network>
  • Loading branch information
NhoxxKienn committed Apr 23, 2024
1 parent 0fd4c06 commit 09452ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub mod pallet {
let who = ensure_signed(origin)?;
ensure!(amount >= T::MinDeposit::get(), Error::<T>::DepositTooSmall);
// Check that a deposit would not overflow, return on failure.
let holding = <Deposits<T>>::get(&funding_id).unwrap_or_default();
let holding = <Deposits<T>>::get(funding_id).unwrap_or_default();
// An overflow here can happen if a user wants to deposit more than he has.
let new_holdings = holding
.checked_add(&amount)
Expand All @@ -266,7 +266,7 @@ pub mod pallet {
let account_id = Self::account_id();
T::Currency::transfer(&who, &account_id, amount, ExistenceRequirement::KeepAlive)?;
// Update the holdings in the deposits map.
<Deposits<T>>::insert(&funding_id, &new_holdings);
<Deposits<T>>::insert(funding_id, new_holdings);
// Emit the 'Deposited' event.
Self::deposit_event(Event::Deposited(funding_id, new_holdings));
Ok(())
Expand Down Expand Up @@ -299,7 +299,7 @@ pub mod pallet {
let channel_id = state.channel_id;

let now = Self::now();
match <StateRegister<T>>::get(&channel_id) {
match <StateRegister<T>>::get(channel_id) {
None => {
let timeout = now
.checked_add(&params.challenge_duration)
Expand Down Expand Up @@ -413,7 +413,7 @@ pub mod pallet {
pub fn conclude(origin: OriginFor<T>, params: ParamsOf<T>) -> DispatchResult {
ensure_signed(origin)?;
let channel_id = params.channel_id::<T::Hasher>();
match <StateRegister<T>>::get(&channel_id) {
match <StateRegister<T>>::get(channel_id) {
Some(dispute) => {
if dispute.phase == Phase::Conclude {
return Ok(());
Expand Down Expand Up @@ -470,7 +470,7 @@ pub mod pallet {
ensure!(state.finalized, Error::<T>::StateNotFinal);

// Check if this channel is being disputed.
if let Some(dispute) = <StateRegister<T>>::get(&channel_id) {
if let Some(dispute) = <StateRegister<T>>::get(channel_id) {
if dispute.phase == Phase::Conclude {
ensure!(
dispute.state.version == state.version,
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<T: Config> Pallet<T> {
for (i, part) in parts.iter().enumerate() {
let fid = Self::calc_funding_id(channel, part);
fids.push(fid);
let deposit = <Deposits<T>>::get(&fid).unwrap_or_default();
let deposit = <Deposits<T>>::get(fid).unwrap_or_default();

sum_outcome = sum_outcome
.checked_add(&outcome[i])
Expand All @@ -607,7 +607,7 @@ impl<T: Config> Pallet<T> {
if sum_deposit >= sum_outcome {
// We redistribute the funds according to the outcome.
for (i, fid) in fids.iter().enumerate() {
<Deposits<T>>::insert(&fid, outcome[i]);
<Deposits<T>>::insert(fid, outcome[i]);
}
}
Ok(())
Expand Down Expand Up @@ -694,14 +694,14 @@ impl<T: Config> Pallet<T> {
require!(cur_acc == next_acc);
frame_support::runtime_print!("PerunPallet:after check balances");

return T::AppRegistry::valid_transition(params, current, next, signer);
T::AppRegistry::valid_transition(params, current, next, signer)
}

fn accumulate_balances(balances: &[BalanceOf<T>]) -> BalanceOf<T> {
let mut acc = BalanceOf::<T>::default();
for b in balances.iter() {
acc += *b;
}
return acc;
acc
}
}
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where

Self {
channel_id: ChannelId::default(),
part: part,
part,
receiver: AccountId::default(),
}
}
Expand All @@ -226,7 +226,7 @@ where

pub fn has_app<T: Config<AppId = AppId>>(&self) -> bool {
let no_app = T::NoApp::get();
return self.app != no_app;
self.app != no_app
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
}
//TODO: benchmark weight and replace constant
fn progress<U: Config>(params: &ParamsOf<U>) -> Weight {
return Weight::from_all(10_000).saturating_add(U::AppRegistry::transition_weight(params));
Weight::from_all(10_000).saturating_add(U::AppRegistry::transition_weight(params))
}
// Storage: PerunModule StateRegister (r:1 w:1)
// Storage: PerunModule Deposits (r:2 w:2)
Expand All @@ -83,7 +83,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
}
//TODO: benchmark weight and replace constant
fn conclude_final(_p: u32, ) -> Weight {
return Weight::from_all(10_000);
Weight::from_all(10_000)
}
// Storage: PerunModule StateRegister (r:1 w:0)
// Storage: PerunModule Deposits (r:1 w:1)
Expand Down Expand Up @@ -115,7 +115,7 @@ impl WeightInfo for () {
}
//TODO: benchmark weight and replace constant
fn progress<U: Config>(params: &ParamsOf<U>) -> Weight {
return Weight::from_all(10_000).saturating_add(U::AppRegistry::transition_weight(params));
Weight::from_all(10_000).saturating_add(U::AppRegistry::transition_weight(params))
}
// Storage: PerunModule StateRegister (r:1 w:1)
// Storage: PerunModule Deposits (r:2 w:2)
Expand All @@ -130,7 +130,7 @@ impl WeightInfo for () {
}
//TODO: benchmark weight and replace constant
fn conclude_final(_p: u32) -> Weight {
return Weight::from_all(10_000);
Weight::from_all(10_000)
}
// Storage: PerunModule StateRegister (r:1 w:0)
// Storage: PerunModule Deposits (r:1 w:1)
Expand Down

0 comments on commit 09452ee

Please sign in to comment.