{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Cardano.Tracing.OrphanInstances.Shelley () where

import           Cardano.Prelude

import           Data.Aeson (Value (..), object)
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.Set as Set
import qualified Data.Text as Text

import           Cardano.Api (textShow)
import qualified Cardano.Api as Api
import           Cardano.Api.Orphans ()
import qualified Cardano.Api.Shelley as Api
import           Cardano.Ledger.Crypto (StandardCrypto)

import           Cardano.Slotting.Block (BlockNo (..))
import           Cardano.Tracing.OrphanInstances.Common
import           Cardano.Tracing.OrphanInstances.Consensus ()
import           Cardano.Tracing.Render (renderTxId)

import           Ouroboros.Consensus.Ledger.SupportsMempool (txId)
import qualified Ouroboros.Consensus.Ledger.SupportsMempool as SupportsMempool
import           Ouroboros.Consensus.Util.Condense (condense)
import           Ouroboros.Network.Block (SlotNo (..), blockHash, blockNo, blockSlot)
import           Ouroboros.Network.Point (WithOrigin, withOriginToMaybe)

import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
import qualified Ouroboros.Consensus.Protocol.Praos as Praos
import           Ouroboros.Consensus.Protocol.TPraos (TPraosCannotForge (..))
import           Ouroboros.Consensus.Shelley.Ledger hiding (TxId)
import           Ouroboros.Consensus.Shelley.Ledger.Inspect
import qualified Ouroboros.Consensus.Shelley.Protocol.Praos as Praos

import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Ledger.Alonzo.PlutusScriptApi as Alonzo
import           Cardano.Ledger.Alonzo.Rules.Bbody (AlonzoBbodyPredFail)
import qualified Cardano.Ledger.Alonzo.Rules.Utxo as Alonzo
import qualified Cardano.Ledger.Alonzo.Rules.Utxos as Alonzo
import           Cardano.Ledger.Alonzo.Rules.Utxow (UtxowPredicateFail (..))
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
import qualified Cardano.Ledger.Alonzo.TxInfo as Alonzo
import qualified Cardano.Ledger.AuxiliaryData as Core
import qualified Cardano.Ledger.Babbage.Rules.Utxo as Babbage
import qualified Cardano.Ledger.Babbage.Rules.Utxow as Babbage
import           Cardano.Ledger.BaseTypes (activeSlotLog, strictMaybeToMaybe)
import           Cardano.Ledger.Chain
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Ledger.Crypto as Core
import qualified Cardano.Ledger.Era as Ledger
import qualified Cardano.Ledger.SafeHash as SafeHash
import qualified Cardano.Ledger.ShelleyMA.Rules.Utxo as MA
import qualified Cardano.Ledger.ShelleyMA.Timelocks as MA
import           Cardano.Protocol.TPraos.BHeader (LastAppliedBlock, labBlockNo)
import           Cardano.Protocol.TPraos.Rules.OCert
import           Cardano.Protocol.TPraos.Rules.Overlay
import           Cardano.Protocol.TPraos.Rules.Tickn
import           Cardano.Protocol.TPraos.Rules.Updn

-- TODO: this should be exposed via Cardano.Api
import           Cardano.Ledger.Shelley.API hiding (ShelleyBasedEra)

import           Cardano.Ledger.Shelley.Rules.Bbody
import           Cardano.Ledger.Shelley.Rules.Deleg
import           Cardano.Ledger.Shelley.Rules.Delegs
import           Cardano.Ledger.Shelley.Rules.Delpl
import           Cardano.Ledger.Shelley.Rules.Epoch
import           Cardano.Ledger.Shelley.Rules.Ledger
import           Cardano.Ledger.Shelley.Rules.Ledgers
import           Cardano.Ledger.Shelley.Rules.Mir
import           Cardano.Ledger.Shelley.Rules.NewEpoch
import           Cardano.Ledger.Shelley.Rules.Newpp
import           Cardano.Ledger.Shelley.Rules.Pool
import           Cardano.Ledger.Shelley.Rules.PoolReap
import           Cardano.Ledger.Shelley.Rules.Ppup
import           Cardano.Ledger.Shelley.Rules.Rupd
import           Cardano.Ledger.Shelley.Rules.Snap
import           Cardano.Ledger.Shelley.Rules.Tick
import           Cardano.Ledger.Shelley.Rules.Upec
import           Cardano.Ledger.Shelley.Rules.Utxo
import           Cardano.Ledger.Shelley.Rules.Utxow
import           Cardano.Protocol.TPraos.API (ChainTransitionError (ChainTransitionError))
import           Cardano.Protocol.TPraos.OCert (KESPeriod (KESPeriod))
import           Cardano.Protocol.TPraos.Rules.Prtcl
import qualified Data.Aeson.Key as Aeson


{- HLINT ignore "Use :" -}

--
-- | instances of @ToObject@
--
-- NOTE: this list is sorted in roughly topological order.

instance ShelleyBasedEra era => ToObject (GenTx (ShelleyBlock protocol era)) where
  toObject :: TracingVerbosity -> GenTx (ShelleyBlock protocol era) -> Object
toObject TracingVerbosity
_ GenTx (ShelleyBlock protocol era)
tx = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"txid" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Text -> Text
Text.take Int
8 (TxId (GenTx (ShelleyBlock protocol era)) -> Text
forall blk. ConvertTxId blk => TxId (GenTx blk) -> Text
renderTxId (GenTx (ShelleyBlock protocol era)
-> TxId (GenTx (ShelleyBlock protocol era))
forall tx. HasTxId tx => tx -> TxId tx
txId GenTx (ShelleyBlock protocol era)
tx)) ]

instance ToJSON (SupportsMempool.TxId (GenTx (ShelleyBlock protocol era))) where
  toJSON :: TxId (GenTx (ShelleyBlock protocol era)) -> Value
toJSON = Text -> Value
String (Text -> Value)
-> (TxId (GenTx (ShelleyBlock protocol era)) -> Text)
-> TxId (GenTx (ShelleyBlock protocol era))
-> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Int -> Text -> Text
Text.take Int
8 (Text -> Text)
-> (TxId (GenTx (ShelleyBlock protocol era)) -> Text)
-> TxId (GenTx (ShelleyBlock protocol era))
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TxId (GenTx (ShelleyBlock protocol era)) -> Text
forall blk. ConvertTxId blk => TxId (GenTx blk) -> Text
renderTxId

instance ShelleyCompatible protocol era => ToObject (Header (ShelleyBlock protocol era)) where
  toObject :: TracingVerbosity -> Header (ShelleyBlock protocol era) -> Object
toObject TracingVerbosity
_verb Header (ShelleyBlock protocol era)
b = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
        [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ShelleyBlock"
        , Key
"hash" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ShelleyHash (ProtoCrypto protocol) -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock protocol era)
-> HeaderHash (Header (ShelleyBlock protocol era))
forall b. HasHeader b => b -> HeaderHash b
blockHash Header (ShelleyBlock protocol era)
b)
        , Key
"slotNo" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock protocol era) -> SlotNo
forall b. HasHeader b => b -> SlotNo
blockSlot Header (ShelleyBlock protocol era)
b)
        , Key
"blockNo" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BlockNo -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock protocol era) -> BlockNo
forall b. HasHeader b => b -> BlockNo
blockNo Header (ShelleyBlock protocol era)
b)
--      , "delegate" .= condense (headerSignerVk h)
        ]

instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "LEDGER" era))
         ) => ToObject (ApplyTxError era) where
  toObject :: TracingVerbosity -> ApplyTxError era -> Object
toObject TracingVerbosity
verb (ApplyTxError [PredicateFailure (EraRule "LEDGER" era)]
predicateFailures) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat ([Object] -> Object) -> [Object] -> Object
forall a b. (a -> b) -> a -> b
$ (LedgerPredicateFailure era -> Object)
-> [LedgerPredicateFailure era] -> [Object]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (TracingVerbosity -> LedgerPredicateFailure era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb) [PredicateFailure (EraRule "LEDGER" era)]
[LedgerPredicateFailure era]
predicateFailures

instance Core.Crypto crypto => ToObject (TPraosCannotForge crypto) where
  toObject :: TracingVerbosity -> TPraosCannotForge crypto -> Object
toObject TracingVerbosity
_verb (TPraosCannotForgeKeyNotUsableYet KESPeriod
wallClockPeriod KESPeriod
keyStartPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TPraosCannotForgeKeyNotUsableYet"
      , Key
"keyStart" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
keyStartPeriod
      , Key
"wallClock" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
wallClockPeriod
      ]
  toObject TracingVerbosity
_verb (TPraosCannotForgeWrongVRF Hash crypto (VerKeyVRF crypto)
genDlgVRFHash Hash crypto (VerKeyVRF crypto)
coreNodeVRFHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TPraosCannotLeadWrongVRF"
      , Key
"expected" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
genDlgVRFHash
      , Key
"actual" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
coreNodeVRFHash
      ]

deriving newtype instance ToJSON KESPeriod

instance ToObject HotKey.KESInfo where
  toObject :: TracingVerbosity -> KESInfo -> Object
toObject TracingVerbosity
_verb HotKey.KESInfo { KESPeriod
kesStartPeriod :: KESInfo -> KESPeriod
kesStartPeriod :: KESPeriod
kesStartPeriod, KESPeriod
kesEndPeriod :: KESInfo -> KESPeriod
kesEndPeriod :: KESPeriod
kesEndPeriod, KESEvolution
kesEvolution :: KESInfo -> KESEvolution
kesEvolution :: KESEvolution
kesEvolution } =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESInfo"
      , Key
"startPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
kesStartPeriod
      , Key
"endPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
kesEndPeriod
      , Key
"evolution" Key -> KESEvolution -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESEvolution
kesEvolution
      ]

instance ToObject HotKey.KESEvolutionError where
  toObject :: TracingVerbosity -> KESEvolutionError -> Object
toObject TracingVerbosity
verb (HotKey.KESCouldNotEvolve KESInfo
kesInfo KESPeriod
targetPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESCouldNotEvolve"
      , Key
"kesInfo" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> KESInfo -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb KESInfo
kesInfo
      , Key
"targetPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
targetPeriod
      ]
  toObject TracingVerbosity
verb (HotKey.KESKeyAlreadyPoisoned KESInfo
kesInfo KESPeriod
targetPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESKeyAlreadyPoisoned"
      , Key
"kesInfo" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> KESInfo -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb KESInfo
kesInfo
      , Key
"targetPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
targetPeriod
      ]

instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "BBODY" era))
         ) => ToObject (ShelleyLedgerError era) where
  toObject :: TracingVerbosity -> ShelleyLedgerError era -> Object
