{-# OPTIONS_GHC -Wno-orphans #-}

-- | This module implements pretty-printing for Cooked structures such as
-- skeletons and chain state.
--
-- It contains orphaned instances of 'PrettyCooked' for Cooked datatypes. They
-- cannot be provided in "Cooked.Pretty.Class" because of dependency cycles and,
-- for ease of maintainability, we chose to centralize all pretty-printing
-- related code in submodules of "Cooked.Pretty" instead of having
-- 'PrettyCooked' instances scattered around.
--
-- Some structure require additional arguments to be pretty-printed and have
-- therefore no instances 'PrettyCooked' (for example 'TxSkel' needs some
-- 'TxSkelContext').
module Cooked.Pretty.Cooked
  ( prettyTxSkel,
    prettyBalancingWallet,
    prettySigners,
    prettyMints,
    mPrettyTxOpts,
    prettyTxSkelOut,
    prettyTxSkelOutDatumMaybe,
    prettyTxSkelIn,
    prettyTxSkelInReference,
    prettyAddressState,
    prettyPayloadGrouped,
    prettyPayload,
    prettyReferenceScriptHash,
  )
where

import Cooked.Conversion
import Cooked.MockChain.BlockChain
import Cooked.MockChain.Direct
import Cooked.MockChain.GenerateTx
import Cooked.MockChain.UtxoState
import Cooked.Output
import Cooked.Pretty.Class
import Cooked.Pretty.Common
import Cooked.Pretty.Options
import Cooked.Skeleton
import Cooked.Wallet
import Data.Default
import Data.Function (on)
import Data.List qualified as List
import Data.Map qualified as Map
import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
import Data.Set qualified as Set
import Optics.Core
import Plutus.Script.Utils.Ada qualified as Script
import Plutus.Script.Utils.Scripts qualified as Script
import Plutus.Script.Utils.Value qualified as Script
import PlutusLedgerApi.V3 qualified as Api
import Prettyprinter ((<+>))
import Prettyprinter qualified as PP

-- | The 'PrettyCooked' instance for 'TxSkelOutDatum' prints the datum it
-- contains according to its own 'PrettyCooked' instance.
instance PrettyCooked TxSkelOutDatum where
  prettyCookedOpt :: PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
prettyCookedOpt PrettyCookedOpts
_ TxSkelOutDatum
TxSkelOutNoDatum = Doc ()
forall a. Monoid a => a
mempty
  prettyCookedOpt PrettyCookedOpts
opts (TxSkelOutDatumHash a
datum) = PrettyCookedOpts -> a -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts a
datum
  prettyCookedOpt PrettyCookedOpts
opts (TxSkelOutDatum a
datum) = PrettyCookedOpts -> a -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts a
datum
  prettyCookedOpt PrettyCookedOpts
opts (TxSkelOutInlineDatum a
datum) = PrettyCookedOpts -> a -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts a
datum

instance PrettyCooked MockChainError where
  prettyCookedOpt :: PrettyCookedOpts -> MockChainError -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (MCEValidationError ValidationPhase
plutusPhase ValidationError
plutusError) =
    [Doc ()] -> Doc ()
forall ann. [Doc ann] -> Doc ann
PP.vsep [Doc ()
"Validation error " Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> ValidationPhase -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts ValidationPhase
plutusPhase, Int -> Doc () -> Doc ()
forall ann. Int -> Doc ann -> Doc ann
PP.indent Int
2 (PrettyCookedOpts -> ValidationError -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts ValidationError
plutusError)]
  -- Here we don't print the skel because we lack its context and this error is
  -- printed alongside the skeleton when a test fails
  prettyCookedOpt PrettyCookedOpts
opts (MCEUnbalanceable Wallet
balWallet Value
missingValue TxSkel
_) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Unbalanceable:"
      Doc ()
"-"
      [ PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
balWallet) Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"does not have enough funds",
        if Value
missingValue Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== Value
forall a. Monoid a => a
mempty
          then Doc ()
"Not enough funds to sustain the minimal ada of the return utxo"
          else Doc ()
"Unable to find" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Value
missingValue
      ]
  prettyCookedOpt PrettyCookedOpts
opts (MCENoSuitableCollateral Integer
fee Integer
percentage Value
colVal) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"No suitable collateral"
      Doc ()
"-"
      [ Doc ()
"Fee was" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
fee,
        Doc ()
"Percentage in params was" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
percentage,
        Doc ()
"Resulting minimal collateral value was" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Value
colVal
      ]
  prettyCookedOpt PrettyCookedOpts
_ (MCEGenerationError (ToCardanoError String
msg ToCardanoError
cardanoError)) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Transaction generation error:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg, ToCardanoError -> Doc ()
forall a ann. Pretty a => a -> Doc ann
forall ann. ToCardanoError -> Doc ann
PP.pretty ToCardanoError
cardanoError]
  prettyCookedOpt PrettyCookedOpts
_ (MCEGenerationError (GenerateTxErrorGeneral String
msg)) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Transaction generation error:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg]
  prettyCookedOpt PrettyCookedOpts
_ (MCEGenerationError (TxBodyError String
msg TxBodyError
err)) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Transaction generation error:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg, TxBodyError -> Doc ()
forall a ann. Show a => a -> Doc ann
PP.viaShow TxBodyError
err]
  prettyCookedOpt PrettyCookedOpts
opts (MCEUnknownOutRefError String
msg TxOutRef
txOutRef) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Unknown transaction output ref:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg, PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxOutRef
txOutRef]
  prettyCookedOpt PrettyCookedOpts
_ (FailWith String
msg) =
    Doc ()
"Failed with:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg
  prettyCookedOpt PrettyCookedOpts
opts (MCEUnknownValidator String
msg ValidatorHash
valHash) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Unknown validator hash:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg, Doc ()
"hash:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (ValidatorHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash ValidatorHash
valHash)]
  prettyCookedOpt PrettyCookedOpts
opts (MCEUnknownDatum String
msg DatumHash
dHash) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"Unknown datum hash:"
      Doc ()
"-"
      [String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
msg, Doc ()
"hash:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (DatumHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash DatumHash
dHash)]

instance (Show a) => PrettyCooked (a, UtxoState) where
  prettyCookedOpt :: PrettyCookedOpts -> (a, UtxoState) -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (a
res, UtxoState
state) =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      Doc ()
"End state:"
      Doc ()
"-"
      [Doc ()
"Returns:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> a -> Doc ()
forall a ann. Show a => a -> Doc ann
PP.viaShow a
res, PrettyCookedOpts -> UtxoState -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts UtxoState
state]

instance (Show a) => PrettyCooked (MockChainReturn a UtxoState) where
  prettyCookedOpt :: PrettyCookedOpts -> MockChainReturn a UtxoState -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Either MockChainError (a, UtxoState)
res, [MockChainLogEntry]
entries) =
    let mcLog :: Doc ()
mcLog = Doc ()
"📘" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"MockChain run log:" Doc ()
"⁍" (PrettyCookedOpts -> MockChainLogEntry -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (MockChainLogEntry -> Doc ()) -> [MockChainLogEntry] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [MockChainLogEntry]
entries)
        mcEndResult :: Doc ()
mcEndResult = case Either MockChainError (a, UtxoState)
res of
          Left MockChainError
err -> Doc ()
"🔴" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> MockChainError -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts MockChainError
err
          Right (a
a, UtxoState
s) -> Doc ()
"🟢" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> (a, UtxoState) -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (a
a, UtxoState
s)
     in [Doc ()] -> Doc ()
forall ann. [Doc ann] -> Doc ann
PP.vsep ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$ if PrettyCookedOpts -> Bool
pcOptPrintLog PrettyCookedOpts
opts then [Doc ()
mcLog, Doc ()
mcEndResult] else [Doc ()
mcEndResult]

-- | This pretty prints a 'MockChainLog' that usually consists of the list of
-- validated or submitted transactions. In the log, we know a transaction has
-- been validated if the 'MCLogSubmittedTxSkel' is followed by a 'MCLogNewTx'.
instance PrettyCooked MockChainLogEntry where
  prettyCookedOpt :: PrettyCookedOpts -> MockChainLogEntry -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (MCLogSubmittedTxSkel SkelContext
skelContext TxSkel
skel) = Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Submitted:" Doc ()
"-" [PrettyCookedOpts -> SkelContext -> TxSkel -> Doc ()
prettyTxSkel PrettyCookedOpts
opts SkelContext
skelContext TxSkel
skel]
  prettyCookedOpt PrettyCookedOpts
opts (MCLogAdjustedTxSkel SkelContext
skelContext TxSkel
skel Integer
fee Maybe (Set TxOutRef, Wallet)
mCollaterals) =
    let mCollateralsDoc :: Maybe [Doc ()]
