Skip to content

Commit 87fc212

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 6a611d8 commit 87fc212

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
@@ -611,6 +611,19 @@ instance IsShelleyBasedEra era => FromJSON (TxOut CtxTx era) where
611611
<*> return ReferenceScriptNone
612612
(Just _dVal, Nothing) -> fail "Only datum JSON was found, this should not be possible."
613613

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

0 commit comments

Comments
 (0)