Skip to content

Commit cba7b3b

Browse files
newhoggyclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 7730a6a commit cba7b3b

File tree

1 file changed

+13
-0
lines changed
  • cardano-api/src/Cardano/Api/Tx/Internal

1 file changed

+13
-0
lines changed

cardano-api/src/Cardano/Api/Tx/Internal/Output.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,19 @@ instance IsShelleyBasedEra era => FromJSON (TxOut CtxTx era) where
615615
<*> return ReferenceScriptNone
616616
(Just _dVal, Nothing) -> fail "Only datum JSON was found, this should not be possible."
617617

618+
-- NOTE: The CtxUTxO instance below still contains significant duplication in the
619+
-- Babbage/Conway/Dijkstra cases (lines ~592-666). Each case has nearly identical
620+
-- inline datum parsing logic that could be extracted into a helper similar to the
621+
-- parseInlineDatum function in the CtxTx instance above.
622+
--
623+
-- POTENTIAL REFACTORING: The inline datum parsing at lines 596-611 (Babbage),
624+
-- 621-636 (Conway), and 646-661 (Dijkstra) could be unified using a helper that
625+
-- takes a BabbageEraOnwards witness, similar to how parseInlineDatum works in CtxTx.
626+
-- This would eliminate ~60 more lines of duplication.
627+
--
628+
-- BLOCKER: The CtxUTxO alonzoTxOutParser differs from CtxTx - it doesn't handle
629+
-- supplemental datums (only datum hash, no datum value). This difference would need
630+
-- to be carefully preserved in any refactoring.
618631
instance IsShelleyBasedEra era => FromJSON (TxOut CtxUTxO era) where
619632
parseJSON = withObject "TxOut" $ \o -> do
620633
case shelleyBasedEra :: ShelleyBasedEra era of

0 commit comments

Comments
 (0)