Trait oasis_runtime_sdk::modules::consensus::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.

Object Safety§

This trait is not object safe.

Implementors§