Skip to content

Commit

Permalink
Unresolved TxOut pretty printing bug resolution (#387)
Browse files Browse the repository at this point in the history
Fixing txout printing resolution bug
  • Loading branch information
Mathieu Montin authored Mar 21, 2024
1 parent c064a94 commit fbfa4e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
27 changes: 9 additions & 18 deletions src/Cooked/Pretty/Cooked.hs
Original file line number Diff line number Diff line change
Expand Up @@ -334,27 +334,18 @@ prettyTxSkelInReference opts skelContext txOutRef = do
)

getReferenceScriptDoc :: (IsAbstractOutput output, ToScriptHash (ReferenceScriptType output)) => PrettyCookedOpts -> output -> Maybe DocCooked
getReferenceScriptDoc opts output =
case output ^. outputReferenceScriptL of
Nothing -> Nothing
Just refScript ->
Just $
"Reference script hash:"
<+> prettyHash (pcOptHashes opts) (toHash . toScriptHash $ refScript)
getReferenceScriptDoc opts output = prettyReferenceScriptHash opts . toScriptHash <$> output ^. outputReferenceScriptL

lookupOutput ::
SkelContext ->
Pl.TxOutRef ->
Maybe (Pl.TxOut, TxSkelOutDatum)
lookupOutput :: SkelContext -> Pl.TxOutRef -> Maybe (Pl.TxOut, TxSkelOutDatum)
lookupOutput (SkelContext managedTxOuts managedTxSkelOutDatums) txOutRef = do
output <- Map.lookup txOutRef managedTxOuts
datumHash <-
case outputOutputDatum output of
Pl.OutputDatum datum -> return (Pl.datumHash datum)
Pl.OutputDatumHash datumHash -> return datumHash
Pl.NoOutputDatum -> Nothing
txSkelOutDatum <- Map.lookup datumHash managedTxSkelOutDatums
return (output, txSkelOutDatum)
return
( output,
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
)

-- | 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
2 changes: 1 addition & 1 deletion src/Cooked/Pretty/Options.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}

-- | Pretty-printing options for 'prettyCookedOpt' and their default values.
module Cooked.Pretty.Options
( PrettyCookedOpts (..),
PrettyCookedHashOpts (..),
PCOptTxOutRefs (..),
hashNamesFromList,
defaultHashNames,
)
where

Expand Down

0 comments on commit fbfa4e9

Please sign in to comment.