{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Bcc.Tracing.OrphanInstances.HardFork () where

import           Bcc.Prelude hiding (All)

import           Data.Aeson
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Short as SBS
import           Data.SOP.Strict

import           Bcc.Tracing.OrphanInstances.Common
import           Bcc.Tracing.OrphanInstances.Consensus ()

import           Bcc.Slotting.Slot (EpochSize (..))
import           Shardagnostic.Consensus.Block (BlockProtocol, CannotForge, ForgeStateInfo,
                     ForgeStateUpdateError)
import           Shardagnostic.Consensus.BlockchainTime (getSlotLength)
import           Shardagnostic.Consensus.Bcc.Condense ()
import           Shardagnostic.Consensus.HardFork.Combinator
import           Shardagnostic.Consensus.HardFork.Combinator.AcrossEras (EraMismatch (..),
                     OneEraCannotForge (..), OneEraEnvelopeErr (..), OneEraForgeStateInfo (..),
                     OneEraForgeStateUpdateError (..), OneEraLedgerError (..),
                     OneEraLedgerUpdate (..), OneEraLedgerWarning (..), OneEraValidationErr (..),
                     mkEraMismatch)
import           Shardagnostic.Consensus.HardFork.Combinator.Condense ()
import           Shardagnostic.Consensus.HardFork.History.EraParams (EraParams (..), SafeZone)
import           Shardagnostic.Consensus.HeaderValidation (OtherHeaderEnvelopeError)
import           Shardagnostic.Consensus.Ledger.Abstract (LedgerError)
import           Shardagnostic.Consensus.Ledger.Inspect (LedgerUpdate, LedgerWarning)
import           Shardagnostic.Consensus.Ledger.SupportsMempool (ApplyTxErr)
import           Shardagnostic.Consensus.Protocol.Abstract (ValidationErr)
import           Shardagnostic.Consensus.TypeFamilyWrappers
import           Shardagnostic.Consensus.Util.Condense (Condense (..))


--
-- instances for hashes
--

instance Condense (OneEraHash xs) where
    condense :: OneEraHash xs -> String
condense = ByteString -> String
forall a. Condense a => a -> String
condense (ByteString -> String)
-> (OneEraHash xs -> ByteString) -> OneEraHash xs -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ByteString -> ByteString
Base16.encode (ByteString -> ByteString)
-> (OneEraHash xs -> ByteString) -> OneEraHash xs -> ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ShortByteString -> ByteString
SBS.fromShort (ShortByteString -> ByteString)
-> (OneEraHash xs -> ShortByteString)
-> OneEraHash xs
-> ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraHash xs -> ShortByteString
forall k (xs :: [k]). OneEraHash xs -> ShortByteString
getOneEraHash

--
-- instances for Header HardForkBlock
--

instance All (ToObject `Compose` Header) xs => ToObject (Header (HardForkBlock xs)) where
    toObject :: TracingVerbosity -> Header (HardForkBlock xs) -> Object
toObject TracingVerbosity
verb =
          NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
        (NS (K Object) xs -> Object)
-> (Header (HardForkBlock xs) -> NS (K Object) xs)
-> Header (HardForkBlock xs)
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject Header)
-> (forall a. Compose ToObject Header a => Header a -> K Object a)
-> NS Header xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject Header)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` Header)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (Header a -> Object) -> Header a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> Header a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
        (NS Header xs -> NS (K Object) xs)
-> (Header (HardForkBlock xs) -> NS Header xs)
-> Header (HardForkBlock xs)
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraHeader xs -> NS Header xs
forall (xs :: [*]). OneEraHeader xs -> NS Header xs
getOneEraHeader
        (OneEraHeader xs -> NS Header xs)
-> (Header (HardForkBlock xs) -> OneEraHeader xs)
-> Header (HardForkBlock xs)
-> NS Header xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Header (HardForkBlock xs) -> OneEraHeader xs
forall (xs :: [*]). Header (HardForkBlock xs) -> OneEraHeader xs
getHardForkHeader


--
-- instances for GenTx HardForkBlock
--

instance All (Compose ToObject GenTx) xs => ToObject (GenTx (HardForkBlock xs)) where
    toObject :: TracingVerbosity -> GenTx (HardForkBlock xs) -> Object
toObject TracingVerbosity
verb =
          NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
        (NS (K Object) xs -> Object)
-> (GenTx (HardForkBlock xs) -> NS (K Object) xs)
-> GenTx (HardForkBlock xs)
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject GenTx)
-> (forall a. Compose ToObject GenTx a => GenTx a -> K Object a)
-> NS GenTx xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject GenTx)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` GenTx)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (GenTx a -> Object) -> GenTx a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> GenTx a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
        (NS GenTx xs -> NS (K Object) xs)
