{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
module Cardano.Api.LedgerState.Internal.LedgerEvent
( LedgerEvent (..)
, AnyProposals (..)
, AnyRatificationState (..)
, MIRDistributionDetails (..)
, PoolReapDetails (..)
, convertRetiredPoolsMap
)
where
import Cardano.Api.Address (StakeCredential, fromShelleyStakeCredential)
import Cardano.Api.Block (EpochNo)
import Cardano.Api.Key.Internal (Hash (..), StakePoolKey)
import Cardano.Ledger.Coin qualified as L
import Cardano.Ledger.Coin qualified as Ledger
import Cardano.Ledger.Compactible qualified as Ledger
import Cardano.Ledger.Conway.Governance qualified as Ledger
import Cardano.Ledger.Core qualified as Ledger.Core
import Cardano.Ledger.Credential qualified as Ledger
import Cardano.Ledger.Keys qualified as Ledger
import Cardano.Ledger.Plutus.Evaluate (PlutusWithContext)
import Cardano.Ledger.Shelley.Rewards (Reward)
import Cardano.Ledger.TxIn qualified as Ledger
import Data.List.NonEmpty (NonEmpty)
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Set (Set)
data AnyProposals
= forall era. Ledger.Core.EraPParams era => AnyProposals (Ledger.Proposals era)
deriving instance Show AnyProposals
data AnyRatificationState
= forall era. Ledger.Core.EraPParams era => AnyRatificationState (Ledger.RatifyState era)
deriving instance Show AnyRatificationState
data LedgerEvent
=
PoolRegistration
|
PoolReRegistration
|
IncrementalRewardsDistribution EpochNo (Map StakeCredential (Set Reward))
|
RewardsDistribution EpochNo (Map StakeCredential (Set Reward))
|
MIRDistribution MIRDistributionDetails
|
PoolReap PoolReapDetails
|
SuccessfulPlutusScript (NonEmpty PlutusWithContext)
|
FailedPlutusScript (NonEmpty PlutusWithContext)
|
NewGovernanceProposals Ledger.TxId AnyProposals
|
RemovedGovernanceVotes
Ledger.TxId
(Set (Ledger.Voter, Ledger.GovActionId))
(Set (Ledger.Credential Ledger.DRepRole))
|
EpochBoundaryRatificationState AnyRatificationState
deriving Int -> LedgerEvent -> ShowS
[LedgerEvent] -> ShowS
LedgerEvent -> String
(Int -> LedgerEvent -> ShowS)
-> (LedgerEvent -> String)
-> ([LedgerEvent] -> ShowS)
-> Show LedgerEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LedgerEvent -> ShowS
showsPrec :: Int -> LedgerEvent -> ShowS
$cshow :: LedgerEvent -> String
show :: LedgerEvent -> String
$cshowList :: [LedgerEvent] -> ShowS
showList :: [LedgerEvent] -> ShowS
Show
data MIRDistributionDetails = MIRDistributionDetails
{ MIRDistributionDetails -> Map StakeCredential Coin
mirddReservePayouts :: Map StakeCredential L.Coin
, MIRDistributionDetails -> Map StakeCredential Coin
mirddTreasuryPayouts :: Map StakeCredential L.Coin
, MIRDistributionDetails -> Coin
mirddReservesToTreasury :: L.Coin
, MIRDistributionDetails -> Coin
mirddTreasuryToReserves :: L.Coin
}
deriving Int -> MIRDistributionDetails -> ShowS
[MIRDistributionDetails] -> ShowS
MIRDistributionDetails -> String
(Int -> MIRDistributionDetails -> ShowS)
-> (MIRDistributionDetails -> String)
-> ([MIRDistributionDetails] -> ShowS)
-> Show MIRDistributionDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MIRDistributionDetails -> ShowS
showsPrec :: Int -> MIRDistributionDetails -> ShowS
$cshow :: MIRDistributionDetails -> String
show :: MIRDistributionDetails -> String
$cshowList :: [MIRDistributionDetails] -> ShowS
showList :: [MIRDistributionDetails] -> ShowS
Show
data PoolReapDetails = PoolReapDetails
{ PoolReapDetails -> EpochNo
prdEpochNo :: EpochNo
, PoolReapDetails
-> Map StakeCredential (Map (Hash StakePoolKey) Coin)
prdRefunded :: Map StakeCredential (Map (Hash StakePoolKey) L.Coin)
, PoolReapDetails
-> Map StakeCredential (Map (Hash StakePoolKey) Coin)
prdUnclaimed :: Map StakeCredential (Map (Hash StakePoolKey) L.Coin)
}
deriving Int -> PoolReapDetails -> ShowS
[PoolReapDetails] -> ShowS
PoolReapDetails -> String
(Int -> PoolReapDetails -> ShowS)
-> (PoolReapDetails -> String)
-> ([PoolReapDetails] -> ShowS)
-> Show PoolReapDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PoolReapDetails -> ShowS
showsPrec :: Int -> PoolReapDetails -> ShowS
$cshow :: PoolReapDetails -> String
show :: PoolReapDetails -> String
$cshowList :: [PoolReapDetails] -> ShowS
showList :: [PoolReapDetails] -> ShowS
Show
convertRetiredPoolsMap
:: Map
(Ledger.Credential Ledger.Staking)
(Map (Ledger.KeyHash Ledger.StakePool) (Ledger.CompactForm Ledger.Coin))
-> Map StakeCredential (Map (Hash StakePoolKey) L.Coin)
convertRetiredPoolsMap :: Map
(Credential Staking) (Map (KeyHash StakePool) (CompactForm Coin))
-> Map StakeCredential (Map (Hash StakePoolKey) Coin)
convertRetiredPoolsMap =
(Credential Staking -> StakeCredential)
-> Map (Credential Staking) (Map (Hash StakePoolKey) Coin)
-> Map StakeCredential (Map (Hash StakePoolKey) Coin)
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys Credential Staking -> StakeCredential
fromShelleyStakeCredential
(Map (Credential Staking) (Map (Hash StakePoolKey) Coin)
-> Map StakeCredential (Map (Hash StakePoolKey) Coin))
-> (Map
(Credential Staking) (Map (KeyHash StakePool) (CompactForm Coin))
-> Map (Credential Staking) (Map (Hash StakePoolKey) Coin))
-> Map
(Credential Staking) (Map (KeyHash StakePool) (CompactForm Coin))
-> Map StakeCredential (Map (Hash StakePoolKey) Coin)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map (KeyHash StakePool) (CompactForm Coin)
-> Map (Hash StakePoolKey) Coin)
-> Map
(Credential Staking) (Map (KeyHash StakePool) (CompactForm Coin))
-> Map (Credential Staking) (Map (Hash StakePoolKey) Coin)
forall a b.
(a -> b)
-> Map (Credential Staking) a -> Map (Credential Staking) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((KeyHash StakePool -> Hash StakePoolKey)
-> Map (KeyHash StakePool) Coin -> Map (Hash StakePoolKey) Coin
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys KeyHash StakePool -> Hash StakePoolKey
StakePoolKeyHash (Map (KeyHash StakePool) Coin -> Map (Hash StakePoolKey) Coin)
-> (Map (KeyHash StakePool) (CompactForm Coin)
-> Map (KeyHash StakePool) Coin)
-> Map (KeyHash StakePool) (CompactForm Coin)
-> Map (Hash StakePoolKey) Coin
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CompactForm Coin -> Coin)
-> Map (KeyHash StakePool) (CompactForm Coin)
-> Map (KeyHash StakePool) Coin
forall a b.
(a -> b) -> Map (KeyHash StakePool) a -> Map (KeyHash StakePool) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
Ledger.fromCompact)