{-# LANGUAGE DataKinds #-}
module Test.Cardano.Ledger.Api.State.Query (
getFilteredDelegationsAndRewardAccounts,
)
where
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Credential (Credential)
import Cardano.Ledger.Keys (KeyHash, KeyRole (StakePool, Staking))
import Cardano.Ledger.UMap (UMap, UView (SPoolUView), domRestrictedMap, rewardMap)
import Data.Map (Map)
import qualified Data.Map.Strict as Map
import Data.Set (Set)
getFilteredDelegationsAndRewardAccounts ::
UMap ->
Set (Credential 'Staking) ->
(Map (Credential 'Staking) (KeyHash 'StakePool), Map (Credential 'Staking) Coin)
getFilteredDelegationsAndRewardAccounts :: UMap
-> Set (Credential 'Staking)
-> (Map (Credential 'Staking) (KeyHash 'StakePool),
Map (Credential 'Staking) Coin)
getFilteredDelegationsAndRewardAccounts UMap
umap Set (Credential 'Staking)
creds =
(Map (Credential 'Staking) (KeyHash 'StakePool)
filteredDelegations, Map (Credential 'Staking) Coin
filteredRwdAcnts)
where
filteredDelegations :: Map (Credential 'Staking) (KeyHash 'StakePool)
filteredDelegations = forall k v. Set k -> UView k v -> Map k v
domRestrictedMap Set (Credential 'Staking)
creds forall a b. (a -> b) -> a -> b
$ UMap -> UView (Credential 'Staking) (KeyHash 'StakePool)
SPoolUView UMap
umap
filteredRwdAcnts :: Map (Credential 'Staking) Coin
filteredRwdAcnts = UMap -> Map (Credential 'Staking) Coin
rewardMap UMap
umap forall k a. Ord k => Map k a -> Set k -> Map k a
`Map.restrictKeys` Set (Credential 'Staking)
creds