Expand description
§jiminy-core
Account layout, validation, math, PDA, and all the zero-copy primitives your Hopper program needs before it touches a token.
This is the systems layer. Everything here works with raw AccountView
bytes and has zero dependencies beyond hopper-runtime itself. If your program
never calls SPL Token, this crate is all you need.
ⓘ
use jiminy_core::prelude::*;§Modules
| Module | |
|---|---|
account | Header, reader, writer, cursor, lifecycle, pod, overlay, collection, list, bits |
abi | Alignment-1 LE field types (LeU64, LeBool, …) and borrow-splitting refs |
check | Validation checks, asserts, PDA derivation & verification |
compat | Optional solana-zero-copy integration (feature: solana-zero-copy) |
instruction | Transaction introspection (sysvar Instructions) |
interface | Cross-program ABI interfaces (jiminy_interface!) |
math | Checked arithmetic, BPS, scaling |
field | Typed field descriptors for named zero-copy offsets |
packed | Reserved bytes and extension-region helpers |
sysvar | Clock & Rent sysvar readers |
state | State machine transition checks |
state_utils | State hygiene helpers for layout lifecycle work |
time | Deadline, cooldown, staleness checks |
event | Zero-alloc event emission via sol_log_data |
programs | Well-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 owned or borrowed Address operands must match |
require_keys_neq! | Two owned or borrowed Address operands must differ |
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 |
assert_legacy_layout! | Validate existing non-Jiminy account ABIs without adding a header |
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 hopper_runtime;pub use field::*;pub use packed::*;pub use state_utils::*;
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. - field
- Typed field descriptors for Jiminy layouts.
- instruction
- Unified instruction access via Sysvar Instructions.
- interface
- Cross-program ABI interface for read-only foreign account access.
- math
- packed
- Packed-layout helpers for forward-compatible state.
- prelude
- Convenience re-exports for the common jiminy-core usage pattern.
- programs
- state
- State machine transition checks.
- state_
utils - State hygiene helpers for zero-copy lifecycle management.
- sysvar
- Zero-copy sysvar readers.
- time
- Time and deadline constraint checks for DeFi programs.
Macros§
- assert_
legacy_ layout - Assert that an existing non-Jiminy account layout is safe to overlay.
- check_
account - Composable account constraint macro.
- check_
account_ strict - Strict account validation. Like
check_account!but requiresowner,disc, andlayout_idas 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
constseeds 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
Podfor 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 viaInto) if false. - require_
accounts_ ne - Require two accounts to have different addresses.
- require_
eq - Require
a == bfor scalar types. - require_
flag - Require bit
nto be set in$byte, else return$err. - require_
gt - Require
a > b. - require_
gte - Require
a >= b. - require_
keys_ eq - Require two
Addressvalues to be equal. - require_
keys_ neq - Require two
Addressvalues to be different. - require_
lt - Require
a < b. - require_
lte - Require
a <= b. - require_
neq - Require
a != bfor scalar types. - require_
pda - Derive a PDA from seeds, verify the account matches, and return the bump.
- segmented_
interface - Declare a read-only interface for a foreign program’s segmented account.
- segmented_
layout - Declare a segmented zero-copy account layout.
- zero_
copy_ layout - Declare a zero-copy account layout with typed field accessors.
Structs§
- Account
View - Zero-copy view over a Solana account.
- Address
- A Solana address (public key): 32 bytes, transparent layout.
Enums§
- Program
Error - Errors that a Solana program can return.
Type Aliases§
- Program
Result - Result type returned by all Hopper instruction handlers.