Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Apr 14, 2023
1 parent b8d979d commit aad8a67
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,29 +1135,26 @@ pub mod pallet {
}
}

let ((actual, maybe_dust_1), maybe_dust_2) = Self::try_mutate_account(
let ((_, maybe_dust_1), maybe_dust_2) = Self::try_mutate_account(
beneficiary,
|to_account, is_new| -> Result<(T::Balance, Option<T::Balance>), DispatchError> {
|to_account, is_new| -> Result<((), Option<T::Balance>), DispatchError> {
ensure!(!is_new, Error::<T, I>::DeadAccount);
Self::try_mutate_account(
slashed,
|from_account, _| -> Result<T::Balance, DispatchError> {
match status {
Status::Free =>
to_account.free = to_account
.free
.checked_add(&actual)
.ok_or(ArithmeticError::Overflow)?,
Status::Reserved =>
to_account.reserved = to_account
.reserved
.checked_add(&actual)
.ok_or(ArithmeticError::Overflow)?,
}
from_account.reserved.saturating_reduce(actual);
Ok(actual)
},
)
Self::try_mutate_account(slashed, |from_account, _| -> DispatchResult {
match status {
Status::Free =>
to_account.free = to_account
.free
.checked_add(&actual)
.ok_or(ArithmeticError::Overflow)?,
Status::Reserved =>
to_account.reserved = to_account
.reserved
.checked_add(&actual)
.ok_or(ArithmeticError::Overflow)?,
}
from_account.reserved.saturating_reduce(actual);
Ok(())
})
},
)?;

Expand Down

0 comments on commit aad8a67

Please sign in to comment.