toObject TracingVerbosity
verb (BBodyError (BlockTransitionError [PredicateFailure (EraRule "BBODY" era)]
fs)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BBodyError"
             , Key
"failures" Key -> [Object] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (PredicateFailure (EraRule "BBODY" era) -> Object)
-> [PredicateFailure (EraRule "BBODY" era)] -> [Object]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (TracingVerbosity
-> PredicateFailure (EraRule "BBODY" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb) [PredicateFailure (EraRule "BBODY" era)]
fs
             ]

instance ( ShelleyBasedEra era
         , ToJSON (Ledger.PParamsDelta era)
         ) => ToObject (ShelleyLedgerUpdate era) where
  toObject :: TracingVerbosity -> ShelleyLedgerUpdate era -> Object
toObject TracingVerbosity
verb (ShelleyUpdatedProtocolUpdates [ProtocolUpdate era]
updates) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ShelleyUpdatedProtocolUpdates"
             , Key
"updates" Key -> [Object] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (ProtocolUpdate era -> Object) -> [ProtocolUpdate era] -> [Object]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (TracingVerbosity -> ProtocolUpdate era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb) [ProtocolUpdate era]
updates
             ]

instance (Ledger.Era era, ToJSON (Ledger.PParamsDelta era))
         => ToObject (ProtocolUpdate era) where
  toObject :: TracingVerbosity -> ProtocolUpdate era -> Object
toObject TracingVerbosity
verb ProtocolUpdate{UpdateProposal era
protocolUpdateProposal :: forall era. ProtocolUpdate era -> UpdateProposal era
protocolUpdateProposal :: UpdateProposal era
protocolUpdateProposal, UpdateState (EraCrypto era)
protocolUpdateState :: forall era. ProtocolUpdate era -> UpdateState (EraCrypto era)
protocolUpdateState :: UpdateState (EraCrypto era)
protocolUpdateState} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"proposal" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> UpdateProposal era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb UpdateProposal era
protocolUpdateProposal
             , Key
"state"    Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> UpdateState (EraCrypto era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb UpdateState (EraCrypto era)
protocolUpdateState
             ]

instance ToJSON (Ledger.PParamsDelta era)
         => ToObject (UpdateProposal era) where
  toObject :: TracingVerbosity -> UpdateProposal era -> Object
toObject TracingVerbosity
_verb UpdateProposal{PParamsDelta era
proposalParams :: forall era. UpdateProposal era -> PParamsDelta era
proposalParams :: PParamsDelta era
proposalParams, Maybe ProtVer
proposalVersion :: forall era. UpdateProposal era -> Maybe ProtVer
proposalVersion :: Maybe ProtVer
proposalVersion, EpochNo
proposalEpoch :: forall era. UpdateProposal era -> EpochNo
proposalEpoch :: EpochNo
proposalEpoch} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"params"  Key -> PParamsDelta era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParamsDelta era
proposalParams
             , Key
"version" Key -> Maybe ProtVer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe ProtVer
proposalVersion
             , Key
"epoch"   Key -> EpochNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= EpochNo
proposalEpoch
             ]

instance Core.Crypto crypto => ToObject (UpdateState crypto) where
  toObject :: TracingVerbosity -> UpdateState crypto -> Object
toObject TracingVerbosity
_verb UpdateState{[KeyHash 'Genesis crypto]
proposalVotes :: forall c. UpdateState c -> [KeyHash 'Genesis c]
proposalVotes :: [KeyHash 'Genesis crypto]
proposalVotes, Bool
proposalReachedQuorum :: forall c. UpdateState c -> Bool
proposalReachedQuorum :: Bool
proposalReachedQuorum} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"proposal"      Key -> [KeyHash 'Genesis crypto] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [KeyHash 'Genesis crypto]
proposalVotes
             , Key
"reachedQuorum" Key -> Bool -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
proposalReachedQuorum
             ]

instance Core.Crypto crypto => ToObject (ChainTransitionError crypto) where
  toObject :: TracingVerbosity -> ChainTransitionError crypto -> Object
toObject TracingVerbosity
verb (ChainTransitionError [PredicateFailure (PRTCL crypto)]
fs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ChainTransitionError"
             , Key
"failures" Key -> [Object] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (PrtclPredicateFailure crypto -> Object)
-> [PrtclPredicateFailure crypto] -> [Object]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (TracingVerbosity -> PrtclPredicateFailure crypto -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb) [PredicateFailure (PRTCL crypto)]
[PrtclPredicateFailure crypto]
fs
             ]

instance ToObject ChainPredicateFailure where
  toObject :: TracingVerbosity -> ChainPredicateFailure -> Object
toObject TracingVerbosity
_verb (HeaderSizeTooLargeCHAIN Natural
hdrSz Natural
maxHdrSz) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HeaderSizeTooLarge"
             , Key
"headerSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
hdrSz
             , Key
"maxHeaderSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
maxHdrSz
             ]
  toObject TracingVerbosity
_verb (BlockSizeTooLargeCHAIN Natural
blkSz Natural
maxBlkSz) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BlockSizeTooLarge"
             , Key
"blockSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
blkSz
             , Key
"maxBlockSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
maxBlkSz
             ]
  toObject TracingVerbosity
_verb (ObsoleteNodeCHAIN Natural
currentPtcl Natural
supportedPtcl) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ObsoleteNode"
             , Key
"explanation" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
explanation
             , Key
"currentProtocol" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
currentPtcl
             , Key
"supportedProtocol" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
supportedPtcl ]
      where
        explanation :: Text
explanation = Text
"A scheduled major protocol version change (hard fork) \
                      \has taken place on the chain, but this node does not \
                      \understand the new major protocol version. This node \
                      \must be upgraded before it can continue with the new \
                      \protocol version."

instance ToObject (PrtlSeqFailure crypto) where
  toObject :: TracingVerbosity -> PrtlSeqFailure crypto -> Object
toObject TracingVerbosity
_verb (WrongSlotIntervalPrtclSeq (SlotNo Word64
lastSlot) (SlotNo Word64
currSlot)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongSlotInterval"
             , Key
"lastSlot" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
lastSlot
             , Key
"currentSlot" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
currSlot
             ]
  toObject TracingVerbosity
_verb (WrongBlockNoPrtclSeq WithOrigin (LastAppliedBlock crypto)
lab BlockNo
currentBlockNo) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongBlockNo"
             , Key
"lastAppliedBlockNo" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= WithOrigin (LastAppliedBlock crypto) -> Text
forall crypto. WithOrigin (LastAppliedBlock crypto) -> Text
showLastAppBlockNo WithOrigin (LastAppliedBlock crypto)
lab
             , Key
"currentBlockNo" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text -> Value
String (Text -> Value) -> (Word64 -> Text) -> Word64 -> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Word64 -> Text
forall a. Show a => a -> Text
textShow (Word64 -> Value) -> Word64 -> Value
forall a b. (a -> b) -> a -> b
$ BlockNo -> Word64
unBlockNo BlockNo
currentBlockNo)
             ]
  toObject TracingVerbosity
_verb (WrongBlockSequencePrtclSeq PrevHash crypto
lastAppliedHash PrevHash crypto
currentHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongBlockSequence"
             , Key
"lastAppliedBlockHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (PrevHash crypto -> Text
forall a. Show a => a -> Text
textShow PrevHash crypto
lastAppliedHash)
             , Key
"currentBlockHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (PrevHash crypto -> Text
forall a. Show a => a -> Text
textShow PrevHash crypto
currentHash)
             ]

instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "LEDGER" era))
         , ToObject (PredicateFailure (Core.EraRule "LEDGERS" era))
         ) => ToObject (BbodyPredicateFailure era) where
  toObject :: TracingVerbosity -> BbodyPredicateFailure era -> Object
toObject TracingVerbosity
_verb (WrongBlockBodySizeBBODY Int
actualBodySz Int
claimedBodySz) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongBlockBodySizeBBODY"
             , Key
"actualBlockBodySize" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualBodySz
             , Key
"claimedBlockBodySize" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
claimedBodySz
             ]
  toObject TracingVerbosity
_verb (InvalidBodyHashBBODY Hash (Crypto era) EraIndependentBlockBody
actualHash Hash (Crypto era) EraIndependentBlockBody
claimedHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidBodyHashBBODY"
             , Key
"actualBodyHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash (Crypto era) EraIndependentBlockBody -> Text
forall a. Show a => a -> Text
textShow Hash (Crypto era) EraIndependentBlockBody
actualHash
             , Key
"claimedBodyHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash (Crypto era) EraIndependentBlockBody -> Text
forall a. Show a => a -> Text
textShow Hash (Crypto era) EraIndependentBlockBody
claimedHash
             ]
  toObject TracingVerbosity
verb (LedgersFailure PredicateFailure (EraRule "LEDGERS" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "LEDGERS" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "LEDGERS" era)
f


instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "LEDGER" era))
         ) => ToObject (LedgersPredicateFailure era) where
  toObject :: TracingVerbosity -> LedgersPredicateFailure era -> Object
toObject TracingVerbosity
verb (LedgerFailure PredicateFailure (EraRule "LEDGER" era)
f) = TracingVerbosity -> LedgerPredicateFailure era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "LEDGER" era)
LedgerPredicateFailure era
f


instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "DELEGS" era))
         , ToObject (PredicateFailure (Core.EraRule "UTXOW" era))
         ) => ToObject (LedgerPredicateFailure era) where
  toObject :: TracingVerbosity -> LedgerPredicateFailure era -> Object
toObject TracingVerbosity
verb (UtxowFailure PredicateFailure (EraRule "UTXOW" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "UTXOW" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "UTXOW" era)
f
  toObject TracingVerbosity
verb (DelegsFailure PredicateFailure (EraRule "DELEGS" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "DELEGS" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "DELEGS" era)
f

instance ( ShelleyBasedEra era
         , ToJSON (Ledger.Value era)
         , ToJSON (Ledger.TxOut era)
         , ToObject (PredicateFailure (Ledger.EraRule "PPUP" era))
         , ToObject (PredicateFailure (Ledger.EraRule "UTXO" era))
         , Ledger.Crypto era ~ StandardCrypto
         ) => ToObject (UtxowPredicateFail era) where
  toObject :: TracingVerbosity -> UtxowPredicateFail era -> Object
toObject TracingVerbosity
v (WrappedShelleyEraFailure UtxowPredicateFailure era
utxoPredFail) =
    TracingVerbosity -> UtxowPredicateFailure era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v UtxowPredicateFailure era
utxoPredFail
  toObject TracingVerbosity
_ (MissingRedeemers [(ScriptPurpose (Crypto era), ScriptHash (Crypto era))]
scripts) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingRedeemers"
             , Key
"scripts" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
-> Value
renderMissingRedeemers [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
[(ScriptPurpose (Crypto era), ScriptHash (Crypto era))]
scripts
             ]
  toObject TracingVerbosity
_ (MissingRequiredDatums Set (DataHash (Crypto era))
required Set (DataHash (Crypto era))
received) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingRequiredDatums"
             , Key
"required" Key -> [Text] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (SafeHash StandardCrypto EraIndependentData -> Text)
-> [SafeHash StandardCrypto EraIndependentData] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Hash Blake2b_256 EraIndependentData -> Text
forall h a. Hash h a -> Text
Crypto.hashToTextAsHex (Hash Blake2b_256 EraIndependentData -> Text)
-> (SafeHash StandardCrypto EraIndependentData
    -> Hash Blake2b_256 EraIndependentData)
-> SafeHash StandardCrypto EraIndependentData
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SafeHash StandardCrypto EraIndependentData
-> Hash Blake2b_256 EraIndependentData
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash)
                                 (Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto era))