-> (GenTx (HardForkBlock xs) -> NS GenTx xs)
-> GenTx (HardForkBlock xs)
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraGenTx xs -> NS GenTx xs
forall (xs :: [*]). OneEraGenTx xs -> NS GenTx xs
getOneEraGenTx
        (OneEraGenTx xs -> NS GenTx xs)
-> (GenTx (HardForkBlock xs) -> OneEraGenTx xs)
-> GenTx (HardForkBlock xs)
-> NS GenTx xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. GenTx (HardForkBlock xs) -> OneEraGenTx xs
forall (xs :: [*]). GenTx (HardForkBlock xs) -> OneEraGenTx xs
getHardForkGenTx

instance  All (Compose ToJSON WrapGenTxId) xs => ToJSON (TxId (GenTx (HardForkBlock xs))) where
    toJSON :: TxId (GenTx (HardForkBlock xs)) -> Value
toJSON =
          NS (K Value) xs -> Value
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
        (NS (K Value) xs -> Value)
-> (TxId (GenTx (HardForkBlock xs)) -> NS (K Value) xs)
-> TxId (GenTx (HardForkBlock xs))
-> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToJSON WrapGenTxId)
-> (forall a.
    Compose ToJSON WrapGenTxId a =>
    WrapGenTxId a -> K Value a)
-> NS WrapGenTxId xs
-> NS (K Value) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToJSON WrapGenTxId)
forall k (t :: k). Proxy t
Proxy @ (ToJSON `Compose` WrapGenTxId)) (Value -> K Value a
forall k a (b :: k). a -> K a b
K (Value -> K Value a)
-> (WrapGenTxId a -> Value) -> WrapGenTxId a -> K Value a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapGenTxId a -> Value
forall a. ToJSON a => a -> Value
toJSON)
        (NS WrapGenTxId xs -> NS (K Value) xs)
-> (TxId (GenTx (HardForkBlock xs)) -> NS WrapGenTxId xs)
-> TxId (GenTx (HardForkBlock xs))
-> NS (K Value) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraGenTxId xs -> NS WrapGenTxId xs
forall (xs :: [*]). OneEraGenTxId xs -> NS WrapGenTxId xs
getOneEraGenTxId
        (OneEraGenTxId xs -> NS WrapGenTxId xs)
-> (TxId (GenTx (HardForkBlock xs)) -> OneEraGenTxId xs)
-> TxId (GenTx (HardForkBlock xs))
-> NS WrapGenTxId xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TxId (GenTx (HardForkBlock xs)) -> OneEraGenTxId xs
forall (xs :: [*]).
TxId (GenTx (HardForkBlock xs)) -> OneEraGenTxId xs
getHardForkGenTxId

instance ToJSON (TxId (GenTx blk)) => ToJSON (WrapGenTxId blk) where
    toJSON :: WrapGenTxId blk -> Value
toJSON = TxId (GenTx blk) -> Value
forall a. ToJSON a => a -> Value
toJSON (TxId (GenTx blk) -> Value)
-> (WrapGenTxId blk -> TxId (GenTx blk))
-> WrapGenTxId blk
-> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapGenTxId blk -> TxId (GenTx blk)
forall blk. WrapGenTxId blk -> GenTxId blk
unwrapGenTxId


--
-- instances for HardForkApplyTxErr
--

instance All (ToObject `Compose` WrapApplyTxErr) xs => ToObject (HardForkApplyTxErr xs) where
    toObject :: TracingVerbosity -> HardForkApplyTxErr xs -> Object
toObject TracingVerbosity
verb (HardForkApplyTxErrFromEra OneEraApplyTxErr xs
err) = TracingVerbosity -> OneEraApplyTxErr xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraApplyTxErr xs
err
    toObject TracingVerbosity
