{-# 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.HashMap.Strict as HMS
import qualified Data.Set as Set
import qualified Data.Text as Text

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           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           Ouroboros.Consensus.Shelley.Ledger hiding (TxId)
import           Ouroboros.Consensus.Shelley.Ledger.Inspect
import           Ouroboros.Consensus.Shelley.Protocol (TPraosCannotForge (..))
import qualified Ouroboros.Consensus.Shelley.Protocol.HotKey as HotKey

import qualified Cardano.Crypto.Hash.Class as Crypto
import           Cardano.Ledger.Alonzo as Alonzo
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 (AlonzoPredFail (..))
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
import qualified Cardano.Ledger.AuxiliaryData as Core
import           Cardano.Ledger.BaseTypes (strictMaybeToMaybe)
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.SafeHash as SafeHash
import qualified Cardano.Ledger.ShelleyMA.Rules.Utxo as MA
import qualified Cardano.Ledger.ShelleyMA.Timelocks as MA


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

import           Shelley.Spec.Ledger.STS.Bbody
import           Shelley.Spec.Ledger.STS.Chain
import           Shelley.Spec.Ledger.STS.Deleg
import           Shelley.Spec.Ledger.STS.Delegs
import           Shelley.Spec.Ledger.STS.Delpl
import           Shelley.Spec.Ledger.STS.Epoch
import           Shelley.Spec.Ledger.STS.Ledger
import           Shelley.Spec.Ledger.STS.Ledgers
import           Shelley.Spec.Ledger.STS.Mir
import           Shelley.Spec.Ledger.STS.NewEpoch
import           Shelley.Spec.Ledger.STS.Newpp
import           Shelley.Spec.Ledger.STS.Ocert
import           Shelley.Spec.Ledger.STS.Overlay
import           Shelley.Spec.Ledger.STS.Pool
import           Shelley.Spec.Ledger.STS.PoolReap
import           Shelley.Spec.Ledger.STS.Ppup
import           Shelley.Spec.Ledger.STS.Rupd
import           Shelley.Spec.Ledger.STS.Snap
import           Shelley.Spec.Ledger.STS.Tick
import           Shelley.Spec.Ledger.STS.Updn
import           Shelley.Spec.Ledger.STS.Upec
import           Shelley.Spec.Ledger.STS.Utxo
import           Shelley.Spec.Ledger.STS.Utxow

{- HLINT ignore "Use :" -}

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

instance ShelleyBasedEra era => ToObject (GenTx (ShelleyBlock era)) where
  toObject :: TracingVerbosity -> GenTx (ShelleyBlock era) -> Object
toObject TracingVerbosity
verb GenTx (ShelleyBlock era)
tx =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject ([(Text, Value)] -> Object) -> [(Text, Value)] -> Object
forall a b. (a -> b) -> a -> b
$
        [ Text
"txid" Text -> TxId (GenTx (ShelleyBlock era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= GenTx (ShelleyBlock era) -> TxId (GenTx (ShelleyBlock era))
forall tx. HasTxId tx => tx -> TxId tx
txId GenTx (ShelleyBlock era)
tx ]
     [(Text, Value)] -> [(Text, Value)] -> [(Text, Value)]
forall a. [a] -> [a] -> [a]
++ [ Text
"tx"   Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= GenTx (ShelleyBlock era) -> String
forall a. Condense a => a -> String
condense GenTx (ShelleyBlock era)
tx | TracingVerbosity
verb TracingVerbosity -> TracingVerbosity -> Bool
forall a. Eq a => a -> a -> Bool
== TracingVerbosity
MaximalVerbosity ]

instance ToJSON (SupportsMempool.TxId (GenTx (ShelleyBlock era))) where
  toJSON :: TxId (GenTx (ShelleyBlock era)) -> Value
toJSON TxId (GenTx (ShelleyBlock era))
i = String -> Value
forall a. ToJSON a => a -> Value
toJSON (TxId (GenTx (ShelleyBlock era)) -> String
forall a. Condense a => a -> String
condense TxId (GenTx (ShelleyBlock era))
i)

instance ShelleyBasedEra era => ToObject (Header (ShelleyBlock era)) where
  toObject :: TracingVerbosity -> Header (ShelleyBlock era) -> Object
toObject TracingVerbosity
_verb Header (ShelleyBlock era)
b = [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
        [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ShelleyBlock"
        , Text
"hash" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ShelleyHash (Crypto era) -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock era) -> HeaderHash (Header (ShelleyBlock era))
forall b. HasHeader b => b -> HeaderHash b
blockHash Header (ShelleyBlock era)
b)
        , Text
"slotNo" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock era) -> SlotNo
forall b. HasHeader b => b -> SlotNo
blockSlot Header (ShelleyBlock era)
b)
        , Text
"blockNo" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= BlockNo -> String
forall a. Condense a => a -> String
condense (Header (ShelleyBlock era) -> BlockNo
forall b. HasHeader b => b -> BlockNo
blockNo Header (ShelleyBlock 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 k v. (Eq k, Hashable k) => [HashMap k v] -> HashMap k v
HMS.unions ([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 ToObject (TPraosCannotForge era) where
  toObject :: TracingVerbosity -> TPraosCannotForge era -> Object
toObject TracingVerbosity
_verb (TPraosCannotForgeKeyNotUsableYet KESPeriod
wallClockPeriod KESPeriod
keyStartPeriod) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
      [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"TPraosCannotForgeKeyNotUsableYet"
      , Text
"keyStart" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESPeriod
keyStartPeriod
      , Text
"wallClock" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESPeriod
wallClockPeriod
      ]
  toObject TracingVerbosity
_verb (TPraosCannotForgeWrongVRF Hash era (VerKeyVRF era)
genDlgVRFHash Hash era (VerKeyVRF era)
coreNodeVRFHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
      [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"TPraosCannotLeadWrongVRF"
      , Text
"expected" Text -> Hash era (VerKeyVRF era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash era (VerKeyVRF era)
genDlgVRFHash
      , Text
"actual" Text -> Hash era (VerKeyVRF era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash era (VerKeyVRF era)
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 } =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
      [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"KESInfo"
      , Text
"startPeriod" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESPeriod
kesStartPeriod
      , Text
"endPeriod" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESPeriod
kesEndPeriod
      , Text
"evolution" Text -> KESEvolution -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESEvolution
kesEvolution
      ]

instance ToObject HotKey.KESEvolutionError where
  toObject :: TracingVerbosity -> KESEvolutionError -> Object
toObject TracingVerbosity
verb (HotKey.KESCouldNotEvolve KESInfo
kesInfo KESPeriod
targetPeriod) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
      [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"KESCouldNotEvolve"
      , Text
"kesInfo" Text -> Object -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TracingVerbosity -> KESInfo -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb KESInfo
kesInfo
      , Text
"targetPeriod" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KESPeriod
targetPeriod
      ]
  toObject TracingVerbosity
verb (HotKey.KESKeyAlreadyPoisoned KESInfo
kesInfo KESPeriod
targetPeriod) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
      [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"KESKeyAlreadyPoisoned"
      , Text
"kesInfo" Text -> Object -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TracingVerbosity -> KESInfo -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb KESInfo
kesInfo
      , Text
"targetPeriod" Text -> KESPeriod -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"BBodyError"
             , Text
"failures" Text -> [Object] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ShelleyUpdatedProtocolUpdates"
             , Text
"updates" Text -> [Object] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 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} =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"proposal" Text -> Object -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TracingVerbosity -> UpdateProposal era -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb UpdateProposal era
protocolUpdateProposal
             , Text
"state"    Text -> Object -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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} =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"params"  Text -> PParamsDelta era -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParamsDelta era
proposalParams
             , Text
"version" Text -> Maybe ProtVer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe ProtVer
proposalVersion
             , Text
"epoch"   Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
proposalEpoch
             ]

instance 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} =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"proposal"      Text -> [KeyHash 'Genesis crypto] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [KeyHash 'Genesis crypto]
proposalVotes
             , Text
"reachedQuorum" Text -> Bool -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ChainTransitionError"
             , Text
"failures" Text -> [Object] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 ( ShelleyBasedEra era
         , ToObject (PredicateFailure (Core.EraRule "UTXOW" era))
         , ToObject (PredicateFailure (Core.EraRule "BBODY" era))
         , ToObject (PredicateFailure (Core.EraRule "TICK" era))
         , ToObject (PredicateFailure (Core.EraRule "TICKN" era))
         ) => ToObject (ChainPredicateFailure era) where
  toObject :: TracingVerbosity -> ChainPredicateFailure era -> Object
toObject TracingVerbosity
_verb (HeaderSizeTooLargeCHAIN Natural
hdrSz Natural
maxHdrSz) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"HeaderSizeTooLarge"
             , Text
"headerSize" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
hdrSz
             , Text
"maxHeaderSize" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
maxHdrSz
             ]
  toObject TracingVerbosity
_verb (BlockSizeTooLargeCHAIN Natural
blkSz Natural
maxBlkSz) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"BlockSizeTooLarge"
             , Text
"blockSize" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
blkSz
             , Text
"maxBlockSize" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
maxBlkSz
             ]
  toObject TracingVerbosity
_verb (ObsoleteNodeCHAIN Natural
currentPtcl Natural
supportedPtcl) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ObsoleteNode"
             , Text
"explanation" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
explanation
             , Text
"currentProtocol" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
currentPtcl
             , Text
"supportedProtocol" Text -> Natural -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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."
  toObject TracingVerbosity
verb (BbodyFailure PredicateFailure (EraRule "BBODY" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "BBODY" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "BBODY" era)
f
  toObject TracingVerbosity
verb (TickFailure  PredicateFailure (EraRule "TICK" era)
f) = TracingVerbosity -> PredicateFailure (EraRule "TICK" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "TICK" era)
f
  toObject TracingVerbosity
verb (TicknFailure  PredicateFailure (EraRule "TICKN" era)
f) = TracingVerbosity
-> PredicateFailure (EraRule "TICKN" era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "TICKN" era)
f
  toObject TracingVerbosity
verb (PrtclFailure PredicateFailure (PRTCL (Crypto era))
f) = TracingVerbosity -> PrtclPredicateFailure (Crypto era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (PRTCL (Crypto era))
PrtclPredicateFailure (Crypto era)
f
  toObject TracingVerbosity
verb (PrtclSeqFailure PrtlSeqFailure (Crypto era)
f) = TracingVerbosity -> PrtlSeqFailure (Crypto era) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PrtlSeqFailure (Crypto era)
f

instance ToObject (PrtlSeqFailure crypto) where
  toObject :: TracingVerbosity -> PrtlSeqFailure crypto -> Object
toObject TracingVerbosity
_verb (WrongSlotIntervalPrtclSeq (SlotNo Word64
lastSlot) (SlotNo Word64
currSlot)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongSlotInterval"
             , Text
"lastSlot" Text -> Word64 -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Word64
lastSlot
             , Text
"currentSlot" Text -> Word64 -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Word64
currSlot
             ]
  toObject TracingVerbosity
_verb (WrongBlockNoPrtclSeq WithOrigin (LastAppliedBlock crypto)
lab BlockNo
currentBlockNo) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongBlockNo"
             , Text
"lastAppliedBlockNo" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= WithOrigin (LastAppliedBlock crypto) -> Text
forall crypto. WithOrigin (LastAppliedBlock crypto) -> Text
showLastAppBlockNo WithOrigin (LastAppliedBlock crypto)
lab
             , Text
"currentBlockNo" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongBlockSequence"
             , Text
"lastAppliedBlockHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (PrevHash crypto -> Text
forall a. Show a => a -> Text
textShow PrevHash crypto
lastAppliedHash)
             , Text
"currentBlockHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongBlockBodySizeBBODY"
             , Text
"actualBlockBodySize" Text -> Int -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Int
actualBodySz
             , Text
"claimedBlockBodySize" Text -> Int -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Int
claimedBodySz
             ]
  toObject TracingVerbosity
_verb (InvalidBodyHashBBODY Hash (Crypto era) EraIndependentBlockBody
actualHash Hash (Crypto era) EraIndependentBlockBody
claimedHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InvalidBodyHashBBODY"
             , Text
"actualBodyHash" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash (Crypto era) EraIndependentBlockBody -> Text
forall a. Show a => a -> Text
textShow Hash (Crypto era) EraIndependentBlockBody
actualHash
             , Text
"claimedBodyHash" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 ToObject (AlonzoPredFail (Alonzo.AlonzoEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> AlonzoPredFail (AlonzoEra StandardCrypto) -> Object
toObject TracingVerbosity
v (WrappedShelleyEraFailure UtxowPredicateFailure (AlonzoEra StandardCrypto)
utxoPredFail) =
    TracingVerbosity
-> UtxowPredicateFailure (AlonzoEra StandardCrypto) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v UtxowPredicateFailure (AlonzoEra StandardCrypto)
utxoPredFail
  toObject TracingVerbosity
_ (MissingRedeemers [(ScriptPurpose (Crypto (AlonzoEra StandardCrypto)),
  ScriptHash (Crypto (AlonzoEra StandardCrypto)))]
scripts) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingRedeemers"
             , Text
"scripts" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
-> Value
renderMissingRedeemers [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
[(ScriptPurpose (Crypto (AlonzoEra StandardCrypto)),
  ScriptHash (Crypto (AlonzoEra StandardCrypto)))]
scripts
             ]
  toObject TracingVerbosity
_ (MissingRequiredDatums Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
required Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
received) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingRequiredDatums"
             , Text
"required" Text -> [Text] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (AlonzoEra StandardCrypto)))
required)
             , Text
"received" Text -> [Text] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (AlonzoEra StandardCrypto)))
received)
             ]
  toObject TracingVerbosity
