1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
//! # Hopper
//!
//! A zero-copy Solana program framework. One access model, one dispatch
//! path, one set of safety rules. Unsafe is available when you need it,
//! and it is spelled `unsafe` so you can find it again.
//!
//! The goals, in priority order:
//!
//! 1. **Safety by default.** Every account byte you touch has been
//! owner-checked, signer-checked, layout-checked, and borrow-checked
//! before you see it. Unsafe is an opt-in escape hatch, never a
//! default.
//! 2. **Low-overhead performance.** Account data points directly at
//! the runtime input region. No deserialization pass, no heap
//! allocation, no hidden format machinery. If it costs compute, it
//! is because you asked for it.
//! 3. **Anchor-grade ergonomics.** `#[hopper::state]`, `#[hopper::context]`,
//! `#[hopper::program]`, and the `#[account(...)]` constraint vocabulary
//! read the same way an Anchor program reads. Porting is a rename,
//! not a rewrite.
//! 4. **Schema that travels.** Every layout, instruction, event, and
//! error is emitted as inspectable compile-time metadata. Off-chain
//! SDKs, IDLs, client generators, and diff tools consume it without
//! parsing source.
//!
//! ## Crate map
//!
//! - `hopper_core`: wire types, account header, segment maps, validation,
//! collections, and opt-in advanced subsystems (frame, receipt, policy,
//! diff, migration) behind feature gates.
//! - `hopper_runtime`: the runtime surface a program actually calls.
//! Context, Account, Pod, guards, CPI, migrations, log macros,
//! entrypoint bridges.
//! - `hopper_macros`: declarative macros. `hopper_layout!`, `hopper_check!`,
//! `hopper_error!`, `hopper_init!`, `hopper_close!`, `hopper_require!`,
//! `hopper_manifest!`, `hopper_segment!`, `hopper_validate!`,
//! `hopper_virtual!`, `hopper_interface!`, `hopper_assert_compatible!`,
//! `hopper_assert_fingerprint!`.
//! - `hopper_macros_proc`: proc-macro DX layer. `#[hopper::state]`,
//! `#[hopper::pod]`, `#[hopper::context]`, `#[hopper::program]`,
//! `#[hopper::migrate]`, `#[hopper::args]`, `#[hopper::error]`,
//! `#[hopper::event]`, `#[hopper::dynamic]`.
//! - `hopper_solana`: SPL Token/Mint readers, Token-2022 checks, CPI
//! guards, Pyth oracle, TWAP, Ed25519/Merkle crypto, authority rotation.
//! - `hopper_system`: System Program instruction builders.
//! - `hopper_token`: SPL Token instruction builders.
//! - `hopper_token_2022`: Token-2022 instruction builders plus extension
//! screening helpers.
//! - `hopper_associated_token`: ATA derivation and instruction builders.
//! - `hopper_schema`: layout manifests, fingerprinting, field-level
//! diffing, compatibility verdicts, Codama/IDL projections, client
//! generation.
//!
//! ## Access model
//!
//! Four reads, one rule: safety first, unsafe by name.
//!
//! ```text
//! Safe full: account.load::<T>() / account.load_mut::<T>()
//! Safe segment: ctx.segment_ref::<T>(i,o) / ctx.segment_mut::<T>(i,o)
//! Explicit raw: unsafe { account.raw_ref() / account.raw_mut() }
//! Cross-prog: account.load_cross_program::<T>()
//! ```
//!
//! `load` and `segment_ref` are the defaults. `raw_ref` is the escape
//! hatch. `load_cross_program` is the Hopper-specific verb for reading
//! an account owned by another program (foreign-ownership checked at
//! the type level).
//!
//! ## Quick start
//!
//! Declare a layout, declare a context, ship a handler.
//!
//! ```ignore
//! use hopper::prelude::*;
//! use hopper::hopper_layout;
//!
//! hopper_layout! {
//! pub struct Vault, disc = 1, version = 1 {
//! authority: [u8; 32] = 32,
//! mint: [u8; 32] = 32,
//! balance: WireU64 = 8,
//! bump: u8 = 1,
//! }
//! }
//! ```
//!
//! That is it. `Vault` is now a zero-copy layout with a 16-byte Hopper
//! header, a segment map, a schema export for the manifest, and a
//! `load::<Vault>()` accessor on every `AccountView`. No derives, no
//! Borsh, no writeback pass.
// ── Hopper Lang modules ──────────────────────────────────────────────
// Re-export crates
pub use hopper_associated_token;
pub use hopper_core;
pub use hopper_runtime;
pub use hopper_schema;
pub use hopper_solana;
pub use hopper_system;
pub use hopper_token;
pub use hopper_token_2022;
/// Optional Metaplex Token Metadata builders. Behind `--features metaplex`.
/// Reach for this via `hopper::hopper_metaplex::CreateMetadataAccountV3`,
/// `CreateMasterEditionV3`, `UpdateMetadataAccountV2`, plus the
/// `metadata_pda` / `master_edition_pda` PDA helpers.
pub use hopper_metaplex;
/// Small utilities. Re-exported at the crate root so `use hopper::utils::hint::likely;`
/// just works.
pub use utils;
// Re-export macros at the crate root
pub use hopper_dispatch;
pub use ;
// Audit I4: schema-epoch migration chain composition. `#[macro_export]`
// macros are always anchored at the defining crate's root, so the
// user-facing path `hopper::layout_migrations!` requires an explicit
// re-export here.
pub use layout_migrations;
/// Destructuring sugar for raw-dispatch handlers.
///
/// Replaces the common pattern:
///
/// ```ignore
/// let [user, vault, system_program, ..] = accounts else {
/// return Err(ProgramError::NotEnoughAccountKeys);
/// };
/// ```
///
/// with the tighter form:
///
/// ```ignore
/// hopper_load!(accounts => [user, vault, system_program]);
/// ```
///
/// The bindings are plain `&AccountView` references (not owned values),
/// matching the destructuring pattern. A trailing `..` is accepted and
/// discards any extra accounts. The macro bails with
/// `ProgramError::NotEnoughAccountKeys` when the slice is too short,
/// mirroring Hopper's existing idiom.
///
/// Use this in the raw-dispatch authoring style (no `#[hopper::context]`).
/// The proc-macro context already binds accounts by name, so this is only
/// useful when you are working with `&[AccountView]` directly - typically
/// inside `fn process_instruction(_, accounts: &[AccountView], _)` before
/// routing to per-variant handlers.
///
/// ## Examples
///
/// ```ignore
/// fn process_deposit(
/// program_id: &Address,
/// accounts: &[AccountView],
/// data: &[u8],
/// ) -> ProgramResult {
/// hopper_load!(accounts => [user, vault, system_program]);
/// user.require_signer()?;
/// vault.require_writable()?;
/// // ... rest of handler ...
/// Ok(())
/// }
/// ```
///
/// With a trailing rest pattern (accept more accounts, ignore them):
///
/// ```ignore
/// hopper_load!(accounts => [user, vault, ..]);
/// ```
///
/// The trailing `..` is redundant with the default behaviour (the macro
/// always accepts more accounts than declared) but is supported for
/// stylistic parity with the native Rust slice pattern.
// Ergonomic guard macros (the "winning architecture" design's
// Jiminy-replacement safety layer). All are `#[macro_export]` from
// hopper_runtime and are re-exported here so programs see them at
// the top-level `hopper::*` path without needing to reach through
// `hopper_runtime::`.
pub use ;
// Optional proc macro re-exports (enabled with `proc-macros` feature)
pub use ;
// Private re-export for generated code to reference runtime types