mCollateralsDoc =
          ( \(Set TxOutRef
collaterals, Wallet
returnWallet) ->
              [ Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Collateral inputs:" Doc ()
"-" (PrettyCookedOpts -> SkelContext -> TxOutRef -> Doc ()
prettyCollateralIn PrettyCookedOpts
opts SkelContext
skelContext (TxOutRef -> Doc ()) -> [TxOutRef] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set TxOutRef -> [TxOutRef]
forall a. Set a -> [a]
Set.toList Set TxOutRef
collaterals),
                Doc ()
"Return collateral target:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
returnWallet)
              ]
          )
            ((Set TxOutRef, Wallet) -> [Doc ()])
-> Maybe (Set TxOutRef, Wallet) -> Maybe [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Set TxOutRef, Wallet)
mCollaterals
     in Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
          Doc ()
"Adjusted:"
          Doc ()
"-"
          ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$ [ PrettyCookedOpts -> SkelContext -> TxSkel -> Doc ()
prettyTxSkel PrettyCookedOpts
opts SkelContext
skelContext TxSkel
skel,
              Doc ()
"Fee:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Integer -> Value
Script.lovelace Integer
fee)
            ]
            [Doc ()] -> [Doc ()] -> [Doc ()]
forall a. [a] -> [a] -> [a]
++ [Doc ()] -> Maybe [Doc ()] -> [Doc ()]
forall a. a -> Maybe a -> a
fromMaybe [] Maybe [Doc ()]
mCollateralsDoc
  prettyCookedOpt PrettyCookedOpts
opts (MCLogNewTx TxId
txId) = Doc ()
"New transaction:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> TxId -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxId
txId
  prettyCookedOpt PrettyCookedOpts
opts (MCLogDiscardedUtxos Integer
n String
s) = PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"balancing utxos were discarded:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty String
s
  prettyCookedOpt PrettyCookedOpts
opts (MCLogUnusedCollaterals (Left Wallet
cWallet)) =
    Doc ()
"Specific request to fetch collateral utxos from "
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
cWallet)
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
" has been disregarded because the transaction does not require collaterals"
  prettyCookedOpt PrettyCookedOpts
opts (MCLogUnusedCollaterals (Right (Set TxOutRef -> Int
forall a. Set a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length -> Int
n))) =
    Doc ()
"Specific request to fetch collateral utxos from the given set of "
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedOpts -> Int -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Int
n
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
" elements has been disregarded because the transaction does not require collaterals"
  prettyCookedOpt PrettyCookedOpts
opts (MCLogAddedReferenceScript Redeemer
red TxOutRef
oRef ScriptHash
sHash) =
    Doc ()
"A reference script located in "
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxOutRef
oRef
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
" has been automatically associated to redeemer "
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> ( case Redeemer
red of
             Redeemer
EmptyRedeemer -> Doc ()
"Empty"
             SomeRedeemer redeemer
s -> PrettyCookedOpts -> redeemer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts redeemer
s
         )
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
" for script "
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedOpts -> ScriptHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts ScriptHash
sHash

prettyTxSkel :: PrettyCookedOpts -> SkelContext -> TxSkel -> DocCooked
prettyTxSkel :: PrettyCookedOpts -> SkelContext -> TxSkel -> Doc ()
prettyTxSkel PrettyCookedOpts
opts SkelContext
skelContext (TxSkel Set TxLabel
lbl TxOpts
txopts TxSkelMints
mints [Wallet]
signers SlotRange
validityRange Map TxOutRef TxSkelRedeemer
ins Set TxOutRef
insReference [TxSkelOut]
outs [TxSkelProposal]
proposals TxSkelWithdrawals
withdrawals) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Transaction skeleton:"
    Doc ()
"-"
    ( [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
        [ Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Labels:" Doc ()
"-" (PrettyCookedOpts -> TxLabel -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxLabel -> Doc ()) -> [TxLabel] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set TxLabel -> [TxLabel]
forall a. Set a -> [a]
Set.toList Set TxLabel
lbl),
          PrettyCookedOpts -> TxOpts -> Maybe (Doc ())
mPrettyTxOpts PrettyCookedOpts
opts TxOpts
txopts,
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Mints:" Doc ()
"-" (PrettyCookedOpts
-> (Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)
-> Doc ()
prettyMints PrettyCookedOpts
opts ((Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)
 -> Doc ())
-> [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)]
-> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxSkelMints
-> [(Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)]
txSkelMintsToList TxSkelMints
mints),
          Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ Doc ()
"Validity interval:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> SlotRange -> Doc ()
forall a ann. Pretty a => a -> Doc ann
forall ann. SlotRange -> Doc ann
PP.pretty SlotRange
validityRange,
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Signers:" Doc ()
"-" (PrettyCookedOpts -> TxOpts -> [Wallet] -> [Doc ()]
prettySigners PrettyCookedOpts
opts TxOpts
txopts [Wallet]
signers),
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Inputs:" Doc ()
"-" (PrettyCookedOpts
-> SkelContext -> (TxOutRef, TxSkelRedeemer) -> Doc ()
prettyTxSkelIn PrettyCookedOpts
opts SkelContext
skelContext ((TxOutRef, TxSkelRedeemer) -> Doc ())
-> [(TxOutRef, TxSkelRedeemer)] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map TxOutRef TxSkelRedeemer -> [(TxOutRef, TxSkelRedeemer)]
forall k a. Map k a -> [(k, a)]
Map.toList Map TxOutRef TxSkelRedeemer
ins),
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Reference inputs:" Doc ()
"-" ((TxOutRef -> Maybe (Doc ())) -> [TxOutRef] -> [Doc ()]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (PrettyCookedOpts -> SkelContext -> TxOutRef -> Maybe (Doc ())
prettyTxSkelInReference PrettyCookedOpts
opts SkelContext
skelContext) ([TxOutRef] -> [Doc ()]) -> [TxOutRef] -> [Doc ()]
forall a b. (a -> b) -> a -> b
$ Set TxOutRef -> [TxOutRef]
forall a. Set a -> [a]
Set.toList Set TxOutRef
insReference),
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Outputs:" Doc ()
"-" (PrettyCookedOpts -> TxSkelOut -> Doc ()
prettyTxSkelOut PrettyCookedOpts
opts (TxSkelOut -> Doc ()) -> [TxSkelOut] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TxSkelOut]
outs),
          Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Proposals:" Doc ()
"-" (PrettyCookedOpts -> TxSkelProposal -> Doc ()
prettyTxSkelProposal PrettyCookedOpts
opts (TxSkelProposal -> Doc ()) -> [TxSkelProposal] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TxSkelProposal]
proposals),
          PrettyCookedOpts -> TxSkelWithdrawals -> Maybe (Doc ())
prettyWithdrawals PrettyCookedOpts
opts TxSkelWithdrawals
withdrawals
        ]
    )

prettyWithdrawals :: PrettyCookedOpts -> TxSkelWithdrawals -> Maybe DocCooked
prettyWithdrawals :: PrettyCookedOpts -> TxSkelWithdrawals -> Maybe (Doc ())
prettyWithdrawals PrettyCookedOpts
pcOpts TxSkelWithdrawals
withdrawals =
  Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Withdrawals:" Doc ()
"-" ([Doc ()] -> Maybe (Doc ())) -> [Doc ()] -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ (Either (Versioned Script) PubKeyHash, (TxSkelRedeemer, Ada))
-> Doc ()
prettyWithdrawal ((Either (Versioned Script) PubKeyHash, (TxSkelRedeemer, Ada))
 -> Doc ())
-> [(Either (Versioned Script) PubKeyHash, (TxSkelRedeemer, Ada))]
-> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TxSkelWithdrawals
-> [(Either (Versioned Script) PubKeyHash, (TxSkelRedeemer, Ada))]
forall k a. Map k a -> [(k, a)]
Map.toList TxSkelWithdrawals
withdrawals
  where
    prettyWithdrawal :: (Either (Script.Versioned Script.Script) Api.PubKeyHash, (TxSkelRedeemer, Script.Ada)) -> DocCooked
    prettyWithdrawal :: (Either (Versioned Script) PubKeyHash, (TxSkelRedeemer, Ada))
-> Doc ()
prettyWithdrawal (Either (Versioned Script) PubKeyHash
cred, (TxSkelRedeemer
red, Ada
ada)) =
      Doc () -> [Doc ()] -> Doc ()
prettyItemizeNoTitle Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$
        ( case Either (Versioned Script) PubKeyHash
cred of
            Left Versioned Script
script -> PrettyCookedOpts -> Versioned Script -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
pcOpts Versioned Script
script Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: PrettyCookedOpts -> TxSkelRedeemer -> [Doc ()]
prettyTxSkelRedeemer PrettyCookedOpts
pcOpts TxSkelRedeemer
red
            Right PubKeyHash
pkh -> [PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
pcOpts PubKeyHash
pkh]
        )
          [Doc ()] -> [Doc ()] -> [Doc ()]
forall a. [a] -> [a] -> [a]
++ [PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
pcOpts (Ada -> Value
forall a. ToValue a => a -> Value
toValue Ada
ada)]

