Skip to content

Commit

Permalink
other fix without redundant maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
mmontin committed Mar 21, 2024
1 parent 863ab2b commit 1bce46d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Cooked/Pretty/Cooked.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
)
Expand All @@ -328,27 +328,22 @@ prettyTxSkelInReference opts skelContext txOutRef = do
"-"
( prettyCookedOpt opts (outputValue output)
: catMaybes
[ prettyTxSkelOutDatumMaybe opts =<< txSkelOutDatum,
[ prettyTxSkelOutDatumMaybe opts txSkelOutDatum,
getReferenceScriptDoc opts output
]
)

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
Expand Down

0 comments on commit 1bce46d

Please sign in to comment.