Skip to content

Commit

Permalink
update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp committed Nov 14, 2023
1 parent 4aeb4dc commit f222d29
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pallets/roles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ pub mod pallet {
/// Not a validator.
NotValidator,
/// Role has already been assigned to provided validator.
RoleAlreadyAssigned,
HasRoleAssigned,
/// No role assigned to provided validator.
RoleNotAssigned,
/// Insufficient bond to become a validator.
InsufficientBond,
/// Insufficient bond to re stake.
NoRoleAssigned,
/// Invalid Re-staking amount, should not exceed total staked amount.
InvalidReStakingBond,
/// Re staking amount should be greater than minimum re-staking bond to become and maintain the role.
InsufficientReStakingBond,
/// Stash controller account already added to Roles Ledger
AccountAlreadyPaired,
Expand Down Expand Up @@ -177,7 +177,7 @@ pub mod pallet {
// Check if role is already assigned.
ensure!(
!AccountRolesMapping::<T>::contains_key(&stash_account),
Error::<T>::RoleAlreadyAssigned
Error::<T>::HasRoleAssigned
);

// Check if stash account is already paired/ re-staked.
Expand All @@ -187,9 +187,9 @@ pub mod pallet {
let min_re_staking_bond = MinReStakingBond::<T>::get();
ensure!(re_stake >= min_re_staking_bond, Error::<T>::InsufficientReStakingBond);

// Validate re-staking bond, should be less than active staked bond.
// Validate re-staking bond, should not exceed active staked bond.
let staking_ledger = pallet_staking::Ledger::<T>::get(&stash_account).unwrap();
ensure!(staking_ledger.active > re_stake, Error::<T>::InsufficientBond);
ensure!(staking_ledger.active > re_stake, Error::<T>::InvalidReStakingBond);

// Update ledger.
let item = RoleStakingLedger { stash: stash_account.clone(), total: re_stake };
Expand Down Expand Up @@ -223,7 +223,7 @@ pub mod pallet {
// check if role is assigned.
ensure!(
Self::is_validator(stash_account.clone(), role.clone()),
Error::<T>::RoleNotAssigned
Error::<T>::NoRoleAssigned
);
// TODO: Call jobs manager to remove the services.
// On successful removal of services, remove the role from the mapping.
Expand Down Expand Up @@ -252,7 +252,7 @@ pub mod pallet {
///
/// This function will return error if
/// - Stash account is not a validator.
/// - Insufficient funds to unbound.
/// - If there is any role assigned to the validator.
///
#[pallet::weight({0})]
#[pallet::call_index(2)]
Expand All @@ -270,7 +270,7 @@ pub mod pallet {
// Ensure no role is assigned to the validator and is eligible to unbound.
ensure!(
!AccountRolesMapping::<T>::contains_key(&stash_account),
Error::<T>::RoleAlreadyAssigned
Error::<T>::HasRoleAssigned
);

// Unbound funds.
Expand Down

0 comments on commit f222d29

Please sign in to comment.