prettyTxParameterChange :: PrettyCookedOpts -> TxParameterChange -> DocCooked
prettyTxParameterChange :: PrettyCookedOpts -> TxParameterChange -> Doc ()
prettyTxParameterChange PrettyCookedOpts
opts (FeePerByte Integer
n) = Doc ()
"Fee per byte:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (FeeFixed Integer
n) = Doc ()
"Fee fixed:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (MaxBlockBodySize Integer
n) = Doc ()
"Max block body size:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (MaxTxSize Integer
n) = Doc ()
"Max transaction size:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (MaxBlockHeaderSize Integer
n) = Doc ()
"Max block header size:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (KeyDeposit Integer
n) = Doc ()
"Key deposit:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (PoolDeposit Integer
n) = Doc ()
"Pool deposit:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (PoolRetirementMaxEpoch Integer
n) = Doc ()
"Pool retirement max epoch:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (PoolNumber Integer
n) = Doc ()
"Pool number:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (PoolInfluence Rational
q) = Doc ()
"Pool influence:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
q
prettyTxParameterChange PrettyCookedOpts
opts (MonetaryExpansion Rational
q) = Doc ()
"Monetary expansion:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
q
prettyTxParameterChange PrettyCookedOpts
opts (TreasuryCut Rational
q) = Doc ()
"Treasury cut:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
q
prettyTxParameterChange PrettyCookedOpts
opts (MinPoolCost Integer
n) = Doc ()
"Min pool cost:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (CoinsPerUTxOByte Integer
n) = Doc ()
"Lovelace per utxo byte:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
_opts (CostModels [Integer]
_pv1 [Integer]
_pv2 [Integer]
_pv3) = Doc ()
"Cost models (unsupported)"
prettyTxParameterChange PrettyCookedOpts
opts (Prices Rational
q Rational
r) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Prices:"
    Doc ()
"-"
    [ Doc ()
"Memory cost:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
q,
      Doc ()
"Step cost:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
r
    ]
prettyTxParameterChange PrettyCookedOpts
opts (MaxTxExUnits Integer
n Integer
m) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Max transaction execution units:"
    Doc ()
"-"
    [ Doc ()
"Max memory:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n,
      Doc ()
"Max steps:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
m
    ]
prettyTxParameterChange PrettyCookedOpts
opts (MaxBlockExUnits Integer
n Integer
m) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Max block execution units:"
    Doc ()
"-"
    [ Doc ()
"Max memory:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n,
      Doc ()
"Max steps:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
m
    ]
prettyTxParameterChange PrettyCookedOpts
opts (MaxValSize Integer
n) = Doc ()
"Max value size:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (CollateralPercentage Integer
n) = Doc ()
"Collateral percentage:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (MaxCollateralInputs Integer
n) = Doc ()
"Max number of collateral inputs:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (PoolVotingThresholds Rational
a Rational
b Rational
c Rational
d Rational
e) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Pool voting thresholds:"
    Doc ()
"-"
    [ Doc ()
"Motion no confidence:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
a,
      Doc ()
"Committee normal:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
b,
      Doc ()
"Committee no confidence:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
c,
      Doc ()
"Hard fork:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
d,
      Doc ()
"Security group:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
e
    ]
prettyTxParameterChange PrettyCookedOpts
opts (DRepVotingThresholds Rational
a Rational
b Rational
c Rational
d Rational
e Rational
f Rational
g Rational
h Rational
i Rational
j) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"DRep voting thresholds:"
    Doc ()
"-"
    [ Doc ()
"Motion no confidence:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
a,
      Doc ()
"Committee normal:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
b,
      Doc ()
"Committee no confidence:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
c,
      Doc ()
"Update constitution:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
d,
      Doc ()
"Hard fork initialization:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
e,
      Doc ()
"Network group:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
f,
      Doc ()
"Economic group:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
g,
      Doc ()
"Technical group:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
h,
      Doc ()
"Governance group:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
i,
      Doc ()
"Treasury withdrawal:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Rational
j
    ]
prettyTxParameterChange PrettyCookedOpts
opts (CommitteeMinSize Integer
n) = Doc ()
"Committee min size:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (CommitteeMaxTermLength Integer
n) = Doc ()
"Committee max term length:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (GovActionLifetime Integer
n) = Doc ()
"Governance action life time:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (GovActionDeposit Integer
n) = Doc ()
"Governance action deposit:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (DRepRegistrationDeposit Integer
n) = Doc ()
"DRep registration deposit:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n
prettyTxParameterChange PrettyCookedOpts
opts (DRepActivity Integer
n) = Doc ()
"DRep activity:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
n

prettyTxSkelRedeemer :: PrettyCookedOpts -> TxSkelRedeemer -> [DocCooked]
prettyTxSkelRedeemer :: PrettyCookedOpts -> TxSkelRedeemer -> [Doc ()]
prettyTxSkelRedeemer PrettyCookedOpts
opts (TxSkelRedeemer Redeemer
red Maybe TxOutRef
mRefScript) =
  [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
    [ case Redeemer
red of
        Redeemer
EmptyRedeemer -> Maybe (Doc ())
forall a. Maybe a
Nothing
        SomeRedeemer redeemer
s -> Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ Doc ()
"Redeemer" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> redeemer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts redeemer
s,
      (Doc ()
"Reference script at:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+>) (Doc () -> Doc ()) -> (TxOutRef -> Doc ()) -> TxOutRef -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOutRef -> Doc ()) -> Maybe TxOutRef -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe TxOutRef
mRefScript
    ]

prettyTxSkelProposal :: PrettyCookedOpts -> TxSkelProposal -> DocCooked
prettyTxSkelProposal :: PrettyCookedOpts -> TxSkelProposal -> Doc ()
prettyTxSkelProposal PrettyCookedOpts
opts TxSkelProposal {Maybe String
Maybe (Versioned Script, TxSkelRedeemer)
Address
TxGovAction
txSkelProposalAddress :: Address
txSkelProposalAction :: TxGovAction
txSkelProposalWitness :: Maybe (Versioned Script, TxSkelRedeemer)
txSkelProposalAnchor :: Maybe String
txSkelProposalAddress :: TxSkelProposal -> Address
txSkelProposalAction :: TxSkelProposal -> TxGovAction
txSkelProposalWitness :: TxSkelProposal -> Maybe (Versioned Script, TxSkelRedeemer)
txSkelProposalAnchor :: TxSkelProposal -> Maybe String
..} =
  Doc () -> [Doc ()] -> Doc ()
prettyItemizeNoTitle Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$
    [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
      [ Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ Doc ()
"Governance action:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> TxGovAction -> Doc ()
prettyTxSkelGovAction PrettyCookedOpts
opts TxGovAction
txSkelProposalAction,
        Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ Doc ()
"Return address:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Address -> Doc ()
forall a. PrettyCooked a => a -> Doc ()
prettyCooked Address
txSkelProposalAddress,
        ( \(Versioned Script
script, TxSkelRedeemer
redeemer) ->
            Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
              Doc ()
"Witness:"
              Doc ()
"-"
              (PrettyCookedOpts -> Versioned Script -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Versioned Script
script Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: PrettyCookedOpts -> TxSkelRedeemer -> [Doc ()]
prettyTxSkelRedeemer PrettyCookedOpts
opts TxSkelRedeemer
redeemer)
        )
          ((Versioned Script, TxSkelRedeemer) -> Doc ())
-> Maybe (Versioned Script, TxSkelRedeemer) -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Versioned Script, TxSkelRedeemer)
txSkelProposalWitness,
        (Doc ()
"Anchor:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+>) (Doc () -> Doc ()) -> (String -> Doc ()) -> String -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty (String -> Doc ()) -> Maybe String -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String
txSkelProposalAnchor
      ]

prettyTxSkelGovAction :: PrettyCookedOpts -> TxGovAction -> DocCooked
prettyTxSkelGovAction :: PrettyCookedOpts -> TxGovAction -> Doc ()
prettyTxSkelGovAction PrettyCookedOpts
opts (TxGovActionParameterChange [TxParameterChange]
params) = Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Parameter changes:" Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$ PrettyCookedOpts -> TxParameterChange -> Doc ()
prettyTxParameterChange PrettyCookedOpts
opts (TxParameterChange -> Doc ()) -> [TxParameterChange] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TxParameterChange]
params
prettyTxSkelGovAction PrettyCookedOpts
opts (TxGovActionHardForkInitiation (Api.ProtocolVersion Integer
major Integer
minor)) =
  Doc ()
"Protocol version:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"(" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
major Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"," Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
minor Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
")"
prettyTxSkelGovAction PrettyCookedOpts
opts (TxGovActionTreasuryWithdrawals Map Credential Lovelace
withdrawals) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Withdrawals:" Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$
    (\(Credential
cred, Lovelace
lv) -> PrettyCookedOpts -> Credential -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Credential
cred Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"|" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Value -> Doc ()
forall a. PrettyCooked a => a -> Doc ()
prettyCooked (Lovelace -> Value
forall a. ToValue a => a -> Value
toValue Lovelace
lv)) ((Credential, Lovelace) -> Doc ())
-> [(Credential, Lovelace)] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Credential Lovelace -> [(Credential, Lovelace)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Credential Lovelace
withdrawals
prettyTxSkelGovAction PrettyCookedOpts
_ TxGovAction
TxGovActionNoConfidence = Doc ()
"No confidence"
prettyTxSkelGovAction PrettyCookedOpts
opts (TxGovActionUpdateCommittee [ColdCommitteeCredential]
toRemoveCreds Map ColdCommitteeCredential Integer
toAddCreds Rational
quorum) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    Doc ()
"Updates in committee:"
    Doc ()
"-"
    [ Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Credentials to remove:" Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$
        (\(Api.ColdCommitteeCredential Credential
cred) -> PrettyCookedOpts -> Credential -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Credential
cred) (ColdCommitteeCredential -> Doc ())
-> [ColdCommitteeCredential] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ColdCommitteeCredential]
toRemoveCreds,
      Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Credentials to add:" Doc ()
"-" ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall a b. (a -> b) -> a -> b
$
        (\(Api.ColdCommitteeCredential Credential
cred, Integer
i) -> PrettyCookedOpts -> Credential -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Credential
cred Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"->" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
i) ((ColdCommitteeCredential, Integer) -> Doc ())
-> [(ColdCommitteeCredential, Integer)] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map ColdCommitteeCredential Integer
-> [(ColdCommitteeCredential, Integer)]
forall k a. Map k a -> [(k, a)]
Map.toList Map ColdCommitteeCredential Integer
toAddCreds,
      Doc ()
"Quorum:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Rational -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Rational -> Rational
Api.toGHC Rational
quorum)
    ]
prettyTxSkelGovAction PrettyCookedOpts
opts (TxGovActionNewConstitution (Api.Constitution Maybe ScriptHash
mScriptHash)) = case Maybe ScriptHash
mScriptHash of
  Maybe ScriptHash
Nothing -> Doc ()
"Empty new constitution"
  Just ScriptHash
sHash -> Doc ()
"New constitution:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> ScriptHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts ScriptHash
sHash

-- | Same as the 'PrettyCooked' instance for 'Wallet' with a suffix mentioning
-- this is the balancing wallet
prettyBalancingWallet :: PrettyCookedOpts -> Wallet -> DocCooked
prettyBalancingWallet :: PrettyCookedOpts -> Wallet -> Doc ()
prettyBalancingWallet PrettyCookedOpts
opts Wallet
w =
  PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
w) Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"[Balancing]"

-- | Prints a list of pubkeys with a flag next to the balancing wallet
prettySigners :: PrettyCookedOpts -> TxOpts -> [Wallet] -> [DocCooked]
prettySigners :: PrettyCookedOpts -> TxOpts -> [Wallet] -> [Doc ()]
prettySigners PrettyCookedOpts
opts TxOpts {txOptBalancingPolicy :: TxOpts -> BalancingPolicy
txOptBalancingPolicy = BalancingPolicy
DoNotBalance} [Wallet]
signers = PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (PubKeyHash -> Doc ())
-> (Wallet -> PubKeyHash) -> Wallet -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Wallet -> PubKeyHash
walletPKHash (Wallet -> Doc ()) -> [Wallet] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Wallet]
signers
prettySigners PrettyCookedOpts
opts TxOpts {txOptBalancingPolicy :: TxOpts -> BalancingPolicy
txOptBalancingPolicy = BalancingPolicy
BalanceWithFirstSigner} (Wallet
firstSigner : [Wallet]
signers) =
  PrettyCookedOpts -> Wallet -> Doc ()
