Skip to content

Commit f2b0c05

Browse files
committed
Add rewards from treasury
1 parent d750ceb commit f2b0c05

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/LedgerEvent.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Cardano.DbSync.Error
2525
import Cardano.DbSync.Ledger.Event
2626
import Cardano.DbSync.Types
2727
import Cardano.DbSync.Util
28+
import qualified Cardano.Ledger.Address as Ledger
2829
import Cardano.Prelude
2930
import Cardano.Slotting.Slot (EpochNo (..))
3031
import Control.Monad.Extra (whenJust)
@@ -105,9 +106,8 @@ insertNewEpochLedgerEvents syncEnv currentEpochNo@(EpochNo curEpoch) =
105106
forM_ en $ \gar -> whenJust (garMTreasury gar) $ \treasuryMap -> do
106107
gaId <- resolveGovActionProposal (garGovActionId gar)
107108
lift $ void $ DB.updateGovActionEnacted gaId (unEpochNo currentEpochNo)
108-
forM_ (Map.toList treasuryMap) $ \(_ra, _c) ->
109-
-- TODO: Add reward
110-
pure ()
109+
let rewards = Map.mapKeys Ledger.raCredential $ Map.map (Set.singleton . mkTreasuryReward) treasuryMap
110+
insertRewardRests ntw (subFromCurrentEpoch 1) currentEpochNo cache (Map.toList rewards)
111111
LedgerMirDist rwd -> do
112112
unless (Map.null rwd) $ do
113113
let rewards = Map.toList rwd

cardano-db-sync/src/Cardano/DbSync/Ledger/Event.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Cardano.DbSync.Ledger.Event (
1515
LedgerEvent (..),
1616
GovActionRefunded (..),
1717
convertAuxLedgerEvent,
18+
mkTreasuryReward,
1819
convertPoolRewards,
1920
ledgerEventName,
2021
splitDeposits,
@@ -324,6 +325,13 @@ convertMirRewards resPay trePay =
324325
, Generic.irAmount = coin
325326
}
326327

328+
mkTreasuryReward :: Coin -> Generic.RewardRest
329+
mkTreasuryReward c =
330+
Generic.RewardRest
331+
{ Generic.irSource = RwdTreasury
332+
, Generic.irAmount = c
333+
}
334+
327335
convertPoolRewards ::
328336
Map StakeCred (Set (Ledger.Reward StandardCrypto)) ->
329337
Generic.Rewards

0 commit comments

Comments
 (0)