Skip to content

Commit

Permalink
implement the free balance helper directly on stack
Browse files Browse the repository at this point in the history
Signed-off-by: xermicus <[email protected]>
  • Loading branch information
xermicus committed Sep 11, 2024
1 parent f4329d0 commit 1e6421e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions substrate/frame/revive/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,6 @@ pub trait Ext: sealing::Sealed {
/// Returns a reference to the account id of the current contract.
fn account_id(&self) -> &AccountIdOf<Self::T>;

/// Returns the balance of an AccountId
fn account_balance(&self, who: &AccountIdOf<Self::T>) -> U256;

/// Returns a reference to the [`H160`] address of the current contract.
fn address(&self) -> H160 {
<Self::T as Config>::AddressMapper::to_address(self.account_id())
Expand Down Expand Up @@ -1264,6 +1261,11 @@ where
fn allows_reentry(&self, id: &T::AccountId) -> bool {
!self.frames().any(|f| &f.account_id == id && !f.allows_reentry)
}

/// Returns the *free* balance of the supplied AccountId.
fn account_balance(&self, who: &T::AccountId) -> U256 {
T::Currency::reducible_balance(who, Preservation::Preserve, Fortitude::Polite).into()
}
}

impl<'a, T, E> Ext for Stack<'a, T, E>
Expand Down Expand Up @@ -1471,10 +1473,6 @@ where
&self.top_frame().account_id
}

fn account_balance(&self, who: &AccountIdOf<Self::T>) -> U256 {
T::Currency::reducible_balance(who, Preservation::Preserve, Fortitude::Polite).into()
}

fn caller(&self) -> Origin<T> {
if let Some(caller) = &self.top_frame().delegate_caller {
caller.clone()
Expand Down

0 comments on commit 1e6421e

Please sign in to comment.