prettyBalancingWallet PrettyCookedOpts
opts Wallet
firstSigner Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: (PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (PubKeyHash -> Doc ())
-> (Wallet -> PubKeyHash) -> Wallet -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Wallet -> PubKeyHash
walletPKHash (Wallet -> Doc ()) -> [Wallet] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Wallet]
signers)
prettySigners PrettyCookedOpts
opts TxOpts {txOptBalancingPolicy :: TxOpts -> BalancingPolicy
txOptBalancingPolicy = BalanceWith Wallet
balancingWallet} [Wallet]
signers =
  [Wallet] -> [Doc ()]
aux [Wallet]
signers
  where
    aux :: [Wallet] -> [DocCooked]
    aux :: [Wallet] -> [Doc ()]
aux [] = []
    aux (Wallet
s : [Wallet]
ss)
      | Wallet
s Wallet -> Wallet -> Bool
forall a. Eq a => a -> a -> Bool
== Wallet
balancingWallet = PrettyCookedOpts -> Wallet -> Doc ()
prettyBalancingWallet PrettyCookedOpts
opts Wallet
balancingWallet Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: [Wallet] -> [Doc ()]
aux [Wallet]
ss
      | Bool
otherwise = PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
s) Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: [Wallet] -> [Doc ()]
aux [Wallet]
ss
-- The following case should never happen for real transactions
prettySigners PrettyCookedOpts
_ TxOpts
_ [] = []

-- | Prints a minting specification
--
-- Examples without and with redeemer
-- > #abcdef "Foo": 500
-- > #123456 "Bar": 1000
--     - Redeemer: red
--     - Reference script at: txOutRef
prettyMints :: PrettyCookedOpts -> (Script.Versioned Script.MintingPolicy, TxSkelRedeemer, Api.TokenName, Integer) -> DocCooked
prettyMints :: PrettyCookedOpts
-> (Versioned MintingPolicy, TxSkelRedeemer, TokenName, Integer)
-> Doc ()
prettyMints PrettyCookedOpts
opts (Versioned MintingPolicy
policy, TxSkelRedeemer
redeemer, TokenName
tokenName, Integer
amount) =
  let docTitle :: Doc ()
docTitle = PrettyCookedOpts -> Versioned MintingPolicy -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Versioned MintingPolicy
policy Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> TokenName -> Doc ()
forall a ann. Show a => a -> Doc ann
PP.viaShow TokenName
tokenName Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
":" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ()
forall a ann. Show a => a -> Doc ann
PP.viaShow Integer
amount
   in case PrettyCookedOpts -> TxSkelRedeemer -> [Doc ()]
prettyTxSkelRedeemer PrettyCookedOpts
opts TxSkelRedeemer
redeemer of
        [] -> Doc ()
docTitle
        [Doc ()]
l -> Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
docTitle Doc ()
"-" [Doc ()]
l

prettyTxSkelOut :: PrettyCookedOpts -> TxSkelOut -> DocCooked
prettyTxSkelOut :: PrettyCookedOpts -> TxSkelOut -> Doc ()
prettyTxSkelOut PrettyCookedOpts
opts (Pays o
output) =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    (Doc ()
"Pays to" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Address -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (o -> Address
forall o.
(IsAbstractOutput o, ToCredential (OwnerType o)) =>
o -> Address
outputAddress o
output))
    Doc ()
"-"
    ( PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (o -> Value
forall o. (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value
outputValue o
output)
        Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
          [ case o -> OutputDatum
forall o.
(IsAbstractOutput o, ToOutputDatum (DatumType o)) =>
o -> OutputDatum
outputOutputDatum o
output of
              Api.OutputDatum Datum
_datum ->
                Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
                  Doc ()
"Datum (inlined):"
                    Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> (Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (Doc () -> Doc ())
-> (TxSkelOutDatum -> Doc ()) -> TxSkelOutDatum -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts)
                      (o
output o -> Optic' A_Lens NoIx o TxSkelOutDatum -> TxSkelOutDatum
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Lens' o (DatumType o)
Optic' A_Lens NoIx o TxSkelOutDatum
forall o. IsAbstractOutput o => Lens' o (DatumType o)
outputDatumL)
              Api.OutputDatumHash DatumHash
dHash ->
                Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
                  Doc ()
"Datum (hashed)"
                    Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"("
                    Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (DatumHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash DatumHash
dHash)
                    Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"):"
                    Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> (Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (Doc () -> Doc ())
-> (TxSkelOutDatum -> Doc ()) -> TxSkelOutDatum -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts)
                      (o
output o -> Optic' A_Lens NoIx o TxSkelOutDatum -> TxSkelOutDatum
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Lens' o (DatumType o)
Optic' A_Lens NoIx o TxSkelOutDatum
forall o. IsAbstractOutput o => Lens' o (DatumType o)
outputDatumL)
              OutputDatum
Api.NoOutputDatum -> Maybe (Doc ())
forall a. Maybe a
Nothing,
            PrettyCookedOpts -> o -> Maybe (Doc ())
forall output.
(IsAbstractOutput output,
 ToScriptHash (ReferenceScriptType output)) =>
PrettyCookedOpts -> output -> Maybe (Doc ())
getReferenceScriptDoc PrettyCookedOpts
opts o
output
          ]
    )

prettyTxSkelOutDatumMaybe :: PrettyCookedOpts -> TxSkelOutDatum -> Maybe DocCooked
prettyTxSkelOutDatumMaybe :: PrettyCookedOpts -> TxSkelOutDatum -> Maybe (Doc ())
prettyTxSkelOutDatumMaybe PrettyCookedOpts
_ TxSkelOutDatum
TxSkelOutNoDatum = Maybe (Doc ())
forall a. Maybe a
Nothing
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts txSkelOutDatum :: TxSkelOutDatum
txSkelOutDatum@(TxSkelOutInlineDatum a
_) =
  Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
    Doc ()
"Datum (inlined):"
      Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxSkelOutDatum
txSkelOutDatum)
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts txSkelOutDatum :: TxSkelOutDatum
txSkelOutDatum@(TxSkelOutDatumHash a
dat) =
  Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
    Doc ()
