Skip to content

Commit

Permalink
Fix Cardano.Api.Query type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Jul 7, 2023
1 parent 367dc9c commit e54c15f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions cardano-api/internal/Cardano/Api/Query.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
Expand Down Expand Up @@ -94,12 +95,11 @@ import Cardano.Api.Value

import qualified Cardano.Chain.Update.Validation.Interface as Byron.Update
import Cardano.Ledger.Binary
import Cardano.Ledger.SafeHash (SafeHash)
import Data.ByteString (ByteString)
import Cardano.Ledger.Core (EraCrypto)
import qualified Cardano.Ledger.Binary.Plain as Plain
import Cardano.Ledger.Core (EraCrypto)
import qualified Cardano.Ledger.Credential as Shelley
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.SafeHash (SafeHash)
import qualified Cardano.Ledger.Shelley.API as Shelley
import qualified Cardano.Ledger.Shelley.Core as Core
import qualified Cardano.Ledger.Shelley.LedgerState as Shelley
Expand Down Expand Up @@ -131,6 +131,7 @@ import qualified Data.Aeson as Aeson
import qualified Data.Aeson.KeyMap as KeyMap
import Data.Aeson.Types (Parser)
import Data.Bifunctor (bimap, first)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as LBS
import Data.Either.Combinators (rightToMaybe)
import qualified Data.HashMap.Strict as HMS
Expand Down Expand Up @@ -729,11 +730,19 @@ consensusQueryInEraInMode erainmode =
-- Conversions of query results from the consensus types.
--

fromConsensusQueryResult :: forall mode block result result'. ConsensusBlockForMode mode ~ block
=> QueryInMode mode result
-> Consensus.Query block result'
-> result'
-> result
fromConsensusQueryResult :: forall mode block result result'.
( ConsensusBlockForMode mode ~ block
, EraCrypto ConwayEra ~ StandardCrypto
, EraCrypto BabbageEra ~ StandardCrypto
, EraCrypto AlonzoEra ~ StandardCrypto
, EraCrypto MaryEra ~ StandardCrypto
, EraCrypto AllegraEra ~ StandardCrypto
, EraCrypto ShelleyEra ~ StandardCrypto
)
=> QueryInMode mode result
-> Consensus.Query block result'
-> result'
-> result
fromConsensusQueryResult (QueryEraHistory CardanoModeIsMultiEra) q' r' =
case q' of
Consensus.BlockQuery (Consensus.QueryHardFork Consensus.GetInterpreter)
Expand Down Expand Up @@ -789,7 +798,7 @@ fromConsensusQueryResult (QueryInEra ShelleyEraInShelleyMode
case (q', r') of
(Consensus.BlockQuery (Consensus.DegenQuery q''),
Consensus.DegenQueryResult r'')
-> Right (fromConsensusQueryResultShelleyBased
-> Right (fromConsensusQueryResultShelleyBased
ShelleyBasedEraShelley q q'' r'')
_ -> fromConsensusQueryResultMismatch

Expand Down Expand Up @@ -860,6 +869,7 @@ fromConsensusQueryResult (QueryInEra ConwayEraInCardanoMode
fromConsensusQueryResultShelleyBased
:: forall era ledgerera protocol result result'.
ShelleyLedgerEra era ~ ledgerera
=> Core.EraCrypto era ~ Consensus.StandardCrypto
=> Core.EraCrypto ledgerera ~ Consensus.StandardCrypto
=> ConsensusProtocol era ~ protocol
=> ShelleyBasedEra era
Expand Down

0 comments on commit e54c15f

Please sign in to comment.