_ (PPViewHashesDontMatch StrictMaybe
  (ScriptIntegrityHash (Crypto (AlonzoEra StandardCrypto)))
ppHashInTxBody StrictMaybe
  (ScriptIntegrityHash (Crypto (AlonzoEra StandardCrypto)))
ppHashFromPParams) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"PPViewHashesDontMatch"
             , Text
"fromTxBody" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (AlonzoEra StandardCrypto)))
ppHashInTxBody)
             , Text
"fromPParams" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (AlonzoEra StandardCrypto)))
ppHashFromPParams)
             ]
  toObject TracingVerbosity
_ (MissingRequiredSigners Set (KeyHash 'Witness (Crypto (AlonzoEra StandardCrypto)))
missingKeyWitnesses) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingRequiredSigners"
             , Text
"witnesses" Text -> [KeyHash 'Witness StandardCrypto] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (KeyHash 'Witness StandardCrypto)
-> [KeyHash 'Witness StandardCrypto]
forall a. Set a -> [a]
Set.toList Set (KeyHash 'Witness StandardCrypto)
Set (KeyHash 'Witness (Crypto (AlonzoEra StandardCrypto)))
missingKeyWitnesses
             ]
  toObject TracingVerbosity
_ (UnspendableUTxONoDatumHash Set (TxIn (Crypto (AlonzoEra StandardCrypto)))
txins) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingRequiredSigners"
             , Text
"txins" Text -> [TxIn StandardCrypto] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (TxIn StandardCrypto) -> [TxIn StandardCrypto]
forall a. Set a -> [a]
Set.toList Set (TxIn StandardCrypto)
Set (TxIn (Crypto (AlonzoEra StandardCrypto)))
txins
             ]
  toObject TracingVerbosity
_ (NonOutputSupplimentaryDatums Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
disallowed Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
acceptable) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NonOutputSupplimentaryDatums"
             , Text
"disallowed" Text
-> [SafeHash StandardCrypto EraIndependentData] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
disallowed
             , Text
"acceptable" Text
-> [SafeHash StandardCrypto EraIndependentData] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (SafeHash StandardCrypto EraIndependentData)
-> [SafeHash StandardCrypto EraIndependentData]
forall a. Set a -> [a]
Set.toList Set (SafeHash StandardCrypto EraIndependentData)
Set (DataHash (Crypto (AlonzoEra StandardCrypto)))
acceptable
             ]
  toObject TracingVerbosity
_ (ExtraRedeemers [RdmrPtr]
rdmrs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ExtraRedeemers"
             , Text
"rdmrs" Text -> [String] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 = [(Text, Value)] -> Value
Aeson.object ([(Text, Value)] -> Value) -> [(Text, Value)] -> Value
forall a b. (a -> b) -> a -> b
$ ((ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)
 -> (Text, Value))
-> [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
-> [(Text, Value)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)
-> (Text, Value)
renderTuple  [(ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)]
scripts
 where
  renderTuple :: (Alonzo.ScriptPurpose StandardCrypto, ScriptHash StandardCrypto) -> Aeson.Pair
  renderTuple :: (ScriptPurpose StandardCrypto, ScriptHash StandardCrypto)
-> (Text, Value)
renderTuple (ScriptPurpose StandardCrypto
scriptPurpose, ScriptHash StandardCrypto
sHash) =  ScriptHash StandardCrypto -> Text
renderScriptHash ScriptHash StandardCrypto
sHash Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
  [(Text, Value)] -> Value
Aeson.object [ Text
"minting" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PolicyID StandardCrypto -> Value
forall a. ToJSON a => a -> Value
toJSON PolicyID StandardCrypto
pid]
renderScriptPurpose (Alonzo.Spending TxIn StandardCrypto
txin) =
  [(Text, Value)] -> Value
Aeson.object [ Text
"spending" Text -> TxIn -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TxIn StandardCrypto -> TxIn
Api.fromShelleyTxIn TxIn StandardCrypto
txin]
renderScriptPurpose (Alonzo.Rewarding RewardAcnt StandardCrypto
rwdAcct) =
  [(Text, Value)] -> Value
Aeson.object [ Text
"rewarding" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
  [(Text, Value)] -> Value
Aeson.object [ Text
"certifying" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (InvalidWitnessesUTXOW [VKey 'Witness (Crypto era)]
wits') =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InvalidWitnessesUTXOW"
             , Text
"invalidWitnesses" Text -> [Text] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (WitHashes Set (KeyHash 'Witness (Crypto era))
wits')) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingVKeyWitnessesUTXOW"
             , Text
"missingWitnesses" Text -> Set (KeyHash 'Witness (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (KeyHash 'Witness (Crypto era))
wits'
             ]
  toObject TracingVerbosity
_verb (MissingScriptWitnessesUTXOW Set (ScriptHash (Crypto era))
missingScripts) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingScriptWitnessesUTXOW"
             , Text
"missingScripts" Text -> Set (ScriptHash (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (ScriptHash (Crypto era))
missingScripts
             ]
  toObject TracingVerbosity
_verb (ScriptWitnessNotValidatingUTXOW Set (ScriptHash (Crypto era))
failedScripts) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ScriptWitnessNotValidatingUTXOW"
             , Text
"failedScripts" Text -> Set (ScriptHash (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MIRInsufficientGenesisSigsUTXOW"
             , Text
"genesisSigs" Text -> Set (KeyHash 'Witness (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (KeyHash 'Witness (Crypto era))
genesisSigs
             ]
  toObject TracingVerbosity
_verb (MissingTxBodyMetadataHash AuxiliaryDataHash (Crypto era)
metadataHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingTxBodyMetadataHash"
             , Text
"metadataHash" Text -> AuxiliaryDataHash (Crypto era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AuxiliaryDataHash (Crypto era)
metadataHash
             ]
  toObject TracingVerbosity
_verb (MissingTxMetadata AuxiliaryDataHash (Crypto era)
txBodyMetadataHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MissingTxMetadata"
             , Text
"txBodyMetadataHash" Text -> AuxiliaryDataHash (Crypto era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AuxiliaryDataHash (Crypto era)
txBodyMetadataHash
             ]
  toObject TracingVerbosity
_verb (ConflictingMetadataHash AuxiliaryDataHash (Crypto era)
txBodyMetadataHash AuxiliaryDataHash (Crypto era)
fullMetadataHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ConflictingMetadataHash"
             , Text
"txBodyMetadataHash" Text -> AuxiliaryDataHash (Crypto era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AuxiliaryDataHash (Crypto era)
txBodyMetadataHash
             , Text
"fullMetadataHash" Text -> AuxiliaryDataHash (Crypto era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AuxiliaryDataHash (Crypto era)
fullMetadataHash
             ]
  toObject TracingVerbosity
_verb UtxowPredicateFailure era
InvalidMetadata =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"BadInputsUTxO"
             , Text
"badInputs" Text -> Set (TxIn (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (TxIn (Crypto era))
badInputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ExpiredUTxO"
             , Text
"ttl"  Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
ttl
             , Text
"slot" Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
slot ]
  toObject TracingVerbosity
_verb (MaxTxSizeUTxO Integer
txsize Integer
maxtxsize) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MaxTxSizeUTxO"
             , Text
"size" Text -> Integer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
txsize
             , Text
"maxSize" Text -> Integer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
maxtxsize ]
  -- TODO: Add the minimum allowed UTxO value to OutputTooSmallUTxO
  toObject TracingVerbosity
_verb (OutputTooSmallUTxO [TxOut era]
badOutputs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"OutputTooSmallUTxO"
             , Text
"outputs" Text -> [TxOut era] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut era]
badOutputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"OutputBootAddrAttrsTooBig"
             , Text
"outputs" Text -> [TxOut era] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut era]
badOutputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"The Byron address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
InputSetEmptyUTxO =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InputSetEmptyUTxO" ]
  toObject TracingVerbosity
_verb (FeeTooSmallUTxO Coin
minfee Coin
txfee) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"FeeTooSmallUTxO"
             , Text
"minimum" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
minfee
             , Text
"fee" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
txfee ]
  toObject TracingVerbosity
_verb (ValueNotConservedUTxO Value era
consumed Value era
produced) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ValueNotConservedUTxO"
             , Text
"consumed" Text -> Value era -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era
consumed
             , Text
"produced" Text -> Value era -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era
produced
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongNetwork"
             , Text
"network" Text -> Network -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Network
network
             , Text
"addrs"   Text -> Set (Addr (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (Addr (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto era))
addrs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongNetworkWithdrawal"
             , Text
"network" Text -> Network -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Network
network
             , Text
"addrs"   Text -> Set (RewardAcnt (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (RewardAcnt (Crypto era))
addrs
             ]

instance ToJSON MA.ValidityInterval where
  toJSON :: ValidityInterval -> Value
toJSON ValidityInterval
vi =
    [(Text, Value)] -> Value
Aeson.object ([(Text, Value)] -> Value) -> [(Text, Value)] -> Value
forall a b. (a -> b) -> a -> b
$
        [ Text
"invalidBefore"    Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
x | SlotNo
x <- StrictMaybe SlotNo -> [SlotNo]
forall a. StrictMaybe a -> [a]
mbfield (ValidityInterval -> StrictMaybe SlotNo
MA.invalidBefore    ValidityInterval
vi) ]
     [(Text, Value)] -> [(Text, Value)] -> [(Text, Value)]
forall a. [a] -> [a] -> [a]
++ [ Text
"invalidHereafter" Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"BadInputsUTxO"
             , Text
"badInputs" Text -> Set (TxIn (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (TxIn (Crypto era))
badInputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ExpiredUTxO"
             , Text
"validityInterval" Text -> ValidityInterval -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ValidityInterval
validityInterval
             , Text
"slot" Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
slot ]
  toObject TracingVerbosity
_verb (MA.MaxTxSizeUTxO Integer
txsize Integer
maxtxsize) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MaxTxSizeUTxO"
             , Text
"size" Text -> Integer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
txsize
             , Text
"maxSize" Text -> Integer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer
maxtxsize ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
MA.InputSetEmptyUTxO =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InputSetEmptyUTxO" ]
  toObject TracingVerbosity
_verb (MA.FeeTooSmallUTxO Coin
minfee Coin
txfee) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"FeeTooSmallUTxO"
             , Text
"minimum" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
minfee
             , Text
"fee" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
txfee ]
  toObject TracingVerbosity
_verb (MA.ValueNotConservedUTxO Value era
consumed Value era
produced) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ValueNotConservedUTxO"
             , Text
"consumed" Text -> Value era -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era
consumed
             , Text
"produced" Text -> Value era -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era
produced
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongNetwork"
             , Text
"network" Text -> Network -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Network
network
             , Text
"addrs"   Text -> Set (Addr (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (Addr (Crypto era))
addrs
             ]
  toObject TracingVerbosity
_verb (MA.WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto era))
addrs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongNetworkWithdrawal"
             , Text
"network" Text -> Network -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Network
network
             , Text
"addrs"   Text -> Set (RewardAcnt (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Set (RewardAcnt (Crypto era))
addrs
             ]
  -- TODO: Add the minimum allowed UTxO value to OutputTooSmallUTxO
  toObject TracingVerbosity
_verb (MA.OutputTooSmallUTxO [TxOut era]
badOutputs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"OutputTooSmallUTxO"
             , Text
"outputs" Text -> [TxOut era] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut era]
badOutputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"OutputBootAddrAttrsTooBig"
             , Text
"outputs" Text -> [TxOut era] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut era]
badOutputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"The Byron address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
MA.TriesToForgeADA =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"TriesToForgeADA" ]
  toObject TracingVerbosity
_verb (MA.OutputTooBigUTxO [TxOut era]
badOutputs) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"OutputTooBigUTxO"
             , Text
"outputs" Text -> [TxOut era] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut era]
badOutputs
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NonGenesisUpdatePPUP"
             , Text
"keys" Text -> Set (KeyHash 'Genesis (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"PPUpdateWrongEpoch"
             , Text
"currentEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
currEpoch
             , Text
"intendedEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
intendedEpoch
             , Text
"votingPeriod"  Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"PVCannotFollowPPUP"
             , Text
"badProtocolVersion" Text -> ProtVer -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"DelegateeNotRegisteredDELEG"
             , Text
"targetPool" Text -> KeyHash 'StakePool (Crypto era) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KeyHash 'StakePool (Crypto era)
targetPool
             ]
  toObject TracingVerbosity
_verb (WithdrawalsNotInRewardsDELEGS Map (RewardAcnt (Crypto era)) Coin
incorrectWithdrawals) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WithdrawalsNotInRewardsDELEGS"
             , Text
"incorrectWithdrawals" Text -> Map (RewardAcnt (Crypto era)) Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 ToObject (DelegPredicateFailure era) where
  toObject :: TracingVerbosity -> DelegPredicateFailure era -> Object
toObject TracingVerbosity
_verb (StakeKeyAlreadyRegisteredDELEG Credential 'Staking (Crypto era)
alreadyRegistered) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakeKeyAlreadyRegisteredDELEG"
             , Text
"credential" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
alreadyRegistered)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Staking credential already registered"
             ]
  toObject TracingVerbosity
_verb (StakeKeyInRewardsDELEG Credential 'Staking (Crypto era)
alreadyRegistered) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakeKeyInRewardsDELEG"
             , Text
"credential" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
alreadyRegistered)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Staking credential registered in rewards map"
             ]
  toObject TracingVerbosity
_verb (StakeKeyNotRegisteredDELEG Credential 'Staking (Crypto era)
notRegistered) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakeKeyNotRegisteredDELEG"
             , Text
"credential" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
notRegistered)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Staking credential not registered"
             ]
  toObject TracingVerbosity
_verb (StakeKeyNonZeroAccountBalanceDELEG Maybe Coin
remBalance) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakeKeyNonZeroAccountBalanceDELEG"
             , Text
"remainingBalance" Text -> Maybe Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Coin
remBalance
             ]
  toObject TracingVerbosity
_verb (StakeDelegationImpossibleDELEG Credential 'Staking (Crypto era)
unregistered) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakeDelegationImpossibleDELEG"
             , Text
"credential" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Credential 'Staking (Crypto era) -> Text
forall a. Show a => a -> Text
textShow Credential 'Staking (Crypto era)
unregistered)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Cannot delegate this stake credential because it is not registered"
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
WrongCertificateTypeDELEG =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypeDELEG" ]
  toObject TracingVerbosity
_verb (GenesisKeyNotInMappingDELEG (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
genesisKeyHash)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"GenesisKeyNotInMappingDELEG"
             , Text
"unknownKeyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisDelegateDELEG"
             , Text
"duplicateKeyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"This genesis key has already been delegated to"
             ]
  toObject TracingVerbosity
_verb (InsufficientForInstantaneousRewardsDELEG MIRPot
mirpot Coin
neededMirAmount Coin
reserves) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InsufficientForInstantaneousRewardsDELEG"
             , Text
"pot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (case MIRPot
mirpot of
                                  MIRPot
ReservesMIR -> Text
"Reserves"
                                  MIRPot
TreasuryMIR -> Text
"Treasury")
             , Text
"neededAmount" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
neededMirAmount
             , Text
"reserves" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
reserves
             ]
  toObject TracingVerbosity
_verb (MIRCertificateTooLateinEpochDELEG SlotNo
currSlot SlotNo
boundSlotNo) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MIRCertificateTooLateinEpochDELEG"
             , Text
"currentSlotNo" Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
currSlot
             , Text
"mustBeSubmittedBeforeSlotNo" Text -> SlotNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo
boundSlotNo
             ]
  toObject TracingVerbosity
_verb (DuplicateGenesisVRFDELEG Hash (Crypto era) (VerKeyVRF (Crypto era))
vrfKeyHash) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisVRFDELEG"
             , Text
"keyHash" Text -> Hash (Crypto era) (VerKeyVRF (Crypto era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash (Crypto era) (VerKeyVRF (Crypto era))
vrfKeyHash
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRTransferNotCurrentlyAllowed =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MIRTransferNotCurrentlyAllowed"
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRNegativesNotCurrentlyAllowed =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MIRNegativesNotCurrentlyAllowed"
             ]
  toObject TracingVerbosity
_verb (InsufficientForTransferDELEG MIRPot
mirpot Coin
attempted Coin
available) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"DuplicateGenesisVRFDELEG"
             , Text
"pot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (case MIRPot
mirpot of
                                  MIRPot
ReservesMIR -> Text
"Reserves"
                                  MIRPot
TreasuryMIR -> Text
"Treasury")
             , Text
"attempted" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
attempted
             , Text
"available" Text -> Coin -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
available
             ]
  toObject TracingVerbosity
_verb DelegPredicateFailure era
MIRProducesNegativeUpdate =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"MIRProducesNegativeUpdate"
             ]


instance ToObject (PoolPredicateFailure era) where
  toObject :: TracingVerbosity -> PoolPredicateFailure era -> Object
toObject TracingVerbosity
_verb (StakePoolNotRegisteredOnKeyPOOL (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
unregStakePool)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakePoolNotRegisteredOnKeyPOOL"
             , Text
"unregisteredKeyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"This stake pool key hash is unregistered"
             ]
  toObject TracingVerbosity
_verb (StakePoolRetirementWrongEpochPOOL Word64
currentEpoch Word64
intendedRetireEpoch Word64
maxRetireEpoch) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakePoolRetirementWrongEpochPOOL"
             , Text
"currentEpoch" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currentEpoch)
             , Text