"Datum (hashed)"
      Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"("
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (DatumHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash (DatumHash -> BuiltinByteString) -> DatumHash -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ Datum -> DatumHash
Script.datumHash (Datum -> DatumHash) -> Datum -> DatumHash
forall a b. (a -> b) -> a -> b
$ BuiltinData -> Datum
Api.Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ a -> BuiltinData
forall a. ToData a => a -> BuiltinData
Api.toBuiltinData a
dat)
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"):"
      Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxSkelOutDatum
txSkelOutDatum)
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts txSkelOutDatum :: TxSkelOutDatum
txSkelOutDatum@(TxSkelOutDatum a
dat) =
  Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
    Doc ()
"Datum (hashed)"
      Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"("
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (DatumHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash (DatumHash -> BuiltinByteString) -> DatumHash -> BuiltinByteString
forall a b. (a -> b) -> a -> b
$ Datum -> DatumHash
Script.datumHash (Datum -> DatumHash) -> Datum -> DatumHash
forall a b. (a -> b) -> a -> b
$ BuiltinData -> Datum
Api.Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ a -> BuiltinData
forall a. ToData a => a -> BuiltinData
Api.toBuiltinData a
dat)
      Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> Doc ()
"):"
      Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (PrettyCookedOpts -> TxSkelOutDatum -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxSkelOutDatum
txSkelOutDatum)

-- | Resolves a "TxOutRef" from a given context, builds a doc cooked for its
-- address and value, and also builds a possibly empty list for its datum and
-- reference script when they exist.
utxoToPartsAsDocCooked :: PrettyCookedOpts -> SkelContext -> Api.TxOutRef -> Maybe (DocCooked, DocCooked, [DocCooked])
utxoToPartsAsDocCooked :: PrettyCookedOpts
-> SkelContext -> TxOutRef -> Maybe (Doc (), Doc (), [Doc ()])
utxoToPartsAsDocCooked PrettyCookedOpts
opts SkelContext
skelContext TxOutRef
txOutRef =
  ( \(TxOut
output, TxSkelOutDatum
txSkelOutDatum) ->
      ( PrettyCookedOpts -> Address -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOut -> Address
forall o.
(IsAbstractOutput o, ToCredential (OwnerType o)) =>
o -> Address
outputAddress TxOut
output),
        PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOut -> Value
forall o. (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value
outputValue TxOut
output),
        [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
          [ PrettyCookedOpts -> TxSkelOutDatum -> Maybe (Doc ())
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts TxSkelOutDatum
txSkelOutDatum,
            PrettyCookedOpts -> TxOut -> Maybe (Doc ())
forall output.
(IsAbstractOutput output,
 ToScriptHash (ReferenceScriptType output)) =>
PrettyCookedOpts -> output -> Maybe (Doc ())
getReferenceScriptDoc PrettyCookedOpts
opts TxOut
output
          ]
      )
  )
    ((TxOut, TxSkelOutDatum) -> (Doc (), Doc (), [Doc ()]))
-> Maybe (TxOut, TxSkelOutDatum)
-> Maybe (Doc (), Doc (), [Doc ()])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SkelContext -> TxOutRef -> Maybe (TxOut, TxSkelOutDatum)
lookupOutput SkelContext
skelContext TxOutRef
txOutRef

prettyCollateralIn :: PrettyCookedOpts -> SkelContext -> Api.TxOutRef -> DocCooked
prettyCollateralIn :: PrettyCookedOpts -> SkelContext -> TxOutRef -> Doc ()
prettyCollateralIn PrettyCookedOpts
opts SkelContext
skelContext TxOutRef
txOutRef =
  case PrettyCookedOpts
-> SkelContext -> TxOutRef -> Maybe (Doc (), Doc (), [Doc ()])
utxoToPartsAsDocCooked PrettyCookedOpts
opts SkelContext
skelContext TxOutRef
txOutRef of
    Maybe (Doc (), Doc (), [Doc ()])
Nothing -> PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxOutRef
txOutRef Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"(non resolved)"
    Just (Doc ()
addressDoc, Doc ()
valueDoc, [Doc ()]
otherDocs) -> Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize (Doc ()
"Belonging to" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
addressDoc) Doc ()
"-" (Doc ()
valueDoc Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: [Doc ()]
otherDocs)

prettyTxSkelIn :: PrettyCookedOpts -> SkelContext -> (Api.TxOutRef, TxSkelRedeemer) -> DocCooked
prettyTxSkelIn :: PrettyCookedOpts
-> SkelContext -> (TxOutRef, TxSkelRedeemer) -> Doc ()
prettyTxSkelIn PrettyCookedOpts
opts SkelContext
skelContext (TxOutRef
txOutRef, TxSkelRedeemer
txSkelRedeemer) =
  case PrettyCookedOpts
-> SkelContext -> TxOutRef -> Maybe (Doc (), Doc (), [Doc ()])
utxoToPartsAsDocCooked PrettyCookedOpts
opts SkelContext
skelContext TxOutRef
txOutRef of
    Maybe (Doc (), Doc (), [Doc ()])
Nothing -> Doc ()
"Spends" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxOutRef
txOutRef Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"(non resolved)"
    Just (Doc ()
addressDoc, Doc ()
valueDoc, [Doc ()]
otherDocs) ->
      Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize (Doc ()
"Spends from" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
addressDoc) Doc ()
"-" (Doc ()
valueDoc Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: PrettyCookedOpts -> TxSkelRedeemer -> [Doc ()]
prettyTxSkelRedeemer PrettyCookedOpts
opts TxSkelRedeemer
txSkelRedeemer [Doc ()] -> [Doc ()] -> [Doc ()]
forall a. Semigroup a => a -> a -> a
<> [Doc ()]
otherDocs)

prettyTxSkelInReference :: PrettyCookedOpts -> SkelContext -> Api.TxOutRef -> Maybe DocCooked
prettyTxSkelInReference :: PrettyCookedOpts -> SkelContext -> TxOutRef -> Maybe (Doc ())
prettyTxSkelInReference PrettyCookedOpts
opts SkelContext
skelContext TxOutRef
txOutRef = do
  (TxOut
output, TxSkelOutDatum
txSkelOutDatum) <- SkelContext -> TxOutRef -> Maybe (TxOut, TxSkelOutDatum)
lookupOutput SkelContext
skelContext TxOutRef
txOutRef
  Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
      (Doc ()
"References output from" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Address -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOut -> Address
forall o.
(IsAbstractOutput o, ToCredential (OwnerType o)) =>
o -> Address
outputAddress TxOut
output))
      Doc ()
