salvus.flow.acta.canonical
salvus.flow.acta.canonical salvus flow acta canonical Canonical JSON encoding for stable digests.
Keys and strings are NFC-normalized, and keys are sorted. Tuples become
lists; list order and None values are preserved. Floats use Python’s
shortest round-trip representation, with negative zero normalized to zero.
Non-string keys and non-finite floats are rejected. Pydantic fields equal
to their defaults are omitted.
Functions
canonical_digest()
canonical_digest()def canonical_digest(value: Any) -> str: ...Return the content digest of value’s canonical JSON form.
Parameters
valueAny — Seecanonicalize.
Returns str — A 64-character lowercase hex digest.
canonical_json()
canonical_json()def canonical_json(value: Any) -> str: ...Render value as canonical JSON text.
Parameters
valueAny — Seecanonicalize.
Returns str — The canonical JSON string: sorted keys, no whitespace, no
NaN/Infinity tokens.canonicalize()
canonicalize()def canonicalize(value: Any) -> Any: ...Convert a value recursively into its canonical JSON-able form.
Parameters
valueAny — A JSON-primitive value, tuple/list thereof, mapping, or frozen Pydantic model. Nested structures are canonicalized recursively.
Returns Any — A structure built only from
dict, list, str, int, float, bool, and None, suitable for json.dumps with sort_keys=True.lossless_json()
lossless_json()def lossless_json(value: Any) -> str: ...Encode JSON data without changing strings, zeros, or mapping order.
Parameters
valueAny — An already JSON-compatible value or encoded field tree.
Returns str — Compact JSON preserving the represented values.