Home / Input Output / cardano-api
Nov 01, 2-3 PM (0)
Nov 01, 3-4 PM (0)
Nov 01, 4-5 PM (0)
Nov 01, 5-6 PM (0)
Nov 01, 6-7 PM (0)
Nov 01, 7-8 PM (0)
Nov 01, 8-9 PM (0)
Nov 01, 9-10 PM (0)
Nov 01, 10-11 PM (0)
Nov 01, 11-12 AM (0)
Nov 02, 12-1 AM (0)
Nov 02, 1-2 AM (0)
Nov 02, 2-3 AM (0)
Nov 02, 3-4 AM (0)
Nov 02, 4-5 AM (0)
Nov 02, 5-6 AM (0)
Nov 02, 6-7 AM (0)
Nov 02, 7-8 AM (0)
Nov 02, 8-9 AM (0)
Nov 02, 9-10 AM (0)
Nov 02, 10-11 AM (0)
Nov 02, 11-12 PM (0)
Nov 02, 12-1 PM (0)
Nov 02, 1-2 PM (0)
Nov 02, 2-3 PM (0)
Nov 02, 3-4 PM (0)
Nov 02, 4-5 PM (0)
Nov 02, 5-6 PM (0)
Nov 02, 6-7 PM (0)
Nov 02, 7-8 PM (0)
Nov 02, 8-9 PM (0)
Nov 02, 9-10 PM (0)
Nov 02, 10-11 PM (0)
Nov 02, 11-12 AM (0)
Nov 03, 12-1 AM (0)
Nov 03, 1-2 AM (0)
Nov 03, 2-3 AM (0)
Nov 03, 3-4 AM (0)
Nov 03, 4-5 AM (0)
Nov 03, 5-6 AM (0)
Nov 03, 6-7 AM (0)
Nov 03, 7-8 AM (0)
Nov 03, 8-9 AM (0)
Nov 03, 9-10 AM (0)
Nov 03, 10-11 AM (0)
Nov 03, 11-12 PM (0)
Nov 03, 12-1 PM (0)
Nov 03, 1-2 PM (2)
Nov 03, 2-3 PM (0)
Nov 03, 3-4 PM (0)
Nov 03, 4-5 PM (0)
Nov 03, 5-6 PM (1)
Nov 03, 6-7 PM (2)
Nov 03, 7-8 PM (0)
Nov 03, 8-9 PM (0)
Nov 03, 9-10 PM (0)
Nov 03, 10-11 PM (0)
Nov 03, 11-12 AM (0)
Nov 04, 12-1 AM (0)
Nov 04, 1-2 AM (0)
Nov 04, 2-3 AM (0)
Nov 04, 3-4 AM (0)
Nov 04, 4-5 AM (0)
Nov 04, 5-6 AM (0)
Nov 04, 6-7 AM (1)
Nov 04, 7-8 AM (1)
Nov 04, 8-9 AM (3)
Nov 04, 9-10 AM (1)
Nov 04, 10-11 AM (0)
Nov 04, 11-12 PM (0)
Nov 04, 12-1 PM (0)
Nov 04, 1-2 PM (0)
Nov 04, 2-3 PM (0)
Nov 04, 3-4 PM (0)
Nov 04, 4-5 PM (0)
Nov 04, 5-6 PM (0)
Nov 04, 6-7 PM (0)
Nov 04, 7-8 PM (0)
Nov 04, 8-9 PM (0)
Nov 04, 9-10 PM (0)
Nov 04, 10-11 PM (0)
Nov 04, 11-12 AM (0)
Nov 05, 12-1 AM (0)
Nov 05, 1-2 AM (0)
Nov 05, 2-3 AM (0)
Nov 05, 3-4 AM (0)
Nov 05, 4-5 AM (0)
Nov 05, 5-6 AM (0)
Nov 05, 6-7 AM (0)
Nov 05, 7-8 AM (0)
Nov 05, 8-9 AM (0)
Nov 05, 9-10 AM (1)
Nov 05, 10-11 AM (1)
Nov 05, 11-12 PM (1)
Nov 05, 12-1 PM (4)
Nov 05, 1-2 PM (0)
Nov 05, 2-3 PM (1)
Nov 05, 3-4 PM (0)
Nov 05, 4-5 PM (1)
Nov 05, 5-6 PM (0)
Nov 05, 6-7 PM (0)
Nov 05, 7-8 PM (1)
Nov 05, 8-9 PM (0)
Nov 05, 9-10 PM (0)
Nov 05, 10-11 PM (0)
Nov 05, 11-12 AM (0)
Nov 06, 12-1 AM (0)
Nov 06, 1-2 AM (0)
Nov 06, 2-3 AM (0)
Nov 06, 3-4 AM (0)
Nov 06, 4-5 AM (0)
Nov 06, 5-6 AM (0)
Nov 06, 6-7 AM (0)
Nov 06, 7-8 AM (0)
Nov 06, 8-9 AM (0)
Nov 06, 9-10 AM (0)
Nov 06, 10-11 AM (0)
Nov 06, 11-12 PM (0)
Nov 06, 12-1 PM (1)
Nov 06, 1-2 PM (1)
Nov 06, 2-3 PM (0)
Nov 06, 3-4 PM (0)
Nov 06, 4-5 PM (0)
Nov 06, 5-6 PM (0)
Nov 06, 6-7 PM (0)
Nov 06, 7-8 PM (0)
Nov 06, 8-9 PM (0)
Nov 06, 9-10 PM (0)
Nov 06, 10-11 PM (0)
Nov 06, 11-12 AM (0)
Nov 07, 12-1 AM (0)
Nov 07, 1-2 AM (0)
Nov 07, 2-3 AM (0)
Nov 07, 3-4 AM (0)
Nov 07, 4-5 AM (0)
Nov 07, 5-6 AM (0)
Nov 07, 6-7 AM (0)
Nov 07, 7-8 AM (0)
Nov 07, 8-9 AM (0)
Nov 07, 9-10 AM (0)
Nov 07, 10-11 AM (0)
Nov 07, 11-12 PM (0)
Nov 07, 12-1 PM (8)
Nov 07, 1-2 PM (2)
Nov 07, 2-3 PM (0)
Nov 07, 3-4 PM (0)
Nov 07, 4-5 PM (3)
Nov 07, 5-6 PM (0)
Nov 07, 6-7 PM (0)
Nov 07, 7-8 PM (0)
Nov 07, 8-9 PM (2)
Nov 07, 9-10 PM (0)
Nov 07, 10-11 PM (0)
Nov 07, 11-12 AM (0)
Nov 08, 12-1 AM (0)
Nov 08, 1-2 AM (0)
Nov 08, 2-3 AM (0)
Nov 08, 3-4 AM (0)
Nov 08, 4-5 AM (0)
Nov 08, 5-6 AM (0)
Nov 08, 6-7 AM (0)
Nov 08, 7-8 AM (0)
Nov 08, 8-9 AM (0)
Nov 08, 9-10 AM (0)
Nov 08, 10-11 AM (0)
Nov 08, 11-12 PM (0)
Nov 08, 12-1 PM (0)
Nov 08, 1-2 PM (0)
Nov 08, 2-3 PM (0)
38 commits this week Nov 01, 2025 - Nov 08, 2025
docs: document remaining duplication in CtxUTxO FromJSON instance
Adds inline documentation noting that the CtxUTxO instance still contains
~60 lines of duplicated code in the Babbage/Conway/Dijkstra cases that
could potentially be refactored using a similar approach to the CtxTx
instance refactoring.