"-"
      ( PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOut -> Value
forall o. (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value
outputValue TxOut
output)
          Doc () -> [Doc ()] -> [Doc ()]
forall a. a -> [a] -> [a]
: [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
            [ PrettyCookedOpts -> TxSkelOutDatum -> Maybe (Doc ())
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts TxSkelOutDatum
txSkelOutDatum,
              PrettyCookedOpts -> TxOut -> Maybe (Doc ())
forall output.
(IsAbstractOutput output,
 ToScriptHash (ReferenceScriptType output)) =>
PrettyCookedOpts -> output -> Maybe (Doc ())
getReferenceScriptDoc PrettyCookedOpts
opts TxOut
output
            ]
      )

getReferenceScriptDoc :: (IsAbstractOutput output, ToScriptHash (ReferenceScriptType output)) => PrettyCookedOpts -> output -> Maybe DocCooked
getReferenceScriptDoc :: forall output.
(IsAbstractOutput output,
 ToScriptHash (ReferenceScriptType output)) =>
PrettyCookedOpts -> output -> Maybe (Doc ())
getReferenceScriptDoc PrettyCookedOpts
opts output
output = PrettyCookedOpts -> ScriptHash -> Doc ()
prettyReferenceScriptHash PrettyCookedOpts
opts (ScriptHash -> Doc ())
-> (ReferenceScriptType output -> ScriptHash)
-> ReferenceScriptType output
-> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReferenceScriptType output -> ScriptHash
forall a. ToScriptHash a => a -> ScriptHash
toScriptHash (ReferenceScriptType output -> Doc ())
-> Maybe (ReferenceScriptType output) -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> output
output output
-> Optic' A_Lens NoIx output (Maybe (ReferenceScriptType output))
-> Maybe (ReferenceScriptType output)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx output (Maybe (ReferenceScriptType output))
forall o.
IsAbstractOutput o =>
Lens' o (Maybe (ReferenceScriptType o))
outputReferenceScriptL

lookupOutput :: SkelContext -> Api.TxOutRef -> Maybe (Api.TxOut, TxSkelOutDatum)
lookupOutput :: SkelContext -> TxOutRef -> Maybe (TxOut, TxSkelOutDatum)
lookupOutput (SkelContext Map TxOutRef TxOut
managedTxOuts Map DatumHash TxSkelOutDatum
managedTxSkelOutDatums) TxOutRef
txOutRef = do
  TxOut
output <- TxOutRef -> Map TxOutRef TxOut -> Maybe TxOut
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup TxOutRef
txOutRef Map TxOutRef TxOut
managedTxOuts
  (TxOut, TxSkelOutDatum) -> Maybe (TxOut, TxSkelOutDatum)
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return
    ( TxOut
output,
      case TxOut -> OutputDatum
forall o.
(IsAbstractOutput o, ToOutputDatum (DatumType o)) =>
o -> OutputDatum
outputOutputDatum TxOut
output of
        Api.OutputDatum Datum
datum -> TxSkelOutDatum
-> DatumHash -> Map DatumHash TxSkelOutDatum -> TxSkelOutDatum
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault TxSkelOutDatum
TxSkelOutNoDatum (Datum -> DatumHash
Script.datumHash Datum
datum) Map DatumHash TxSkelOutDatum
managedTxSkelOutDatums
        Api.OutputDatumHash DatumHash
datumHash -> TxSkelOutDatum
-> DatumHash -> Map DatumHash TxSkelOutDatum -> TxSkelOutDatum
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault TxSkelOutDatum
TxSkelOutNoDatum DatumHash
datumHash Map DatumHash TxSkelOutDatum
managedTxSkelOutDatums
        OutputDatum
Api.NoOutputDatum -> TxSkelOutDatum
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
-- list, return nothing.
mPrettyTxOpts :: PrettyCookedOpts -> TxOpts -> Maybe DocCooked
mPrettyTxOpts :: PrettyCookedOpts -> TxOpts -> Maybe (Doc ())
mPrettyTxOpts
  PrettyCookedOpts
opts
  TxOpts
    { Bool
txOptEnsureMinAda :: Bool
txOptEnsureMinAda :: TxOpts -> Bool
txOptEnsureMinAda,
      Bool
txOptAutoSlotIncrease :: Bool
txOptAutoSlotIncrease :: TxOpts -> Bool
txOptAutoSlotIncrease,
      [RawModTx]
txOptUnsafeModTx :: [RawModTx]
txOptUnsafeModTx :: TxOpts -> [RawModTx]
txOptUnsafeModTx,
      BalanceOutputPolicy
txOptBalanceOutputPolicy :: BalanceOutputPolicy
txOptBalanceOutputPolicy :: TxOpts -> BalanceOutputPolicy
txOptBalanceOutputPolicy,
      FeePolicy
txOptFeePolicy :: FeePolicy
txOptFeePolicy :: TxOpts -> FeePolicy
txOptFeePolicy,
      BalancingPolicy
txOptBalancingPolicy :: TxOpts -> BalancingPolicy
txOptBalancingPolicy :: BalancingPolicy
txOptBalancingPolicy,
      BalancingUtxos
txOptBalancingUtxos :: BalancingUtxos
txOptBalancingUtxos :: TxOpts -> BalancingUtxos
txOptBalancingUtxos,
      Maybe EmulatorParamsModification
txOptEmulatorParamsModification :: Maybe EmulatorParamsModification
txOptEmulatorParamsModification :: TxOpts -> Maybe EmulatorParamsModification
txOptEmulatorParamsModification,
      CollateralUtxos
txOptCollateralUtxos :: CollateralUtxos
txOptCollateralUtxos :: TxOpts -> CollateralUtxos
txOptCollateralUtxos,
      AnchorResolution
txOptAnchorResolution :: AnchorResolution
txOptAnchorResolution :: TxOpts -> AnchorResolution
txOptAnchorResolution
    } =
    Doc () -> Doc () -> [Doc ()] -> Maybe (Doc ())
prettyItemizeNonEmpty Doc ()
"Options:" Doc ()
"-" ([Doc ()] -> Maybe (Doc ())) -> [Doc ()] -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$
      [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
        [ Bool -> (Bool -> Doc ()) -> Bool -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot Bool
forall a. Default a => a
def Bool -> Doc ()
prettyEnsureMinAda Bool
txOptEnsureMinAda,
          Bool -> (Bool -> Doc ()) -> Bool -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot Bool
True Bool -> Doc ()
prettyAutoSlotIncrease Bool
txOptAutoSlotIncrease,
          BalanceOutputPolicy
-> (BalanceOutputPolicy -> Doc ())
-> BalanceOutputPolicy
-> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot BalanceOutputPolicy
forall a. Default a => a
def BalanceOutputPolicy -> Doc ()
prettyBalanceOutputPolicy BalanceOutputPolicy
txOptBalanceOutputPolicy,
          FeePolicy -> (FeePolicy -> Doc ()) -> FeePolicy -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot FeePolicy
forall a. Default a => a
def FeePolicy -> Doc ()
prettyBalanceFeePolicy FeePolicy
txOptFeePolicy,
          BalancingPolicy
-> (BalancingPolicy -> Doc ()) -> BalancingPolicy -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot BalancingPolicy
forall a. Default a => a
def BalancingPolicy -> Doc ()
prettyBalancingPolicy BalancingPolicy
txOptBalancingPolicy,
          BalancingUtxos
-> (BalancingUtxos -> Doc ()) -> BalancingUtxos -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot BalancingUtxos
forall a. Default a => a
def BalancingUtxos -> Doc ()
prettyBalancingUtxos BalancingUtxos
txOptBalancingUtxos,
          [RawModTx]
-> ([RawModTx] -> Doc ()) -> [RawModTx] -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot [] [RawModTx] -> Doc ()
prettyUnsafeModTx [RawModTx]
txOptUnsafeModTx,
          Maybe EmulatorParamsModification
-> (Maybe EmulatorParamsModification -> Doc ())
-> Maybe EmulatorParamsModification
-> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot Maybe EmulatorParamsModification
forall a. Default a => a
def Maybe EmulatorParamsModification -> Doc ()
prettyEmulatorParamsModification Maybe EmulatorParamsModification
txOptEmulatorParamsModification,
          CollateralUtxos
-> (CollateralUtxos -> Doc ()) -> CollateralUtxos -> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot CollateralUtxos
forall a. Default a => a
def CollateralUtxos -> Doc ()
prettyCollateralUtxos CollateralUtxos
txOptCollateralUtxos,
          AnchorResolution
-> (AnchorResolution -> Doc ())
-> AnchorResolution
-> Maybe (Doc ())
forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot AnchorResolution
forall a. Default a => a
def AnchorResolution -> Doc ()
prettyAnchorResolution AnchorResolution
txOptAnchorResolution
        ]
    where
      prettyIfNot :: (Eq a) => a -> (a -> DocCooked) -> a -> Maybe DocCooked
      prettyIfNot :: forall a. Eq a => a -> (a -> Doc ()) -> a -> Maybe (Doc ())
prettyIfNot a
defaultValue a -> Doc ()
f a
x
        | a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
defaultValue Bool -> Bool -> Bool
&& Bool -> Bool
not (PrettyCookedOpts -> Bool
pcOptPrintDefaultTxOpts PrettyCookedOpts
opts) = Maybe (Doc ())
forall a. Maybe a
Nothing
        | Bool
otherwise = Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ a -> Doc ()
f a
x
      prettyEnsureMinAda :: Bool -> DocCooked
      prettyEnsureMinAda :: Bool -> Doc ()
prettyEnsureMinAda Bool
True = Doc ()
"Ensure min Ada per transaction"
      prettyEnsureMinAda Bool
False = Doc ()
"Do not ensure min Ada per transaction"
      prettyAutoSlotIncrease :: Bool -> DocCooked
      prettyAutoSlotIncrease :: Bool -> Doc ()
prettyAutoSlotIncrease Bool
True = Doc ()
"Automatic slot increase"
      prettyAutoSlotIncrease Bool
False = Doc ()
"No automatic slot increase"
      prettyBalanceOutputPolicy :: BalanceOutputPolicy -> DocCooked
      prettyBalanceOutputPolicy :: BalanceOutputPolicy -> Doc ()
prettyBalanceOutputPolicy BalanceOutputPolicy
AdjustExistingOutput = Doc ()
"Balance policy: Adjust existing outputs"
      prettyBalanceOutputPolicy BalanceOutputPolicy
DontAdjustExistingOutput = Doc ()
"Balance policy: Don't adjust existing outputs"
      prettyBalancingPolicy :: BalancingPolicy -> DocCooked
      prettyBalancingPolicy :: BalancingPolicy -> Doc ()
prettyBalancingPolicy BalancingPolicy
BalanceWithFirstSigner = Doc ()
"Balance with first signer"
      prettyBalancingPolicy (BalanceWith Wallet
w) = Doc ()
"Balance with" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
w)
      prettyBalancingPolicy BalancingPolicy
DoNotBalance = Doc ()
"Do not balance"
      prettyUnsafeModTx :: [RawModTx] -> DocCooked
      prettyUnsafeModTx :: [RawModTx] -> Doc ()
prettyUnsafeModTx [] = Doc ()
"No transaction modifications"
      prettyUnsafeModTx ([RawModTx] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length -> Int
n) = PrettyCookedOpts -> Int -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Int
n Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
"transaction" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc () -> Doc () -> Int -> Doc ()
forall amount doc.
(Num amount, Eq amount) =>
doc -> doc -> amount -> doc
PP.plural Doc ()
"modification" Doc ()
"modifications" Int
n
      prettyEmulatorParamsModification :: Maybe EmulatorParamsModification -> DocCooked
      prettyEmulatorParamsModification :: Maybe EmulatorParamsModification -> Doc ()
prettyEmulatorParamsModification Maybe EmulatorParamsModification
Nothing = Doc ()
"No modifications of protocol paramters"
      prettyEmulatorParamsModification Just {} = Doc ()
"With modifications of protocol parameters"
      prettyCollateralUtxos :: CollateralUtxos -> DocCooked
      prettyCollateralUtxos :: CollateralUtxos -> Doc ()
prettyCollateralUtxos CollateralUtxos
CollateralUtxosFromBalancingWallet =
        Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Collateral policy:" Doc ()
"-" [Doc ()
"Use value-only utxos from balancing wallet", Doc ()
"Send return collaterals to balancing wallet"]
      prettyCollateralUtxos (CollateralUtxosFromWallet Wallet
w)
        | Doc ()
prettyWallet <- PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
w) =
            Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Collateral policy:" Doc ()
"-" [Doc ()
"Use value-only utxos from" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
prettyWallet, Doc ()
"Send return collaterals to" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ()
prettyWallet]
      prettyCollateralUtxos (CollateralUtxosFromSet Set TxOutRef
txOutRefs Wallet
w) =
        Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
          Doc ()
"Collateral policy:"
          Doc ()
"-"
          [ Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Choose among the following TxOutRefs:" Doc ()
"-" (PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOutRef -> Doc ()) -> [TxOutRef] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set TxOutRef -> [TxOutRef]
forall a. Set a -> [a]
Set.toList Set TxOutRef
txOutRefs),
            Doc ()
"Send return collaterals to" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> PubKeyHash -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (Wallet -> PubKeyHash
walletPKHash Wallet
w)
          ]
      prettyBalancingUtxos :: BalancingUtxos -> DocCooked
      prettyBalancingUtxos :: BalancingUtxos -> Doc ()
