{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}

module Cardano.Ledger.DRep (
  DRep (DRepCredential, DRepKeyHash, DRepScriptHash, DRepAlwaysAbstain, DRepAlwaysNoConfidence),
  DRepState (..),
  drepExpiryL,
  drepAnchorL,
  drepDepositL,
  drepDelegsL,
) where

import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders (Decode (..), Encode (..), decode, encode, (!>), (<!))
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Credential (Credential (..), credToText, parseCredential)
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Hashes (ScriptHash)
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Control.DeepSeq (NFData (..))
import Data.Aeson (
  FromJSON (..),
  FromJSONKey (..),
  FromJSONKeyFunction (..),
  KeyValue (..),
  ToJSON (..),
  ToJSONKey (..),
  Value (..),
  object,
  withObject,
  withText,
  (.!=),
  (.:),
  (.:?),
 )
import Data.Aeson.Types (toJSONKeyText)
import Data.Set (Set)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks (..))

-- =======================================
-- DRep and DRepState

data DRep c
  = DRepKeyHash !(KeyHash 'DRepRole c)
  | DRepScriptHash !(ScriptHash c)
  | DRepAlwaysAbstain
  | DRepAlwaysNoConfidence
  deriving (Int -> DRep c -> ShowS
forall c. Int -> DRep c -> ShowS
forall c. [DRep c] -> ShowS
forall c. DRep c -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DRep c] -> ShowS
$cshowList :: forall c. [DRep c] -> ShowS
show :: DRep c -> String
$cshow :: forall c. DRep c -> String
showsPrec :: Int -> DRep c -> ShowS
$cshowsPrec :: forall c. Int -> DRep c -> ShowS
Show, DRep c -> DRep c -> Bool
forall c. DRep c -> DRep c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DRep c -> DRep c -> Bool
$c/= :: forall c. DRep c -> DRep c -> Bool
== :: DRep c -> DRep c -> Bool
$c== :: forall c. DRep c -> DRep c -> Bool
Eq, DRep c -> DRep c -> Ordering
forall c. Eq (DRep c)
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall c. DRep c -> DRep c -> Bool
forall c. DRep c -> DRep c -> Ordering
forall c. DRep c -> DRep c -> DRep c
min :: DRep c -> DRep c -> DRep c
$cmin :: forall c. DRep c -> DRep c -> DRep c
max :: DRep c -> DRep c -> DRep c
$cmax :: forall c. DRep c -> DRep c -> DRep c
>= :: DRep c -> DRep c -> Bool
$c>= :: forall c. DRep c -> DRep c -> Bool
> :: DRep c -> DRep c -> Bool
$c> :: forall c. DRep c -> DRep c -> Bool
<= :: DRep c -> DRep c -> Bool
$c<= :: forall c. DRep c -> DRep c -> Bool
< :: DRep c -> DRep c -> Bool
$c< :: forall c. DRep c -> DRep c -> Bool
compare :: DRep c -> DRep c -> Ordering
$ccompare :: forall c. DRep c -> DRep c -> Ordering
Ord, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x. Rep (DRep c) x -> DRep c
forall c x. DRep c -> Rep (DRep c) x
$cto :: forall c x. Rep (DRep c) x -> DRep c
$cfrom :: forall c x. DRep c -> Rep (DRep c) x
Generic, forall c. Context -> DRep c -> IO (Maybe ThunkInfo)
forall c. Proxy (DRep c) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (DRep c) -> String
$cshowTypeOf :: forall c. Proxy (DRep c) -> String
wNoThunks :: Context -> DRep c -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall c. Context -> DRep c -> IO (Maybe ThunkInfo)
noThunks :: Context -> DRep c -> IO (Maybe ThunkInfo)
$cnoThunks :: forall c. Context -> DRep c -> IO (Maybe ThunkInfo)
NoThunks, forall c. DRep c -> ()
forall a. (a -> ()) -> NFData a
rnf :: DRep c -> ()
$crnf :: forall c. DRep c -> ()
NFData)

instance Crypto c => EncCBOR (DRep c) where
  encCBOR :: DRep c -> Encoding
encCBOR (DRepKeyHash KeyHash 'DRepRole c
kh) =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Word -> Encode 'Open t
Sum forall c. KeyHash 'DRepRole c -> DRep c
DRepKeyHash Word
0
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To KeyHash 'DRepRole c
kh
  encCBOR (DRepScriptHash ScriptHash c
sh) =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Word -> Encode 'Open t
Sum forall c. ScriptHash c -> DRep c
DRepScriptHash Word
1
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To ScriptHash c
sh
  encCBOR DRep c
