From 1bce46d10f9c4bda6134c377d1a9b1eba04545c1 Mon Sep 17 00:00:00 2001 From: mmontin Date: Thu, 21 Mar 2024 15:39:10 +0100 Subject: [PATCH] other fix without redundant maybe --- src/Cooked/Pretty/Cooked.hs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Cooked/Pretty/Cooked.hs b/src/Cooked/Pretty/Cooked.hs index 389a4fb9e..66dac56d7 100644 --- a/src/Cooked/Pretty/Cooked.hs +++ b/src/Cooked/Pretty/Cooked.hs @@ -314,7 +314,7 @@ prettyTxSkelIn opts skelContext (txOutRef, txSkelRedeemer) = do ( prettyCookedOpt opts (outputValue output) : catMaybes [ redeemerDoc, - prettyTxSkelOutDatumMaybe opts =<< txSkelOutDatum, + prettyTxSkelOutDatumMaybe opts txSkelOutDatum, getReferenceScriptDoc opts output ] ) @@ -328,7 +328,7 @@ prettyTxSkelInReference opts skelContext txOutRef = do "-" ( prettyCookedOpt opts (outputValue output) : catMaybes - [ prettyTxSkelOutDatumMaybe opts =<< txSkelOutDatum, + [ prettyTxSkelOutDatumMaybe opts txSkelOutDatum, getReferenceScriptDoc opts output ] ) @@ -336,19 +336,14 @@ prettyTxSkelInReference opts skelContext txOutRef = do getReferenceScriptDoc :: (IsAbstractOutput output, ToScriptHash (ReferenceScriptType output)) => PrettyCookedOpts -> output -> Maybe DocCooked getReferenceScriptDoc opts output = prettyReferenceScriptHash opts . toScriptHash <$> output ^. outputReferenceScriptL -lookupOutput :: SkelContext -> Pl.TxOutRef -> Maybe (Pl.TxOut, Maybe TxSkelOutDatum) +lookupOutput :: SkelContext -> Pl.TxOutRef -> Maybe (Pl.TxOut, TxSkelOutDatum) lookupOutput (SkelContext managedTxOuts managedTxSkelOutDatums) txOutRef = do output <- Map.lookup txOutRef managedTxOuts - return - ( output, - do - datumHash <- - case outputOutputDatum output of - Pl.OutputDatum datum -> return (Pl.datumHash datum) - Pl.OutputDatumHash datumHash -> return datumHash - Pl.NoOutputDatum -> Nothing - Map.lookup datumHash managedTxSkelOutDatums - ) + let txSkelOutDatum = case outputOutputDatum output of + Pl.OutputDatum datum -> Map.findWithDefault TxSkelOutNoDatum (Pl.datumHash datum) managedTxSkelOutDatums + Pl.OutputDatumHash datumHash -> Map.findWithDefault TxSkelOutNoDatum datumHash managedTxSkelOutDatums + Pl.NoOutputDatum -> TxSkelOutNoDatum + return (output, txSkelOutDatum) -- | Pretty-print a list of transaction skeleton options, only printing an -- option if its value is non-default. If no non-default options are in the