Skip to content

Commit

Permalink
wrap condition under ensure!
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp committed Nov 7, 2023
1 parent 09570d3 commit 96f3b0c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pallets/roles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,14 @@ pub mod pallet {
!AccountRolesMapping::<T>::contains_key(&stash_account),
Error::<T>::RoleAlreadyAssigned
);

// Check if stash account is already paired.
if <Ledger<T>>::contains_key(&stash_account) {
return Err(Error::<T>::AlreadyPaired.into())
}
ensure!(!<Ledger<T>>::contains_key(&stash_account), Error::<T>::AlreadyPaired);

// Check if min active bond is met.
let min_active_bond = MinActiveBond::<T>::get();
if bond_value < min_active_bond.into() {
return Err(Error::<T>::InsufficientBond.into())
}
ensure!(bond_value > min_active_bond.into(), Error::<T>::InsufficientBond);

// Bond with stash account.
let stash_balance = T::Currency::free_balance(&stash_account);
let value = bond_value.min(stash_balance);
Expand Down

0 comments on commit 96f3b0c

Please sign in to comment.