"intendedRetirementEpoch" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
intendedRetireEpoch)
             , Text
"maxEpochForRetirement" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
maxRetireEpoch)
             ]
  toObject TracingVerbosity
_verb (StakePoolCostTooLowPOOL Coin
certCost Coin
protCost) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"StakePoolCostTooLowPOOL"
             , Text
"certificateCost" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
certCost)
             , Text
"protocolParCost" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
protCost)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"The stake pool cost is too low"
             ]
  toObject TracingVerbosity
_verb (PoolMedataHashTooBig KeyHash 'StakePool (Crypto era)
poolID Int
hashSize) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"PoolMedataHashTooBig"
             , Text
"poolID" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KeyHash 'StakePool (Crypto era) -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool (Crypto era)
poolID)
             , Text
"hashSize" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Int -> Text
forall a. Show a => a -> Text
textShow Int
hashSize)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 -> [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: Delegation certificate"
                    ]
      Word8
1 -> [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: MIR certificate"
                    ]
      Word8
2 -> [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"Wrong certificate type: Genesis certificate"
                    ]
      Word8
k -> [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongCertificateTypePOOL"
                    , Text
"certificateType" Text -> Word8 -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Word8
k
                    , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongNetworkPOOL"
             , Text
"networkId" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Network -> Text
forall a. Show a => a -> Text
textShow Network
networkId)
             , Text
