Skip to main content

Crate jiminy_core

Crate jiminy_core 

Source
Expand description

§jiminy-core

Account layout, validation, math, PDA, and all the zero-copy primitives your pinocchio program needs before it touches a token.

This is the systems layer. Everything here works with raw AccountView bytes and has zero dependencies beyond pinocchio itself. If your program never calls SPL Token, this crate is all you need.

use jiminy_core::prelude::*;

§Modules

Module
accountHeader, reader, writer, cursor, lifecycle, pod, overlay, collection, list, bits
abiAlignment-1 LE field types (LeU64, LeBool, …) and borrow-splitting refs
checkValidation checks, asserts, PDA derivation & verification
compatOptional solana-zero-copy integration (feature: solana-zero-copy)
instructionTransaction introspection (sysvar Instructions)
interfaceCross-program ABI interfaces (jiminy_interface!)
mathChecked arithmetic, BPS, scaling
sysvarClock & Rent sysvar readers
stateState machine transition checks
timeDeadline, cooldown, staleness checks
eventZero-alloc event emission via sol_log_data
programsWell-known program IDs (feature: programs)

§Macros

All macros are declarative (macro_rules!). No proc macros.

Macro
require!if !cond { return Err(e) } – the universal guard
require_keys_eq!Two addresses must match
check_accounts_unique!Pairwise uniqueness for any N accounts
error_codes!Define numbered error codes without a proc macro
instruction_dispatch!Byte-tag instruction routing
jiminy_interface!Read-only interface for foreign program accounts
impl_pod!Batch unsafe impl Pod
segmented_layout!Fixed prefix + dynamic segments for variable-length accounts

§What does NOT belong here

Token/mint readers, Token-2022 screening, CPI guards, Ed25519, Merkle, oracles, AMM math, lending, staking, vesting – see jiminy-solana, jiminy-finance, and other domain crates.

Re-exports§

pub use pinocchio;

Modules§

abi
Jiminy ABI field primitives — alignment-1 wire types.
account
Account-centric types: header, zero-copy IO, lifecycle, POD, iteration.
check
Account and instruction validation checks.
compat
Compatibility modules for optional external crate integrations.
event
Zero-alloc event emission via sol_log_data.
instruction
Unified instruction access via Sysvar Instructions.
interface
Cross-program ABI interface for read-only foreign account access.
math
prelude
Convenience re-exports for the common jiminy-core usage pattern.
programs
state
State machine transition checks.
sysvar
Zero-copy sysvar readers.
time
Time and deadline constraint checks for DeFi programs.

Macros§

check_account
Composable account constraint macro.
check_account_strict
Strict account validation. Like check_account! but requires owner, disc, and layout_id as the first three arguments. Forgetting any of them is a compile error.
check_accounts_unique
Verify that all passed accounts have unique addresses.
close_account
Close a Jiminy account: transfer lamports and write close sentinel.
derive_ata_const
Derive an ATA address at compile time. Requires known bump.
derive_pda
Derive a PDA with a known bump. Cheap (~100 CU, no curve check).
derive_pda_const
Derive a PDA at compile time. Requires const seeds and bump.
emit
Emit byte slices as a structured event log entry.
error_codes
Define numbered program error codes that map to ProgramError::Custom.
find_pda
Find a PDA and return (Address, u8) with the canonical bump.
impl_pod
Implement Pod for a list of types in one shot.
init_account
Initialize a Jiminy account: CPI CreateAccount, zero-init, write header.
instruction_dispatch
Route instruction data to handler functions based on a single-byte tag.
jiminy_interface
Declare a read-only interface for a foreign program’s account layout.
require
Require a boolean condition: return $err (converted via Into) if false.
require_accounts_ne
Require two accounts to have different addresses.
require_eq
Require a == b for scalar types.
require_flag
Require bit n to be set in $byte, else return $err.
require_gt
Require a > b.
require_gte
Require a >= b.
require_keys_eq
Require two Address values to be equal.
require_keys_neq
Require two Address values to be different.
require_lt
Require a < b.
require_lte
Require a <= b.
require_neq
Require a != b for scalar types.
require_pda
Derive a PDA from seeds, verify the account matches, and return the bump.
segmented_layout
Declare a segmented zero-copy account layout.
zero_copy_layout
Declare a zero-copy account layout with typed field accessors.

Structs§

AccountView
Wrapper struct for a RuntimeAccount.
Address
The address of a Solana account.

Enums§

ProgramError
Reasons the program may fail

Type Aliases§

ProgramResult