Trait API

Source
pub trait API {
    // Required methods
    fn transfer<C: Context>(
        ctx: &C,
        to: Address,
        amount: &BaseUnits,
        hook: MessageEventHookInvocation,
    ) -> Result<(), Error>;
    fn withdraw<C: Context>(
        ctx: &C,
        from: Address,
        amount: &BaseUnits,
        hook: MessageEventHookInvocation,
    ) -> Result<(), Error>;
    fn escrow<C: Context>(
        ctx: &C,
        to: Address,
        amount: &BaseUnits,
        hook: MessageEventHookInvocation,
    ) -> Result<(), Error>;
    fn reclaim_escrow<C: Context>(
        ctx: &C,
        from: Address,
        amount: u128,
        hook: MessageEventHookInvocation,
    ) -> Result<(), Error>;
    fn consensus_denomination() -> Result<Denomination, Error>;
    fn ensure_compatible_tx_signer() -> Result<(), Error>;
    fn account<C: Context>(
        ctx: &C,
        addr: Address,
    ) -> Result<ConsensusAccount, Error>;
    fn delegation<C: Context>(
        ctx: &C,
        delegator_addr: Address,
        escrow_addr: Address,
    ) -> Result<ConsensusDelegation, Error>;
    fn amount_from_consensus<C: Context>(
        ctx: &C,
        amount: u128,
    ) -> Result<u128, Error>;
    fn amount_to_consensus<C: Context>(
        ctx: &C,
        amount: u128,
    ) -> Result<u128, Error>;
    fn height_for_epoch<C: Context>(
        ctx: &C,
        epoch: EpochTime,
    ) -> Result<u64, Error>;
    fn round_roots<C: Context>(
        ctx: &C,
        runtime_id: Namespace,
        round: u64,
    ) -> Result<Option<RoundRoots>, Error>;
}
Expand description

Interface that can be called from other modules.

Required Methods§

Source

fn transfer<C: Context>( ctx: &C, to: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>

Transfer an amount from the runtime account.

Source

fn withdraw<C: Context>( ctx: &C, from: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>

Withdraw an amount into the runtime account.

Source

fn escrow<C: Context>( ctx: &C, to: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>

Escrow an amount of the runtime account funds.

Source

fn reclaim_escrow<C: Context>( ctx: &C, from: Address, amount: u128, hook: MessageEventHookInvocation, ) -> Result<(), Error>

Reclaim an amount of runtime staked shares.

Source

fn consensus_denomination() -> Result<Denomination, Error>

Returns consensus token denomination.

Source

fn ensure_compatible_tx_signer() -> Result<(), Error>

Ensures transaction signer is consensus compatible.

Source

fn account<C: Context>( ctx: &C, addr: Address, ) -> Result<ConsensusAccount, Error>

Query consensus account info.

Source

fn delegation<C: Context>( ctx: &C, delegator_addr: Address, escrow_addr: Address, ) -> Result<ConsensusDelegation, Error>

Query consensus delegation info.

Source

fn amount_from_consensus<C: Context>( ctx: &C, amount: u128, ) -> Result<u128, Error>

Convert runtime amount to consensus amount, scaling as needed.

Source

fn amount_to_consensus<C: Context>(ctx: &C, amount: u128) -> Result<u128, Error>

Convert consensus amount to runtime amount, scaling as needed.

Source

fn height_for_epoch<C: Context>(ctx: &C, epoch: EpochTime) -> Result<u64, Error>

Determine consensus height corresponding to the given epoch transition. This query may be expensive in case the epoch is far back.

Source

fn round_roots<C: Context>( ctx: &C, runtime_id: Namespace, round: u64, ) -> Result<Option<RoundRoots>, Error>

Round roots return the round roots for the given runtime ID and round.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§