Skip to main content

Module receipt

Module receipt 

Source
Expand description

State Receipts – structured mutation summaries.

A StateReceipt captures a complete record of what happened during an instruction’s execution: which fields changed, what the before/after fingerprints were, which invariants ran, which capabilities were active, and how many CPI calls or journal appends occurred.

§Use Cases

  • Audit trails: Emit receipts as events for off-chain indexing
  • Test assertions: Verify exact mutation footprint in tests
  • Post-mutation validation: Feed receipt to invariant checks
  • Debugging: Log receipts during development
  • CLI inspection: Decode receipt bytes with hopper receipt

§Usage

// Before mutation
let mut receipt = StateReceipt::<8>::begin(
    &layout_id,
    account_data,
);

// ... mutations happen ...

// After mutation
receipt.commit(account_data);
receipt.set_invariants(true, 3);
receipt.set_policy_flags(DEPOSIT_CAPS.bits());
receipt.set_cpi_count(1);
receipt.set_journal_appends(2);

// Emit as event
emit_slices(&[&receipt.to_bytes()]);

Structs§

DecodedReceipt
Decoded receipt from wire bytes. Useful for CLI and off-chain tooling.
ReceiptExplain
Human-readable explanation of a decoded receipt.
ReceiptNarrative
An auto-generated human-readable narrative describing a mutation.
StateReceipt
A structured record of a state mutation.

Enums§

CompatImpact
Compatibility impact level encoded in a receipt.
FailureStage
Stage of instruction execution at which a failure was recorded.
NarrativeRisk
Risk level for a receipt narrative.
Phase
Instruction execution phase encoded in a receipt.

Constants§

FAILED_INVARIANT_NONE
Sentinel value for failed_invariant_idx meaning “no invariant was associated with the failure”.
MAX_RECEIPT_FIELDS
Maximum fields tracked in a receipt’s changed-field bitmask.
RECEIPT_SIZE
Receipt summary size in bytes.
RECEIPT_SIZE_LEGACY
Legacy receipt size, kept as a named constant for readers that want to quickly check if they received the shorter pre-0.2 receipt and ignore the failure-payload suffix.