prettyBalancingUtxos BalancingUtxos
BalancingUtxosFromBalancingWallet = Doc ()
"Balance with 'only value' utxos from the balancing wallet"
      prettyBalancingUtxos (BalancingUtxosFromSet Set TxOutRef
utxos) = Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Balance with the following utxos:" Doc ()
"-" (PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts (TxOutRef -> Doc ()) -> [TxOutRef] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set TxOutRef -> [TxOutRef]
forall a. Set a -> [a]
Set.toList Set TxOutRef
utxos)
      prettyBalanceFeePolicy :: FeePolicy -> DocCooked
      prettyBalanceFeePolicy :: FeePolicy -> Doc ()
prettyBalanceFeePolicy FeePolicy
AutoFeeComputation = Doc ()
"Use automatically computed fee"
      prettyBalanceFeePolicy (ManualFee Integer
fee) = Doc ()
"Use the following fee:" Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedOpts -> Integer -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Integer
fee
      prettyAnchorResolution :: AnchorResolution -> DocCooked
      prettyAnchorResolution :: AnchorResolution -> Doc ()
prettyAnchorResolution AnchorResolution
AnchorResolutionHttp = Doc ()
"Resolve anchor url with an (unsafe) http connection"
      prettyAnchorResolution (AnchorResolutionLocal Map String ByteString
urlMap) = Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"Resolve anchor url with the following table keys" Doc ()
"-" (String -> Doc ()
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
PP.pretty (String -> Doc ()) -> [String] -> [Doc ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map String ByteString -> [String]
forall k a. Map k a -> [k]
Map.keys Map String ByteString
urlMap)

-- | Pretty print a 'UtxoState'. Print the known wallets first, then unknown
-- pubkeys, then scripts.
instance PrettyCooked UtxoState where
  prettyCookedOpt :: PrettyCookedOpts -> UtxoState -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts =
    Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize Doc ()
"UTxO state:" Doc ()
"•"
      ([Doc ()] -> Doc ())
-> (UtxoState -> [Doc ()]) -> UtxoState -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Address, UtxoPayloadSet) -> Doc ())
-> [(Address, UtxoPayloadSet)] -> [Doc ()]
forall a b. (a -> b) -> [a] -> [b]
map ((Address -> UtxoPayloadSet -> Doc ())
-> (Address, UtxoPayloadSet) -> Doc ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (PrettyCookedOpts -> Address -> UtxoPayloadSet -> Doc ()
prettyAddressState PrettyCookedOpts
opts))
      ([(Address, UtxoPayloadSet)] -> [Doc ()])
-> (UtxoState -> [(Address, UtxoPayloadSet)])
-> UtxoState
-> [Doc ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Address, UtxoPayloadSet)
 -> (Address, UtxoPayloadSet) -> Ordering)