_verb (HardForkApplyTxErrWrongEra MismatchEraInfo xs
mismatch) =
      [(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
"HardForkApplyTxErrWrongEra"
        , Text
"currentEra" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
ledgerEraName
        , Text
"txEra"      Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
otherEraName
        ]
      where
        EraMismatch {Text
ledgerEraName :: EraMismatch -> Text
ledgerEraName :: Text
ledgerEraName, Text
otherEraName :: EraMismatch -> Text
otherEraName :: Text
otherEraName} = MismatchEraInfo xs -> EraMismatch
forall (xs :: [*]). SListI xs => MismatchEraInfo xs -> EraMismatch
mkEraMismatch MismatchEraInfo xs
mismatch

instance All (ToObject `Compose` WrapApplyTxErr) xs => ToObject (OneEraApplyTxErr xs) where
    toObject :: TracingVerbosity -> OneEraApplyTxErr xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraApplyTxErr xs -> NS (K Object) xs)
-> OneEraApplyTxErr xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapApplyTxErr)
-> (forall a.
    Compose ToObject WrapApplyTxErr a =>
    WrapApplyTxErr a -> K Object a)
-> NS WrapApplyTxErr xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapApplyTxErr)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapApplyTxErr)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapApplyTxErr a -> Object) -> WrapApplyTxErr a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapApplyTxErr a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapApplyTxErr xs -> NS (K Object) xs)
-> (OneEraApplyTxErr xs -> NS WrapApplyTxErr xs)
-> OneEraApplyTxErr xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraApplyTxErr xs -> NS WrapApplyTxErr xs
forall (xs :: [*]). OneEraApplyTxErr xs -> NS WrapApplyTxErr xs
getOneEraApplyTxErr

instance ToObject (ApplyTxErr blk) => ToObject (WrapApplyTxErr blk) where
    toObject :: TracingVerbosity -> WrapApplyTxErr blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> ApplyTxErr blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (ApplyTxErr blk -> Object)
-> (WrapApplyTxErr blk -> ApplyTxErr blk)
-> WrapApplyTxErr blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapApplyTxErr blk -> ApplyTxErr blk
forall blk. WrapApplyTxErr blk -> ApplyTxErr blk
unwrapApplyTxErr


--
-- instances for HardForkLedgerError
--

instance All (ToObject `Compose` WrapLedgerErr) xs => ToObject (HardForkLedgerError xs) where
    toObject :: TracingVerbosity -> HardForkLedgerError xs -> Object
toObject TracingVerbosity
verb (HardForkLedgerErrorFromEra OneEraLedgerError xs
err) = TracingVerbosity -> OneEraLedgerError xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraLedgerError xs
err

    toObject TracingVerbosity
_verb (HardForkLedgerErrorWrongEra MismatchEraInfo xs
mismatch) =
      [(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
"HardForkLedgerErrorWrongEra"
        , Text
"currentEra" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
ledgerEraName
        , Text
"blockEra"   Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
otherEraName
        ]
      where
        EraMismatch {Text
ledgerEraName :: Text
ledgerEraName :: EraMismatch -> Text
ledgerEraName, Text
otherEraName :: Text
otherEraName :: EraMismatch -> Text
otherEraName} = MismatchEraInfo xs -> EraMismatch
forall (xs :: [*]). SListI xs => MismatchEraInfo xs -> EraMismatch
mkEraMismatch MismatchEraInfo xs
mismatch

instance All (ToObject `Compose` WrapLedgerErr) xs => ToObject (OneEraLedgerError xs) where
    toObject :: TracingVerbosity -> OneEraLedgerError xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraLedgerError xs -> NS (K Object) xs)
-> OneEraLedgerError xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapLedgerErr)
-> (forall a.
    Compose ToObject WrapLedgerErr a =>
    WrapLedgerErr a -> K Object a)
-> NS WrapLedgerErr xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapLedgerErr)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapLedgerErr)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapLedgerErr a -> Object) -> WrapLedgerErr a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapLedgerErr a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapLedgerErr xs -> NS (K Object) xs)
-> (OneEraLedgerError xs -> NS WrapLedgerErr xs)
-> OneEraLedgerError xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraLedgerError xs -> NS WrapLedgerErr xs
forall (xs :: [*]). OneEraLedgerError xs -> NS WrapLedgerErr xs
getOneEraLedgerError

instance ToObject (LedgerError blk) => ToObject (WrapLedgerErr blk) where
    toObject :: TracingVerbosity -> WrapLedgerErr blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> LedgerError blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (LedgerError blk -> Object)
