{-# 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 Bcc.Tracing.OrphanInstances.Sophie () where

import           Bcc.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 Bcc.Api as Api
import           Bcc.Api.Orphans ()
import qualified Bcc.Api.Sophie as Api
import           Bcc.Ledger.Crypto (StandardCrypto)

import           Bcc.Slotting.Block (BlockNo (..))
import           Bcc.Tracing.OrphanInstances.Common
import           Bcc.Tracing.OrphanInstances.Consensus ()

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

import           Shardagnostic.Consensus.Sophie.Ledger hiding (TxId)
import           Shardagnostic.Consensus.Sophie.Ledger.Inspect
import           Shardagnostic.Consensus.Sophie.Protocol (TOptimumCannotForge (..))
import qualified Shardagnostic.Consensus.Sophie.Protocol.HotKey as HotKey

import qualified Bcc.Crypto.Hash.Class as Crypto
import           Bcc.Ledger.Aurum as Aurum
import qualified Bcc.Ledger.Aurum.ZerepochScriptApi as Aurum
import           Bcc.Ledger.Aurum.Rules.Bbody (AurumBbodyPredFail)
import qualified Bcc.Ledger.Aurum.Rules.Utxo as Aurum
import qualified Bcc.Ledger.Aurum.Rules.Utxos as Aurum
import           Bcc.Ledger.Aurum.Rules.Utxow (AurumPredFail (..))
import qualified Bcc.Ledger.Aurum.Tx as Aurum
import qualified Bcc.Ledger.Aurum.TxInfo as Aurum
import qualified Bcc.Ledger.AuxiliaryData as Core
import           Bcc.Ledger.BaseTypes (strictMaybeToMaybe)
import qualified Bcc.Ledger.Core as Core
import qualified Bcc.Ledger.Core as Ledger
import qualified Bcc.Ledger.Crypto as Core
import qualified Bcc.Ledger.Era as Ledger
import qualified Bcc.Ledger.SafeHash as SafeHash
import qualified Bcc.Ledger.SophieMA.Rules.Utxo as MA
import qualified Bcc.Ledger.SophieMA.Timelocks as MA
import           Bcc.Protocol.TOptimum.BHeader (LastAppliedBlock, labBlockNo)
import           Bcc.Protocol.TOptimum.Rules.OCert
import           Bcc.Protocol.TOptimum.Rules.Overlay
import           Bcc.Protocol.TOptimum.Rules.Updn

-- TODO: this should be exposed via Bcc.Api
import           Sophie.Spec.Ledger.API hiding (SophieBasedEra)

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

{- HLINT ignore "Use :" -}

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

instance SophieBasedEra era => ToObject (GenTx (SophieBlock era)) where
  toObject :: TracingVerbosity -> GenTx (SophieBlock era) -> Object
toObject TracingVerbosity
verb GenTx (SophieBlock 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 (SophieBlock era)) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= GenTx (SophieBlock era) -> TxId (GenTx (SophieBlock era))
forall tx. HasTxId tx => tx -> TxId tx
txId GenTx (SophieBlock 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 (SophieBlock era) -> String
forall a. Condense a => a -> String
condense GenTx (SophieBlock era)
tx | TracingVerbosity
verb TracingVerbosity -> TracingVerbosity -> Bool
forall a. Eq a => a -> a -> Bool
== TracingVerbosity
MaximalVerbosity ]

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

instance SophieBasedEra era => ToObject (Header (SophieBlock era)) where
  toObject :: TracingVerbosity -> Header (SophieBlock era) -> Object
toObject TracingVerbosity
_verb Header (SophieBlock 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
"SophieBlock"
        , Text
"hash" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SophieHash (Crypto era) -> String
forall a. Condense a => a -> String
condense (Header (SophieBlock era) -> HeaderHash (Header (SophieBlock era))
forall b. HasHeader b => b -> HeaderHash b
blockHash Header (SophieBlock 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 (SophieBlock era) -> SlotNo
forall b. HasHeader b => b -> SlotNo
blockSlot Header (SophieBlock 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 (SophieBlock era) -> BlockNo
forall b. HasHeader b => b -> BlockNo
blockNo Header (SophieBlock era)
b)
--      , "delegate" .= condense (headerSignerVk h)
        ]

instance ( SophieBasedEra 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 Core.Crypto crypto => ToObject (TOptimumCannotForge crypto) where
  toObject :: TracingVerbosity -> TOptimumCannotForge crypto -> Object
toObject TracingVerbosity
_verb (TOptimumCannotForgeKeyNotUsableYet 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
"TOptimumCannotForgeKeyNotUsableYet"
      , 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 (TOptimumCannotForgeWrongVRF Hash crypto (VerKeyVRF crypto)
genDlgVRFHash Hash crypto (VerKeyVRF crypto)
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
"TOptimumCannotLeadWrongVRF"
      , Text
"expected" Text -> Hash crypto (VerKeyVRF crypto) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
genDlgVRFHash
      , Text
"actual" Text -> Hash crypto (VerKeyVRF crypto) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Hash crypto (VerKeyVRF crypto)
coreNodeVRFHash
      ]

deriving newtype instance ToJSON KESPeriod

instance ToObject HotKey.KESInfo where
  toObject :: TracingVerbosity -> KESInfo -> Object
toObject TracingVerbosity
_verb HotKey.KESInfo { KESPeriod
kesStartPeriod :: KESInfo -> KESPeriod
kesStartPeriod :: KESPeriod
kesStartPeriod, KESPeriod
kesEndPeriod :: KESInfo -> KESPeriod
kesEndPeriod :: KESPeriod
kesEndPeriod, KESEvolution
kesEvolution :: KESInfo -> KESEvolution
kesEvolution :: KESEvolution
kesEvolution } =
    [(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 ( SophieBasedEra era
         , ToObject (PredicateFailure (UTXO era))
         , ToObject (PredicateFailure (UTXOW era))
         , ToObject (PredicateFailure (Core.EraRule "BBODY" era))
         ) => ToObject (SophieLedgerError era) where
  toObject :: TracingVerbosity -> SophieLedgerError 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 ( SophieBasedEra era
         , ToJSON (Ledger.PParamsDelta era)
         ) => ToObject (SophieLedgerUpdate era) where
  toObject :: TracingVerbosity -> SophieLedgerUpdate era -> Object
toObject TracingVerbosity
verb (SophieUpdatedProtocolUpdates [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
"SophieUpdatedProtocolUpdates"
             , 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 (Ledger.Era era, ToJSON (Ledger.PParamsDelta era))
         => ToObject (ProtocolUpdate era) where
  toObject :: TracingVerbosity -> ProtocolUpdate era -> Object
toObject TracingVerbosity
verb ProtocolUpdate{UpdateProposal era
protocolUpdateProposal :: forall era. ProtocolUpdate era -> UpdateProposal era
protocolUpdateProposal :: UpdateProposal era
protocolUpdateProposal, UpdateState (EraCrypto era)
protocolUpdateState :: forall era. ProtocolUpdate era -> UpdateState (EraCrypto era)
protocolUpdateState :: UpdateState (EraCrypto era)
protocolUpdateState} =
    [(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 Core.Crypto crypto => ToObject (UpdateState crypto) where
  toObject :: TracingVerbosity -> UpdateState crypto -> Object
toObject TracingVerbosity
_verb UpdateState{[KeyHash 'Genesis crypto]
proposalVotes :: forall c. UpdateState c -> [KeyHash 'Genesis c]
proposalVotes :: [KeyHash 'Genesis crypto]
proposalVotes, Bool
proposalReachedQuorum :: forall c. UpdateState c -> Bool
proposalReachedQuorum :: Bool
proposalReachedQuorum} =
    [(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 ( SophieBasedEra 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 ( SophieBasedEra 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 ( SophieBasedEra 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 ( SophieBasedEra 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 (AurumPredFail (Aurum.AurumEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> AurumPredFail (AurumEra StandardCrypto) -> Object
toObject TracingVerbosity
v (WrappedSophieEraFailure UtxowPredicateFailure (AurumEra StandardCrypto)
utxoPredFail) =
    TracingVerbosity
-> UtxowPredicateFailure (AurumEra StandardCrypto) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
v UtxowPredicateFailure (AurumEra StandardCrypto)
utxoPredFail
  toObject TracingVerbosity
_ (MissingRedeemers [(ScriptPurpose (Crypto (AurumEra StandardCrypto)),
  ScriptHash (Crypto (AurumEra 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 (AurumEra StandardCrypto)),
  ScriptHash (Crypto (AurumEra StandardCrypto)))]
scripts
             ]
  toObject TracingVerbosity
_ (MissingRequiredDatums Set (DataHash (Crypto (AurumEra StandardCrypto)))
required Set (DataHash (Crypto (AurumEra 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 (AurumEra 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 (AurumEra StandardCrypto)))
received)
             ]
  toObject TracingVerbosity
_ (PPViewHashesDontMatch StrictMaybe
  (ScriptIntegrityHash (Crypto (AurumEra StandardCrypto)))
ppHashInTxBody StrictMaybe
  (ScriptIntegrityHash (Crypto (AurumEra 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 (AurumEra 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 (AurumEra StandardCrypto)))
ppHashFromPParams)
             ]
  toObject TracingVerbosity
_ (MissingRequiredSigners Set (KeyHash 'Witness (Crypto (AurumEra 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 (AurumEra StandardCrypto)))
missingKeyWitnesses
             ]
  toObject TracingVerbosity
_ (UnspendableUTxONoDatumHash Set (TxIn (Crypto (AurumEra 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 (AurumEra StandardCrypto)))
txins
             ]
  toObject TracingVerbosity
_ (NonOutputSupplimentaryDatums Set (DataHash (Crypto (AurumEra StandardCrypto)))
disallowed Set (DataHash (Crypto (AurumEra 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 (AurumEra 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 (AurumEra 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.fromAurumRdmrPtr) [RdmrPtr]
rdmrs
             ]

renderScriptIntegrityHash :: Maybe (Aurum.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.fromSophieScriptHash

renderMissingRedeemers :: [(Aurum.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 :: (Aurum.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 :: Aurum.ScriptPurpose StandardCrypto -> Aeson.Value
renderScriptPurpose :: ScriptPurpose StandardCrypto -> Value
renderScriptPurpose (Aurum.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 (Aurum.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.fromSophieTxIn TxIn StandardCrypto
txin]
renderScriptPurpose (Aurum.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.fromSophieStakeAddr RewardAcnt StandardCrypto
rwdAcct)]
renderScriptPurpose (Aurum.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.fromSophieCertificate DCert StandardCrypto
cert)]

instance ( SophieBasedEra 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 ( SophieBasedEra 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 Cole 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 ( SophieBasedEra 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 Cole address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure era
MA.TriesToForgeBCC =
    [(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
"TriesToForgeBCC" ]
  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 Ledger.Era era => ToObject (PpupPredicateFailure era) where
  toObject :: TracingVerbosity -> PpupPredicateFailure era -> Object
toObject TracingVerbosity
_verb (NonGenesisUpdatePPUP Set (KeyHash 'Genesis (Crypto era))
proposalKeys Set (KeyHash 'Genesis (Crypto era))
genesisKeys) =
    [(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 ( SophieBasedEra 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 Ledger.Era era => 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 (VestedKeyNotInMappingDELEG (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
vestedKeyHash)) =
    [(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
"VestedKeyNotInMappingDELEG"
             , 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)))
vestedKeyHash)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"This vested 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 (DuplicateVestedDelegateDELEG (KeyHash Hash (ADDRHASH (Crypto era)) (VerKeyDSIGN (DSIGN (Crypto era)))
vestedKeyHash)) =
    [(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
"DuplicateVestedDelegateDELEG"
             , 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)))
vestedKeyHash)
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"This vested 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 (DuplicateVestedVRFDELEG 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
"DuplicateVestedVRFDELEG"
             , 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 Sophie 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 (UnknownGenesisVestedKeyOVERLAY (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
"UnknownGenesisVestedKeyOVERLAY"
             , 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 (WrongGenesisVestedColdKeyOVERLAY 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
"WrongGenesisVestedColdKeyOVERLAY"
             , 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 (WrongGenesisVestedVRFKeyOVERLAY 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
"WrongGenesisVestedVRFKeyOVERLAY"
             , 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)
             ]


--------------------------------------------------------------------------------
-- Aurum related
--------------------------------------------------------------------------------


instance ToObject (Aurum.UtxoPredicateFailure (Aurum.AurumEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> UtxoPredicateFailure (AurumEra StandardCrypto) -> Object
toObject TracingVerbosity
_verb (Aurum.BadInputsUTxO Set (TxIn (Crypto (AurumEra 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 (AurumEra 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 (AurumEra StandardCrypto)))
badInputs
             ]
  toObject TracingVerbosity
_verb (Aurum.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 (Aurum.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 (AurumEra StandardCrypto)
Aurum.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 (Aurum.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 (Aurum.ValueNotConservedUTxO Value (AurumEra StandardCrypto)
consumed Value (AurumEra 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 (AurumEra StandardCrypto)
Value StandardCrypto
consumed
             , Text
"produced" Text -> Value StandardCrypto -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value (AurumEra 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 (AurumEra StandardCrypto)
Value StandardCrypto
consumed Value (AurumEra StandardCrypto)
Value StandardCrypto
produced
             ]
  toObject TracingVerbosity
_verb (Aurum.WrongNetwork Network
network Set (Addr (Crypto (AurumEra 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 (AurumEra StandardCrypto)))
addrs
             ]
  toObject TracingVerbosity
_verb (Aurum.WrongNetworkWithdrawal Network
network Set (RewardAcnt (Crypto (AurumEra 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 (AurumEra StandardCrypto)))
addrs
             ]
  toObject TracingVerbosity
_verb (Aurum.OutputTooSmallUTxO [TxOut (AurumEra 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 (AurumEra StandardCrypto)] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut (AurumEra StandardCrypto)]
[TxOut (AurumEra 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 (Aurum.UtxosFailure PredicateFailure (EraRule "UTXOS" (AurumEra StandardCrypto))
predFailure) =
    TracingVerbosity
-> UtxosPredicateFailure (AurumEra StandardCrypto) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "UTXOS" (AurumEra StandardCrypto))
UtxosPredicateFailure (AurumEra StandardCrypto)
predFailure
  toObject TracingVerbosity
_verb (Aurum.OutputBootAddrAttrsTooBig [TxOut (AurumEra 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 (AurumEra StandardCrypto)] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [TxOut (AurumEra StandardCrypto)]
[TxOut (AurumEra StandardCrypto)]
txouts
             , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"The Cole address attributes are too big"
             ]
  toObject TracingVerbosity
_verb UtxoPredicateFailure (AurumEra StandardCrypto)
Aurum.TriesToForgeBCC =
    [(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
"TriesToForgeBCC" ]
  toObject TracingVerbosity
_verb (Aurum.OutputTooBigUTxO [(Int, Int, TxOut (AurumEra 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 (AurumEra StandardCrypto))] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [(Int, Int, TxOut (AurumEra StandardCrypto))]
[(Int, Int, TxOut (AurumEra 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 (Aurum.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 (Aurum.ScriptsNotPaidUTxO UTxO (AurumEra 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 (AurumEra StandardCrypto) -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UTxO (AurumEra StandardCrypto)
utxos
             ]
  toObject TracingVerbosity
_verb (Aurum.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 (Aurum.CollateralContainsNonBCC Value (AurumEra 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
"CollateralContainsNonBCC"
             , Text
"inputs" Text -> Value StandardCrypto -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value (AurumEra StandardCrypto)
Value StandardCrypto
inputs
             ]
  toObject TracingVerbosity
_verb (Aurum.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 (Aurum.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 (Aurum.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 (AurumEra StandardCrypto)
Aurum.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 (Aurum.UtxosPredicateFailure (AurumEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> UtxosPredicateFailure (AurumEra StandardCrypto) -> Object
toObject TracingVerbosity
_ (Aurum.ValidationTagMismatch IsValid
isValidating TagMismatchDescription
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 -> TagMismatchDescription -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TagMismatchDescription
reason
             ]
  toObject TracingVerbosity
_ (Aurum.CollectErrors [CollectError (Crypto (AurumEra 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 (AurumEra StandardCrypto))]
errors
             ]
  toObject TracingVerbosity
verb (Aurum.UpdateFailure PredicateFailure (EraRule "PPUP" (AurumEra StandardCrypto))
pFailure) =
    TracingVerbosity
-> PpupPredicateFailure (AurumEra StandardCrypto) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb PredicateFailure (EraRule "PPUP" (AurumEra StandardCrypto))
PpupPredicateFailure (AurumEra StandardCrypto)
pFailure

deriving newtype instance ToJSON Aurum.IsValid

instance ToJSON (Aurum.CollectError StandardCrypto) where
  toJSON :: CollectError StandardCrypto -> Value
toJSON CollectError StandardCrypto
cError =
    case CollectError StandardCrypto
cError of
      Aurum.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
          ]
      Aurum.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
          ]
      Aurum.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 ToJSON Aurum.TagMismatchDescription where
  toJSON :: TagMismatchDescription -> Value
toJSON TagMismatchDescription
tmd = case TagMismatchDescription
tmd of
    TagMismatchDescription
Aurum.PassedUnexpectedly ->
      [(Text, Value)] -> Value
object
        [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"TagMismatchDescription"
        , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"PassedUnexpectedly"
        ]
    Aurum.FailedUnexpectedly [FailureDescription]
forReasons ->
      [(Text, Value)] -> Value
object
        [ Text
"kind" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"TagMismatchDescription"
        , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"FailedUnexpectedly"
        , Text
"reconstruction" Text -> [FailureDescription] -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= [FailureDescription]
forReasons
        ]

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

instance ToObject (AurumBbodyPredFail (Aurum.AurumEra StandardCrypto)) where
  toObject :: TracingVerbosity
-> AurumBbodyPredFail (AurumEra StandardCrypto) -> Object
toObject TracingVerbosity
_ AurumBbodyPredFail (AurumEra 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
"AurumBbodyPredFail"
                            , Text
"error" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (AurumBbodyPredFail (AurumEra StandardCrypto) -> Text
forall a b. (Show a, ConvertText String b) => a -> b
show AurumBbodyPredFail (AurumEra 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 bcc-cli

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

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