required)
             , Key
"received" Key -> [Text] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (SafeHash StandardCrypto EraIndependentData -> Text)
-> [SafeHash StandardCrypto EraIndependentData] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Hash Blake2b_256 EraIndependentData -> Text
forall h a. Hash h a -> Text
Crypto.hashToTextAsHex (Hash Blake2b_256 EraIndependentData -> Text)
-> (SafeHash StandardCrypto EraIndependentData
    -> Hash Blake2b_256 EraIndependentData)
-> SafeHash StandardCrypto EraIndependentData
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SafeHash StandardCrypto EraIndependentData
-> Hash Blake2b_256 EraIndependentData
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash)
                                 (Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto era))
received)
             ]
  toObject TracingVerbosity
_ (PPViewHashesDontMatch StrictMaybe (ScriptIntegrityHash (Crypto era))
ppHashInTxBody StrictMaybe (ScriptIntegrityHash (Crypto era))
ppHashFromPParams) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PPViewHashesDontMatch"
             , Key
"fromTxBody" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe (ScriptIntegrityHash StandardCrypto) -> Value
renderScriptIntegrityHash (StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Maybe (ScriptIntegrityHash StandardCrypto)
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (ScriptIntegrityHash StandardCrypto)
StrictMaybe (ScriptIntegrityHash (Crypto era))
ppHashInTxBody)
             , Key
"fromPParams" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe (ScriptIntegrityHash StandardCrypto) -> Value
renderScriptIntegrityHash (StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Maybe (ScriptIntegrityHash StandardCrypto)
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (ScriptIntegrityHash StandardCrypto)
StrictMaybe (ScriptIntegrityHash (Crypto era))
ppHashFromPParams)
             ]
  toObject TracingVerbosity
_ (MissingRequiredSigners Set (KeyHash 'Witness (Crypto era))
missingKeyWitnesses) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingRequiredSigners"
             , Key
"witnesses" Key -> [KeyHash 'Witness StandardCrypto] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (KeyHash 'Witness StandardCrypto)
-> [KeyHash 'Witness StandardCrypto]
forall a. Set a -> [a]
Set.toList Set (KeyHash 'Witness StandardCrypto)
Set (KeyHash 'Witness (Crypto era))
missingKeyWitnesses
             ]
  toObject TracingVerbosity
_ (UnspendableUTxONoDatumHash Set (TxIn (Crypto era))
txins) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingRequiredSigners"
             , Key
"txins" Key -> [TxIn StandardCrypto] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn StandardCrypto) -> [TxIn StandardCrypto]
forall a. Set a -> [a]
Set.toList Set (TxIn StandardCrypto)
Set (TxIn (Crypto era))
txins
             ]
  toObject TracingVerbosity
_ (NonOutputSupplimentaryDatums Set (DataHash (Crypto era))
disallowed Set (DataHash (Crypto era))
acceptable) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NonOutputSupplimentaryDatums"
             , Key
"disallowed" Key -> [SafeHash StandardCrypto EraIndependentData] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto era))
disallowed
             , Key
"acceptable" Key -> [SafeHash StandardCrypto EraIndependentData] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto era))
acceptable
             ]
  toObject TracingVerbosity
_ (ExtraRedeemers [RdmrPtr]
rdmrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ExtraRedeemers"
             , Key
"rdmrs" Key -> [String] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (RdmrPtr -> String) -> [RdmrPtr] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (ScriptWitnessIndex -> String
Api.renderScriptWitnessIndex (ScriptWitnessIndex -> String)
-> (RdmrPtr -> ScriptWitnessIndex) -> RdmrPtr -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. RdmrPtr -> ScriptWitnessIndex
Api.fromAlonzoRdmrPtr) [RdmrPtr]
rdmrs
             ]

renderScriptIntegrityHash :: Maybe (Alonzo.ScriptIntegrityHash StandardCrypto) -> Aeson.Value
renderScriptIntegrityHash :: Maybe (ScriptIntegrityHash StandardCrypto) -> Value
renderScriptIntegrityHash (Just ScriptIntegrityHash StandardCrypto
witPPDataHash) =
  Text -> Value
Aeson.String (Text -> Value)
-> (Hash Blake2b_256 EraIndependentScriptIntegrity -> Text)
-> Hash Blake2b_256 EraIndependentScriptIntegrity
-> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Hash Blake2b_256 EraIndependentScriptIntegrity -> Text
forall h a. Hash h a -> Text
Crypto.hashToTextAsHex (Hash Blake2b_256 EraIndependentScriptIntegrity -> Value)
-> Hash Blake2b_256 EraIndependentScriptIntegrity -> Value
forall a b. (a -> b) -> a -> b
$ ScriptIntegrityHash StandardCrypto
-> Hash (HASH StandardCrypto) EraIndependentScriptIntegrity
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash ScriptIntegrityHash StandardCrypto
witPPDataHash
renderScriptIntegrityHash Maybe (ScriptIntegrityHash StandardCrypto)
Nothing = Value
Aeson.Null

renderScriptHash :: ScriptHash StandardCrypto -> Text
renderScriptHash :: ScriptHash StandardCrypto -> Text
renderScriptHash = ScriptHash -> Text
forall a. SerialiseAsRawBytes a => a -> Text
Api.serialiseToRawBytesHexText (ScriptHash -> Text)
-> (ScriptHash StandardCrypto -> ScriptHash)
-> ScriptHash StandardCrypto
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ScriptHash StandardCrypto -> ScriptHash
Api.fromShelleyScriptHash