The comment includes:
- NOTE: Identifies the specific lines containing duplication
- POTENTIAL REFACTORING: Suggests how it could be addressed (similar to
  parseInlineDatum helper in CtxTx)
- BLOCKER: Documents the key difference that must be preserved - CtxUTxO's
  alonzoTxOutParser doesn't handle supplemental datums, unlike CtxTx

This serves as documentation for future maintainers who may want to
complete the refactoring, while explaining why it wasn't done in this PR.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
docs: add comprehensive inline documentation for TxOut JSON parsing refactoring
This commit adds detailed inline documentation to explain the design decisions,
assumptions, and potential issues in the refactored TxOut JSON parsing code.

Key documentation areas:

1. parseBabbageOnwardsTxOut:
   - MOTIVATION: Explains this eliminates ~100 lines of duplication
   - DESIGN: Documents the two-phase parsing strategy (Alonzo + Babbage reconciliation)
   - ASSUMPTION: Notes BabbageEraOnwards covers exactly three eras

2. parseInlineDatum:
   - CRITICAL DISTINCTION: Explains why Babbage uses scriptDataJsonToHashable
     vs Conway+ using scriptDataFromJson (CBOR encoding preservation requirement)
   - VALIDATION: Documents hash verification logic
   - POTENTIAL ISSUE: Warns about wildcard pattern assumption

