Struct noble_balances::Module[][src]

pub struct Module<T: Config<I>, I: Instance = DefaultInstance>(_);

Implementations

impl<T: Config<I> + 'static, I: Instance> Module<T, I>[src]

pub fn total_issuance() -> T::Balance[src]

The total units issued in the system.

pub fn locks<K: EncodeLike<T::AccountId>>(
    key: K
) -> Vec<BalanceLock<T::Balance>>
[src]

Any liquidity locks on some account balances. NOTE: Should only be accessed when setting, changing and freeing a lock.

impl<T: Config<I>, I: Instance> Module<T, I>[src]

Can also be called using Call.

pub fn transfer(
    origin: T::Origin,
    dest: <T::Lookup as StaticLookup>::Source,
    value: T::Balance
) -> DispatchResult
[src]

Transfer some liquid free balance to another account.

transfer will set the FreeBalance of the sender and receiver. It will decrease the total issuance of the system by the TransferFee. If the sender’s account is below the existential deposit as a result of the transfer, the account will be reaped.

The dispatch origin for this call must be Signed by the transactor.

  • Dependent on arguments but not critical, given proper implementations for input config types. See related functions below.
  • It contains a limited number of reads and writes internally and no complex computation.

Related functions:

  • ensure_can_withdraw is always called internally but has a bounded complexity.
  • Transferring balances to accounts that did not exist before will cause T::OnNewAccount::on_new_account to be called.
  • Removing enough funds from an account will trigger T::DustRemoval::on_unbalanced.
  • transfer_keep_alive works the same way as transfer, but has an additional check that the transfer will not kill the origin account.

  • Base Weight: 73.64 µs, worst case scenario (account created, account removed)
  • DB Weight: 1 Read and 1 Write to destination account
  • Origin account is already in memory, so no DB operations for them.

NOTE: Calling this function will bypass origin filters.

pub fn force_transfer(
    origin: T::Origin,
    source: <T::Lookup as StaticLookup>::Source,
    dest: <T::Lookup as StaticLookup>::Source,
    value: T::Balance
) -> DispatchResult
[src]

Exactly as transfer, except the origin must be root and the source account may be specified.

  • Same as transfer, but additional read and write because the source account is not assumed to be in the overlay.

NOTE: Calling this function will bypass origin filters.

pub fn transfer_keep_alive(
    origin: T::Origin,
    dest: <T::Lookup as StaticLookup>::Source,
    value: T::Balance
) -> DispatchResult
[src]

Same as the transfer call, but with a check that the transfer will not kill the origin account.

99% of the time you want transfer instead.

  • Cheaper than transfer because account cannot be killed.
  • Base Weight: 51.4 µs
  • DB Weight: 1 Read and 1 Write to dest (sender is in overlay already) #

NOTE: Calling this function will bypass origin filters.

impl<T: Config<I>, I: Instance> Module<T, I>[src]

pub fn free_balance(who: impl Borrow<T::AccountId>) -> T::Balance[src]

Get the free balance of an account.

pub fn usable_balance(who: impl Borrow<T::AccountId>) -> T::Balance[src]

Get the balance of an account that can be used for transfers, reservations, or any other non-locking, non-transaction-fee activity. Will be at most free_balance.

pub fn usable_balance_for_fees(who: impl Borrow<T::AccountId>) -> T::Balance[src]

Get the balance of an account that can be used for paying transaction fees (not tipping, or any other kind of fees, though). Will be at most free_balance.

pub fn reserved_balance(who: impl Borrow<T::AccountId>) -> T::Balance[src]

Get the reserved balance of an account.

pub fn mutate_account<R>(
    who: &T::AccountId,
    f: impl FnOnce(&mut AccountData<T::Balance>) -> R
) -> Result<R, StoredMapError>
[src]

Mutate an account to some new value, or delete it entirely with None. Will enforce ExistentialDeposit law, annulling the account as needed.

NOTE: Doesn’t do any preparatory work for creating a new account, so should only be used when it is known that the account already exists.

NOTE: LOW-LEVEL: This will not attempt to maintain total issuance. It is expected that the caller will do this.

Trait Implementations

impl<T: Config<I>, I: Instance> Callable<T> for Module<T, I>[src]

type Call = Call<T, I>

impl<T: Clone + Config<I>, I: Clone + Instance> Clone for Module<T, I>[src]

impl<T: Copy + Config<I>, I: Copy + Instance> Copy for Module<T, I>[src]

impl<T: Config<I>, I: Instance> Currency<<T as Config>::AccountId> for Module<T, I> where
    T::Balance: MaybeSerializeDeserialize + Debug
[src]

type Balance = T::Balance

The balance of an account.

type PositiveImbalance = PositiveImbalance<T, I>

The opaque token type for an imbalance. This is returned by unbalanced operations and must be dealt with. It may be dropped but cannot be cloned. Read more

type NegativeImbalance = NegativeImbalance<T, I>

The opaque token type for an imbalance. This is returned by unbalanced operations and must be dealt with. It may be dropped but cannot be cloned. Read more