renderMissingRedeemers :: [(Alonzo.ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)] -> Aeson.Value
renderMissingRedeemers :: [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
-> Value
renderMissingRedeemers [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
scripts = [Pair] -> Value
Aeson.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ ((ScriptPurpose StandardCrypto, ScriptHash StandardCrypto) -> Pair)
-> [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
-> [Pair]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (ScriptPurpose StandardCrypto, ScriptHash StandardCrypto) -> Pair
renderTuple  [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
scripts
 where
  renderTuple :: (Alonzo.ScriptPurpose StandardCrypto, ScriptHash StandardCrypto) -> Aeson.Pair
  renderTuple :: (ScriptPurpose StandardCrypto, ScriptHash StandardCrypto) -> Pair
renderTuple (ScriptPurpose StandardCrypto
scriptPurpose, ScriptHash StandardCrypto
sHash) =
    Text -> Key
Aeson.fromText (ScriptHash StandardCrypto -> Text
renderScriptHash ScriptHash StandardCrypto
sHash) Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ScriptPurpose StandardCrypto -> Value
renderScriptPurpose ScriptPurpose StandardCrypto
scriptPurpose

renderScriptPurpose :: Alonzo.ScriptPurpose StandardCrypto -> Aeson.Value
renderScriptPurpose :: ScriptPurpose StandardCrypto -> Value
renderScriptPurpose (Alonzo.Minting PolicyID StandardCrypto
pid) =
  [Pair] -> Value
Aeson.object [ Key
"minting" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PolicyID StandardCrypto -> Value
forall a. ToJSON a => a -> Value
toJSON PolicyID StandardCrypto
pid]
renderScriptPurpose (Alonzo.Spending TxIn StandardCrypto
txin) =
  [Pair] -> Value
Aeson.object [ Key
"spending" Key -> TxIn -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TxIn StandardCrypto -> TxIn
Api.fromShelleyTxIn TxIn StandardCrypto
txin]
renderScriptPurpose (Alonzo.Rewarding RewardAcnt StandardCrypto
rwdAcct) =
  [Pair] -> Value
Aeson.object [ Key
"rewarding" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String (StakeAddress -> Text
forall addr. SerialiseAddress addr => addr -> Text
Api.serialiseAddress (StakeAddress -> Text) -> StakeAddress -> Text
forall a b. (a -> b) -> a -> b
$ RewardAcnt StandardCrypto -> StakeAddress
Api.fromShelleyStakeAddr RewardAcnt StandardCrypto
rwdAcct)]
renderScriptPurpose (Alonzo.Certifying DCert StandardCrypto
cert) =
  [Pair] -> Value
Aeson.object [ Key
"certifying" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TextEnvelopeDescr -> Value
forall a. ToJSON a => a -> Value
toJSON (Certificate -> TextEnvelopeDescr
forall a. HasTextEnvelope a => a -> TextEnvelopeDescr
Api.textEnvelopeDefaultDescr (Certificate -> TextEnvelopeDescr)
-> Certificate -> TextEnvelopeDescr
forall a b. (a -> b) -> a -> b
$ DCert StandardCrypto -> Certificate
Api.fromShelleyCertificate DCert StandardCrypto
cert)]

instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (Core.EraRule "UTXO" era))
         ) => ToObject (UtxowPredicateFailure era) where
  toObject :: TracingVerbosity -> UtxowPredicateFailure era -> Object
toObject TracingVerbosity
_verb (ExtraneousScriptWitnessesUTXOW Set (ScriptHash (Crypto era))
extraneousScripts) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidWitnessesUTXOW"
             , Key
"extraneousScripts" Key -> Set (ScriptHash (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (ScriptHash (Crypto era))
extraneousScripts
             ]
  toObject TracingVerbosity
_verb (InvalidWitnessesUTXOW [VKey 'Witness (Crypto era)]
wits') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidWitnessesUTXOW"
             , Key
"invalidWitnesses" Key -> [Text] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (VKey 'Witness (Crypto era) -> Text)
-> [VKey 'Witness (Crypto era)] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map VKey 'Witness (Crypto era) -> Text
forall a. Show a => a -> Text
textShow [VKey 'Witness (Crypto era)]
wits'
             ]
  toObject TracingVerbosity
_verb (MissingVKeyWitnessesUTXOW Set (KeyHash 'Witness (Crypto era))
wits') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingVKeyWitnessesUTXOW"
             , Key
"missingWitnesses" Key -> Set (KeyHash 'Witness (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (KeyHash 'Witness (Crypto era))
wits'
             ]
  toObject TracingVerbosity
_verb (MissingScriptWitnessesUTXOW Set (ScriptHash (Crypto era))
missingScripts) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingScriptWitnessesUTXOW"
             , Key
"missingScripts" Key -> Set (ScriptHash (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (ScriptHash (Crypto era))
missingScripts
             ]
  toObject TracingVerbosity
_verb (ScriptWitnessNotValidatingUTXOW Set (ScriptHash (Crypto era))
failedScripts) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ScriptWitnessNotValidatingUTXOW"
             , Key
"failedScripts" Key -> Set (ScriptHash (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (ScriptHash (Crypto era))
failedScripts
             ]
  toObject TracingVerbosity
verb (UtxoFailure PredicateFailure (EraRule "UTXO" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "UTXO" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "UTXO" era)
f
  toObject TracingVerbosity
_verb (MIRInsufficientGenesisSigsUTXOW Set (KeyHash 'Witness (Crypto era))
genesisSigs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRInsufficientGenesisSigsUTXOW"
             , Key
"genesisSigs" Key -> Set (KeyHash 'Witness (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (KeyHash 'Witness (Crypto era))
genesisSigs
             ]
  toObject TracingVerbosity
_verb (MissingTxBodyMetadataHash AuxiliaryDataHash (Crypto era)
metadataHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingTxBodyMetadataHash"
             , Key
"metadataHash" Key -> AuxiliaryDataHash (Crypto era) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AuxiliaryDataHash (Crypto era)
metadataHash
             ]
  toObject TracingVerbosity
_verb (MissingTxMetadata AuxiliaryDataHash (Crypto era)
txBodyMetadataHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MissingTxMetadata"
             , Key
"txBodyMetadataHash" Key -> AuxiliaryDataHash (Crypto era) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AuxiliaryDataHash (Crypto era)
txBodyMetadataHash
             ]
  toObject TracingVerbosity
_verb (ConflictingMetadataHash AuxiliaryDataHash (Crypto era)
txBodyMetadataHash AuxiliaryDataHash (Crypto era)
fullMetadataHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConflictingMetadataHash"
             , Key
"txBodyMetadataHash" Key -> AuxiliaryDataHash (Crypto era) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AuxiliaryDataHash (Crypto era)
txBodyMetadataHash
             , Key
"fullMetadataHash" Key -> AuxiliaryDataHash (Crypto era) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AuxiliaryDataHash (Crypto era)
fullMetadataHash
             ]
  toObject TracingVerbosity
_verb UtxowPredicateFailure era
InvalidMetadata =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidMetadata"
             ]

instance ( ShelleyBasedEra era
         , ToJSON (Core.Value era)
         , ToJSON (Core.TxOut era)
         , ToObject (PredicateFailure (Core.EraRule "PPUP" era))
         )
      => ToObject (UtxoPredicateFailure era) where
  toObject :: TracingVerbosity -> UtxoPredicateFailure era -> Object
toObject TracingVerbosity
_verb (BadInputsUTxO Set (TxIn (Crypto era))
badInputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BadInputsUTxO"
             , Key
"badInputs" Key -> Set (TxIn (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era))
badInputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era)) -> Value
forall era. Set (TxIn era) -> Value
renderBadInputsUTxOErr Set (TxIn (Crypto era))
badInputs
             ]
  toObject TracingVerbosity
_verb (ExpiredUTxO SlotNo
ttl SlotNo
slot) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ExpiredUTxO"
             , Key
"ttl"  Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
ttl
             , Key
"slot" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
slot ]
  toObject TracingVerbosity
_verb (MaxTxSizeUTxO Integer
txsize Integer
maxtxsize) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MaxTxSizeUTxO"
             , Key
"size" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
txsize
             , Key
"maxSize" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
maxtxsize ]
  -- TODO: Add the minimum allowed UTxO value to OutputTooSmallUTxO
  toObject TracingVerbosity
_verb (OutputTooSmallUTxO [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputTooSmallUTxO"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The output is smaller than the allow minimum \
                                 \UTxO value defined in the protocol parameters"
             ]
  toObject TracingVerbosity
_verb (OutputBootAddrAttrsTooBig [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputBootAddrAttrsTooBig"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The Byron address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
InputSetEmptyUTxO =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InputSetEmptyUTxO" ]
  toObject TracingVerbosity
_verb (FeeTooSmallUTxO Coin
minfee Coin
txfee) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FeeTooSmallUTxO"
             , Key
"minimum" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
minfee
             , Key
"fee" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
txfee ]
  toObject TracingVerbosity
_verb (ValueNotConservedUTxO Value era
consumed Value era
produced) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ValueNotConservedUTxO"
             , Key
"consumed" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
consumed
             , Key
"produced" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
produced
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era -> Value era -> Value
forall val. Show val => val -> val -> Value
renderValueNotConservedErr Value era
consumed Value era
produced
             ]
  toObject TracingVerbosity
verb (UpdateFailure PredicateFailure (EraRule "PPUP" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "PPUP" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "PPUP" era)
f

  toObject TracingVerbosity
_verb (WrongNetwork Network
network Set (Addr (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetwork"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (Addr (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (Addr (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetworkWithdrawal"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (RewardAcnt (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (RewardAcnt (Crypto era))
addrs
             ]


instance ToJSON MA.ValidityInterval where
  toJSON :: ValidityInterval -> Value
toJSON ValidityInterval
vi =
    [Pair] -> Value
Aeson.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
        [ Key
"invalidBefore"    Key -> SlotNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
x | SlotNo
x <- StrictMaybe SlotNo -> [SlotNo]
forall a. StrictMaybe a -> [a]
mbfield (ValidityInterval -> StrictMaybe SlotNo
MA.invalidBefore    ValidityInterval
vi) ]
     [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Key
"invalidHereafter" Key -> SlotNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
x | SlotNo
x <- StrictMaybe SlotNo -> [SlotNo]
forall a. StrictMaybe a -> [a]
mbfield (ValidityInterval -> StrictMaybe SlotNo
MA.invalidHereafter ValidityInterval
vi) ]
    where
      mbfield :: StrictMaybe a -> [a]
mbfield StrictMaybe a
SNothing  = []
      mbfield (SJust a
x) = [a
x]

instance ( ShelleyBasedEra era
         , ToJSON (Core.Value era)
         , ToJSON (Core.TxOut era)
         , ToObject (PredicateFailure (Core.EraRule "PPUP" era))
         ) => ToObject (MA.UtxoPredicateFailure era) where
  toObject :: TracingVerbosity -> UtxoPredicateFailure era -> Object
toObject TracingVerbosity
_verb (MA.BadInputsUTxO Set (TxIn (Crypto era))
badInputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BadInputsUTxO"
             , Key
"badInputs" Key -> Set (TxIn (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era))
badInputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era)) -> Value
forall era. Set (TxIn era) -> Value
renderBadInputsUTxOErr Set (TxIn (Crypto era))
badInputs
             ]
  toObject TracingVerbosity
_verb (MA.OutsideValidityIntervalUTxO ValidityInterval
validityInterval SlotNo
slot) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ExpiredUTxO"
             , Key
"validityInterval" Key -> ValidityInterval -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ValidityInterval
validityInterval
             , Key
"slot" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
slot ]
  toObject TracingVerbosity
_verb (MA.MaxTxSizeUTxO Integer
txsize Integer
maxtxsize) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MaxTxSizeUTxO"
             , Key
"size" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
txsize
             , Key
"maxSize" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
maxtxsize ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
MA.InputSetEmptyUTxO =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InputSetEmptyUTxO" ]
  toObject TracingVerbosity
_verb (MA.FeeTooSmallUTxO Coin
minfee Coin
txfee) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FeeTooSmallUTxO"
             , Key
"minimum" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
minfee
             , Key
"fee" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
txfee ]
  toObject TracingVerbosity
_verb (MA.ValueNotConservedUTxO Value era
consumed Value era
produced) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ValueNotConservedUTxO"
             , Key
"consumed" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
consumed
             , Key
"produced" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
produced
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era -> Value era -> Value
forall val. Show val => val -> val -> Value
renderValueNotConservedErr Value era
consumed Value era
produced
             ]
  toObject TracingVerbosity
_verb (MA.WrongNetwork Network
network Set (Addr (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetwork"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (Addr (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (Addr (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (MA.WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetworkWithdrawal"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (RewardAcnt (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (RewardAcnt (Crypto era))
addrs
             ]
  -- TODO: Add the minimum allowed UTxO value to OutputTooSmallUTxO
  toObject TracingVerbosity
_verb (MA.OutputTooSmallUTxO [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputTooSmallUTxO"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The output is smaller than the allow minimum \
                                 \UTxO value defined in the protocol parameters"
             ]
  toObject TracingVerbosity
verb (MA.UpdateFailure PredicateFailure (EraRule "PPUP" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "PPUP" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "PPUP" era)
f
  toObject TracingVerbosity
_verb (MA.OutputBootAddrAttrsTooBig [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputBootAddrAttrsTooBig"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The Byron address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
MA.TriesToForgeADA =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TriesToForgeADA" ]
  toObject TracingVerbosity
_verb (MA.OutputTooBigUTxO [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputTooBigUTxO"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Too many asset ids in the tx output"
             ]

renderBadInputsUTxOErr ::  Set (TxIn era) -> Aeson.Value
renderBadInputsUTxOErr :: Set (TxIn era) -> Value
renderBadInputsUTxOErr Set (TxIn era)
txIns
  | Set (TxIn era) -> Bool
forall a. Set a -> Bool
Set.null Set (TxIn era)
txIns = Text -> Value
String Text
"The transaction contains no inputs."
  | Bool
otherwise = Text -> Value
String Text
"The transaction contains inputs that do not exist in the UTxO set."

renderValueNotConservedErr :: Show val => val -> val -> Aeson.Value
renderValueNotConservedErr :: val -> val -> Value
renderValueNotConservedErr val
consumed val
produced = Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$
    Text
"This transaction consumed " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> val -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show val
consumed Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" but produced " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> val -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show val
produced

instance Ledger.Era era => ToObject (PpupPredicateFailure era) where
  toObject :: TracingVerbosity -> PpupPredicateFailure era -> Object
toObject TracingVerbosity
_verb (NonGenesisUpdatePPUP Set (KeyHash 'Genesis (Crypto era))
proposalKeys Set (KeyHash 'Genesis (Crypto era))
genesisKeys) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NonGenesisUpdatePPUP"
             , Key
"keys" Key -> Set (KeyHash 'Genesis (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (KeyHash 'Genesis (Crypto era))
proposalKeys Set (KeyHash 'Genesis (Crypto era))
-> Set (KeyHash 'Genesis (Crypto era))
-> Set (KeyHash 'Genesis (Crypto era))
forall a. Ord a => Set a -> Set a -> Set a
Set.\\ Set (KeyHash 'Genesis (Crypto era))
genesisKeys ]
  toObject TracingVerbosity
_verb (PPUpdateWrongEpoch EpochNo
currEpoch EpochNo
intendedEpoch VotingPeriod
votingPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PPUpdateWrongEpoch"
             , Key
"currentEpoch" Key -> EpochNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= EpochNo
currEpoch
             , Key
"intendedEpoch" Key -> EpochNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= EpochNo
intendedEpoch
             , Key
"votingPeriod"  Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (VotingPeriod -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show VotingPeriod
votingPeriod)
             ]
  toObject TracingVerbosity
_verb (PVCannotFollowPPUP ProtVer
badPv) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PVCannotFollowPPUP"
             , Key
"badProtocolVersion" Key -> ProtVer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ProtVer
badPv
             ]


instance ( ShelleyBasedEra era
         , ToObject (PredicateFailure (Core.EraRule "DELPL" era))
         ) => ToObject (DelegsPredicateFailure era) where
  toObject :: TracingVerbosity -> DelegsPredicateFailure era -> Object
toObject TracingVerbosity
_verb (DelegateeNotRegisteredDELEG KeyHash 'StakePool (Crypto era)
targetPool) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DelegateeNotRegisteredDELEG"
             , Key
"targetPool" Key -> KeyHash 'StakePool (Crypto era) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool (Crypto era)
targetPool
             ]
  toObject TracingVerbosity
_verb (WithdrawalsNotInRewardsDELEGS Map (RewardAcnt (Crypto era)) Coin
incorrectWithdrawals) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WithdrawalsNotInRewardsDELEGS"
             , Key
"incorrectWithdrawals" Key -> Map (RewardAcnt (Crypto era)) Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Map (RewardAcnt (Crypto era)) Coin
incorrectWithdrawals
             ]
  toObject TracingVerbosity
verb (DelplFailure PredicateFailure (EraRule "DELPL" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "DELPL" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "DELPL" era)
f


instance ( ToObject (PredicateFailure (Core.EraRule "POOL" era))
         , ToObject (PredicateFailure (Core.EraRule "DELEG" era))
         ) => ToObject (DelplPredicateFailure era) where
  toObject :: TracingVerbosity -> DelplPredicateFailure era -> Object
toObject TracingVerbosity
verb (PoolFailure PredicateFailure (EraRule "POOL" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "POOL" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "POOL" era)
f
  toObject TracingVerbosity
verb (DelegFailure PredicateFailure (EraRule "DELEG" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "DELEG" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "DELEG" era)
f

instance Ledger.Era era => ToObject (DelegPredicateFailure era) where
  toObject :: TracingVerbosity -> DelegPredicateFailure era -> Object
toObject TracingVerbosity
_verb (StakeKeyAlreadyRegisteredDELEG Credential 'Staking (Crypto era)
alreadyRegistered) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakeKeyAlreadyRegisteredDELEG"
             , Key
"credential" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
alreadyRegistered)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Staking credential already registered"
             ]
  toObject TracingVerbosity
_verb (StakeKeyInRewardsDELEG Credential 'Staking (Crypto era)
alreadyRegistered) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakeKeyInRewardsDELEG"
             , Key
"credential" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
alreadyRegistered)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Staking credential registered in rewards map"
             ]
  toObject TracingVerbosity
_verb (StakeKeyNotRegisteredDELEG Credential 'Staking (Crypto era)
notRegistered) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakeKeyNotRegisteredDELEG"
             , Key
"credential" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
notRegistered)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Staking credential not registered"
             ]
  toObject TracingVerbosity
_verb (StakeKeyNonZeroAccountBalanceDELEG Maybe Coin
remBalance) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakeKeyNonZeroAccountBalanceDELEG"
             , Key
"remainingBalance" Key -> Maybe Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Coin
remBalance
             ]
  toObject TracingVerbosity
_verb (StakeDelegationImpossibleDELEG Credential 'Staking (Crypto era)
unregistered) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakeDelegationImpossibleDELEG"
             , Key
"credential" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
unregistered)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Cannot delegate this stake credential because it is not registered"
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
WrongCertificateTypeDELEG =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypeDELEG" ]
  toObject TracingVerbosity
_verb (GenesisKeyNotInMappingDELEG (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
genesisKeyHash)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GenesisKeyNotInMappingDELEG"
             , Key
"unknownKeyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
-> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
genesisKeyHash)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"This genesis key is not in the delegation mapping"
             ]
  toObject TracingVerbosity
_verb (DuplicateGenesisDelegateDELEG (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
genesisKeyHash)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisDelegateDELEG"
             , Key
"duplicateKeyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
-> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
genesisKeyHash)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"This genesis key has already been delegated to"
             ]
  toObject TracingVerbosity
_verb (InsufficientForInstantaneousRewardsDELEG MIRPot
mirpot Coin
neededMirAmount Coin
reserves) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InsufficientForInstantaneousRewardsDELEG"
             , Key
"pot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (case MIRPot
mirpot of
                                  MIRPot
ReservesMIR -> Text
"Reserves"
                                  MIRPot
TreasuryMIR -> Text
"Treasury")
             , Key
"neededAmount" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
neededMirAmount
             , Key
"reserves" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
reserves
             ]
  toObject TracingVerbosity
_verb (MIRCertificateTooLateinEpochDELEG SlotNo
currSlot SlotNo
boundSlotNo) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRCertificateTooLateinEpochDELEG"
             , Key
"currentSlotNo" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
currSlot
             , Key
"mustBeSubmittedBeforeSlotNo" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
boundSlotNo
             ]
  toObject TracingVerbosity
_verb (DuplicateGenesisVRFDELEG Hash (Crypto era) (VerKeyVRF (Crypto era))
vrfKeyHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisVRFDELEG"
             , Key
"keyHash" Key -> Hash (Crypto era) (VerKeyVRF (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash (Crypto era) (VerKeyVRF (Crypto era))
vrfKeyHash
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRTransferNotCurrentlyAllowed =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRTransferNotCurrentlyAllowed"
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRNegativesNotCurrentlyAllowed =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRNegativesNotCurrentlyAllowed"
             ]
  toObject TracingVerbosity
_verb (InsufficientForTransferDELEG MIRPot
mirpot Coin
attempted Coin
available) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisVRFDELEG"
             , Key
"pot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (case MIRPot
mirpot of
                                  MIRPot
ReservesMIR -> Text
"Reserves"
                                  MIRPot
TreasuryMIR -> Text
"Treasury")
             , Key
"attempted" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
attempted
             , Key
"available" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
available
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRProducesNegativeUpdate =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRProducesNegativeUpdate"
             ]
  toObject TracingVerbosity
_verb (MIRNegativeTransfer MIRPot
pot Coin
coin) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MIRNegativeTransfer"
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Attempt to transfer a negative amount from a pot."
             , Key
"pot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (case MIRPot
pot of
                                  MIRPot
ReservesMIR -> Text
"Reserves"
                                  MIRPot
TreasuryMIR -> Text
"Treasury")
             , Key
"amount" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
coin
             ]

instance ToObject (PoolPredicateFailure era) where
  toObject :: TracingVerbosity -> PoolPredicateFailure era -> Object
toObject TracingVerbosity
_verb (StakePoolNotRegisteredOnKeyPOOL (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
unregStakePool)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakePoolNotRegisteredOnKeyPOOL"
             , Key
"unregisteredKeyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
-> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
unregStakePool)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"This stake pool key hash is unregistered"
             ]
  toObject TracingVerbosity
_verb (StakePoolRetirementWrongEpochPOOL Word64
currentEpoch Word64
intendedRetireEpoch Word64
maxRetireEpoch) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakePoolRetirementWrongEpochPOOL"
             , Key
"currentEpoch" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currentEpoch)
             , Key
"intendedRetirementEpoch" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
intendedRetireEpoch)
             , Key
"maxEpochForRetirement" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
maxRetireEpoch)
             ]
  toObject TracingVerbosity
_verb (StakePoolCostTooLowPOOL Coin
certCost Coin
protCost) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StakePoolCostTooLowPOOL"
             , Key
"certificateCost" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
certCost)
             , Key
"protocolParCost" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
protCost)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The stake pool cost is too low"
             ]
  toObject TracingVerbosity
