{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Shelley.State.CertState (
  ShelleyCertState (..),
  mkShelleyCertState,
  shelleyCertDStateL,
  shelleyCertPStateL,
  shelleyObligationCertState,
  shelleyCertsTotalDepositsTxBody,
  shelleyCertsTotalRefundsTxBody,
) where

import Cardano.Ledger.Binary (
  DecShareCBOR (..),
  EncCBOR (..),
  Interns,
  decSharePlusLensCBOR,
  decodeRecordNamedT,
  encodeListLen,
 )
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core
import Cardano.Ledger.Credential (Credential (..))
import Cardano.Ledger.Shelley.Era (ShelleyEra)
import Cardano.Ledger.State
import qualified Cardano.Ledger.UMap as UM
import Control.DeepSeq (NFData (..))
import Data.Aeson (KeyValue, ToJSON (..), object, pairs, (.=))
import Data.Default (Default (..))
import qualified Data.Foldable as F
import qualified Data.Map.Strict as Map
import GHC.Generics (Generic)
import Lens.Micro (Lens', lens, (&), (.~), (^.), _2)
import NoThunks.Class (NoThunks (..))

data ShelleyCertState era = ShelleyCertState
  { forall era. ShelleyCertState era -> PState era
shelleyCertPState :: !(PState era)
  , forall era. ShelleyCertState era -> DState era
shelleyCertDState :: !(DState era)
  }
  deriving (Int -> ShelleyCertState era -> ShowS
[ShelleyCertState era] -> ShowS
ShelleyCertState era -> String
(Int -> ShelleyCertState era -> ShowS)
-> (ShelleyCertState era -> String)
-> ([ShelleyCertState era] -> ShowS)
-> Show (ShelleyCertState era)
forall era. Int -> ShelleyCertState era -> ShowS
forall era. [ShelleyCertState era] -> ShowS
forall era. ShelleyCertState era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> ShelleyCertState era -> ShowS
showsPrec :: Int -> ShelleyCertState era -> ShowS
$cshow :: forall era. ShelleyCertState era -> String
show :: ShelleyCertState era -> String
$cshowList :: forall era. [ShelleyCertState era] -> ShowS
showList :: [ShelleyCertState era] -> ShowS
Show, ShelleyCertState era -> ShelleyCertState era -> Bool
(ShelleyCertState era -> ShelleyCertState era -> Bool)
-> (ShelleyCertState era -> ShelleyCertState era -> Bool)
-> Eq (ShelleyCertState era)
forall era. ShelleyCertState era -> ShelleyCertState era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era. ShelleyCertState era -> ShelleyCertState era -> Bool
== :: ShelleyCertState era -> ShelleyCertState era -> Bool
$c/= :: forall era. ShelleyCertState era -> ShelleyCertState era -> Bool
/= :: ShelleyCertState era -> ShelleyCertState era -> Bool
Eq, (forall x. ShelleyCertState era -> Rep (ShelleyCertState era) x)
-> (forall x. Rep (ShelleyCertState era) x -> ShelleyCertState era)
-> Generic (ShelleyCertState era)
forall x. Rep (ShelleyCertState era) x -> ShelleyCertState era
forall x. ShelleyCertState era -> Rep (ShelleyCertState era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (ShelleyCertState era) x -> ShelleyCertState era
forall era x. ShelleyCertState era -> Rep (ShelleyCertState era) x
$cfrom :: forall era x. ShelleyCertState era -> Rep (ShelleyCertState era) x
from :: forall x. ShelleyCertState era -> Rep (ShelleyCertState era) x
$cto :: forall era x. Rep (ShelleyCertState era) x -> ShelleyCertState era
to :: forall x. Rep (ShelleyCertState era) x -> ShelleyCertState era
Generic)

mkShelleyCertState :: EraCertState era => PState era -> DState era -> CertState era
mkShelleyCertState :: forall era.
EraCertState era =>
PState era -> DState era -> CertState era
mkShelleyCertState PState era
p DState era
d =
  CertState era
forall a. Default a => a
def
    CertState era -> (CertState era -> CertState era) -> CertState era
forall a b. a -> (a -> b) -> b
& (PState era -> Identity (PState era))
-> CertState era -> Identity (CertState era)
forall era. EraCertState era => Lens' (CertState era) (PState era)
Lens' (CertState era) (PState era)
certPStateL ((PState era -> Identity (PState era))
 -> CertState era -> Identity (CertState era))
-> PState era -> CertState era -> CertState era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ PState era
p
    CertState era -> (CertState era -> CertState era) -> CertState era
forall a b. a -> (a -> b) -> b
& (DState era -> Identity (DState era))
-> CertState era -> Identity (CertState era)
forall era. EraCertState era => Lens' (CertState era) (DState era)
Lens' (CertState era) (DState era)
certDStateL ((DState era -> Identity (DState era))
 -> CertState era -> Identity (CertState era))
-> DState era -> CertState era -> CertState era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ DState era
d

shelleyCertDStateL :: Lens' (ShelleyCertState era) (DState era)
shelleyCertDStateL :: forall era (f :: * -> *).
Functor f =>
(DState era -> f (DState era))
-> ShelleyCertState era -> f (ShelleyCertState era)
shelleyCertDStateL = (ShelleyCertState era -> DState era)
-> (ShelleyCertState era -> DState era -> ShelleyCertState era)
-> Lens
     (ShelleyCertState era)
     (ShelleyCertState era)
     (DState era)
     (DState era)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyCertState era -> DState era
forall era. ShelleyCertState era -> DState era
shelleyCertDState (\ShelleyCertState era
ds DState era
u -> ShelleyCertState era
ds {shelleyCertDState = u})
{-# INLINE shelleyCertDStateL #-}

shelleyCertPStateL :: Lens' (ShelleyCertState era) (PState era)
shelleyCertPStateL :: forall era (f :: * -> *).
Functor f =>
(PState era -> f (PState era))
-> ShelleyCertState era -> f (ShelleyCertState era)
shelleyCertPStateL = (ShelleyCertState era -> PState era)
-> (ShelleyCertState era -> PState era -> ShelleyCertState era)
-> Lens
     (ShelleyCertState era)
     (ShelleyCertState era)
     (PState era)
     (PState era)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ShelleyCertState era -> PState era
forall era. ShelleyCertState era -> PState era
shelleyCertPState (\ShelleyCertState era
ds PState era
u -> ShelleyCertState era
ds {shelleyCertPState = u})
{-# INLINE shelleyCertPStateL #-}

toCertStatePairs :: KeyValue e a => ShelleyCertState era -> [a]
toCertStatePairs :: forall e a era. KeyValue e a => ShelleyCertState era -> [a]
toCertStatePairs certState :: ShelleyCertState era
certState@(ShelleyCertState PState era
_ DState era
_) =
  let ShelleyCertState {PState era
DState era
shelleyCertPState :: forall era. ShelleyCertState era -> PState era
shelleyCertDState :: forall era. ShelleyCertState era -> DState era
shelleyCertPState :: PState era
shelleyCertDState :: DState era
..} = ShelleyCertState era
certState
   in [ Key
"dstate" Key -> DState era -> a
forall v. ToJSON v => Key -> v -> a
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DState era
shelleyCertDState
      , Key
"pstate" Key -> PState era -> a
forall v. ToJSON v => Key -> v -> a
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PState era
shelleyCertPState
      ]

shelleyObligationCertState :: EraCertState era => CertState era -> Obligations
shelleyObligationCertState :: forall era. EraCertState era => CertState era -> Obligations
shelleyObligationCertState CertState era
certState =
  Obligations
    { oblStake :: Coin
oblStake =
        CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
UM.fromCompact (UView (Credential 'Staking) RDPair -> CompactForm Coin
forall k. UView k RDPair -> CompactForm Coin
UM.sumDepositUView (UMap -> UView (Credential 'Staking) RDPair
UM.RewDepUView (CertState era
certState CertState era -> Getting UMap (CertState era) UMap -> UMap
forall s a. s -> Getting a s a -> a
^. (DState era -> Const UMap (DState era))
-> CertState era -> Const UMap (CertState era)
forall era. EraCertState era => Lens' (CertState era) (DState era)
Lens' (CertState era) (DState era)
certDStateL ((DState era -> Const UMap (DState era))
 -> CertState era -> Const UMap (CertState era))
-> ((UMap -> Const UMap UMap)
    -> DState era -> Const UMap (DState era))
-> Getting UMap (CertState era) UMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UMap -> Const UMap UMap) -> DState era -> Const UMap (DState era)
forall era (f :: * -> *).
Functor f =>
(UMap -> f UMap) -> DState era -> f (DState era)
dsUnifiedL)))
    , oblPool :: Coin
oblPool = (Coin -> Coin -> Coin)
-> Coin -> Map (KeyHash 'StakePool) Coin -> Coin
forall b a. (b -> a -> b) -> b -> Map (KeyHash 'StakePool) a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' Coin -> Coin -> Coin
forall a. Semigroup a => a -> a -> a
(<>) (Integer -> Coin
Coin Integer
0) (CertState era
certState CertState era
-> Getting
     (Map (KeyHash 'StakePool) Coin)
     (CertState era)
     (Map (KeyHash 'StakePool) Coin)
-> Map (KeyHash 'StakePool) Coin
forall s a. s -> Getting a s a -> a
^. (PState era -> Const (Map (KeyHash 'StakePool) Coin) (PState era))
-> CertState era
-> Const (Map (KeyHash 'StakePool) Coin) (CertState era)
forall era. EraCertState era => Lens' (CertState era) (PState era)
Lens' (CertState era) (PState era)
certPStateL ((PState era -> Const (Map (KeyHash 'StakePool) Coin) (PState era))
 -> CertState era
 -> Const (Map (KeyHash 'StakePool) Coin) (CertState era))
-> ((Map (KeyHash 'StakePool) Coin
     -> Const
          (Map (KeyHash 'StakePool) Coin) (Map (KeyHash 'StakePool) Coin))
    -> PState era
    -> Const (Map (KeyHash 'StakePool) Coin) (PState era))
-> Getting
     (Map (KeyHash 'StakePool) Coin)
     (CertState era)
     (Map (KeyHash 'StakePool) Coin)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map (KeyHash 'StakePool) Coin
 -> Const
      (Map (KeyHash 'StakePool) Coin) (Map (KeyHash 'StakePool) Coin))
-> PState era -> Const (Map (KeyHash 'StakePool) Coin) (PState era)
forall era (f :: * -> *).
Functor f =>
(Map (KeyHash 'StakePool) Coin
 -> f (Map (KeyHash 'StakePool) Coin))
-> PState era -> f (PState era)
psDepositsL)
    , oblDRep :: Coin
oblDRep = Integer -> Coin
Coin Integer
0
    , oblProposal :: Coin
oblProposal = Integer -> Coin
Coin Integer
0
    }

shelleyCertsTotalDepositsTxBody ::
  EraTxBody era => PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalDepositsTxBody :: forall era.
EraTxBody era =>
PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalDepositsTxBody PParams era
pp ShelleyCertState {PState era
shelleyCertPState :: forall era. ShelleyCertState era -> PState era
shelleyCertPState :: PState era
shelleyCertPState} =
  PParams era -> (KeyHash 'StakePool -> Bool) -> TxBody era -> Coin
forall era.
EraTxBody era =>
PParams era -> (KeyHash 'StakePool -> Bool) -> TxBody era -> Coin
getTotalDepositsTxBody PParams era
pp (KeyHash 'StakePool -> Map (KeyHash 'StakePool) PoolParams -> Bool
forall k a. Ord k => k -> Map k a -> Bool
`Map.member` PState era -> Map (KeyHash 'StakePool) PoolParams
forall era. PState era -> Map (KeyHash 'StakePool) PoolParams
psStakePoolParams PState era
shelleyCertPState)

shelleyCertsTotalRefundsTxBody ::
  EraTxBody era => PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalRefundsTxBody :: forall era.
EraTxBody era =>
PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalRefundsTxBody PParams era
pp ShelleyCertState {DState era
shelleyCertDState :: forall era. ShelleyCertState era -> DState era
shelleyCertDState :: DState era
shelleyCertDState} =
  PParams era
-> (Credential 'Staking -> Maybe Coin)
-> (Credential 'DRepRole -> Maybe Coin)
-> TxBody era
-> Coin
forall era.
EraTxBody era =>
PParams era
-> (Credential 'Staking -> Maybe Coin)
-> (Credential 'DRepRole -> Maybe Coin)
-> TxBody era
-> Coin
getTotalRefundsTxBody
    PParams era
pp
    (DState era -> Credential 'Staking -> Maybe Coin
forall era. DState era -> Credential 'Staking -> Maybe Coin
lookupDepositDState DState era
shelleyCertDState)
    (Maybe Coin -> Credential 'DRepRole -> Maybe Coin
forall a b. a -> b -> a
const Maybe Coin
forall a. Maybe a
Nothing)

instance EraCertState ShelleyEra where
  type CertState ShelleyEra = ShelleyCertState ShelleyEra

  certDStateL :: Lens' (CertState ShelleyEra) (DState ShelleyEra)
certDStateL = (DState ShelleyEra -> f (DState ShelleyEra))
-> CertState ShelleyEra -> f (CertState ShelleyEra)
(DState ShelleyEra -> f (DState ShelleyEra))
-> ShelleyCertState ShelleyEra -> f (ShelleyCertState ShelleyEra)
forall era (f :: * -> *).
Functor f =>
(DState era -> f (DState era))
-> ShelleyCertState era -> f (ShelleyCertState era)
shelleyCertDStateL
  {-# INLINE certDStateL #-}

  certPStateL :: Lens' (CertState ShelleyEra) (PState ShelleyEra)
certPStateL = (PState ShelleyEra -> f (PState ShelleyEra))
-> CertState ShelleyEra -> f (CertState ShelleyEra)
(PState ShelleyEra -> f (PState ShelleyEra))
-> ShelleyCertState ShelleyEra -> f (ShelleyCertState ShelleyEra)
forall era (f :: * -> *).
Functor f =>
(PState era -> f (PState era))
-> ShelleyCertState era -> f (ShelleyCertState era)
shelleyCertPStateL
  {-# INLINE certPStateL #-}

  obligationCertState :: CertState ShelleyEra -> Obligations
obligationCertState = CertState ShelleyEra -> Obligations
forall era. EraCertState era => CertState era -> Obligations
shelleyObligationCertState

  certsTotalDepositsTxBody :: EraTxBody ShelleyEra =>
PParams ShelleyEra
-> CertState ShelleyEra -> TxBody ShelleyEra -> Coin
certsTotalDepositsTxBody = PParams ShelleyEra
-> CertState ShelleyEra -> TxBody ShelleyEra -> Coin
PParams ShelleyEra
-> ShelleyCertState ShelleyEra -> TxBody ShelleyEra -> Coin
forall era.
EraTxBody era =>
PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalDepositsTxBody

  certsTotalRefundsTxBody :: EraTxBody ShelleyEra =>
PParams ShelleyEra
-> CertState ShelleyEra -> TxBody ShelleyEra -> Coin
certsTotalRefundsTxBody = PParams ShelleyEra
-> CertState ShelleyEra -> TxBody ShelleyEra -> Coin
PParams ShelleyEra
-> ShelleyCertState ShelleyEra -> TxBody ShelleyEra -> Coin
forall era.
EraTxBody era =>
PParams era -> ShelleyCertState era -> TxBody era -> Coin
shelleyCertsTotalRefundsTxBody

instance ToJSON (ShelleyCertState era) where
  toJSON :: ShelleyCertState era -> Value
toJSON = [Pair] -> Value
object ([Pair] -> Value)
-> (ShelleyCertState era -> [Pair])
-> ShelleyCertState era
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyCertState era -> [Pair]
forall e a era. KeyValue e a => ShelleyCertState era -> [a]
toCertStatePairs
  toEncoding :: ShelleyCertState era -> Encoding
toEncoding = Series -> Encoding
pairs (Series -> Encoding)
-> (ShelleyCertState era -> Series)
-> ShelleyCertState era
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Series] -> Series
forall a. Monoid a => [a] -> a
mconcat ([Series] -> Series)
-> (ShelleyCertState era -> [Series])
-> ShelleyCertState era
-> Series
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyCertState era -> [Series]
forall e a era. KeyValue e a => ShelleyCertState era -> [a]
toCertStatePairs

instance Era era => EncCBOR (ShelleyCertState era) where
  encCBOR :: ShelleyCertState era -> Encoding
encCBOR ShelleyCertState {PState era
shelleyCertPState :: forall era. ShelleyCertState era -> PState era
shelleyCertPState :: PState era
shelleyCertPState, DState era
shelleyCertDState :: forall era. ShelleyCertState era -> DState era
shelleyCertDState :: DState era
shelleyCertDState} =
    Word -> Encoding
encodeListLen Word
2
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PState era -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR PState era
shelleyCertPState
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> DState era -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR DState era
shelleyCertDState

instance Era era => DecShareCBOR (ShelleyCertState era) where
  type
    Share (ShelleyCertState era) =
      ( Interns (Credential 'Staking)
      , Interns (KeyHash 'StakePool)
      , Interns (Credential 'DRepRole)
      , Interns (Credential 'HotCommitteeRole)
      )
  decSharePlusCBOR :: forall s.
StateT
  (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
decSharePlusCBOR = Text
-> (ShelleyCertState era -> Int)
-> StateT
     (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
-> StateT
     (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
forall (m :: (* -> *) -> * -> *) s a.
(MonadTrans m, Monad (m (Decoder s))) =>
Text -> (a -> Int) -> m (Decoder s) a -> m (Decoder s) a
decodeRecordNamedT Text
"ShelleyCertState" (Int -> ShelleyCertState era -> Int
forall a b. a -> b -> a
const Int
2) (StateT
   (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
 -> StateT
      (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era))
-> StateT
     (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
-> StateT
     (Share (ShelleyCertState era)) (Decoder s) (ShelleyCertState era)
forall a b. (a -> b) -> a -> b
$ do
    PState era
shelleyCertPState <- Lens'
  (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
   Interns (Credential 'DRepRole),
   Interns (Credential 'HotCommitteeRole))
  (Share (PState era))
-> StateT
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Decoder s)
     (PState era)
forall b bs s.
DecShareCBOR b =>
Lens' bs (Share b) -> StateT bs (Decoder s) b
decSharePlusLensCBOR (Share (PState era) -> f (Share (PState era)))
-> (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
    Interns (Credential 'DRepRole),
    Interns (Credential 'HotCommitteeRole))
-> f (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
(Interns (KeyHash 'StakePool) -> f (Interns (KeyHash 'StakePool)))
-> (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
    Interns (Credential 'DRepRole),
    Interns (Credential 'HotCommitteeRole))
-> f (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
forall s t a b. Field2 s t a b => Lens s t a b
Lens'
  (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
   Interns (Credential 'DRepRole),
   Interns (Credential 'HotCommitteeRole))
  (Share (PState era))
Lens
  (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
   Interns (Credential 'DRepRole),
   Interns (Credential 'HotCommitteeRole))
  (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
   Interns (Credential 'DRepRole),
   Interns (Credential 'HotCommitteeRole))
  (Interns (KeyHash 'StakePool))
  (Interns (KeyHash 'StakePool))
_2
    DState era
shelleyCertDState <-
      Lens'
  (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
   Interns (Credential 'DRepRole),
   Interns (Credential 'HotCommitteeRole))
  (Share (DState era))
-> StateT
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Decoder s)
     (DState era)
forall b bs s.
DecShareCBOR b =>
Lens' bs (Share b) -> StateT bs (Decoder s) b
decSharePlusLensCBOR (Lens'
   (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
    Interns (Credential 'DRepRole),
    Interns (Credential 'HotCommitteeRole))
   (Share (DState era))
 -> StateT
      (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
       Interns (Credential 'DRepRole),
       Interns (Credential 'HotCommitteeRole))
      (Decoder s)
      (DState era))
-> Lens'
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Share (DState era))
-> StateT
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Decoder s)
     (DState era)
forall a b. (a -> b) -> a -> b
$
        ((Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
  Interns (Credential 'DRepRole),
  Interns (Credential 'HotCommitteeRole))
 -> (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
     Interns (Credential 'DRepRole)))
-> ((Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
     Interns (Credential 'DRepRole),
     Interns (Credential 'HotCommitteeRole))
    -> (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
        Interns (Credential 'DRepRole))
    -> (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
        Interns (Credential 'DRepRole),
        Interns (Credential 'HotCommitteeRole)))
-> Lens
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole))
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens (\(Interns (Credential 'Staking)
cs, Interns (KeyHash 'StakePool)
ks, Interns (Credential 'DRepRole)
cd, Interns (Credential 'HotCommitteeRole)
_) -> (Interns (Credential 'Staking)
cs, Interns (KeyHash 'StakePool)
ks, Interns (Credential 'DRepRole)
cd)) (\(Interns (Credential 'Staking)
_, Interns (KeyHash 'StakePool)
_, Interns (Credential 'DRepRole)
_, Interns (Credential 'HotCommitteeRole)
ch) (Interns (Credential 'Staking)
cs, Interns (KeyHash 'StakePool)
ks, Interns (Credential 'DRepRole)
cd) -> (Interns (Credential 'Staking)
cs, Interns (KeyHash 'StakePool)
ks, Interns (Credential 'DRepRole)
cd, Interns (Credential 'HotCommitteeRole)
ch))
    ShelleyCertState era
-> StateT
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Decoder s)
     (ShelleyCertState era)
forall a.
a
-> StateT
     (Interns (Credential 'Staking), Interns (KeyHash 'StakePool),
      Interns (Credential 'DRepRole),
      Interns (Credential 'HotCommitteeRole))
     (Decoder s)
     a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ShelleyCertState {PState era
DState era
shelleyCertPState :: PState era
shelleyCertDState :: DState era
shelleyCertPState :: PState era
shelleyCertDState :: DState era
..}

instance Default (ShelleyCertState era) where
  def :: ShelleyCertState era
def = PState era -> DState era -> ShelleyCertState era
forall era. PState era -> DState era -> ShelleyCertState era
ShelleyCertState PState era
forall a. Default a => a
def DState era
forall a. Default a => a
def

instance Era era => NoThunks (ShelleyCertState era)

instance Era era => NFData (ShelleyCertState era)