Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
feature: impl evm_reducible_balance
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjscksdn98 committed Oct 24, 2023
1 parent 60cd620 commit 59e1f62
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions frame/balances/src/impl_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,31 @@ impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pallet<T, I>
// Liquid balance is what is neither on hold nor frozen/required for provider.
a.free.saturating_sub(untouchable)
}

/// This method will only be used until migrations to fungible traits are done.
fn evm_reducible_balance(
who: &T::AccountId,
preservation: Preservation,
force: Fortitude,
) -> Self::Balance {
Self::account(who).usable()
let a = Self::account(who);
let mut untouchable = Zero::zero();
if force == Polite {
// In the case for EVM, we only care about frozen balance.
untouchable = a.frozen;
}
// If we want to keep our provider ref..
if preservation == Preserve
// ..or we don't want the account to die and our provider ref is needed for it to live..
|| preservation == Protect && !a.free.is_zero() &&
frame_system::Pallet::<T>::providers(who) == 1
// ..or we don't care about the account dying but our provider ref is required..
|| preservation == Expendable && !a.free.is_zero() &&
!frame_system::Pallet::<T>::can_dec_provider(who)
{
// ..then the ED needed..
untouchable = untouchable.max(T::ExistentialDeposit::get());
}
a.free.saturating_sub(untouchable)
}
fn can_deposit(
who: &T::AccountId,
Expand Down

0 comments on commit 59e1f62

Please sign in to comment.