diff --git a/cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Alonzo.hs b/cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Alonzo.hs index 546bfc142..0c8125d61 100644 --- a/cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Alonzo.hs +++ b/cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Alonzo.hs @@ -10,7 +10,7 @@ module Cardano.Mock.Forging.Tx.Alonzo where -import Cardano.Prelude hiding (sum, (.)) +import Cardano.Prelude hiding (head, sum, (.)) import qualified Data.Map.Strict as Map import Data.Maybe (fromJust) @@ -39,7 +39,7 @@ import Cardano.Ledger.Hashes import Cardano.Ledger.Keys import Cardano.Ledger.Mary.Value import Cardano.Ledger.Shelley.Metadata -import Cardano.Ledger.Shelley.PParams hiding (emptyPParamsUpdate, _protocolVersion) +import Cardano.Ledger.Shelley.PParams hiding (_protocolVersion, emptyPParamsUpdate) import Cardano.Ledger.Shelley.TxBody (DCert (..), PoolCert (..), PoolMetadata (..), PoolParams (..), StakePoolRelay (..), Wdrl (..)) import Cardano.Ledger.ShelleyMA.Timelocks @@ -86,7 +86,7 @@ mkHFTx = mkSimpleTx True $ TxBody a b c d e f n (Strict.SJust upd) i j k l m where TxBody a b c d e f n _ i j k l m = emptyTxBody - upd = Update (ProposedPPUpdates $ Map.singleton (unregisteredGenesisKeys !! 0) pparams) (EpochNo 1) + upd = Update (ProposedPPUpdates $ Map.singleton (head unregisteredGenesisKeys) pparams) (EpochNo 1) pparams = emptyPParamsUpdate {_protocolVersion = Strict.SJust $ ProtVer 7 0} addValidityInterval :: SlotNo diff --git a/cardano-db-sync/src/Cardano/DbSync/Cache.hs b/cardano-db-sync/src/Cardano/DbSync/Cache.hs index 5b554d17c..6d7b41d84 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Cache.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Cache.hs @@ -340,7 +340,8 @@ queryMAWithCache cache policyId asset = case cache of UninitiatedCache -> do let !bs = Generic.unScriptHash $ policyID policyId - fmap (maybe (Left bs) Right) $ DB.queryMultiAssetId bs (unAssetName asset) + maybe (Left bs) Right + <$> DB.queryMultiAssetId bs (unAssetName asset) Cache ci -> do mp <- liftIO $ readTVarIO (cMultiAssets ci) case LRU.lookup (policyId, asset) mp of @@ -352,7 +353,8 @@ queryMAWithCache cache policyId asset = liftIO $ missMAssets (cStats ci) -- miss. The lookup doesn't change the cache on a miss. let !bs = Generic.unScriptHash $ policyID policyId - maId <- fmap (maybe (Left bs) Right) $ DB.queryMultiAssetId bs (unAssetName asset) + maId <- maybe (Left bs) Right + <$> DB.queryMultiAssetId bs (unAssetName asset) whenRight maId $ liftIO . atomically . modifyTVar (cMultiAssets ci) . LRU.insert (policyId, asset) pure maId diff --git a/cardano-db-sync/src/Cardano/DbSync/Default.hs b/cardano-db-sync/src/Cardano/DbSync/Default.hs index edebc7028..9629f197a 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Default.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Default.hs @@ -26,7 +26,8 @@ import Cardano.DbSync.Era.Shelley.Insert (insertShelleyBlock) import Cardano.DbSync.Era.Shelley.Insert.Epoch (insertPoolDepositRefunds, insertRewards) import Cardano.DbSync.Era.Shelley.Validate (validateEpochRewards) import Cardano.DbSync.Error -import Cardano.DbSync.LedgerState (LedgerEvent (..), ApplyResult (..), applyBlockAndSnapshot) +import Cardano.DbSync.LedgerState (ApplyResult (..), LedgerEvent (..), + applyBlockAndSnapshot) import Cardano.DbSync.Rollback (rollbackToPoint) import Cardano.DbSync.Types import Cardano.DbSync.Util @@ -43,8 +44,8 @@ import qualified Data.Map.Strict as Map import qualified Data.Set as Set import qualified Data.Strict.Maybe as Strict -import Database.Persist.SqlBackend.Internal.StatementCache import Database.Persist.SqlBackend.Internal +import Database.Persist.SqlBackend.Internal.StatementCache import Ouroboros.Consensus.Cardano.Block (HardForkBlock (..)) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Rewards.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Rewards.hs index 13e1cdae9..66b2c8281 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Rewards.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Rewards.hs @@ -34,7 +34,7 @@ data Reward = Reward -- Shelley/Allegra/Mary. This is a huge pain in the neck for `db-sync` so we define a -- generic one instead. newtype Rewards = Rewards - { rwdRewards :: (Map StakeCred (Set Reward)) + { rwdRewards :: Map StakeCred (Set Reward) } deriving (Eq, Show) elemCount :: Rewards -> Int diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/StakeDist.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/StakeDist.hs index 45a53a426..604c53a0c 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/StakeDist.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/StakeDist.hs @@ -26,10 +26,10 @@ import qualified Cardano.Ledger.Shelley.LedgerState as Shelley import Cardano.DbSync.Types -import Data.VMap (VB, VMap (..), VP) -import qualified Data.VMap as VMap import qualified Data.Map.Strict as Map import qualified Data.Vector.Generic as VG +import Data.VMap (VB, VMap (..), VP) +import qualified Data.VMap as VMap import Ouroboros.Consensus.Block import Ouroboros.Consensus.Cardano.Block (LedgerState (..), StandardCrypto) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs index 28590d5ae..bd8886f58 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs @@ -265,7 +265,7 @@ insertStaking tracer cache blkId genesis = do } let params = zip [0..] $ Map.elems (sgsPools $ sgStaking genesis) let network = sgNetworkId genesis - forM_ params $ uncurry (insertPoolRegister tracer uninitiatedCache (\_ -> False) network 0 blkId txId) + forM_ params $ uncurry (insertPoolRegister tracer uninitiatedCache (const False) network 0 blkId txId) let stakes = zip [0..] $ Map.toList (sgsStake $ sgStaking genesis) forM_ stakes $ \(n, (keyStaking, keyPool)) -> do insertStakeRegistration (EpochNo 0) txId (2 * n) (Generic.annotateStakingCred network (KeyHashObj keyStaking)) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs index 438852ef6..5d6212178 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs @@ -6,9 +6,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} module Cardano.DbSync.Era.Shelley.Insert ( insertShelleyBlock @@ -49,8 +47,8 @@ import qualified Cardano.Ledger.BaseTypes as Ledger import Cardano.Ledger.Coin (Coin (..)) import qualified Cardano.Ledger.Coin as Ledger import qualified Cardano.Ledger.Credential as Ledger -import qualified Cardano.Ledger.Keys as Ledger import Cardano.Ledger.Keys +import qualified Cardano.Ledger.Keys as Ledger import Cardano.Ledger.Mary.Value (AssetName (..), PolicyID (..), Value (..)) import qualified Cardano.Ledger.Shelley.API.Wallet as Shelley import qualified Cardano.Ledger.Shelley.TxBody as Shelley @@ -944,7 +942,7 @@ insertMultiAsset cache policy a@(AssetName aName) = do mId <- queryMAWithCache cache policy a case mId of Right maId -> pure maId - Left (policyBs) -> DB.insertMultiAssetUnchecked $ + Left policyBs -> DB.insertMultiAssetUnchecked $ DB.MultiAsset { DB.multiAssetPolicy = policyBs , DB.multiAssetName = aName diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs index d0a0ec4a8..65f7044e7 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs @@ -22,8 +22,8 @@ import Cardano.DbSync.Util (textShow) import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Crypto (StandardCrypto) -import qualified Cardano.Ledger.Shelley.Rewards as Ledger import Cardano.Ledger.Shelley.API (Network) +import qualified Cardano.Ledger.Shelley.Rewards as Ledger import Cardano.Slotting.Slot (EpochNo (..)) @@ -35,14 +35,14 @@ import qualified Data.Map.Strict as Map import qualified Data.Set as Set import Database.Esqueleto.Experimental (InnerJoin (InnerJoin), SqlBackend, Value (Value), - desc, from, not_, on, orderBy, select, table, val, where_, (:&) ((:&)), - (==.), (^.)) + desc, from, not_, on, orderBy, select, table, val, where_, (:&) ((:&)), (==.), + (^.)) {- HLINT ignore "Fuse on/on" -} validateEpochRewards :: (MonadBaseControl IO m, MonadIO m) - => Trace IO Text -> Network -> EpochNo -> EpochNo -> (Map StakeCred (Set (Ledger.Reward StandardCrypto))) + => Trace IO Text -> Network -> EpochNo -> EpochNo -> Map StakeCred (Set (Ledger.Reward StandardCrypto)) -> ReaderT SqlBackend m () validateEpochRewards tracer network _earnedEpochNo spendableEpochNo rmap = do actualCount <- Db.queryNormalEpochRewardCount (unEpochNo spendableEpochNo) diff --git a/cardano-db-tool/src/Cardano/DbTool/Validate/Ledger.hs b/cardano-db-tool/src/Cardano/DbTool/Validate/Ledger.hs index 4cc096960..38507a722 100644 --- a/cardano-db-tool/src/Cardano/DbTool/Validate/Ledger.hs +++ b/cardano-db-tool/src/Cardano/DbTool/Validate/Ledger.hs @@ -5,9 +5,9 @@ module Cardano.DbTool.Validate.Ledger import Control.Monad (when) import Control.Monad.Trans.Except.Exit (orDie) +import Control.Tracer (nullTracer) import Data.Text (Text) import qualified Data.Text as Text -import Control.Tracer (nullTracer) import Prelude import qualified Cardano.Db as DB diff --git a/cardano-db/src/Cardano/Db/Query.hs b/cardano-db/src/Cardano/Db/Query.hs index d916de178..402d5ec1b 100644 --- a/cardano-db/src/Cardano/Db/Query.hs +++ b/cardano-db/src/Cardano/Db/Query.hs @@ -125,8 +125,8 @@ import Database.Esqueleto.Experimental (Entity, From, PersistEntity, P SqlBackend, SqlExpr, SqlQuery, Value (Value, unValue), ValueList, count, countRows, desc, entityKey, entityVal, exists, from, in_, innerJoin, isNothing, just, leftJoin, limit, max_, min_, notExists, not_, on, orderBy, select, - subList_select, sum_, table, type (:&) ((:&)), unSqlBackendKey, val, valList, where_, - (&&.), (<=.), (==.), (>.), (>=.), (?.), (^.), (||.)) + subList_select, sum_, table, type (:&) ((:&)), unSqlBackendKey, val, valList, + where_, (&&.), (<=.), (==.), (>.), (>=.), (?.), (^.), (||.)) import Database.Esqueleto.Experimental.From (ToFrom (..)) import Database.Persist.Class.PersistQuery (selectList) @@ -447,7 +447,7 @@ queryNormalEpochRewardCount epochNum = do res <- select $ do rwd <- from $ table @Reward where_ (rwd ^. RewardSpendableEpoch ==. val epochNum) - where_ (rwd ^. RewardType `in_` (valList [RwdMember, RwdLeader])) + where_ (rwd ^. RewardType `in_` valList [RwdMember, RwdLeader]) pure countRows pure $ maybe 0 unValue (listToMaybe res)