DRepAlwaysAbstain =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Word -> Encode 'Open t
Sum forall c. DRep c
DRepAlwaysAbstain Word
2
  encCBOR DRep c
DRepAlwaysNoConfidence =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Word -> Encode 'Open t
Sum forall c. DRep c
DRepAlwaysNoConfidence Word
3

instance Crypto c => DecCBOR (DRep c) where
  decCBOR :: forall s. Decoder s (DRep c)
decCBOR = forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
    forall t.
Text -> (Word -> Decode 'Open t) -> Decode ('Closed 'Dense) t
Summands Text
"DRep" forall a b. (a -> b) -> a -> b
$ \case
      Word
0 -> forall t. t -> Decode 'Open t
SumD forall c. KeyHash 'DRepRole c -> DRep c
DRepKeyHash forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      Word
1 -> forall t. t -> Decode 'Open t
SumD forall c. ScriptHash c -> DRep c
DRepScriptHash forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      Word
2 -> forall t. t -> Decode 'Open t
SumD forall c. DRep c
DRepAlwaysAbstain
      Word
3 -> forall t. t -> Decode 'Open t
SumD forall c. DRep c
DRepAlwaysNoConfidence
      Word
k -> forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
k

dRepToCred :: DRep c -> Maybe (Credential 'DRepRole c)
dRepToCred :: forall c. DRep c -> Maybe (Credential 'DRepRole c)
dRepToCred (DRepKeyHash KeyHash 'DRepRole c
kh) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj KeyHash 'DRepRole c
kh
dRepToCred (DRepScriptHash ScriptHash c
sh) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall (kr :: KeyRole) c. ScriptHash c -> Credential kr c
ScriptHashObj ScriptHash c
sh
dRepToCred DRep c
_ = forall a. Maybe a
Nothing

instance Crypto c => ToJSON (DRep c) where
  toJSON :: DRep c -> Value
toJSON = Text -> Value
String forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. DRep c -> Text
dRepToText

instance Crypto c => ToJSONKey (DRep c) where
  toJSONKey :: ToJSONKeyFunction (DRep c)
toJSONKey = forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText forall c. DRep c -> Text
dRepToText

dRepToText :: DRep c -> T.Text
dRepToText :: forall c. DRep c -> Text
dRepToText = \case
  DRep c
DRepAlwaysAbstain -> Text
"drep-alwaysAbstain"
  DRep c
DRepAlwaysNoConfidence -> Text
"drep-alwaysNoConfidence"
  DRepCredential Credential 'DRepRole c
cred -> Text
"drep-" forall a. Semigroup a => a -> a -> a
<> forall (kr :: KeyRole) c. Credential kr c -> Text
credToText Credential 'DRepRole c
cred

instance Crypto c => FromJSON (DRep c) where
  parseJSON :: Value -> Parser (DRep c)
parseJSON = forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"DRep" forall (f :: * -> *) c.
(MonadFail f, Crypto c) =>
Text -> f (DRep c)
parseDRep

instance Crypto c => FromJSONKey (DRep c) where
  fromJSONKey :: FromJSONKeyFunction (DRep c)
fromJSONKey = forall a. (Text -> Parser a) -> FromJSONKeyFunction a
FromJSONKeyTextParser forall (f :: * -> *) c.
(MonadFail f, Crypto c) =>
Text -> f (DRep c)
parseDRep

parseDRep :: (MonadFail f, Crypto c) => T.Text -> f (DRep c)
parseDRep :: forall (f :: * -> *) c.
(MonadFail f, Crypto c) =>
Text -> f (DRep c)
parseDRep Text
t = case (Char -> Bool) -> Text -> (Text, Text)
T.span (forall a. Eq a => a -> a -> Bool
/= Char
'-') Text
t of
  (Text
"drep", Text
restWithDash)
    | Text
restWithDash forall a. Eq a => a -> a -> Bool
== Text
"-alwaysAbstain" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall c. DRep c
DRepAlwaysAbstain
    | Text
restWithDash forall a. Eq a => a -> a -> Bool
== Text
"-alwaysNoConfidence" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall c. DRep c
DRepAlwaysNoConfidence
    | (Text
"-", Text
rest) <- (Char -> Bool) -> Text -> (Text, Text)
T.span (forall a. Eq a => a -> a -> Bool
== Char
'-') Text
restWithDash ->
        forall c. Credential 'DRepRole c -> DRep c
DRepCredential forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) c (kr :: KeyRole).
(MonadFail m, Crypto c) =>
Text -> m (Credential kr c)
parseCredential Text
rest
  (Text, Text)
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"Invalid DRep: " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> String
show Text
t

pattern DRepCredential :: Credential 'DRepRole c -> DRep c
pattern $bDRepCredential :: forall c. Credential 'DRepRole c -> DRep c
$mDRepCredential :: forall {r} {c}.
DRep c -> (Credential 'DRepRole c -> r) -> ((# #) -> r) -> r
DRepCredential c <- (dRepToCred -> Just c)
  where
    DRepCredential Credential 'DRepRole c
c = case Credential 'DRepRole c
c of
      ScriptHashObj ScriptHash c
sh -> forall c. ScriptHash c -> DRep c
DRepScriptHash ScriptHash c
sh
      KeyHashObj KeyHash 'DRepRole c
kh -> forall c. KeyHash 'DRepRole c -> DRep c
DRepKeyHash KeyHash 'DRepRole c
kh

{-# COMPLETE DRepCredential, DRepAlwaysAbstain, DRepAlwaysNoConfidence :: DRep #-}

data DRepState c = DRepState
  { forall c. DRepState c -> EpochNo
drepExpiry :: !EpochNo
  , forall c. DRepState c -> StrictMaybe (Anchor c)
drepAnchor :: !(StrictMaybe (Anchor c))
  , forall c. DRepState c -> Coin
drepDeposit :: !Coin
  , forall c. DRepState c -> Set (Credential 'Staking c)
drepDelegs :: !(Set (Credential 'Staking c))
  }
  deriving (Int -> DRepState c -> ShowS
forall c. Int -> DRepState c -> ShowS
forall c. [DRepState c] -> ShowS
forall c. DRepState c -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DRepState c] -> ShowS
$cshowList :: forall c. [DRepState c] -> ShowS
show :: DRepState c -> String
$cshow :: forall c. DRepState c -> String
showsPrec :: Int -> DRepState c -> ShowS
$cshowsPrec :: forall c. Int -> DRepState c -> ShowS
Show, DRepState c -> DRepState c -> Bool
forall c. DRepState c -> DRepState c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DRepState c -> DRepState c -> Bool
$c/= :: forall c. DRepState c -> DRepState c -> Bool
== :: DRepState c -> DRepState c -> Bool
$c== :: forall c. DRepState c -> DRepState c -> Bool
Eq, DRepState c -> DRepState c -> Bool
DRepState c -> DRepState c -> Ordering
forall c. Eq (DRepState c)
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall c. DRepState c -> DRepState c -> Bool
forall c. DRepState c -> DRepState c -> Ordering
forall c. DRepState c -> DRepState c -> DRepState c
min :: DRepState c -> DRepState c -> DRepState c
$cmin :: forall c. DRepState c -> DRepState c -> DRepState c
max :: DRepState c -> DRepState c -> DRepState c
$cmax :: forall c. DRepState c -> DRepState c -> DRepState c
>= :: DRepState c -> DRepState c -> Bool
$c>= :: forall c. DRepState c -> DRepState c -> Bool
> :: DRepState c -> DRepState c -> Bool
$c> :: forall c. DRepState c -> DRepState c -> Bool
<= :: DRepState c -> DRepState c -> Bool
$c<= :: forall c. DRepState c -> DRepState c -> Bool
< :: DRepState c -> DRepState c -> Bool
$c< :: forall c. DRepState c -> DRepState c -> Bool
compare :: DRepState c -> DRepState c -> Ordering
$ccompare :: forall c. DRepState c -> DRepState c -> Ordering
Ord, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x. Rep (DRepState c) x -> DRepState c
forall c x. DRepState c -> Rep (DRepState c) x
$cto :: forall c x. Rep (DRepState c) x -> DRepState c
$cfrom :: forall c x. DRepState c -> Rep (DRepState c) x
Generic)

instance NoThunks (DRepState era)

instance Crypto c => NFData (DRepState c)

instance Crypto c => DecCBOR (DRepState c) where
  decCBOR :: forall s. Decoder s (DRepState c)
decCBOR = do
    forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Decode ('Closed 'Dense) t
RecD forall c.
EpochNo
-> StrictMaybe (Anchor c)
-> Coin
-> Set (Credential 'Staking c)
-> DRepState c
DRepState
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From

instance Crypto c => EncCBOR (DRepState c) where
  encCBOR :: DRepState c -> Encoding
encCBOR DRepState {Set (Credential 'Staking c)
StrictMaybe (Anchor c)
EpochNo
Coin
drepDelegs :: Set (Credential 'Staking c)
drepDeposit :: Coin
drepAnchor :: StrictMaybe (Anchor c)
drepExpiry :: EpochNo
drepDelegs :: forall c. DRepState c -> Set (Credential 'Staking c)
drepDeposit :: forall c. DRepState c -> Coin
drepAnchor :: forall c. DRepState c -> StrictMaybe (Anchor c)
drepExpiry :: forall c. DRepState c -> EpochNo
..} =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Encode ('Closed 'Dense) t
Rec forall c.
EpochNo
-> StrictMaybe (Anchor c)
-> Coin
-> Set (Credential 'Staking c)
-> DRepState c
DRepState
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To EpochNo
drepExpiry
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To StrictMaybe (Anchor c)
drepAnchor
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
drepDeposit
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (Credential 'Staking c)
drepDelegs

instance Crypto c => ToJSON (DRepState c) where
  toJSON :: DRepState c -> Value
toJSON x :: DRepState c
x@(DRepState EpochNo
_ StrictMaybe (Anchor c)
_ Coin
_ Set (Credential 'Staking c)
_) =
    let DRepState {Set (Credential 'Staking c)
StrictMaybe (Anchor c)
EpochNo
Coin
drepDelegs :: Set (Credential 'Staking c)
drepDeposit :: Coin
drepAnchor :: StrictMaybe (Anchor c)
drepExpiry :: EpochNo
drepDelegs :: forall c. DRepState c -> Set (Credential 'Staking c)
drepDeposit :: forall c. DRepState c -> Coin
drepAnchor :: forall c. DRepState c -> StrictMaybe (Anchor c)
drepExpiry :: forall c. DRepState c -> EpochNo
..} = DRepState c
x
     in forall a. ToJSON a => a -> Value
toJSON forall a b. (a -> b) -> a -> b
$
          [Pair] -> Value
object forall a b. (a -> b) -> a -> b
$
            [ Key
"expiry" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON EpochNo
drepExpiry
            , Key
"deposit" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON Coin
drepDeposit
            , Key
"delegators" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON Set (Credential 'Staking c)
drepDelegs
            ]
              forall a. [a] -> [a] -> [a]
++ [Key
"anchor" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= forall a. ToJSON a => a -> Value
toJSON Anchor c
anchor | SJust Anchor c
anchor <- [StrictMaybe (Anchor c)
drepAnchor]]

instance Crypto c => FromJSON (DRepState c) where
  parseJSON :: Value -> Parser (DRepState c)
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"DRepState" forall a b. (a -> b) -> a -> b
$ \Object
o ->
    forall c.
EpochNo
-> StrictMaybe (Anchor c)
-> Coin
-> Set (Credential 'Staking c)
-> DRepState c
DRepState
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"expiry"
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"anchor" forall a. Parser (Maybe a) -> a -> Parser a
.!= forall a. StrictMaybe a
SNothing
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"deposit"
      -- Construction of DRep state with deleagations is intentionally prohibited, since
      -- there is a requirement to retain the invariant of delegations in the UMap
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty

drepExpiryL :: Lens' (DRepState c) EpochNo
drepExpiryL :: forall c. Lens' (DRepState c) EpochNo
drepExpiryL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall c. DRepState c -> EpochNo
drepExpiry (\DRepState c
x EpochNo
y -> DRepState c
x {drepExpiry :: EpochNo
drepExpiry = EpochNo
y})

drepAnchorL :: Lens' (DRepState c) (StrictMaybe (Anchor c))
drepAnchorL :: forall c. Lens' (DRepState c) (StrictMaybe (Anchor c))
drepAnchorL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall c. DRepState c -> StrictMaybe (Anchor c)
drepAnchor (\DRepState c
x StrictMaybe (Anchor c)
y -> DRepState c
x {drepAnchor :: StrictMaybe (Anchor c)
drepAnchor = StrictMaybe (Anchor c)
y})

drepDepositL :: Lens' (DRepState c) Coin
drepDepositL :: forall c. Lens' (DRepState c) Coin
drepDepositL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall c. DRepState c -> Coin
drepDeposit (\DRepState c
x Coin
y -> DRepState c
x {drepDeposit :: Coin
drepDeposit = Coin
y})

drepDelegsL :: Lens' (DRepState c) (Set (Credential 'Staking c))
drepDelegsL :: forall c. Lens' (DRepState c) (Set (Credential 'Staking c))
drepDelegsL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall c. DRepState c -> Set (Credential 'Staking c)
drepDelegs (\DRepState c
x Set (Credential 'Staking c)
y -> DRepState c
x {drepDelegs :: Set (Credential 'Staking c)
drepDelegs = Set (Credential 'Staking c)
y})