-> (WrapLedgerErr blk -> LedgerError blk)
-> WrapLedgerErr blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapLedgerErr blk -> LedgerError blk
forall blk. WrapLedgerErr blk -> LedgerError blk
unwrapLedgerErr


--
-- instances for HardForkLedgerWarning
--

instance ( All (ToObject `Compose` WrapLedgerWarning) xs
         , All SingleEraBlock xs
         ) => ToObject (HardForkLedgerWarning xs) where
    toObject :: TracingVerbosity -> HardForkLedgerWarning xs -> Object
toObject TracingVerbosity
verb HardForkLedgerWarning xs
warning = case HardForkLedgerWarning xs
warning of
      HardForkWarningInEra OneEraLedgerWarning xs
err -> TracingVerbosity -> OneEraLedgerWarning xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraLedgerWarning xs
err

      HardForkWarningTransitionMismatch EraIndex xs
toEra EraParams
eraParams EpochNo
epoch ->
        [(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
"HardForkWarningTransitionMismatch"
          , Text
"toEra"           Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          , Text
"eraParams"       Text -> Object -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= TracingVerbosity -> EraParams -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb EraParams
eraParams
          , Text
"transitionEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
epoch
          ]

      HardForkWarningTransitionInFinalEra EraIndex xs
fromEra EpochNo
epoch ->
        [(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
"HardForkWarningTransitionInFinalEra"
          , Text
"fromEra"         Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
fromEra
          , Text
"transitionEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
epoch
          ]

      HardForkWarningTransitionUnconfirmed EraIndex xs
toEra ->
        [(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
"HardForkWarningTransitionUnconfirmed"
          , Text
"toEra" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          ]

      HardForkWarningTransitionReconfirmed EraIndex xs
fromEra EraIndex xs
toEra EpochNo
prevEpoch EpochNo
newEpoch ->
        [(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
"HardForkWarningTransitionReconfirmed"
          , Text
"fromEra"             Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
fromEra
          , Text
"toEra"               Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          , Text
"prevTransitionEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
prevEpoch
          , Text
"newTransitionEpoch"  Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
newEpoch
          ]

instance All (ToObject `Compose` WrapLedgerWarning) xs => ToObject (OneEraLedgerWarning xs) where
    toObject :: TracingVerbosity -> OneEraLedgerWarning xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraLedgerWarning xs -> NS (K Object) xs)
-> OneEraLedgerWarning xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapLedgerWarning)
-> (forall a.
    Compose ToObject WrapLedgerWarning a =>
    WrapLedgerWarning a -> K Object a)
-> NS WrapLedgerWarning xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapLedgerWarning)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapLedgerWarning)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapLedgerWarning a -> Object)
-> WrapLedgerWarning a
-> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapLedgerWarning a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapLedgerWarning xs -> NS (K Object) xs)
-> (OneEraLedgerWarning xs -> NS WrapLedgerWarning xs)
-> OneEraLedgerWarning xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraLedgerWarning xs -> NS WrapLedgerWarning xs
forall (xs :: [*]).
OneEraLedgerWarning xs -> NS WrapLedgerWarning xs
getOneEraLedgerWarning

instance ToObject (LedgerWarning blk) => ToObject (WrapLedgerWarning blk) where
    toObject :: TracingVerbosity -> WrapLedgerWarning blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> LedgerWarning blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (LedgerWarning blk -> Object)
-> (WrapLedgerWarning blk -> LedgerWarning blk)
-> WrapLedgerWarning blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapLedgerWarning blk -> LedgerWarning blk
forall blk. WrapLedgerWarning blk -> LedgerWarning blk
unwrapLedgerWarning

instance ToObject EraParams where
    toObject :: TracingVerbosity -> EraParams -> Object
toObject TracingVerbosity
_verb EraParams{ EpochSize
eraEpochSize :: EraParams -> EpochSize
eraEpochSize :: EpochSize
eraEpochSize, SlotLength
eraSlotLength :: EraParams -> SlotLength
eraSlotLength :: SlotLength
eraSlotLength, SafeZone
eraSafeZone :: EraParams -> SafeZone
eraSafeZone :: SafeZone
eraSafeZone} =
      [(Text, Value)] -> Object