3. reconcileDatums:
   - BACKWARDS COMPATIBILITY: Lists the three valid JSON formats accepted
   - ERROR HANDLING: Explains conflicting datum detection and error messages
   - EXHAUSTIVENESS: Documents how direct GADT matching enables compiler verification
     when new eras are added to BabbageEraOnwards

4. eraName helper:
   - Documents switch from ShelleyBasedEra to direct BabbageEraOnwards matching
   - Explains benefit: compiler enforces exhaustiveness, preventing incomplete updates

This documentation will help future maintainers understand the design rationale
and be aware of assumptions that need revisiting when the protocol evolves.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
refactor(api): extract Babbage/Conway/Dijkstra parsing into unified helper
Creates parseBabbageOnwardsTxOut helper function to eliminate the final
source of duplication in the FromJSON instance. The three era cases
(Babbage, Conway, Dijkstra) now each call this single helper function.

This completes the refactoring by:
- Reducing the FromJSON instance by ~10 more lines
- Making the code structure clearer with simple era-based dispatch
- Consolidating all Babbage+ era parsing logic in one place
- Maintaining full backwards compatibility with all tests passing

The main case expression now clearly shows the parsing strategy for
each era, with complex logic extracted into well-named helper functions.
refactor(api): extract inline datum parsing into helper function
Eliminates ~50 lines of code duplication by extracting the repeated
inline datum parsing logic from Babbage/Conway/Dijkstra cases into a
single parseInlineDatum helper function.

The refactored helper:
- Parses both inlineDatumhash and inlineDatum fields
- Validates that the datum matches its hash
- Handles era-specific parsing differences between Babbage
  (scriptDataJsonToHashable) and Conway/Dijkstra (scriptDataFromJson)
- Maintains identical behavior with all existing tests passing

This consolidation improves maintainability by ensuring consistent
error handling and validation across all Babbage+ eras.
refactor(api): unify reconcileBabbage and reconcileConway functions
Replaces two nearly-identical datum reconciliation functions with a
single reconcileDatums function that works for all Babbage+ eras,
eliminating ~40 lines of duplicated code.

The unified function:
- Works with BabbageEraOnwards constraint (covering Babbage, Conway, Dijkstra)
- Uses era witness to construct appropriate ReferenceScript types
- Generates era-specific error messages dynamically
- Handles conflicting Alonzo-style and Babbage-style datums

All tests pass, confirming behavioral equivalence and backwards
compatibility.
test(api): add comprehensive JSON tests for TxOut instances
Implements extensive test coverage for the ToJSON and FromJSON instances
of TxOut across all eras and contexts, ensuring robust JSON serialization
and deserialization behavior.

Test modules added:
- Test.Cardano.Api.TxOut.Gen: Specialized generators for TxOut with specific
  datum types (no datum, datum hash, supplemental, inline) and invalid JSON
  scenarios for error testing
- Test.Cardano.Api.TxOut.Helpers: Test utilities including JSON field
  assertions, parse failure validators, and datum equality checks