_verb (PoolMedataHashTooBig KeyHash 'StakePool (Crypto era)
poolID Int
hashSize) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PoolMedataHashTooBig"
             , Key
"poolID" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KeyHash 'StakePool (Crypto era) -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool (Crypto era)
poolID)
             , Key
"hashSize" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Int -> Text
forall a. Show a => a -> Text
textShow Int
hashSize)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The stake pool metadata hash is too large"
             ]

-- Apparently this should never happen according to the Shelley exec spec
  toObject TracingVerbosity
_verb (WrongCertificateTypePOOL Word8
index) =
    case Word8
index of
      Word8
0 -> [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: Delegation certificate"
                    ]
      Word8
1 -> [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: MIR certificate"
                    ]
      Word8
2 -> [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: Genesis certificate"
                    ]
      Word8
k -> [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Key
"certificateType" Key -> Word8 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word8
k
                    , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: Unknown certificate type"
                    ]

  toObject TracingVerbosity
_verb (WrongNetworkPOOL Network
networkId Network
listedNetworkId KeyHash 'StakePool (Crypto era)
poolId) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetworkPOOL"
             , Key
"networkId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Network -> Text
forall a. Show a => a -> Text
textShow Network
networkId)
             , Key
"listedNetworkId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Network -> Text
forall a. Show a => a -> Text
textShow Network
listedNetworkId)
             , Key
"poolId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KeyHash 'StakePool (Crypto era) -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool (Crypto era)
poolId)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Wrong network ID in pool registration certificate"
             ]

instance ( ToObject (PredicateFailure (Core.EraRule "NEWEPOCH" era))
         , ToObject (PredicateFailure (Core.EraRule "RUPD" era))
         ) => ToObject (TickPredicateFailure era) where
  toObject :: TracingVerbosity -> TickPredicateFailure era -> Object
