Skip to main content

Module remaining

Module remaining 

Source
Expand description

Remaining-accounts accessor with strict and passthrough modes.

The declared context validates exactly ACCOUNT_COUNT accounts. Any accounts beyond that index are “remaining”: pool participants, keeper bot recipients, arbitrary fanout destinations, remainder destinations for sweeps, and so on. Hopper exposes two ways to consume them.

§Strict mode

Default. The accessor rejects any remaining account whose address matches a previously seen account (either declared or already yielded). Protects against accidental double-spending when a caller tries to alias one slot into two different roles.

let rem = ctx.remaining_accounts();
for maybe_acc in rem.iter() {
    let acc = maybe_acc?; // errors on duplicate
    // ...
}

§Passthrough mode

Opt-in. Preserves duplicates verbatim. Use when the caller is expected to pass the same account in multiple roles (batched CPI fan-in, for example).

let rem = ctx.remaining_accounts_passthrough();

Both modes are O(n) with no heap and no syscalls. Strict mode keeps a small const-sized seen-address cache sized at 64; past that, it falls back to a linear scan of the declared slice plus the yielded-view cursor.

Structs§

RemainingAccounts
Zero-allocation remaining-accounts view.
RemainingIter
Iterator yielded by RemainingAccounts::iter.

Enums§

RemainingError
Error surface for the remaining-accounts accessor.
RemainingMode
Duplicate-handling policy for a RemainingAccounts view.

Constants§

MAX_REMAINING_ACCOUNTS
Upper bound on remaining-account iterator length. Matches Quasar’s MAX_REMAINING_ACCOUNTS so programs porting from one framework to the other see the same ceiling. Exceeding this returns an error rather than risking unbounded stack usage in the seen-address cache.

Functions§

strict
Ergonomic fall-through used by the proc-macro codegen when the user wants to just burn through remaining accounts without a mode.