- Test.Cardano.Api.TxOut.Json: Main test module organizing all test suites
- Test.Cardano.Api.TxOut.JsonRoundtrip: Roundtrip property tests for all
  eras (Shelley through Conway) in both CtxTx and CtxUTxO contexts
- Test.Cardano.Api.TxOut.JsonEdgeCases: Edge case tests for supplemental
  datum behavior, null field handling, and ToJSON output validation
- Test.Cardano.Api.TxOut.JsonErrorCases: Error case tests for conflicting
  datums, mismatched hashes, partial fields, and invalid data

Coverage highlights:
- All eras from Byron through Dijkstra (where supported)
- Both transaction contexts (CtxTx and CtxUTxO)
- All datum types including edge cases like supplemental datums
- Comprehensive error handling validation
- JSON field presence and null handling verification

This test suite ensures the TxOut JSON instances maintain backward
compatibility while properly handling the complex datum type variations
across different Cardano eras.
refactor: extract Babbage/Conway/Dijkstra parsing into unified helper
Creates parseBabbageOnwardsTxOut helper function to eliminate the final
source of duplication in the FromJSON instance. The three era cases
(Babbage, Conway, Dijkstra) now each call this single helper function.

This completes the refactoring by:
- Reducing the FromJSON instance by ~10 more lines
- Making the code structure clearer with simple era-based dispatch
- Consolidating all Babbage+ era parsing logic in one place
- Maintaining full backwards compatibility with all tests passing

The main case expression now clearly shows the parsing strategy for
each era, with complex logic extracted into well-named helper functions.
refactor: extract inline datum parsing into helper function
Eliminates ~50 lines of code duplication by extracting the repeated
inline datum parsing logic from Babbage/Conway/Dijkstra cases into a
single parseInlineDatum helper function.

The refactored helper:
- Parses both inlineDatumhash and inlineDatum fields
- Validates that the datum matches its hash
- Handles era-specific parsing differences between Babbage
  (scriptDataJsonToHashable) and Conway/Dijkstra (scriptDataFromJson)
- Maintains identical behavior with all existing tests passing

This consolidation improves maintainability by ensuring consistent
error handling and validation across all Babbage+ eras.
refactor: unify reconcileBabbage and reconcileConway functions
Replaces two nearly-identical datum reconciliation functions with a
single reconcileDatums function that works for all Babbage+ eras,
eliminating ~40 lines of duplicated code.

The unified function:
- Works with BabbageEraOnwards constraint (covering Babbage, Conway, Dijkstra)
- Uses era witness to construct appropriate ReferenceScript types
- Generates era-specific error messages dynamically
- Handles conflicting Alonzo-style and Babbage-style datums

All tests pass, confirming behavioral equivalence and backwards
compatibility.
test: add comprehensive JSON tests for TxOut instances
Implements extensive test coverage for TxOut JSON serialization across
all supported eras and contexts, ensuring correct handling of datums,
reference scripts, and edge cases.

Test modules added:
- Test.Cardano.Api.TxOut.Gen: Generators for specific datum types
- Test.Cardano.Api.TxOut.Helpers: Assertion utilities and JSON manipulation
- Test.Cardano.Api.TxOut.Json: Test suite orchestration
- Test.Cardano.Api.TxOut.JsonRoundtrip: Roundtrip property tests
- Test.Cardano.Api.TxOut.JsonEdgeCases: Edge case validation
- Test.Cardano.Api.TxOut.JsonErrorCases: Error handling tests

Coverage includes:
- All eras from Shelley through Conway (Dijkstra commented out)
- Both CtxTx and CtxUTxO contexts
- All datum types (None, Hash, Supplemental, Inline)
- Supplemental datum field ambiguity handling
- Conflicting datum field detection
- Mismatched hash validation
- Partial field error cases
- Null field handling semantics

Adds tasty-hunit dependency for unit test assertions alongside existing
property-based tests using hedgehog.