Commit c668629
committed
refactor(api): migrate JSON instances to use Exp.IsEra constraints
Refactors JSON serialization instances for core types to use the experimental
Exp.IsEra constraint system instead of IsShelleyBasedEra/IsCardanoEra. This
unifies the constraint approach across the codebase and simplifies era-based
type class instances.
Key Changes:
- AddressInEra: Migrate ToJSON/FromJSON instances to Exp.IsEra
- ReferenceScript: Update JSON instances using Exp.convert for era witnesses
- TxOut (CtxTx/CtxUTxO): Consolidate era-specific parsing into unified handlers
- TxOutValue: Simplify FromJSON with direct era conversion
Implementation Details:
- Use Exp.useEra for obtaining era witnesses at the type level
- Convert era witnesses to required eon types (AlonzoEraOnwards, BabbageEraOnwards, etc.)
- Consolidate duplicate reconciliation logic into single reconcileDatums function
- Remove redundant era-specific pattern matching in favor of generic handlers
This refactoring maintains full backwards compatibility with existing JSON
formats while reducing code duplication and improving maintainability. The
changes prepare the codebase for easier extension to future eras by
centralizing era-handling logic.1 parent f710b2b commit c668629
File tree
4 files changed
+96
-281
lines changed- cardano-api/src/Cardano/Api
- Plutus/Internal
- Tx/Internal
4 files changed
+96
-281
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
370 | 371 | | |
371 | 372 | | |
372 | 373 | | |
373 | | - | |
374 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
375 | 378 | | |
376 | | - | |
| 379 | + | |
377 | 380 | | |
378 | | - | |
| 381 | + | |
379 | 382 | | |
380 | 383 | | |
381 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
1647 | 1648 | | |
1648 | 1649 | | |
1649 | 1650 | | |
1650 | | - | |
| 1651 | + | |
1651 | 1652 | | |
1652 | 1653 | | |
1653 | 1654 | | |
1654 | | - | |
| 1655 | + | |
1655 | 1656 | | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
| 1657 | + | |
| 1658 | + | |
1660 | 1659 | | |
1661 | 1660 | | |
1662 | 1661 | | |
| |||
0 commit comments