forall a. ToObject a => [(Text, a)] -> HashMap Text a
mkObject
        [ Text
"epochSize"  Text -> Word64 -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochSize -> Word64
unEpochSize EpochSize
eraEpochSize
        , Text
"slotLength" Text -> NominalDiffTime -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotLength -> NominalDiffTime
getSlotLength SlotLength
eraSlotLength
        , Text
"safeZone"   Text -> SafeZone -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SafeZone
eraSafeZone
        ]

deriving instance ToJSON SafeZone


--
-- instances for HardForkLedgerUpdate
--

instance ( All (ToObject `Compose` WrapLedgerUpdate) xs
         , All SingleEraBlock xs
         ) => ToObject (HardForkLedgerUpdate xs) where
    toObject :: TracingVerbosity -> HardForkLedgerUpdate xs -> Object
toObject TracingVerbosity
verb HardForkLedgerUpdate xs
update = case HardForkLedgerUpdate xs
update of
      HardForkUpdateInEra OneEraLedgerUpdate xs
err -> TracingVerbosity -> OneEraLedgerUpdate xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraLedgerUpdate xs
err

      HardForkUpdateTransitionConfirmed EraIndex xs
fromEra EraIndex xs
toEra EpochNo
epoch ->
        [(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
"HardForkUpdateTransitionConfirmed"
          , Text
"fromEra"         Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
fromEra
          , Text
"toEra"           Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          , Text
"transitionEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
epoch
          ]

      HardForkUpdateTransitionDone EraIndex xs
fromEra EraIndex xs
toEra EpochNo
epoch ->
        [(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
"HardForkUpdateTransitionDone"
          , Text
"fromEra"         Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
fromEra
          , Text
"toEra"           Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          , Text
"transitionEpoch" Text -> EpochNo -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
epoch
          ]

      HardForkUpdateTransitionRolledBack EraIndex xs
fromEra EraIndex xs
toEra ->
        [(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
"HardForkUpdateTransitionRolledBack"
          , Text
"fromEra" Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
fromEra
          , Text
"toEra"   Text -> String -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EraIndex xs -> String
forall a. Condense a => a -> String
condense EraIndex xs
toEra
          ]

instance All (ToObject `Compose` WrapLedgerUpdate) xs => ToObject (OneEraLedgerUpdate xs) where
    toObject :: TracingVerbosity -> OneEraLedgerUpdate xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraLedgerUpdate xs -> NS (K Object) xs)
-> OneEraLedgerUpdate xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapLedgerUpdate)
-> (forall a.
    Compose ToObject WrapLedgerUpdate a =>
    WrapLedgerUpdate a -> K Object a)
-> NS WrapLedgerUpdate xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapLedgerUpdate)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapLedgerUpdate)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapLedgerUpdate a -> Object)
-> WrapLedgerUpdate a
-> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapLedgerUpdate a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapLedgerUpdate xs -> NS (K Object) xs)
-> (OneEraLedgerUpdate xs -> NS WrapLedgerUpdate xs)
-> OneEraLedgerUpdate xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraLedgerUpdate xs -> NS WrapLedgerUpdate xs
forall (xs :: [*]). OneEraLedgerUpdate xs -> NS WrapLedgerUpdate xs
getOneEraLedgerUpdate

instance ToObject (LedgerUpdate blk) => ToObject (WrapLedgerUpdate blk) where
    toObject :: TracingVerbosity -> WrapLedgerUpdate blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> LedgerUpdate blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (LedgerUpdate blk -> Object)
-> (WrapLedgerUpdate blk -> LedgerUpdate blk)
-> WrapLedgerUpdate blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapLedgerUpdate blk -> LedgerUpdate blk
forall blk. WrapLedgerUpdate blk -> LedgerUpdate blk
unwrapLedgerUpdate


--
-- instances for HardForkEnvelopeErr
--

instance All (ToObject `Compose` WrapEnvelopeErr) xs => ToObject (HardForkEnvelopeErr xs) where
    toObject :: TracingVerbosity -> HardForkEnvelopeErr xs -> Object
toObject TracingVerbosity
verb (HardForkEnvelopeErrFromEra OneEraEnvelopeErr xs
err) = TracingVerbosity -> OneEraEnvelopeErr xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraEnvelopeErr xs
err

    toObject TracingVerbosity