toObject TracingVerbosity
verb (NewEpochFailure PredicateFailure (EraRule "NEWEPOCH" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "NEWEPOCH" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "NEWEPOCH" era)
f
  toObject TracingVerbosity
verb (RupdFailure PredicateFailure (EraRule "RUPD" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "RUPD" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "RUPD" era)
f

instance ToObject TicknPredicateFailure where
  toObject :: TracingVerbosity -> TicknPredicateFailure -> Object
toObject TracingVerbosity
_verb TicknPredicateFailure
x = case TicknPredicateFailure
x of {} -- no constructors

instance ( ToObject (PredicateFailure (Core.EraRule "EPOCH" era))
         , ToObject (PredicateFailure (Core.EraRule "MIR" era))
         ) => ToObject (NewEpochPredicateFailure era) where
  toObject :: TracingVerbosity -> NewEpochPredicateFailure era -> Object
toObject TracingVerbosity
verb (EpochFailure PredicateFailure (EraRule "EPOCH" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "EPOCH" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "EPOCH" era)
f
  toObject TracingVerbosity
verb (MirFailure PredicateFailure (EraRule "MIR" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "MIR" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "MIR" era)
f
  toObject TracingVerbosity
_verb (CorruptRewardUpdate RewardUpdate (Crypto era)
update) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CorruptRewardUpdate"
             , Key
"update" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (RewardUpdate (Crypto era) -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show RewardUpdate (Crypto era)
update) ]


instance ( ToObject (PredicateFailure (Core.EraRule "POOLREAP" era))
         , ToObject (PredicateFailure (Core.EraRule "SNAP" era))
         , ToObject (PredicateFailure (Core.EraRule "UPEC" era))
         ) => ToObject (EpochPredicateFailure era) where
  toObject :: TracingVerbosity -> EpochPredicateFailure era -> Object
toObject TracingVerbosity
verb (PoolReapFailure PredicateFailure (EraRule "POOLREAP" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "POOLREAP" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "POOLREAP" era)
f
  toObject TracingVerbosity
verb (SnapFailure PredicateFailure (EraRule "SNAP" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "SNAP" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "SNAP" era)
f
  toObject TracingVerbosity
verb (UpecFailure PredicateFailure (EraRule "UPEC" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "UPEC" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "UPEC" era)
f


instance ToObject (PoolreapPredicateFailure era) where
  toObject :: TracingVerbosity -> PoolreapPredicateFailure era -> Object
toObject TracingVerbosity
_verb PoolreapPredicateFailure era
x = case PoolreapPredicateFailure era
x of {} -- no constructors


instance ToObject (SnapPredicateFailure era) where
  toObject :: TracingVerbosity -> SnapPredicateFailure era -> Object
toObject TracingVerbosity
_verb SnapPredicateFailure era
x = case SnapPredicateFailure era
x of {} -- no constructors

-- TODO: Need to elaborate more on this error
instance ToObject (NewppPredicateFailure era) where
  toObject :: TracingVerbosity -> NewppPredicateFailure era -> Object
toObject TracingVerbosity
_verb (UnexpectedDepositPot Coin
outstandingDeposits Coin
depositPot) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnexpectedDepositPot"
             , Key
"outstandingDeposits" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
outstandingDeposits)
             , Key
"depositPot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
depositPot)
             ]


instance ToObject (MirPredicateFailure era) where
  toObject :: TracingVerbosity -> MirPredicateFailure era -> Object
toObject TracingVerbosity
_verb MirPredicateFailure era
x = case MirPredicateFailure era
x of {} -- no constructors


instance ToObject (RupdPredicateFailure era) where
  toObject :: TracingVerbosity -> RupdPredicateFailure era -> Object
toObject TracingVerbosity
_verb RupdPredicateFailure era
x = case RupdPredicateFailure era
x of {} -- no constructors


instance Core.Crypto crypto => ToObject (PrtclPredicateFailure crypto) where
  toObject :: TracingVerbosity -> PrtclPredicateFailure crypto -> Object
toObject  TracingVerbosity
verb (OverlayFailure PredicateFailure (OVERLAY crypto)
f) = TracingVerbosity -> OverlayPredicateFailure crypto -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (OVERLAY crypto)
OverlayPredicateFailure crypto
f
  toObject  TracingVerbosity
verb (UpdnFailure PredicateFailure (UPDN crypto)
f) = TracingVerbosity -> UpdnPredicateFailure crypto -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (UPDN crypto)
UpdnPredicateFailure crypto
f


instance Core.Crypto crypto => ToObject (OverlayPredicateFailure crypto) where
  toObject :: TracingVerbosity -> OverlayPredicateFailure crypto -> Object
toObject TracingVerbosity
_verb (UnknownGenesisKeyOVERLAY (KeyHash Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
genKeyHash)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnknownGenesisKeyOVERLAY"
             , Key
"unknownKeyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto)) -> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
genKeyHash)
             ]
  toObject TracingVerbosity
_verb (VRFKeyBadLeaderValue Nonce
seedNonce (SlotNo Word64
currSlotNo) Nonce
prevHashNonce CertifiedVRF (VRF crypto) Nonce
leaderElecVal) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyBadLeaderValueOVERLAY"
             , Key
"seedNonce" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
seedNonce)
             , Key
"currentSlot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currSlotNo)
             , Key
"previousHashAsNonce" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
prevHashNonce)
             , Key
"leaderElectionValue" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (CertifiedVRF (VRF crypto) Nonce -> Text
forall a. Show a => a -> Text
textShow CertifiedVRF (VRF crypto) Nonce
leaderElecVal)
             ]
  toObject TracingVerbosity
_verb (VRFKeyBadNonce Nonce
seedNonce (SlotNo Word64
currSlotNo) Nonce
prevHashNonce CertifiedVRF (VRF crypto) Nonce
blockNonce) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyBadNonceOVERLAY"
             , Key
"seedNonce" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
seedNonce)
             , Key
"currentSlot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currSlotNo)
             , Key
"previousHashAsNonce" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
prevHashNonce)
             , Key
"blockNonce" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (CertifiedVRF (VRF crypto) Nonce -> Text
forall a. Show a => a -> Text
textShow CertifiedVRF (VRF crypto) Nonce
blockNonce)
             ]
  toObject TracingVerbosity
_verb (VRFKeyWrongVRFKey KeyHash 'StakePool crypto
issuerHash Hash crypto (VerKeyVRF crypto)
regVRFKeyHash Hash crypto (VerKeyVRF crypto)
unregVRFKeyHash) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyWrongVRFKeyOVERLAY"
             , Key
"poolHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool crypto -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool crypto
issuerHash
             , Key
"registeredVRFKeHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto) -> Text
forall a. Show a => a -> Text
textShow Hash crypto (VerKeyVRF crypto)
regVRFKeyHash
             , Key
"unregisteredVRFKeyHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto) -> Text
forall a. Show a => a -> Text
textShow Hash crypto (VerKeyVRF crypto)
unregVRFKeyHash
             ]
  --TODO: Pipe slot number with VRFKeyUnknown
  toObject TracingVerbosity
_verb (VRFKeyUnknown (KeyHash Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
kHash)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyUnknownOVERLAY"
             , Key
"keyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto)) -> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
kHash)
             ]
  toObject TracingVerbosity
_verb (VRFLeaderValueTooBig OutputVRF (VRF crypto)
leadElecVal Rational
weightOfDelegPool ActiveSlotCoeff
actSlotCoefff) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFLeaderValueTooBigOVERLAY"
             , Key
"leaderElectionValue" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (OutputVRF (VRF crypto) -> Text
forall a. Show a => a -> Text
textShow OutputVRF (VRF crypto)
leadElecVal)
             , Key
"delegationPoolWeight" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Rational -> Text
forall a. Show a => a -> Text
textShow Rational
weightOfDelegPool)
             , Key
"activeSlotCoefficient" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (ActiveSlotCoeff -> Text
forall a. Show a => a -> Text
textShow ActiveSlotCoeff
actSlotCoefff)
             ]
  toObject TracingVerbosity
_verb (NotActiveSlotOVERLAY SlotNo
notActiveSlotNo) =
    -- TODO: Elaborate on NotActiveSlot error
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NotActiveSlotOVERLAY"
             , Key
"slot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (SlotNo -> Text
forall a. Show a => a -> Text
textShow SlotNo
notActiveSlotNo)
             ]
  toObject TracingVerbosity
_verb (WrongGenesisColdKeyOVERLAY KeyHash 'BlockIssuer crypto
actual KeyHash 'GenesisDelegate crypto
expected) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongGenesisColdKeyOVERLAY"
             , Key
"actual" Key -> KeyHash 'BlockIssuer crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'BlockIssuer crypto
actual
             , Key
"expected" Key -> KeyHash 'GenesisDelegate crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'GenesisDelegate crypto
expected ]
  toObject TracingVerbosity
_verb (WrongGenesisVRFKeyOVERLAY KeyHash 'BlockIssuer crypto
issuer Hash crypto (VerKeyVRF crypto)
actual Hash crypto (VerKeyVRF crypto)
expected) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongGenesisVRFKeyOVERLAY"
             , Key
"issuer" Key -> KeyHash 'BlockIssuer crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'BlockIssuer crypto
issuer
             , Key
"actual" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
actual
             , Key
"expected" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
expected ]
  toObject TracingVerbosity
verb (OcertFailure PredicateFailure (OCERT crypto)
f) = TracingVerbosity -> OcertPredicateFailure crypto -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (OCERT crypto)
OcertPredicateFailure crypto
f


instance ToObject (OcertPredicateFailure crypto) where
  toObject :: TracingVerbosity -> OcertPredicateFailure crypto -> Object
toObject TracingVerbosity
_verb (KESBeforeStartOCERT (KESPeriod KESEvolution
oCertstart) (KESPeriod KESEvolution
current)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESBeforeStartOCERT"
             , Key
"opCertKESStartPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
oCertstart)
             , Key
"currentKESPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
current)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Your operational certificate's KES start period \
                                 \is before the KES current period."
             ]
  toObject TracingVerbosity
_verb (KESAfterEndOCERT (KESPeriod KESEvolution
current) (KESPeriod KESEvolution
oCertstart) Word64
maxKESEvolutions) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESAfterEndOCERT"
             , Key
"currentKESPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
current)
             , Key
"opCertKESStartPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
oCertstart)
             , Key
"maxKESEvolutions" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String  (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
maxKESEvolutions)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The operational certificate's KES start period is \
                                 \greater than the max number of KES + the KES current period"
             ]
  toObject TracingVerbosity
_verb (CounterTooSmallOCERT Word64
lastKEScounterUsed Word64
currentKESCounter) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CounterTooSmallOCert"
             , Key
"currentKESCounter" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currentKESCounter)
             , Key
"lastKESCounter" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
lastKEScounterUsed)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The operational certificate's last KES counter is greater \
                                 \than the current KES counter."
             ]
  toObject TracingVerbosity
_verb (InvalidSignatureOCERT Word64
oCertCounter KESPeriod
oCertKESStartPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidSignatureOCERT"
             , Key
"opCertKESStartPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESPeriod -> Text
forall a. Show a => a -> Text
textShow KESPeriod
oCertKESStartPeriod)
             , Key
"opCertCounter" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
oCertCounter)
             ]
  toObject TracingVerbosity
_verb (InvalidKesSignatureOCERT KESEvolution
currKESPeriod KESEvolution
startKESPeriod KESEvolution
expectedKESEvolutions String
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidKesSignatureOCERT"
             , Key
"opCertKESStartPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
startKESPeriod)
             , Key
"opCertKESCurrentPeriod" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
currKESPeriod)
             , Key
"opCertExpectedKESEvolutions" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
expectedKESEvolutions)
             , Key
"error" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
err ]
  toObject TracingVerbosity
_verb (NoCounterForKeyHashOCERT (KeyHash Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
stakePoolKeyHash)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoCounterForKeyHashOCERT"
             , Key
"stakePoolKeyHash" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto)) -> Text
forall a. Show a => a -> Text
textShow Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
stakePoolKeyHash)
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"A counter was not found for this stake pool key hash"
             ]



instance ToObject (UpdnPredicateFailure crypto) where
  toObject :: TracingVerbosity -> UpdnPredicateFailure crypto -> Object
toObject TracingVerbosity
_verb UpdnPredicateFailure crypto
x = case UpdnPredicateFailure crypto
x of {} -- no constructors

instance ToObject (UpecPredicateFailure era) where
  toObject :: TracingVerbosity -> UpecPredicateFailure era -> Object
toObject TracingVerbosity
_verb (NewPpFailure (UnexpectedDepositPot totalOutstanding depositPot)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnexpectedDepositPot"
             , Key
"totalOutstanding" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=  Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
totalOutstanding)
             , Key
"depositPot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
depositPot)
             ]


--------------------------------------------------------------------------------
-- Alonzo related
--------------------------------------------------------------------------------


instance ( Ledger.Era era
         , ToJSON (Ledger.Value era)
         , ToJSON (Ledger.TxOut era)
         , ToObject (PredicateFailure (Ledger.EraRule "UTXOS" era))
         , ShelleyBasedEra era
         ) => ToObject (Alonzo.UtxoPredicateFailure era) where
  toObject :: TracingVerbosity -> UtxoPredicateFailure era -> Object
