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
Bumpsstruct for PDA bump storage - A
HopperAccountsimpl withtry_from_accounts - A static
ContextDescriptorfor schema/explain
§Account kinds
Each field specifies a kind wrapped in parentheses, with optional modifiers:
| Kind | Description | Writable | Signer |
|---|---|---|---|
(signer) | Verified signer (SignerAccount) | no | yes |
(mut signer) | Mutable + signer | yes | yes |
(account<T>) | Layout-bound HopperAccount | no | no |
(mut account<T>) | Mutable layout-bound account | yes | no |
(program) | Verified executable (ProgramRef) | no | no |
(unchecked) | No-validation passthrough | no | no |
(mut unchecked) | Mutable unchecked passthrough | yes | no |
§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(())
})