_verb (HardForkEnvelopeErrWrongEra MismatchEraInfo xs
mismatch) =
      [(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
"HardForkEnvelopeErrWrongEra"
        , Text
"currentEra" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
ledgerEraName
        , Text
"blockEra"   Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
otherEraName
        ]
      where
        EraMismatch {Text
ledgerEraName :: Text
ledgerEraName :: EraMismatch -> Text
ledgerEraName, Text
otherEraName :: Text
otherEraName :: EraMismatch -> Text
otherEraName} = MismatchEraInfo xs -> EraMismatch
forall (xs :: [*]). SListI xs => MismatchEraInfo xs -> EraMismatch
mkEraMismatch MismatchEraInfo xs
mismatch

instance All (ToObject `Compose` WrapEnvelopeErr) xs => ToObject (OneEraEnvelopeErr xs) where
    toObject :: TracingVerbosity -> OneEraEnvelopeErr xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraEnvelopeErr xs -> NS (K Object) xs)
-> OneEraEnvelopeErr xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapEnvelopeErr)
-> (forall a.
    Compose ToObject WrapEnvelopeErr a =>
    WrapEnvelopeErr a -> K Object a)
-> NS WrapEnvelopeErr xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapEnvelopeErr)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapEnvelopeErr)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapEnvelopeErr a -> Object) -> WrapEnvelopeErr a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapEnvelopeErr a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapEnvelopeErr xs -> NS (K Object) xs)
-> (OneEraEnvelopeErr xs -> NS WrapEnvelopeErr xs)
-> OneEraEnvelopeErr xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraEnvelopeErr xs -> NS WrapEnvelopeErr xs
forall (xs :: [*]). OneEraEnvelopeErr xs -> NS WrapEnvelopeErr xs
getOneEraEnvelopeErr

instance ToObject (OtherHeaderEnvelopeError blk) => ToObject (WrapEnvelopeErr blk) where
    toObject :: TracingVerbosity -> WrapEnvelopeErr blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> OtherHeaderEnvelopeError blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (OtherHeaderEnvelopeError blk -> Object)
-> (WrapEnvelopeErr blk -> OtherHeaderEnvelopeError blk)
-> WrapEnvelopeErr blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapEnvelopeErr blk -> OtherHeaderEnvelopeError blk
forall blk. WrapEnvelopeErr blk -> OtherHeaderEnvelopeError blk
unwrapEnvelopeErr


--
-- instances for HardForkValidationErr
--

instance All (ToObject `Compose` WrapValidationErr) xs => ToObject (HardForkValidationErr xs) where
    toObject :: TracingVerbosity -> HardForkValidationErr xs -> Object
toObject TracingVerbosity
verb (HardForkValidationErrFromEra OneEraValidationErr xs
err) = TracingVerbosity -> OneEraValidationErr xs -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb OneEraValidationErr xs
err

    toObject TracingVerbosity
_verb (HardForkValidationErrWrongEra MismatchEraInfo xs
mismatch) =
      [(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
"HardForkValidationErrWrongEra"
        , Text
"currentEra" Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
ledgerEraName
        , Text
"blockEra"   Text -> Text -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text
otherEraName
        ]
      where
        EraMismatch {Text
ledgerEraName :: Text
ledgerEraName :: EraMismatch -> Text
ledgerEraName, Text
otherEraName :: Text
otherEraName :: EraMismatch -> Text
otherEraName} = MismatchEraInfo xs -> EraMismatch
forall (xs :: [*]). SListI xs => MismatchEraInfo xs -> EraMismatch
mkEraMismatch MismatchEraInfo xs
mismatch

instance All (ToObject `Compose` WrapValidationErr) xs => ToObject (OneEraValidationErr xs) where
    toObject :: TracingVerbosity -> OneEraValidationErr xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraValidationErr xs -> NS (K Object) xs)
-> OneEraValidationErr xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapValidationErr)
-> (forall a.
    Compose ToObject WrapValidationErr a =>
    WrapValidationErr a -> K Object a)
-> NS WrapValidationErr xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapValidationErr)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapValidationErr)) (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapValidationErr a -> Object)
-> WrapValidationErr a
-> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapValidationErr a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapValidationErr xs -> NS (K Object) xs)
-> (OneEraValidationErr xs -> NS WrapValidationErr xs)
-> OneEraValidationErr xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraValidationErr xs -> NS WrapValidationErr xs
forall (xs :: [*]).
OneEraValidationErr xs -> NS WrapValidationErr xs
getOneEraValidationErr