toObject TracingVerbosity
_verb (Alonzo.BadInputsUTxO Set (TxIn (Crypto era))
badInputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BadInputsUTxO"
             , Key
"badInputs" Key -> Set (TxIn (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era))
badInputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (TxIn (Crypto era)) -> Value
forall era. Set (TxIn era) -> Value
renderBadInputsUTxOErr Set (TxIn (Crypto era))
badInputs
             ]
  toObject TracingVerbosity
_verb (Alonzo.OutsideValidityIntervalUTxO ValidityInterval
validtyInterval SlotNo
slot) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ExpiredUTxO"
             , Key
"validityInterval" Key -> ValidityInterval -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ValidityInterval
validtyInterval
             , Key
"slot" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
slot
             ]
  toObject TracingVerbosity
_verb (Alonzo.MaxTxSizeUTxO Integer
txsize Integer
maxtxsize) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MaxTxSizeUTxO"
             , Key
"size" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
txsize
             , Key
"maxSize" Key -> Integer -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Integer
maxtxsize
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
Alonzo.InputSetEmptyUTxO =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InputSetEmptyUTxO" ]
  toObject TracingVerbosity
_verb (Alonzo.FeeTooSmallUTxO Coin
minfee Coin
currentFee) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FeeTooSmallUTxO"
             , Key
"minimum" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
minfee
             , Key
"fee" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
currentFee
             ]
  toObject TracingVerbosity
_verb (Alonzo.ValueNotConservedUTxO Value era
consumed Value era
produced) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ValueNotConservedUTxO"
             , Key
"consumed" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
consumed
             , Key
"produced" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
produced
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era -> Value era -> Value
forall val. Show val => val -> val -> Value
renderValueNotConservedErr Value era
consumed Value era
produced
             ]
  toObject TracingVerbosity
_verb (Alonzo.WrongNetwork Network
network Set (Addr (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetwork"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (Addr (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (Addr (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (Alonzo.WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto era))
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetworkWithdrawal"
             , Key
"network" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
network
             , Key
"addrs"   Key -> Set (RewardAcnt (Crypto era)) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (RewardAcnt (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (Alonzo.OutputTooSmallUTxO [TxOut era]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputTooSmallUTxO"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The output is smaller than the allow minimum \
                                 \UTxO value defined in the protocol parameters"
             ]
  toObject TracingVerbosity
verb (Alonzo.UtxosFailure PredicateFailure (EraRule "UTXOS" era)
predFailure) =
    TracingVerbosity
-> PredicateFailure (EraRule "UTXOS" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "UTXOS" era)
predFailure
  toObject TracingVerbosity
_verb (Alonzo.OutputBootAddrAttrsTooBig [TxOut era]
txouts) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputBootAddrAttrsTooBig"
             , Key
"outputs" Key -> [TxOut era] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [TxOut era]
txouts
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"The Byron address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
Alonzo.TriesToForgeADA =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TriesToForgeADA" ]
  toObject TracingVerbosity
_verb (Alonzo.OutputTooBigUTxO [(Integer, Integer, TxOut era)]
badOutputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutputTooBigUTxO"
             , Key
"outputs" Key -> [(Integer, Integer, TxOut era)] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Integer, Integer, TxOut era)]
badOutputs
             , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Too many asset ids in the tx output"
             ]
  toObject TracingVerbosity
_verb (Alonzo.InsufficientCollateral Coin
computedBalance Coin
suppliedFee) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InsufficientCollateral"
             , Key
"balance" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
computedBalance
             , Key
"txfee" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
suppliedFee
             ]
  toObject TracingVerbosity
_verb (Alonzo.ScriptsNotPaidUTxO UTxO era
utxos) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ScriptsNotPaidUTxO"
             , Key
"utxos" Key -> UTxO era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= UTxO era
utxos
             ]
  toObject TracingVerbosity
_verb (Alonzo.ExUnitsTooBigUTxO ExUnits
pParamsMaxExUnits ExUnits
suppliedExUnits) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ExUnitsTooBigUTxO"
             , Key
"maxexunits" Key -> ExUnits -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ExUnits
pParamsMaxExUnits
             , Key
"exunits" Key -> ExUnits -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ExUnits
suppliedExUnits
             ]
  toObject TracingVerbosity
_verb (Alonzo.CollateralContainsNonADA Value era
inputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CollateralContainsNonADA"
             , Key
"inputs" Key -> Value era -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value era
inputs
             ]
  toObject TracingVerbosity
_verb (Alonzo.WrongNetworkInTxBody Network
actualNetworkId Network
netIdInTxBody) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WrongNetworkInTxBody"
             , Key
"networkid" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
actualNetworkId
             , Key
"txbodyNetworkId" Key -> Network -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Network
netIdInTxBody
             ]
  toObject TracingVerbosity
_verb (Alonzo.OutsideForecast SlotNo
slotNum) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutsideForecast"
             , Key
"slot" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
slotNum
             ]
  toObject TracingVerbosity
_verb (Alonzo.TooManyCollateralInputs Natural
maxCollateralInputs Natural
numberCollateralInputs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TooManyCollateralInputs"
             , Key
"max" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
maxCollateralInputs
             , Key
"inputs" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
numberCollateralInputs
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
Alonzo.NoCollateralInputs =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoCollateralInputs" ]

instance ( ToJSON (Alonzo.CollectError (Ledger.Crypto era))
         , ToObject (PredicateFailure (Ledger.EraRule "PPUP" era))
         ) =>ToObject (Alonzo.UtxosPredicateFailure era) where
  toObject :: TracingVerbosity -> UtxosPredicateFailure era -> Object
toObject TracingVerbosity
_ (Alonzo.ValidationTagMismatch IsValid
isValidating TagMismatchDescription
reason) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ValidationTagMismatch"
             , Key
"isvalidating" Key -> IsValid -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IsValid
isValidating
             , Key
"reason" Key -> TagMismatchDescription -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TagMismatchDescription
reason
             ]
  toObject TracingVerbosity
_ (Alonzo.CollectErrors [CollectError (Crypto era)]
errors) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CollectErrors"
             , Key
"errors" Key -> [CollectError (Crypto era)] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [CollectError (Crypto era)]
errors
             ]
  toObject TracingVerbosity
verb (Alonzo.UpdateFailure PredicateFailure (EraRule "PPUP" era)
pFailure) =
    TracingVerbosity -> PredicateFailure (EraRule "PPUP" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "PPUP" era)
pFailure

deriving newtype instance ToJSON Alonzo.IsValid

instance ToJSON (Alonzo.CollectError StandardCrypto) where
  toJSON :: CollectError StandardCrypto -> Value
toJSON CollectError StandardCrypto
cError =
    case CollectError StandardCrypto
cError of
      Alonzo.NoRedeemer ScriptPurpose StandardCrypto
sPurpose ->
        [Pair] -> Value
object
          [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoRedeemer"
          , Key
"scriptpurpose" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ScriptPurpose StandardCrypto -> Value
renderScriptPurpose ScriptPurpose StandardCrypto
sPurpose
          ]
      Alonzo.NoWitness ScriptHash StandardCrypto
sHash ->
        [Pair] -> Value
object
          [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoWitness"
          , Key
"scripthash" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ScriptHash StandardCrypto -> Value
forall a. ToJSON a => a -> Value
toJSON ScriptHash StandardCrypto
sHash
          ]
      Alonzo.NoCostModel Language
lang ->
        [Pair] -> Value
object
          [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoCostModel"
          , Key
"language" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Language -> Value
forall a. ToJSON a => a -> Value
toJSON Language
lang
          ]
      Alonzo.BadTranslation TranslationError StandardCrypto
err ->
        [Pair] -> Value
object
          [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PlutusTranslationError"
          , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= case TranslationError StandardCrypto
err of
              Alonzo.ByronTxOutInContext TxOutSource StandardCrypto
txOutSource ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$
                  Text
"Cannot construct a Plutus ScriptContext from this transaction "
                    Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"due to a Byron UTxO being created or spent: "
                    Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TxOutSource StandardCrypto -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show TxOutSource StandardCrypto
txOutSource
              Alonzo.TranslationLogicMissingInput TxIn StandardCrypto
txin ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Transaction input does not exist in the UTxO: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TxIn StandardCrypto -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show TxIn StandardCrypto
txin
              Alonzo.RdmrPtrPointsToNothing RdmrPtr
ptr ->
                [Pair] -> Value
object
                  [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RedeemerPointerPointsToNothing"
                  , Key
"ptr" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (ScriptWitnessIndex -> String
Api.renderScriptWitnessIndex (ScriptWitnessIndex -> String)
-> (RdmrPtr -> ScriptWitnessIndex) -> RdmrPtr -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. RdmrPtr -> ScriptWitnessIndex
Api.fromAlonzoRdmrPtr) RdmrPtr
ptr
                  ]
              Alonzo.LanguageNotSupported Language
lang ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Language not supported: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Language -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show Language
lang
              Alonzo.InlineDatumsNotSupported TxOutSource StandardCrypto
txOutSource ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Inline datums not supported, output source: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TxOutSource StandardCrypto -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show TxOutSource StandardCrypto
txOutSource
              Alonzo.ReferenceScriptsNotSupported TxOutSource StandardCrypto
txOutSource ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Reference scripts not supported, output source: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TxOutSource StandardCrypto -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show TxOutSource StandardCrypto
txOutSource
              Alonzo.ReferenceInputsNotSupported Set (TxIn StandardCrypto)
txins ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Reference inputs not supported: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Set (TxIn StandardCrypto) -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show Set (TxIn StandardCrypto)
txins
              Alonzo.TimeTranslationPastHorizon Text
msg ->
                Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Text
"Time translation requested past the horizon: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show Text
msg
          ]

instance ToJSON Alonzo.TagMismatchDescription where
  toJSON :: TagMismatchDescription -> Value
toJSON TagMismatchDescription
tmd = case TagMismatchDescription
tmd of
    TagMismatchDescription
Alonzo.PassedUnexpectedly ->
      [Pair] -> Value
object
        [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TagMismatchDescription"
        , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PassedUnexpectedly"
        ]
    Alonzo.FailedUnexpectedly NonEmpty FailureDescription
forReasons ->
      [Pair] -> Value
object
        [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TagMismatchDescription"
        , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FailedUnexpectedly"
        , Key
"reconstruction" Key -> NonEmpty FailureDescription -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= NonEmpty FailureDescription
forReasons
        ]

instance ToJSON Alonzo.FailureDescription where
  toJSON :: FailureDescription -> Value
toJSON FailureDescription
f = case FailureDescription
f of
    Alonzo.PlutusFailure Text
t ByteString
_bs ->
      [Pair] -> Value
object
        [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FailureDescription"
        , Key
"error" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PlutusFailure"
        , Key
"description" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
t
        -- , "reconstructionDetail" .= bs
        ]

instance ( Ledger.Era era
         , Show (PredicateFailure (Ledger.EraRule "LEDGERS" era))
         ) => ToObject (AlonzoBbodyPredFail era) where
  toObject :: TracingVerbosity -> AlonzoBbodyPredFail era -> Object