"listedNetworkId" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Network -> Text
forall a. Show a => a -> Text
textShow Network
listedNetworkId)
             , Text
"poolId" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KeyHash 'StakePool (Crypto era) -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool (Crypto era)
poolId)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CorruptRewardUpdate"
             , Text
"update" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"UnexpectedDepositPot"
             , Text
"outstandingDeposits" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
outstandingDeposits)
             , Text
"depositPot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"UnknownGenesisKeyOVERLAY"
             , Text
"unknownKeyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"VRFKeyBadLeaderValueOVERLAY"
             , Text
"seedNonce" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
seedNonce)
             , Text
"currentSlot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currSlotNo)
             , Text
"previousHashAsNonce" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
prevHashNonce)
             , Text
"leaderElectionValue" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"VRFKeyBadNonceOVERLAY"
             , Text
"seedNonce" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
seedNonce)
             , Text
"currentSlot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currSlotNo)
             , Text
"previousHashAsNonce" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Nonce -> Text
forall a. Show a => a -> Text
textShow Nonce
prevHashNonce)
             , Text
"blockNonce" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"VRFKeyWrongVRFKeyOVERLAY"
             , Text
"poolHash" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KeyHash 'StakePool crypto -> Text
forall a. Show a => a -> Text
textShow KeyHash 'StakePool crypto
issuerHash
             , Text
