Skip to main content

Canonical records

The presschain-models repository provides Rust records that are useful at API, projection and integration boundaries. They translate lower-level protocol state into named fields while preserving the identifiers and relationships applications need.

CapsuleRecord

Current fields include:
The model serializes field names in camelCase for JSON. A projection can use this record to render a Capsule card or article verification page without forcing the client to decode every raw contract tuple.

EvidenceRecord

Current evidence projections include:
The nested tally contains support, reject and participation counts plus status and finalization state.

ContributorRecord

Current contributor projections include:
Keep share_bps as an integer. Convert to a display percentage only at the UI boundary.

Metadata envelope versus projection record

Canonical Capsule metadata is publication input. It is normalized and hashed before or during publication. CapsuleRecord is a read model that may include convenient title, summary, canonical URL and cover fields. Do not attempt to reproduce an on-chain metadata hash by serializing a transformed projection. Use the canonical metadata envelope and canonicalization rules.

JavaScript serialization

Large EVM integers and 256-bit identifiers require careful JSON handling. A practical boundary representation is:
Use exact hex strings for bytes32 identifiers and decimal strings for integer quantities that can exceed the safe JavaScript number range.

Add projection provenance

When an API must be auditable, attach chain coordinates beside the semantic record:
This keeps domain models clean while still allowing consumers to trace a projected fact back to network state.

Compatibility discipline

Treat changes to canonical records as versioned API changes when they affect serialized shape or meaning. Adding a convenience UI field and changing the semantics of status are not equivalent changes. A strong projection layer makes those distinctions explicit instead of depending on every client to infer them.