instance ToObject (ValidationErr (BlockProtocol blk)) => ToObject (WrapValidationErr blk) where
    toObject :: TracingVerbosity -> WrapValidationErr blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> ValidationErr (BlockProtocol blk) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (ValidationErr (BlockProtocol blk) -> Object)
-> (WrapValidationErr blk -> ValidationErr (BlockProtocol blk))
-> WrapValidationErr blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapValidationErr blk -> ValidationErr (BlockProtocol blk)
forall blk.
WrapValidationErr blk -> ValidationErr (BlockProtocol blk)
unwrapValidationErr


--
-- instances for HardForkCannotForge
--

-- It's a type alias:
-- type HardForkCannotForge xs = OneEraCannotForge xs

instance All (ToObject `Compose` WrapCannotForge) xs => ToObject (OneEraCannotForge xs) where
    toObject :: TracingVerbosity -> OneEraCannotForge xs -> Object
toObject TracingVerbosity
verb =
        NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
      (NS (K Object) xs -> Object)
-> (OneEraCannotForge xs -> NS (K Object) xs)
-> OneEraCannotForge xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapCannotForge)
-> (forall a.
    Compose ToObject WrapCannotForge a =>
    WrapCannotForge a -> K Object a)
-> NS WrapCannotForge xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapCannotForge)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapCannotForge))
              (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapCannotForge a -> Object) -> WrapCannotForge a -> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapCannotForge a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
      (NS WrapCannotForge xs -> NS (K Object) xs)
-> (OneEraCannotForge xs -> NS WrapCannotForge xs)
-> OneEraCannotForge xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraCannotForge xs -> NS WrapCannotForge xs
forall (xs :: [*]). OneEraCannotForge xs -> NS WrapCannotForge xs
getOneEraCannotForge

instance ToObject (CannotForge blk) => ToObject (WrapCannotForge blk) where
    toObject :: TracingVerbosity -> WrapCannotForge blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> CannotForge blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (CannotForge blk -> Object)
-> (WrapCannotForge blk -> CannotForge blk)
-> WrapCannotForge blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapCannotForge blk -> CannotForge blk
forall blk. WrapCannotForge blk -> CannotForge blk
unwrapCannotForge


--
-- instances for HardForkForgeStateInfo
--

-- It's a type alias:
-- type HardForkForgeStateInfo xs = OneEraForgeStateInfo xs

instance All (ToObject `Compose` WrapForgeStateInfo) xs => ToObject (OneEraForgeStateInfo xs) where
    toObject :: TracingVerbosity -> OneEraForgeStateInfo xs -> Object
toObject TracingVerbosity
verb OneEraForgeStateInfo xs
forgeStateInfo =
        [(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
"HardForkForgeStateInfo"
          , Text
"forgeStateInfo" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Object -> Value
forall a. ToJSON a => a -> Value
toJSON Object
forgeStateInfo'
          ]
      where
        forgeStateInfo' :: Object
        forgeStateInfo' :: Object
forgeStateInfo' =
              NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
            (NS (K Object) xs -> Object)
-> (OneEraForgeStateInfo xs -> NS (K Object) xs)
-> OneEraForgeStateInfo xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapForgeStateInfo)
-> (forall a.
    Compose ToObject WrapForgeStateInfo a =>
    WrapForgeStateInfo a -> K Object a)
-> NS WrapForgeStateInfo xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapForgeStateInfo)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapForgeStateInfo))
                    (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapForgeStateInfo a -> Object)
-> WrapForgeStateInfo a
-> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapForgeStateInfo a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
            (NS WrapForgeStateInfo xs -> NS (K Object) xs)
-> (OneEraForgeStateInfo xs -> NS WrapForgeStateInfo xs)
-> OneEraForgeStateInfo xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraForgeStateInfo xs -> NS WrapForgeStateInfo xs
forall (xs :: [*]).
OneEraForgeStateInfo xs -> NS WrapForgeStateInfo xs
getOneEraForgeStateInfo
            (OneEraForgeStateInfo xs -> Object)
-> OneEraForgeStateInfo xs -> Object
forall a b. (a -> b) -> a -> b
$ OneEraForgeStateInfo xs
forgeStateInfo

