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.
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.