"registeredVRFKeHash" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash crypto (VerKeyVRF crypto) -> Text
forall a. Show a => a -> Text
textShow Hash crypto (VerKeyVRF crypto)
regVRFKeyHash
             , Text
"unregisteredVRFKeyHash" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"VRFKeyUnknownOVERLAY"
             , Text
"keyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"VRFLeaderValueTooBigOVERLAY"
             , Text
"leaderElectionValue" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (OutputVRF (VRF crypto) -> Text
forall a. Show a => a -> Text
textShow OutputVRF (VRF crypto)
leadElecVal)
             , Text
"delegationPoolWeight" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Rational -> Text
forall a. Show a => a -> Text
textShow Rational
weightOfDelegPool)
             , Text
"activeSlotCoefficient" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NotActiveSlotOVERLAY"
             , Text
"slot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongGenesisColdKeyOVERLAY"
             , Text
"actual" Text -> KeyHash 'BlockIssuer crypto -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KeyHash 'BlockIssuer crypto
actual
             , Text
"expected" Text -> KeyHash 'GenesisDelegate crypto -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KeyHash 'GenesisDelegate crypto
expected ]
  toObject TracingVerbosity
_verb (WrongGenesisVRFKeyOVERLAY KeyHash 'BlockIssuer crypto
issuer Hash crypto (VerKeyVRF crypto)
actual Hash crypto (VerKeyVRF crypto)
expected) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"WrongGenesisVRFKeyOVERLAY"
             , Text
