Skip to main content

hopper_context

Attribute Macro hopper_context 

Source
#[hopper_context]
Expand description

Generate typed context accessors with segment-level borrow tracking.

Each field annotated with #[account(mut(field1, field2))] gets accessor methods that:

  1. Look up the segment by const offset (no string matching)
  2. Register a segment borrow in the registry
  3. Return a typed reference via pointer cast

§Example

#[hopper_context]
pub struct Deposit {
    #[account(signer, mut)]
    pub depositor: AccountView,

    #[account(mut(balance))]
    pub vault: Vault,
}

// Generated:
// impl<'a> Deposit<'a> {
//     pub fn vault_balance_mut(&mut self) -> Result<RefMut<WireU64>, ProgramError> { ... }
// }