From dc441dbb79f6998e2e7b3854eabafc1fed332bf3 Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 20 Oct 2023 01:42:01 +1100 Subject: [PATCH 1/2] Delete AlonzoEraOnly --- cardano-api/cardano-api.cabal | 1 - .../internal/Cardano/Api/Eon/AlonzoEraOnly.hs | 106 ------------------ cardano-api/internal/Cardano/Api/Eras/Case.hs | 29 ----- cardano-api/src/Cardano/Api.hs | 10 -- 4 files changed, 146 deletions(-) delete mode 100644 cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 2466004bef..4bc66fdc33 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -56,7 +56,6 @@ library internal Cardano.Api.DeserialiseAnyOf Cardano.Api.DRepMetadata Cardano.Api.Eon.AllegraEraOnwards - Cardano.Api.Eon.AlonzoEraOnly Cardano.Api.Eon.AlonzoEraOnwards Cardano.Api.Eon.BabbageEraOnly Cardano.Api.Eon.BabbageEraOnwards diff --git a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs b/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs deleted file mode 100644 index f62890c947..0000000000 --- a/cardano-api/internal/Cardano/Api/Eon/AlonzoEraOnly.hs +++ /dev/null @@ -1,106 +0,0 @@ -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} - -module Cardano.Api.Eon.AlonzoEraOnly - ( AlonzoEraOnly(..) - , alonzoEraOnlyConstraints - , alonzoEraOnlyToCardanoEra - , alonzoEraOnlyToShelleyBasedEra - - , AlonzoEraOnlyConstraints - ) where - -import Cardano.Api.Eon.ShelleyBasedEra -import Cardano.Api.Eras.Core -import Cardano.Api.Modes -import Cardano.Api.Query.Types - -import Cardano.Binary -import qualified Cardano.Crypto.Hash.Blake2b as Blake2b -import qualified Cardano.Crypto.Hash.Class as C -import qualified Cardano.Crypto.VRF as C -import qualified Cardano.Ledger.Api as L -import qualified Cardano.Ledger.BaseTypes as L -import qualified Cardano.Ledger.Core as L -import qualified Cardano.Ledger.Mary.Value as L -import qualified Cardano.Ledger.SafeHash as L -import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus -import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus -import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus - -import Data.Aeson -import Data.Typeable (Typeable) - -data AlonzoEraOnly era where - AlonzoEraOnlyAlonzo :: AlonzoEraOnly AlonzoEra - -deriving instance Show (AlonzoEraOnly era) -deriving instance Eq (AlonzoEraOnly era) - -instance Eon AlonzoEraOnly where - inEonForEra no yes = \case - ByronEra -> no - ShelleyEra -> no - AllegraEra -> no - MaryEra -> no - AlonzoEra -> yes AlonzoEraOnlyAlonzo - BabbageEra -> no - ConwayEra -> no - -instance ToCardanoEra AlonzoEraOnly where - toCardanoEra = \case - AlonzoEraOnlyAlonzo -> AlonzoEra - -type AlonzoEraOnlyConstraints era = - ( C.HashAlgorithm (L.HASH (L.EraCrypto (ShelleyLedgerEra era))) - , C.Signable (L.VRF (L.EraCrypto (ShelleyLedgerEra era))) L.Seed - , Consensus.PraosProtocolSupportsNode (ConsensusProtocol era) - , Consensus.ShelleyCompatible (ConsensusProtocol era) (ShelleyLedgerEra era) - , L.ADDRHASH (Consensus.PraosProtocolSupportsNodeCrypto (ConsensusProtocol era)) ~ Blake2b.Blake2b_224 - , L.AlonzoEraPParams (ShelleyLedgerEra era) - , L.AlonzoEraTx (ShelleyLedgerEra era) - , L.AlonzoEraTxBody (ShelleyLedgerEra era) - , L.AlonzoEraTxOut (ShelleyLedgerEra era) - , L.AlonzoEraTxWits (ShelleyLedgerEra era) - , L.Crypto (L.EraCrypto (ShelleyLedgerEra era)) - , L.Era (ShelleyLedgerEra era) - , L.EraCrypto (ShelleyLedgerEra era) ~ L.StandardCrypto - , L.EraPParams (ShelleyLedgerEra era) - , L.EraTx (ShelleyLedgerEra era) - , L.EraTxBody (ShelleyLedgerEra era) - , L.ExactEra L.AlonzoEra (ShelleyLedgerEra era) - , L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody L.StandardCrypto - , L.ProtVerAtMost (ShelleyLedgerEra era) 6 - , L.ProtVerAtMost (ShelleyLedgerEra era) 8 - , L.ShelleyEraTxBody (ShelleyLedgerEra era) - , L.ShelleyEraTxCert (ShelleyLedgerEra era) - , L.Value (ShelleyLedgerEra era) ~ L.MaryValue L.StandardCrypto - - , FromCBOR (Consensus.ChainDepState (ConsensusProtocol era)) - , FromCBOR (DebugLedgerState era) - , IsCardanoEra era - , IsShelleyBasedEra era - , ToJSON (DebugLedgerState era) - , Typeable era - ) - -alonzoEraOnlyConstraints :: () - => AlonzoEraOnly era - -> (AlonzoEraOnlyConstraints era => a) - -> a -alonzoEraOnlyConstraints = \case - AlonzoEraOnlyAlonzo -> id - -alonzoEraOnlyToCardanoEra :: AlonzoEraOnly era -> CardanoEra era -alonzoEraOnlyToCardanoEra = shelleyBasedToCardanoEra . alonzoEraOnlyToShelleyBasedEra - -alonzoEraOnlyToShelleyBasedEra :: AlonzoEraOnly era -> ShelleyBasedEra era -alonzoEraOnlyToShelleyBasedEra = \case - AlonzoEraOnlyAlonzo -> ShelleyBasedEraAlonzo diff --git a/cardano-api/internal/Cardano/Api/Eras/Case.hs b/cardano-api/internal/Cardano/Api/Eras/Case.hs index 6b3b631fea..1b0de807fe 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Case.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Case.hs @@ -22,25 +22,19 @@ module Cardano.Api.Eras.Case -- Case on MaryEraOnwards , caseMaryEraOnlyOrAlonzoEraOnwards - -- Case on AlonzoEraOnwards - , caseAlonzoOnlyOrBabbageEraOnwards - -- Proofs , noByronEraInShelleyBasedEra - , disjointAlonzoEraOnlyAndBabbageEraOnwards , disjointByronEraOnlyAndShelleyBasedEra -- Conversions , shelleyToAllegraEraToByronToAllegraEra , shelleyToAlonzoEraToShelleyToBabbageEra - , alonzoEraOnlyToAlonzoEraOnwards , alonzoEraOnwardsToMaryEraOnwards , babbageEraOnwardsToMaryEraOnwards , babbageEraOnwardsToAlonzoEraOnwards ) where import Cardano.Api.Eon.AllegraEraOnwards -import Cardano.Api.Eon.AlonzoEraOnly import Cardano.Api.Eon.AlonzoEraOnwards import Cardano.Api.Eon.BabbageEraOnwards import Cardano.Api.Eon.ByronAndAllegraEraOnwards @@ -226,18 +220,6 @@ caseMaryEraOnlyOrAlonzoEraOnwards l r = \case MaryEraOnwardsBabbage -> r AlonzoEraOnwardsBabbage MaryEraOnwardsConway -> r AlonzoEraOnwardsConway --- | @caseAlonzoOnlyOrBabbageEraOnwards f g era@ applies @f@ to alonzo; --- and applies @g@ to babbage and later eras. -caseAlonzoOnlyOrBabbageEraOnwards :: () - => (AlonzoEraOnly era -> a) - -> (BabbageEraOnwards era -> a) - -> AlonzoEraOnwards era - -> a -caseAlonzoOnlyOrBabbageEraOnwards l r = \case - AlonzoEraOnwardsAlonzo -> l AlonzoEraOnlyAlonzo - AlonzoEraOnwardsBabbage -> r BabbageEraOnwardsBabbage - AlonzoEraOnwardsConway -> r BabbageEraOnwardsConway - {-# DEPRECATED noByronEraInShelleyBasedEra "Use disjointByronEraOnlyAndShelleyBasedEra instead" #-} noByronEraInShelleyBasedEra :: ShelleyBasedEra era -> ByronEraOnly era -> a noByronEraInShelleyBasedEra = flip disjointByronEraOnlyAndShelleyBasedEra @@ -245,11 +227,6 @@ noByronEraInShelleyBasedEra = flip disjointByronEraOnlyAndShelleyBasedEra disjointByronEraOnlyAndShelleyBasedEra :: ByronEraOnly era -> ShelleyBasedEra era -> a disjointByronEraOnlyAndShelleyBasedEra ByronEraOnlyByron sbe = case sbe of {} -disjointAlonzoEraOnlyAndBabbageEraOnwards :: AlonzoEraOnly era -> BabbageEraOnwards era -> a -disjointAlonzoEraOnlyAndBabbageEraOnwards eonL eonR = - case eonL of - AlonzoEraOnlyAlonzo -> case eonR of {} - shelleyToAllegraEraToByronToAllegraEra :: ShelleyToAllegraEra era -> ByronToAllegraEra era shelleyToAllegraEraToByronToAllegraEra = \case ShelleyToAllegraEraShelley -> ByronToAllegraEraShelley @@ -272,12 +249,6 @@ alonzoEraOnwardsToMaryEraOnwards = \case AlonzoEraOnwardsBabbage -> MaryEraOnwardsBabbage AlonzoEraOnwardsConway -> MaryEraOnwardsConway -alonzoEraOnlyToAlonzoEraOnwards :: () - => AlonzoEraOnly era - -> AlonzoEraOnwards era -alonzoEraOnlyToAlonzoEraOnwards = \case - AlonzoEraOnlyAlonzo -> AlonzoEraOnwardsAlonzo - babbageEraOnwardsToMaryEraOnwards :: () => BabbageEraOnwards era -> MaryEraOnwards era diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index cbfd138bec..0c033500d8 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -125,11 +125,6 @@ module Cardano.Api ( -- ** From Alonzo - AlonzoEraOnly(..), - alonzoEraOnlyConstraints, - alonzoEraOnlyToCardanoEra, - alonzoEraOnlyToShelleyBasedEra, - AlonzoEraOnwards(..), alonzoEraOnwardsConstraints, alonzoEraOnwardsToCardanoEra, @@ -163,7 +158,6 @@ module Cardano.Api ( caseShelleyToMaryOrAlonzoEraOnwards, caseShelleyToAlonzoOrBabbageEraOnwards, caseShelleyToBabbageOrConwayEraOnwards, - caseAlonzoOnlyOrBabbageEraOnwards, -- ** Eon relaxation @@ -171,9 +165,6 @@ module Cardano.Api ( shelleyToAllegraEraToByronToAllegraEra, shelleyToAlonzoEraToShelleyToBabbageEra, - -- *** for AlonzoEraOnly - alonzoEraOnlyToAlonzoEraOnwards, - -- *** for AlonzoEraOnwards alonzoEraOnwardsToMaryEraOnwards, @@ -1028,7 +1019,6 @@ import Cardano.Api.Convenience.Construction import Cardano.Api.Convenience.Query import Cardano.Api.DeserialiseAnyOf import Cardano.Api.DRepMetadata -import Cardano.Api.Eon.AlonzoEraOnly import Cardano.Api.Eon.AlonzoEraOnwards import Cardano.Api.Eon.BabbageEraOnwards import Cardano.Api.Eon.ByronAndAllegraEraOnwards From 9281f5ed808ca4841373da8adf55250072a8614c Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 20 Oct 2023 02:33:31 +1100 Subject: [PATCH 2/2] Export caseMaryEraOnlyOrAlonzoEraOnwards. --- cardano-api/src/Cardano/Api.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 0c033500d8..c65082f8ee 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -159,6 +159,9 @@ module Cardano.Api ( caseShelleyToAlonzoOrBabbageEraOnwards, caseShelleyToBabbageOrConwayEraOnwards, + -- Case on MaryEraOnwards + caseMaryEraOnlyOrAlonzoEraOnwards, + -- ** Eon relaxation -- *** for AlonzoEraOnly