macro_rules! init_account {
($payer:expr, $account:expr, $program_id:expr, $Layout:ty) => { ... };
}Expand description
Initialize a Jiminy account: CPI CreateAccount, zero-init, write header.
Owns the full creation path so developers cannot forget zero_init or
layout_id. Returns Ok(()) after creating a fully-initialized account
with a valid 16-byte Jiminy header and zero-filled body.
Follow with Layout::load_checked_mut() to get a mutable overlay
for setting field values.
Note: Requires pinocchio_system in scope. This macro is re-exported
by the root jiminy crate which provides it automatically.
ⓘ
init_account!(payer, account, program_id, Vault)?;
// Now set fields via overlay:
let mut data = account.try_borrow_mut()?;
let vault = Vault::overlay_mut(&mut data)?;
vault.balance = 0;
vault.authority = *authority;Expands to:
rent_exempt_min(Layout::LEN)for lamports- CPI
CreateAccountwith correct space and owner zero_initthe full data slicewrite_headerwith disc + version + layout_id