mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
Balances: repatriate_reserved should respect freezes (#13885)
* repatriate_reserved should respect freezes * Docs * Fix and clean * Formatting * Update frame/balances/src/types.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * Fix * Simplify * Fixes * Fixes --------- Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,7 @@ use frame_support::{
|
||||
ensure,
|
||||
pallet_prelude::DispatchResult,
|
||||
traits::{
|
||||
tokens::{fungible, BalanceStatus as Status},
|
||||
tokens::{fungible, BalanceStatus as Status, Fortitude::Polite, Precision::BestEffort},
|
||||
Currency, DefensiveSaturating, ExistenceRequirement,
|
||||
ExistenceRequirement::AllowDeath,
|
||||
Get, Imbalance, LockIdentifier, LockableCurrency, NamedReservableCurrency,
|
||||
@@ -590,13 +590,18 @@ where
|
||||
/// Is a no-op if:
|
||||
/// - the value to be moved is zero; or
|
||||
/// - the `slashed` id equal to `beneficiary` and the `status` is `Reserved`.
|
||||
///
|
||||
/// This is `Polite` and thus will not repatriate any funds which would lead the total balance
|
||||
/// to be less than the frozen amount. Returns `Ok` with the actual amount of funds moved,
|
||||
/// which may be less than `value` since the operation is done an a `BestEffort` basis.
|
||||
fn repatriate_reserved(
|
||||
slashed: &T::AccountId,
|
||||
beneficiary: &T::AccountId,
|
||||
value: Self::Balance,
|
||||
status: Status,
|
||||
) -> Result<Self::Balance, DispatchError> {
|
||||
let actual = Self::do_transfer_reserved(slashed, beneficiary, value, true, status)?;
|
||||
let actual =
|
||||
Self::do_transfer_reserved(slashed, beneficiary, value, BestEffort, Polite, status)?;
|
||||
Ok(value.saturating_sub(actual))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user