Skip to content

Commit 780af13

Browse files
committed
Move rewardTypeToSource from cardano-db to cardano-db-sync
This DRASTICALLY reduces the number of dependencies required by anyone who just wants to use the cardano-db package.
1 parent f9d8f2a commit 780af13

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

cardano-db-sync/src/Cardano/DbSync/LedgerEvent.hs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import Cardano.Prelude hiding (All)
3535

3636
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
3737
import Cardano.DbSync.Types
38+
import Cardano.DbSync.Util
3839

3940
import Cardano.Slotting.Slot (EpochNo (..))
4041

cardano-db-sync/src/Cardano/DbSync/Util.hs

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Cardano.DbSync.Util
2121
, renderByteArray
2222
, renderPoint
2323
, renderSlotList
24+
, rewardTypeToSource
2425
, textPrettyShow
2526
, textShow
2627
, thrd3
@@ -35,9 +36,11 @@ import Cardano.Prelude hiding (catch)
3536

3637
import Cardano.BM.Trace (Trace, logError, logInfo)
3738

38-
import Cardano.Db (textShow)
39+
import Cardano.Db (RewardSource (..), textShow)
3940

4041
import Cardano.Ledger.Coin (Coin (..))
42+
import qualified Cardano.Ledger.Shelley.Rewards as Shelley
43+
4144

4245
import Cardano.DbSync.Config.Types ()
4346
import Cardano.DbSync.Types
@@ -183,6 +186,12 @@ renderSlotList xs
183186
| otherwise =
184187
mconcat [ "[", textShow (unSlotNo $ List.head xs), "..", textShow (unSlotNo $ List.last xs), "]" ]
185188

189+
rewardTypeToSource :: Shelley.RewardType -> RewardSource
190+
rewardTypeToSource rt =
191+
case rt of
192+
Shelley.LeaderReward -> RwdLeader
193+
Shelley.MemberReward -> RwdMember
194+
186195
maybeFromStrict :: Strict.Maybe a -> Maybe a
187196
maybeFromStrict Strict.Nothing = Nothing
188197
maybeFromStrict (Strict.Just a) = Just a

cardano-db/cardano-db.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ library
5757
, bytestring
5858
, cardano-crypto-class
5959
, cardano-ledger-core
60-
, cardano-ledger-shelley
6160
, cardano-slotting
6261
, containers
6362
, conduit

cardano-db/src/Cardano/Db/Types.hs

-8
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ module Cardano.Db.Types
3434
, renderScriptPurpose
3535
, renderScriptType
3636
, renderSyncState
37-
, rewardTypeToSource
3837
, showRewardSource
3938
, word64ToAda
4039
) where
4140

4241
import Cardano.Ledger.Coin (DeltaCoin (..))
43-
import Cardano.Ledger.Shelley.Rewards as Shelley
4442

4543
import qualified Codec.Binary.Bech32 as Bech32
4644

@@ -231,12 +229,6 @@ renderSyncState ss =
231229
SyncFollowing -> "following"
232230
SyncLagging -> "lagging"
233231

234-
rewardTypeToSource :: Shelley.RewardType -> RewardSource
235-
rewardTypeToSource rt =
236-
case rt of
237-
Shelley.LeaderReward -> RwdLeader
238-
Shelley.MemberReward -> RwdMember
239-
240232
renderScriptPurpose :: ScriptPurpose -> Text
241233
renderScriptPurpose ss =
242234
case ss of

0 commit comments

Comments
 (0)