mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
Bug fix of currencies implementation for pallet-balances (#11875)
* Add test * Fix the bug * Add similar test for named reservable * Extend test with "overflow" repatriation * Expand test for `NamedReservableCurrency` * Add notes about return values meaning
This commit is contained in:
@@ -1000,6 +1000,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Is a no-op if:
|
||||
/// - the value to be moved is zero; or
|
||||
/// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`.
|
||||
///
|
||||
/// NOTE: returns actual amount of transferred value in `Ok` case.
|
||||
fn do_transfer_reserved(
|
||||
slashed: &T::AccountId,
|
||||
beneficiary: &T::AccountId,
|
||||
@@ -1013,7 +1015,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
|
||||
if slashed == beneficiary {
|
||||
return match status {
|
||||
Status::Free => Ok(Self::unreserve(slashed, value)),
|
||||
Status::Free => Ok(value.saturating_sub(Self::unreserve(slashed, value))),
|
||||
Status::Reserved => Ok(value.saturating_sub(Self::reserved_balance(slashed))),
|
||||
}
|
||||
}
|
||||
@@ -1785,6 +1787,8 @@ where
|
||||
/// Unreserve some funds, returning any amount that was unable to be unreserved.
|
||||
///
|
||||
/// Is a no-op if the value to be unreserved is zero or the account does not exist.
|
||||
///
|
||||
/// NOTE: returns amount value which wasn't successfully unreserved.
|
||||
fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance {
|
||||
if value.is_zero() {
|
||||
return Zero::zero()
|
||||
|
||||
Reference in New Issue
Block a user