Skip to main content

Module lazy

Module lazy 

Source
Expand description

Runtime-typed lazy account parsing.

The substrate’s hopper_native::LazyContext defers account parsing until a handler requests an account. This module wraps that context with Hopper runtime AccountView, Address, and ProgramError types. The wrapper delegates parsing to the substrate; it does not copy account data.

ⓘ
hopper::lazy_entrypoint!(process);

fn process(ctx: &mut hopper::prelude::LazyContext) -> ProgramResult {
    let payer = ctx.next_signer()?;          // runtime AccountView
    let vault = ctx.next_writable()?;
    match ctx.instruction_data().first() {
        Some(0) => ping(),
        _ => Err(ProgramError::InvalidInstructionData),
    }
}

Programs that want native substrate types can use the substrate-level hopper_lazy_entrypoint! macro directly.

Structs§

LazyContext
Runtime-typed view over a native lazy parsing context.