1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Balance API for the sandbox.
use frame_support::{sp_runtime::DispatchError, traits::fungible::Mutate};

use super::Sandbox;
use crate::{runtime::AccountIdFor, BalanceOf, Runtime};

impl<R> Sandbox<R>
where
    R: Runtime,
    R::Config: pallet_balances::Config,
{
    /// Mint tokens to an account.
    ///
    /// # Arguments
    ///
    /// * `address` - The address of the account to add tokens to.
    /// * `amount` - The number of tokens to add.
    pub fn mint_into(
        &mut self,
        address: AccountIdFor<R::Config>,
        amount: BalanceOf<R::Config>,
    ) -> Result<BalanceOf<R::Config>, DispatchError> {
        self.execute_with(|| pallet_balances::Pallet::<R::Config>::mint_into(&address, amount))
    }

    /// Return the free balance of an account.
    ///
    /// # Arguments
    ///
    /// * `address` - The address of the account to query.
    pub fn free_balance(&mut self, address: &AccountIdFor<R::Config>) -> BalanceOf<R::Config> {
        self.execute_with(|| pallet_balances::Pallet::<R::Config>::free_balance(address))
    }
}