# jiminy-core
Account layout, zero-copy IO, validation, PDA, sysvar access, lifecycle, math, time checks. Everything your pinocchio program needs before it touches a token.
`#![no_std]` / `no_alloc` / BPF-safe
```toml
[dependencies]
jiminy-core = "0.16"
```
## What's in here
| `account` | 16-byte header, `AccountReader`, `AccountWriter`, `SliceCursor`, lifecycle (close/realloc), pod, `zero_copy_layout!`, `segmented_layout!`, `ZeroCopySlice`, segments, list, bitflags |
| `check` | Owner / signer / key checks, PDA derivation and verification |
| `instruction` | Transaction introspection via the Instructions sysvar |
| `math` | Checked arithmetic, BPS helpers, scaling with u128 intermediates |
| `sysvar` | Clock and Rent readers (syscall-based + account-based) |
| `state` | State-machine transition validation |
| `time` | Deadline, cooldown, slot-staleness checks |
| `abi` | Alignment-1 LE field types (`LeU64`, `LeBool`, …) and borrow-splitting refs (`FieldRef`, `FieldMut`) |
| `interface` | Cross-program ABI interfaces (`jiminy_interface!`) |
| `event` | Zero-alloc event emission via `sol_log_data` |
| `programs` | Well-known program IDs *(feature-gated)* |
## New in 0.16
- `VerifiedAccount<T>` / `VerifiedAccountMut<T>`: type-safe wrappers returned by `load()` / `load_mut()` / `load_foreign()`. Infallible `get()` / `get_mut()` access after construction.
- `strict` feature: production hardening mode. Disables `validate_version_compatible()` at compile time.
- `jiminy_interface!` version parameter: `version = N` to match foreign layouts at any version.
- Compile-time alignment assertion in `jiminy_interface!`: prevents over-aligned types.
- `init_segments_with_capacity()`: capacity-aware segment init for push/remove workflows.
- Push overlap protection: `segment_push` checks next segment offset to prevent overwrites.
- Exact size enforcement: Tiers 1 and 2 require `data.len() == expected_size`.
- `load_mut()` backed by `RefMut`: eliminates mutable aliasing UB.
## New in 0.15
- `abi` module: 9 alignment-safe LE wire types (`LeU64`, `LeI128`, `LeBool`, etc.). `#[repr(transparent)]` over `[u8; N]`. Safe on all targets, zero overhead on SBF.
- `FieldRef` / `FieldMut`: typed views over field byte slices. Borrow-split account data without `unsafe`.
- `split_fields` / `split_fields_mut`: generated by `zero_copy_layout!`. Decompose account data into independent per-field slices.
- Const field offsets: `zero_copy_layout!` now emits `pub const header: usize = 0`, etc.
- `jiminy_interface!` macro: read-only ABI interface for foreign program accounts. Same `LAYOUT_ID`, no crate dependency.
- `segmented_layout!` macro: variable-length accounts with multiple dynamic segments. `SegmentDescriptor` (8 bytes), `SegmentSlice`, `SegmentSliceMut`, auto-computed offsets, bounds-checked validation.
<details>
<summary>New in 0.14</summary>
- `zero_copy_layout!` macro: declare `#[repr(C)]` structs that overlay directly onto account bytes. No proc macros.
- `ZeroCopySlice` / `ZeroCopySliceMut`: length-prefixed arrays in account data. Zero-copy iteration, indexing, mutation.
- `pod_read<T>()`: alignment-safe owned copy via `read_unaligned`. Works everywhere.
- `clock_timestamp()`, `clock_slot()`, `clock_epoch()`: syscall-based sysvar access. No account slot needed.
- `rent_lamports_per_byte_year()`: same, for Rent.
</details>
## Usage
```rust,ignore
use jiminy_core::prelude::*;
let reader = AccountReader::new_checked(data, EXPECTED_DISC, EXPECTED_VER)?;
let owner = reader.pubkey_at(0)?;
let amount = reader.u64_at(32)?;
```
`programs` feature is on by default. `log` feature adds `sol_log` wrappers.
## About
Built by [MoonManQuark](https://x.com/moonmanquark) / [Bluefoot Labs](https://github.com/BluefootLabs).
Donations: `solanadevdao.sol` (`F42ZovBoRJZU4av5MiESVwJWnEx8ZQVFkc1RM29zMxNT`)
## License
Apache-2.0