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§
sourcefn transfer<C: Context>(
ctx: &C,
to: Address,
amount: &BaseUnits,
hook: MessageEventHookInvocation,
) -> Result<(), Error>
fn transfer<C: Context>( ctx: &C, to: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>
Transfer an amount from the runtime account.
sourcefn withdraw<C: Context>(
ctx: &C,
from: Address,
amount: &BaseUnits,
hook: MessageEventHookInvocation,
) -> Result<(), Error>
fn withdraw<C: Context>( ctx: &C, from: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>
Withdraw an amount into the runtime account.
sourcefn escrow<C: Context>(
ctx: &C,
to: Address,
amount: &BaseUnits,
hook: MessageEventHookInvocation,
) -> Result<(), Error>
fn escrow<C: Context>( ctx: &C, to: Address, amount: &BaseUnits, hook: MessageEventHookInvocation, ) -> Result<(), Error>
Escrow an amount of the runtime account funds.
sourcefn reclaim_escrow<C: Context>(
ctx: &C,
from: Address,
amount: u128,
hook: MessageEventHookInvocation,
) -> Result<(), Error>
fn reclaim_escrow<C: Context>( ctx: &C, from: Address, amount: u128, hook: MessageEventHookInvocation, ) -> Result<(), Error>
Reclaim an amount of runtime staked shares.
sourcefn consensus_denomination() -> Result<Denomination, Error>
fn consensus_denomination() -> Result<Denomination, Error>
Returns consensus token denomination.
sourcefn ensure_compatible_tx_signer() -> Result<(), Error>
fn ensure_compatible_tx_signer() -> Result<(), Error>
Ensures transaction signer is consensus compatible.
sourcefn account<C: Context>(
ctx: &C,
addr: Address,
) -> Result<ConsensusAccount, Error>
fn account<C: Context>( ctx: &C, addr: Address, ) -> Result<ConsensusAccount, Error>
Query consensus account info.
sourcefn delegation<C: Context>(
ctx: &C,
delegator_addr: Address,
escrow_addr: Address,
) -> Result<ConsensusDelegation, Error>
fn delegation<C: Context>( ctx: &C, delegator_addr: Address, escrow_addr: Address, ) -> Result<ConsensusDelegation, Error>
Query consensus delegation info.
sourcefn amount_from_consensus<C: Context>(
ctx: &C,
amount: u128,
) -> Result<u128, Error>
fn amount_from_consensus<C: Context>( ctx: &C, amount: u128, ) -> Result<u128, Error>
Convert runtime amount to consensus amount, scaling as needed.
sourcefn amount_to_consensus<C: Context>(ctx: &C, amount: u128) -> Result<u128, Error>
fn amount_to_consensus<C: Context>(ctx: &C, amount: u128) -> Result<u128, Error>
Convert consensus amount to runtime amount, scaling as needed.
sourcefn height_for_epoch<C: Context>(ctx: &C, epoch: EpochTime) -> Result<u64, Error>
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.
sourcefn round_roots<C: Context>(
ctx: &C,
runtime_id: Namespace,
round: u64,
) -> Result<Option<RoundRoots>, Error>
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.