instance ToObject (ForgeStateInfo blk) => ToObject (WrapForgeStateInfo blk) where
    toObject :: TracingVerbosity -> WrapForgeStateInfo blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> ForgeStateInfo blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (ForgeStateInfo blk -> Object)
-> (WrapForgeStateInfo blk -> ForgeStateInfo blk)
-> WrapForgeStateInfo blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapForgeStateInfo blk -> ForgeStateInfo blk
forall blk. WrapForgeStateInfo blk -> ForgeStateInfo blk
unwrapForgeStateInfo


--
-- instances for HardForkForgeStateUpdateError
--

-- It's a type alias:
-- type HardForkForgeStateUpdateError xs = OneEraForgeStateUpdateError xs

instance All (ToObject `Compose` WrapForgeStateUpdateError) xs => ToObject (OneEraForgeStateUpdateError xs) where
    toObject :: TracingVerbosity -> OneEraForgeStateUpdateError xs -> Object
toObject TracingVerbosity
verb OneEraForgeStateUpdateError xs
forgeStateUpdateError =
        [(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
"HardForkForgeStateUpdateError"
          , Text
"forgeStateUpdateError" Text -> Value -> (Text, Value)
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Object -> Value
forall a. ToJSON a => a -> Value
toJSON Object
forgeStateUpdateError'
          ]
      where
        forgeStateUpdateError' :: Object
        forgeStateUpdateError' :: Object
forgeStateUpdateError' =
              NS (K Object) xs -> Object
forall k l (h :: (k -> *) -> l -> *) (xs :: l) a.
(HCollapse h, SListIN h xs) =>
h (K a) xs -> CollapseTo h a
hcollapse
            (NS (K Object) xs -> Object)
-> (OneEraForgeStateUpdateError xs -> NS (K Object) xs)
-> OneEraForgeStateUpdateError xs
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Proxy (Compose ToObject WrapForgeStateUpdateError)
-> (forall a.
    Compose ToObject WrapForgeStateUpdateError a =>
    WrapForgeStateUpdateError a -> K Object a)
-> NS WrapForgeStateUpdateError xs
-> NS (K Object) xs
forall k l (h :: (k -> *) -> l -> *) (c :: k -> Constraint)
       (xs :: l) (proxy :: (k -> Constraint) -> *) (f :: k -> *)
       (f' :: k -> *).
(AllN (Prod h) c xs, HAp h) =>
proxy c
-> (forall (a :: k). c a => f a -> f' a) -> h f xs -> h f' xs
hcmap (Proxy (Compose ToObject WrapForgeStateUpdateError)
forall k (t :: k). Proxy t
Proxy @ (ToObject `Compose` WrapForgeStateUpdateError))
                    (Object -> K Object a
forall k a (b :: k). a -> K a b
K (Object -> K Object a)
-> (WrapForgeStateUpdateError a -> Object)
-> WrapForgeStateUpdateError a
-> K Object a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> WrapForgeStateUpdateError a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb)
            (NS WrapForgeStateUpdateError xs -> NS (K Object) xs)
-> (OneEraForgeStateUpdateError xs
    -> NS WrapForgeStateUpdateError xs)
-> OneEraForgeStateUpdateError xs
-> NS (K Object) xs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. OneEraForgeStateUpdateError xs -> NS WrapForgeStateUpdateError xs
forall (xs :: [*]).
OneEraForgeStateUpdateError xs -> NS WrapForgeStateUpdateError xs
getOneEraForgeStateUpdateError
            (OneEraForgeStateUpdateError xs -> Object)
-> OneEraForgeStateUpdateError xs -> Object
forall a b. (a -> b) -> a -> b
$ OneEraForgeStateUpdateError xs
forgeStateUpdateError

instance ToObject (ForgeStateUpdateError blk) => ToObject (WrapForgeStateUpdateError blk) where
    toObject :: TracingVerbosity -> WrapForgeStateUpdateError blk -> Object
toObject TracingVerbosity
verb = TracingVerbosity -> ForgeStateUpdateError blk -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb (ForgeStateUpdateError blk -> Object)
-> (WrapForgeStateUpdateError blk -> ForgeStateUpdateError blk)
-> WrapForgeStateUpdateError blk
-> Object
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. WrapForgeStateUpdateError blk -> ForgeStateUpdateError blk
forall blk.
WrapForgeStateUpdateError blk -> ForgeStateUpdateError blk
unwrapForgeStateUpdateError