Skip to main content

hopper_accounts

Macro hopper_accounts 

Source
macro_rules! hopper_accounts {
    (
        $(#[$attr:meta])*
        pub struct $name:ident {
            $( $field:ident : ( $($kind:tt)+ ) ),+ $(,)?
        }
    ) => { ... };
}
Expand description

Generate a typed instruction context struct with validated account parsing.

Produces:

  • The account struct itself
  • A Bumps struct for PDA bump storage
  • A HopperAccounts impl with try_from_accounts
  • A static ContextDescriptor for schema/explain

§Account kinds

Each field specifies a kind wrapped in parentheses, with optional modifiers:

KindDescriptionWritableSigner
(signer)Verified signer (SignerAccount)noyes
(mut signer)Mutable + signeryesyes
(account<T>)Layout-bound HopperAccountnono
(mut account<T>)Mutable layout-bound accountyesno
(program)Verified executable (ProgramRef)nono
(unchecked)No-validation passthroughnono
(mut unchecked)Mutable unchecked passthroughyesno

§Example

hopper_accounts! {
    pub struct Deposit {
        authority: (mut signer),
        vault: (mut account<VaultState>),
        system_program: (program),
    }
}

Then use with hopper_entry:

hopper_entry::<DepositIx, _>(program_id, accounts, data, |ctx, args| {
    let vault = ctx.accounts.vault.write()?;
    // ...
    Ok(())
})