-> [(Address, UtxoPayloadSet)] -> [(Address, UtxoPayloadSet)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy (Address, UtxoPayloadSet) -> (Address, UtxoPayloadSet) -> Ordering
forall a. (Address, a) -> (Address, a) -> Ordering
addressOrdering
      ([(Address, UtxoPayloadSet)] -> [(Address, UtxoPayloadSet)])
-> (UtxoState -> [(Address, UtxoPayloadSet)])
-> UtxoState
-> [(Address, UtxoPayloadSet)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Address UtxoPayloadSet -> [(Address, UtxoPayloadSet)]
forall k a. Map k a -> [(k, a)]
Map.toList
      (Map Address UtxoPayloadSet -> [(Address, UtxoPayloadSet)])
-> (UtxoState -> Map Address UtxoPayloadSet)
-> UtxoState
-> [(Address, UtxoPayloadSet)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UtxoState -> Map Address UtxoPayloadSet
utxoState
    where
      addressOrdering :: (Api.Address, a) -> (Api.Address, a) -> Ordering
      addressOrdering :: forall a. (Address, a) -> (Address, a) -> Ordering
addressOrdering
        (a1 :: Address
a1@(Api.Address (Api.PubKeyCredential PubKeyHash
pkh1) Maybe StakingCredential
_), a
_)
        (a2 :: Address
a2@(Api.Address (Api.PubKeyCredential PubKeyHash
pkh2) Maybe StakingCredential
_), a
_) =
          case (PubKeyHash -> Maybe Int
walletPKHashToId PubKeyHash
pkh1, PubKeyHash -> Maybe Int
walletPKHashToId PubKeyHash
pkh2) of
            (Just Int
i, Just Int
j) -> Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Int
i Int
j
            (Just Int
_, Maybe Int
Nothing) -> Ordering
LT
            (Maybe Int
Nothing, Just Int
_) -> Ordering
GT
            (Maybe Int
Nothing, Maybe Int
Nothing) -> Address -> Address -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Address
a1 Address
a2
      addressOrdering
        (Api.Address (Api.PubKeyCredential PubKeyHash
_) Maybe StakingCredential
_, a
_)
        (Api.Address (Api.ScriptCredential ScriptHash
_) Maybe StakingCredential
_, a
_) = Ordering
LT
      addressOrdering (Address
a1, a
_) (Address
a2, a
_) = Address -> Address -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Address
a1 Address
a2

-- | Pretty prints the state of an address, that is the list of UTxOs (including
-- value and datum), grouped
prettyAddressState :: PrettyCookedOpts -> Api.Address -> UtxoPayloadSet -> DocCooked
prettyAddressState :: PrettyCookedOpts -> Address -> UtxoPayloadSet -> Doc ()
prettyAddressState PrettyCookedOpts
opts Address
address UtxoPayloadSet
payloadSet =
  Doc () -> Doc () -> [Doc ()] -> Doc ()
prettyItemize
    (PrettyCookedOpts -> Address -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Address
address)
    Doc ()
"-"
    ( ([UtxoPayload] -> Maybe (Doc ())) -> [[UtxoPayload]] -> [Doc ()]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (PrettyCookedOpts -> [UtxoPayload] -> Maybe (Doc ())
prettyPayloadGrouped PrettyCookedOpts
opts)
        ([[UtxoPayload]] -> [Doc ()])
-> (UtxoPayloadSet -> [[UtxoPayload]])
-> UtxoPayloadSet
-> [Doc ()]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UtxoPayload] -> [[UtxoPayload]]
group
        ([UtxoPayload] -> [[UtxoPayload]])
-> (UtxoPayloadSet -> [UtxoPayload])
-> UtxoPayloadSet
-> [[UtxoPayload]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UtxoPayload -> UtxoPayload -> Ordering)
-> [UtxoPayload] -> [UtxoPayload]
forall a. (a -> a -> Ordering) -> [a] -> [a]
List.sortBy (Ada -> Ada -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Ada -> Ada -> Ordering)
-> (UtxoPayload -> Ada) -> UtxoPayload -> UtxoPayload -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (Value -> Ada
Script.fromValue (Value -> Ada) -> (UtxoPayload -> Value) -> UtxoPayload -> Ada
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UtxoPayload -> Value
utxoPayloadValue))
        ([UtxoPayload] -> [UtxoPayload])
-> (UtxoPayloadSet -> [UtxoPayload])
-> UtxoPayloadSet
-> [UtxoPayload]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UtxoPayloadSet -> [UtxoPayload]
utxoPayloadSet
        (UtxoPayloadSet -> [Doc ()]) -> UtxoPayloadSet -> [Doc ()]
forall a b. (a -> b) -> a -> b
$ UtxoPayloadSet
payloadSet
    )
  where
    similar :: UtxoPayload -> UtxoPayload -> Bool
    similar :: UtxoPayload -> UtxoPayload -> Bool
similar
      (UtxoPayload TxOutRef
_ Value
value1 TxSkelOutDatum
skelOutDatum1 Maybe ScriptHash
refScript1)
      (UtxoPayload TxOutRef
_ Value
value2 TxSkelOutDatum
skelOutDatum2 Maybe ScriptHash
refScript2) =
        Value
value1 Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== Value
value2
          Bool -> Bool -> Bool
&& TxSkelOutDatum
skelOutDatum1 TxSkelOutDatum -> TxSkelOutDatum -> Bool
forall a. Eq a => a -> a -> Bool
== TxSkelOutDatum
skelOutDatum2
          Bool -> Bool -> Bool
&& Maybe ScriptHash
refScript1 Maybe ScriptHash -> Maybe ScriptHash -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ScriptHash
refScript2
    group :: [UtxoPayload] -> [[UtxoPayload]]
    group :: [UtxoPayload] -> [[UtxoPayload]]
group =
      case PrettyCookedOpts -> PCOptTxOutRefs
pcOptPrintTxOutRefs PrettyCookedOpts
opts of
        PCOptTxOutRefs
PCOptTxOutRefsFull -> (UtxoPayload -> [UtxoPayload]) -> [UtxoPayload] -> [[UtxoPayload]]
forall a b. (a -> b) -> [a] -> [b]
map (UtxoPayload -> [UtxoPayload] -> [UtxoPayload]
forall a. a -> [a] -> [a]
: [])
        PCOptTxOutRefs
_ -> (UtxoPayload -> UtxoPayload -> Bool)
-> [UtxoPayload] -> [[UtxoPayload]]
forall a. (a -> a -> Bool) -> [a] -> [[a]]
List.groupBy UtxoPayload -> UtxoPayload -> Bool
similar

-- | Pretty prints payloads (datum and value corresponding to 1 UTxO) grouped
-- together when they carry same value and datum
prettyPayloadGrouped :: PrettyCookedOpts -> [UtxoPayload] -> Maybe DocCooked
prettyPayloadGrouped :: PrettyCookedOpts -> [UtxoPayload] -> Maybe (Doc ())
prettyPayloadGrouped PrettyCookedOpts
_ [] = Maybe (Doc ())
forall a. Maybe a
Nothing
prettyPayloadGrouped PrettyCookedOpts
opts [UtxoPayload
payload] =
  PrettyCookedOpts -> Bool -> UtxoPayload -> Maybe (Doc ())
prettyPayload
    PrettyCookedOpts
opts
    (PrettyCookedOpts -> PCOptTxOutRefs
pcOptPrintTxOutRefs PrettyCookedOpts
opts PCOptTxOutRefs -> PCOptTxOutRefs -> Bool
forall a. Eq a => a -> a -> Bool
/= PCOptTxOutRefs
PCOptTxOutRefsHidden)
    UtxoPayload
payload
prettyPayloadGrouped PrettyCookedOpts
opts (UtxoPayload
payload : [UtxoPayload]
rest) =
  let cardinality :: Int
cardinality = Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ [UtxoPayload] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [UtxoPayload]
rest
   in (Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.parens (Doc ()
"×" Doc () -> Doc () -> Doc ()
forall a. Semigroup a => a -> a -> a
<> PrettyCookedOpts -> Int -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Int
cardinality) Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+>)
        (Doc () -> Doc ()) -> Maybe (Doc ()) -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PrettyCookedOpts -> Bool -> UtxoPayload -> Maybe (Doc ())
prettyPayload PrettyCookedOpts
opts Bool
False UtxoPayload
payload

prettyPayload :: PrettyCookedOpts -> Bool -> UtxoPayload -> Maybe DocCooked
prettyPayload :: PrettyCookedOpts -> Bool -> UtxoPayload -> Maybe (Doc ())
prettyPayload
  PrettyCookedOpts
opts
  Bool
showTxOutRef
  ( UtxoPayload
      { TxOutRef
utxoPayloadTxOutRef :: TxOutRef
utxoPayloadTxOutRef :: UtxoPayload -> TxOutRef
utxoPayloadTxOutRef,
        Value
utxoPayloadValue :: UtxoPayload -> Value
utxoPayloadValue :: Value
utxoPayloadValue,
        TxSkelOutDatum
utxoPayloadSkelOutDatum :: TxSkelOutDatum
utxoPayloadSkelOutDatum :: UtxoPayload -> TxSkelOutDatum
utxoPayloadSkelOutDatum,
        Maybe ScriptHash
utxoPayloadReferenceScript :: Maybe ScriptHash
utxoPayloadReferenceScript :: UtxoPayload -> Maybe ScriptHash
utxoPayloadReferenceScript
      }
    ) =
    case [Maybe (Doc ())] -> [Doc ()]
forall a. [Maybe a] -> [a]
catMaybes
      [ if Bool
showTxOutRef
          then Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ PrettyCookedOpts -> TxOutRef -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts TxOutRef
utxoPayloadTxOutRef
          else Maybe (Doc ())
forall a. Maybe a
Nothing,
        Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (PrettyCookedOpts -> Value -> Doc ()
forall a. PrettyCooked a => PrettyCookedOpts -> a -> Doc ()
prettyCookedOpt PrettyCookedOpts
opts Value
utxoPayloadValue),
        PrettyCookedOpts -> TxSkelOutDatum -> Maybe (Doc ())
prettyTxSkelOutDatumMaybe PrettyCookedOpts
opts TxSkelOutDatum
utxoPayloadSkelOutDatum,
        PrettyCookedOpts -> ScriptHash -> Doc ()
prettyReferenceScriptHash PrettyCookedOpts
opts (ScriptHash -> Doc ()) -> Maybe ScriptHash -> Maybe (Doc ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ScriptHash
utxoPayloadReferenceScript
      ] of
      [] -> Maybe (Doc ())
forall a. Maybe a
Nothing
      [Doc ()
doc] -> Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ())) -> Doc () -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align Doc ()
doc
      [Doc ()]
docs -> Doc () -> Maybe (Doc ())
forall a. a -> Maybe a
Just (Doc () -> Maybe (Doc ()))
-> ([Doc ()] -> Doc ()) -> [Doc ()] -> Maybe (Doc ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc () -> Doc ()
forall ann. Doc ann -> Doc ann
PP.align (Doc () -> Doc ()) -> ([Doc ()] -> Doc ()) -> [Doc ()] -> Doc ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Doc ()] -> Doc ()
forall ann. [Doc ann] -> Doc ann
PP.vsep ([Doc ()] -> Maybe (Doc ())) -> [Doc ()] -> Maybe (Doc ())
forall a b. (a -> b) -> a -> b
$ [Doc ()]
docs

prettyReferenceScriptHash :: PrettyCookedOpts -> Script.ScriptHash -> DocCooked
prettyReferenceScriptHash :: PrettyCookedOpts -> ScriptHash -> Doc ()
prettyReferenceScriptHash PrettyCookedOpts
opts ScriptHash
scriptHash =
  Doc ()
"Reference script hash:"
    Doc () -> Doc () -> Doc ()
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PrettyCookedHashOpts -> BuiltinByteString -> Doc ()
prettyHash (PrettyCookedOpts -> PrettyCookedHashOpts
pcOptHashes PrettyCookedOpts
opts) (ScriptHash -> BuiltinByteString
forall a. ToHash a => a -> BuiltinByteString
toHash ScriptHash
scriptHash)