fn slash(
    who: &T::AccountId,
    value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
[src]

Slash a target account who, returning the negative imbalance created and any left over amount that could not be slashed.

Is a no-op if value to be slashed is zero or the account does not exist.

NOTE: slash() prefers free balance, but assumes that reserve balance can be drawn from in extreme circumstances. can_slash() should be used prior to slash() to avoid having to draw from reserved funds, however we err on the side of punishment if things are inconsistent or can_slash wasn’t used appropriately.

fn deposit_into_existing(
    who: &T::AccountId,
    value: Self::Balance
) -> Result<Self::PositiveImbalance, DispatchError>
[src]

Deposit some value into the free balance of an existing target account who.

Is a no-op if the value to be deposited is zero.

fn deposit_creating(
    who: &T::AccountId,
    value: Self::Balance
) -> Self::PositiveImbalance
[src]

Deposit some value into the free balance of who, possibly creating a new account.

This function is a no-op if:

  • the value to be deposited is zero; or
  • the value to be deposited is less than the required ED and the account does not yet exist; or
  • the deposit would necessitate the account to exist and there are no provider references; or
  • value is so large it would cause the balance of who to overflow.

fn withdraw(
    who: &T::AccountId,
    value: Self::Balance,
    reasons: WithdrawReasons,
    liveness: ExistenceRequirement
) -> Result<Self::NegativeImbalance, DispatchError>
[src]

Withdraw some free balance from an account, respecting existence requirements.

Is a no-op if value to be withdrawn is zero.

fn make_free_balance_be(
    who: &T::AccountId,
    value: Self::Balance
) -> SignedImbalance<Self::Balance, Self::PositiveImbalance>
[src]

Force the new free balance of a target account who to some new value balance.

impl<T: Config<I>, I: Instance> Debug for Module<T, I> where
    T: Debug,
    I: Debug
[src]

impl<T: Eq + Config<I>, I: Eq + Instance> Eq for Module<T, I>[src]

impl<T: Config<I>, I: Instance> GetNobleVersion for Module<T, I>[src]

impl<T: Config<I>, I: Instance> IntegrityTest for Module<T, I>[src]

impl<T: Config<I>, I: Instance> LockableCurrency<<T as Config>::AccountId> for Module<T, I> where
    T::Balance: MaybeSerializeDeserialize + Debug
[src]

type Moment = T::BlockNumber

The quantity used to denote time; usually just a BlockNumber.

type MaxLocks = T::MaxLocks

The maximum number of locks a user should have on their account.

impl<T: Config<I>, I: Instance> ModuleErrorMetadata for Module<T, I>[src]

impl<T: Config + Config<I>, I: Instance> OffchainWorker<<T as Config>::BlockNumber> for Module<T, I>[src]

impl<T: Config + Config<I>, I: Instance> OnFinalize<<T as Config>::BlockNumber> for Module<T, I>[src]

impl<T: Config<I>, I: Instance> OnGenesis for Module<T, I>[src]

impl<T: Config + Config<I>, I: Instance> OnInitialize<<T as Config>::BlockNumber> for Module<T, I>[src]

impl<T: Config<I>, I: Instance> OnRuntimeUpgrade for Module<T, I>[src]

impl<T: PartialEq + Config<I>, I: PartialEq + Instance> PartialEq<Module<T, I>> for Module<T, I>[src]

impl<T: Config<I>, I: Instance> ReservableCurrency<<T as Config>::AccountId> for Module<T, I> where
    T::Balance: MaybeSerializeDeserialize + Debug
[src]

fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool[src]

Check if who can reserve value from their free balance.

Always true if value to be reserved is zero.

fn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult[src]

Move value from the free balance from who to their reserved balance.

Is a no-op if value to be reserved is zero.

fn unreserve(who: &T::AccountId, value: Self::Balance) -> Self::Balance[src]

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.

fn slash_reserved(
    who: &T::AccountId,
    value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
[src]

Slash from reserved balance, returning the negative imbalance created, and any amount that was unable to be slashed.

Is a no-op if the value to be slashed is zero or the account does not exist.

fn repatriate_reserved(
    slashed: &T::AccountId,
    beneficiary: &T::AccountId,
    value: Self::Balance,
    status: Status
) -> Result<Self::Balance, DispatchError>
[src]

Move the reserved balance of one account into the balance of another, according to status.

Is a no-op if:

  • the value to be moved is zero; or
  • the slashed id equal to beneficiary and the status is Reserved.

impl<T: Config<I>, I: Instance> StructuralEq for Module<T, I>[src]

impl<T: Config<I>, I: Instance> StructuralPartialEq for Module<T, I>[src]

Auto Trait Implementations

impl<T, I> RefUnwindSafe for Module<T, I> where
    I: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, I> Send for Module<T, I> where
    I: Send,
    T: Send

impl<T, I> Sync for Module<T, I> where
    I: Sync,
    T: Sync

impl<T, I> Unpin for Module<T, I> where
    I: Unpin,
    T: Unpin

impl<T, I> UnwindSafe for Module<T, I> where
    I: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IsType<T> for T[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 

pub fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Member for T where
    T: 'static + Send + Sync + Debug + Eq + PartialEq<T> + Clone
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 

impl<T, S> UniqueSaturatedInto<T> for S where
    T: Bounded,
    S: TryInto<T>, 

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,