"issuer" Text -> KeyHash 'BlockIssuer crypto -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= KeyHash 'BlockIssuer crypto
issuer
             , Text
"actual" Text -> Hash crypto (VerKeyVRF crypto) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
actual
             , Text
"expected" Text -> Hash crypto (VerKeyVRF crypto) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"KESBeforeStartOCERT"
             , Text
"opCertKESStartPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
oCertstart)
             , Text
"currentKESPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
current)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"KESAfterEndOCERT"
             , Text
"currentKESPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
current)
             , Text
"opCertKESStartPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
oCertstart)
             , Text
"maxKESEvolutions" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String  (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
maxKESEvolutions)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CounterTooSmallOCert"
             , Text
"currentKESCounter" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
currentKESCounter)
             , Text
"lastKESCounter" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Word64 -> Text
forall a. Show a => a -> Text
textShow Word64
lastKEScounterUsed)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InvalidSignatureOCERT"
             , Text
"opCertKESStartPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESPeriod -> Text
forall a. Show a => a -> Text
textShow KESPeriod
oCertKESStartPeriod)
             , Text
"opCertCounter" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"InvalidKesSignatureOCERT"
             , Text
"opCertKESStartPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
startKESPeriod)
             , Text
"opCertKESCurrentPeriod" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
currKESPeriod)
             , Text