toObject TracingVerbosity
_ AlonzoBbodyPredFail era
err = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AlonzoBbodyPredFail"
                            , Key
"error" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (AlonzoBbodyPredFail era -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show AlonzoBbodyPredFail era
err)
                            ]

--------------------------------------------------------------------------------
-- Babbage related
--------------------------------------------------------------------------------

instance ( ToJSON (Ledger.Value era)
         , ToJSON (Ledger.TxOut era)
         , ShelleyBasedEra era
         , ToObject (UtxowPredicateFail era)
         , ToObject (PredicateFailure (Ledger.EraRule "UTXOS" era))
         ) => ToObject (Babbage.BabbageUtxoPred era) where
  toObject :: TracingVerbosity -> BabbageUtxoPred era -> Object
toObject TracingVerbosity
v BabbageUtxoPred era
err =
    case BabbageUtxoPred era
err of
      Babbage.FromAlonzoUtxoFail UtxoPredicateFailure era
alonzoFail ->
        TracingVerbosity -> UtxoPredicateFailure era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v UtxoPredicateFailure era
alonzoFail

      Babbage.IncorrectTotalCollateralField Coin
provided Coin
declared ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnequalCollateralReturn"
                , Key
"collateralProvided" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
provided
                , Key
"collateralDeclared" Key -> Coin -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Coin
declared
                ]
      Babbage.BabbageOutputTooSmallUTxO [(TxOut era, Coin)]
outputs->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BabbageOutputTooSmall"
                , Key
"outputs" Key -> [(TxOut era, Coin)] -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(TxOut era, Coin)]
outputs
                ]

instance ( Ledger.Era era
         , ShelleyBasedEra era
         , Ledger.Crypto era ~ StandardCrypto
         , ToJSON (Ledger.Value era)
         , ToJSON (Ledger.TxOut era)
         , ToObject (UtxowPredicateFailure era)
         , ToObject (PredicateFailure (Ledger.EraRule "PPUP" era))
         , ToObject (PredicateFailure (Ledger.EraRule "UTXO" era))
         ) => ToObject (Babbage.BabbageUtxowPred era) where
  toObject :: TracingVerbosity -> BabbageUtxowPred era -> Object
toObject TracingVerbosity
v BabbageUtxowPred era
err =
    case BabbageUtxowPred era
err of
      Babbage.FromAlonzoUtxowFail UtxowPredicateFail era
alonzoFail ->
        TracingVerbosity -> UtxowPredicateFail era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v UtxowPredicateFail era
alonzoFail
      Babbage.UtxoFailure PredicateFailure (EraRule "UTXO" era)
utxoFail ->
        TracingVerbosity -> PredicateFailure (EraRule "UTXO" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v PredicateFailure (EraRule "UTXO" era)
utxoFail
      -- TODO: Plutus team needs to expose a better error type.
      Babbage.MalformedScriptWitnesses Set (ScriptHash (Crypto era))
s ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MalformedScriptWitnesses"
                , Key
"scripts" Key -> Set (ScriptHash StandardCrypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (ScriptHash StandardCrypto)
Set (ScriptHash (Crypto era))
s
                ]
      Babbage.MalformedReferenceScripts Set (ScriptHash (Crypto era))
s ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MalformedReferenceScripts"
                , Key
"scripts" Key -> Set (ScriptHash StandardCrypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set (ScriptHash StandardCrypto)
Set (ScriptHash (Crypto era))
s
                ]

instance Core.Crypto crypto => ToObject (Praos.PraosValidationErr crypto) where
  toObject :: TracingVerbosity -> PraosValidationErr crypto -> Object
toObject TracingVerbosity
_ PraosValidationErr crypto
err' =
    case PraosValidationErr crypto
err' of
      Praos.VRFKeyUnknown KeyHash 'StakePool crypto
unknownKeyHash ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyUnknown"
                , Key
"vrfKey" Key -> KeyHash 'StakePool crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool crypto
unknownKeyHash
                ]
      Praos.VRFKeyWrongVRFKey KeyHash 'StakePool crypto
stakePoolKeyHash Hash crypto (VerKeyVRF crypto)
registeredVrfForSaidStakepool Hash crypto (VerKeyVRF crypto)
wrongKeyHashInBlockHeader ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyWrongVRFKey"
                , Key
"stakePoolKeyHash" Key -> KeyHash 'StakePool crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool crypto
stakePoolKeyHash
                , Key
"stakePoolVrfKey" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
registeredVrfForSaidStakepool
                , Key
"blockHeaderVrfKey" Key -> Hash crypto (VerKeyVRF crypto) -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
wrongKeyHashInBlockHeader
                ]
      Praos.VRFKeyBadProof SlotNo
slotNo Nonce
nonce CertifiedVRF (VRF crypto) InputVRF
vrfCalculatedVal->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFKeyBadProof"
                , Key
"slotNumberUsedInVrfCalculation" Key -> SlotNo -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SlotNo
slotNo
                , Key
"nonceUsedInVrfCalculation" Key -> Nonce -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Nonce
nonce
                , Key
"calculatedVrfValue" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (CertifiedVRF (VRF crypto) InputVRF -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show CertifiedVRF (VRF crypto) InputVRF
vrfCalculatedVal)
                ]
      Praos.VRFLeaderValueTooBig Natural
leaderValue Rational
sigma ActiveSlotCoeff
f->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"VRFLeaderValueTooBig"
                , Key
"leaderValue" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
leaderValue
                , Key
"sigma" Key -> Rational -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Rational
sigma
                , Key
"f" Key -> FixedPoint -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ActiveSlotCoeff -> FixedPoint
activeSlotLog ActiveSlotCoeff
f
                ]
      Praos.KESBeforeStartOCERT KESPeriod
startKesPeriod KESPeriod
currKesPeriod ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESBeforeStartOCERT"
                , Key
"opCertStartingKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
startKesPeriod
                , Key
"currentKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
currKesPeriod
                ]
      Praos.KESAfterEndOCERT KESPeriod
currKesPeriod KESPeriod
startKesPeriod Word64
maxKesKeyEvos ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KESAfterEndOCERT"
                , Key
"opCertStartingKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
startKesPeriod
                , Key
"currentKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
currKesPeriod
                , Key
"maxKesKeyEvolutions" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
maxKesKeyEvos
                ]
      Praos.CounterTooSmallOCERT Word64
lastCounter Word64
currentCounter ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CounterTooSmallOCERT"
                , Key
"lastCounter" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
lastCounter
                , Key
"currentCounter" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
currentCounter
                ]
      Praos.CounterOverIncrementedOCERT Word64
lastCounter Word64
currentCounter ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CounterOverIncrementedOCERT"
                , Key
"lastCounter" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
lastCounter
                , Key
"currentCounter" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
currentCounter
                ]
      Praos.InvalidSignatureOCERT Word64
counter KESPeriod
oCertStartKesPeriod String
err ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidSignatureOCERT"
                , Key
"counter" Key -> Word64 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64
counter
                , Key
"opCertStartingKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
oCertStartKesPeriod
                , Key
"error" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
err
                ]
      Praos.InvalidKesSignatureOCERT KESEvolution
currentKesPeriod KESEvolution
opCertStartKesPeriod KESEvolution
expectedKesEvos String
err ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InvalidKesSignatureOCERT"
                , Key
"currentKesPeriod" Key -> KESEvolution -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESEvolution
currentKesPeriod
                , Key
"opCertStartingKesPeriod" Key -> KESEvolution -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESEvolution
opCertStartKesPeriod
                , Key
"expectedKesEvolutions" Key -> KESEvolution -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESEvolution
expectedKesEvos
                , Key
"error" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String
err
                ]
      Praos.NoCounterForKeyHashOCERT KeyHash 'BlockIssuer crypto
stakePoolKeyHash->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NoCounterForKeyHashOCERT"
                , Key
"stakePoolKeyHash" Key -> KeyHash 'BlockIssuer crypto -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'BlockIssuer crypto
stakePoolKeyHash
                ]

instance ToObject (Praos.PraosCannotForge crypto) where
  toObject :: TracingVerbosity -> PraosCannotForge crypto -> Object
toObject TracingVerbosity
_ (Praos.PraosCannotForgeKeyNotUsableYet KESPeriod
currentKesPeriod KESPeriod
startingKesPeriod) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PraosCannotForgeKeyNotUsableYet"
            , Key
"currentKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
currentKesPeriod
            , Key
"opCertStartingKesPeriod" Key -> KESPeriod -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KESPeriod
startingKesPeriod
            ]

instance ToObject Praos.PraosEnvelopeError where
  toObject :: TracingVerbosity -> PraosEnvelopeError -> Object
toObject TracingVerbosity
_ PraosEnvelopeError
err' =
    case PraosEnvelopeError
err' of
      Praos.ObsoleteNode Natural
maxPtclVersionFromPparams Natural
blkHeaderPtclVersion ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ObsoleteNode"
                , Key
"maxMajorProtocolVersion" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
maxPtclVersionFromPparams
                , Key
"headerProtocolVersion" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
blkHeaderPtclVersion
                ]
      Praos.HeaderSizeTooLarge Natural
headerSize Natural
ledgerViewMaxHeaderSize ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HeaderSizeTooLarge"
                , Key
"maxHeaderSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
ledgerViewMaxHeaderSize
                , Key
"headerSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
headerSize
                ]
      Praos.BlockSizeTooLarge Natural
blockSize Natural
ledgerViewMaxBlockSize ->
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BlockSizeTooLarge"
                , Key
"maxBlockSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
ledgerViewMaxBlockSize
                , Key
"blockSize" Key -> Natural -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Natural
blockSize
                ]

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

showLastAppBlockNo :: WithOrigin (LastAppliedBlock crypto) -> Text
showLastAppBlockNo :: WithOrigin (LastAppliedBlock crypto) -> Text
showLastAppBlockNo WithOrigin (LastAppliedBlock crypto)
wOblk =  case WithOrigin (LastAppliedBlock crypto)
-> Maybe (LastAppliedBlock crypto)
forall t. WithOrigin t -> Maybe t
withOriginToMaybe WithOrigin (LastAppliedBlock crypto)
wOblk of
                     Maybe (LastAppliedBlock crypto)
Nothing -> Text
"Genesis Block"
                     Just LastAppliedBlock crypto
blk -> Word64 -> Text
forall a. Show a => a -> Text
textShow (Word64 -> Text) -> (BlockNo -> Word64) -> BlockNo -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BlockNo -> Word64
unBlockNo (BlockNo -> Text) -> BlockNo -> Text
forall a b. (a -> b) -> a -> b
$ LastAppliedBlock crypto -> BlockNo
forall crypto. LastAppliedBlock crypto -> BlockNo
labBlockNo LastAppliedBlock crypto
blk

-- Common to cardano-cli

deriving newtype instance Core.Crypto crypto => ToJSON (Core.AuxiliaryDataHash crypto)

deriving newtype instance Core.Crypto crypto => ToJSON (TxId crypto)