"opCertExpectedKESEvolutions" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (KESEvolution -> Text
forall a. Show a => a -> Text
textShow KESEvolution
expectedKESEvolutions)
             , Text
"error" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= String
err ]
  toObject TracingVerbosity
_verb (NoCounterForKeyHashOCERT (KeyHash Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
stakePoolKeyHash)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NoCounterForKeyHashOCERT"
             , Text
"stakePoolKeyHash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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)) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"UnexpectedDepositPot"
             , Text
"totalOutstanding" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.=  Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
totalOutstanding)
             , Text
"depositPot" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (Coin -> Text
forall a. Show a => a -> Text
textShow Coin
depositPot)
             ]


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


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

instance ToObject (Alonzo.UtxosPredicateFailure (AlonzoEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> UtxosPredicateFailure (AlonzoEra StandardCrypto) -> Object
toObject TracingVerbosity
_ (Alonzo.ValidationTagMismatch IsValid
isValidating Text
reason) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"ValidationTagMismatch"
             , Text
"isvalidating" Text -> IsValid -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= IsValid
isValidating
             , Text
"reason" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
reason
             ]
  toObject TracingVerbosity
_ (Alonzo.CollectErrors [CollectError (Crypto (AlonzoEra StandardCrypto))]
errors) =
    [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CollectErrors"
             , Text
"errors" Text -> [CollectError StandardCrypto] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [CollectError StandardCrypto]
[CollectError (Crypto (AlonzoEra StandardCrypto))]
errors
             ]
  toObject TracingVerbosity
verb (Alonzo.UpdateFailure PredicateFailure (EraRule "PPUP" (AlonzoEra StandardCrypto))
pFailure) =
    TracingVerbosity
-> PpupPredicateFailure (AlonzoEra StandardCrypto) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "PPUP" (AlonzoEra StandardCrypto))
PpupPredicateFailure (AlonzoEra StandardCrypto)
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 ->
        [(Text, Value)] -> Value
object
          [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NoRedeemer"
          , Text
"scriptpurpose" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ScriptPurpose StandardCrypto -> Value
renderScriptPurpose ScriptPurpose StandardCrypto
sPurpose
          ]
      Alonzo.NoWitness ScriptHash StandardCrypto
sHash ->
        [(Text, Value)] -> Value
object
          [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NoWitness"
          , Text
"scripthash" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ScriptHash StandardCrypto -> Value
forall a. ToJSON a => a -> Value
toJSON ScriptHash StandardCrypto
sHash
          ]
      Alonzo.NoCostModel Language
lang ->
        [(Text, Value)] -> Value
object
          [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"CollectError"
          , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"NoCostModel"
          , Text
"language" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Language -> Value
forall a. ToJSON a => a -> Value
toJSON Language
lang
          ]

instance ToObject (AlonzoBbodyPredFail (Alonzo.AlonzoEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> AlonzoBbodyPredFail (AlonzoEra StandardCrypto) -> Object
toObject TracingVerbosity
_ AlonzoBbodyPredFail (AlonzoEra StandardCrypto)
err = [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"AlonzoBbodyPredFail"
                            , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (AlonzoBbodyPredFail (AlonzoEra StandardCrypto) -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show AlonzoBbodyPredFail (AlonzoEra StandardCrypto)
err)
                            ]

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

textShow :: Show a => a -> Text
textShow :: a -> Text
textShow = String -> Text
Text.pack (String -> Text) -> (a -> String) -> a -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> String
forall a b. (Show a, ConvertText String b) => a -> b
show

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 ToJSON (TxId crypto)