From c58df97919d1d8856408142401873fc0563b7b4c Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 29 Sep 2023 10:39:21 +1000 Subject: [PATCH] New caseAlonzoOnlyOrBabbageEraOnwards and alonzoEraOnlyToAlonzoEraOnwards functions --- cardano-api/internal/Cardano/Api/Eras/Case.hs | 22 +++++++++++++++++++ cardano-api/src/Cardano/Api.hs | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/cardano-api/internal/Cardano/Api/Eras/Case.hs b/cardano-api/internal/Cardano/Api/Eras/Case.hs index 31fe6eb19e..e42bb4bf6f 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Case.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Case.hs @@ -19,14 +19,20 @@ module Cardano.Api.Eras.Case , caseShelleyToAlonzoOrBabbageEraOnwards , caseShelleyToBabbageOrConwayEraOnwards + -- Case on AlonzoEraOnwards + , caseAlonzoOnlyOrBabbageEraOnwards + + -- Proofs , noByronEraInShelleyBasedEra -- Conversions , shelleyToAllegraEraToByronToAllegraEra + , alonzoEraOnlyToAlonzoEraOnwards , alonzoEraOnwardsToMaryEraOnwards ) 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 @@ -180,6 +186,16 @@ caseShelleyToBabbageOrConwayEraOnwards l r = \case ShelleyBasedEraBabbage -> l ShelleyToBabbageEraBabbage ShelleyBasedEraConway -> r ConwayEraOnwardsConway +caseAlonzoOnlyOrBabbageEraOnwards :: () + => (AlonzoEraOnly era -> a) + -> (BabbageEraOnwards era -> a) + -> AlonzoEraOnwards era + -> a +caseAlonzoOnlyOrBabbageEraOnwards l r = \case + AlonzoEraOnwardsAlonzo -> l AlonzoEraOnlyAlonzo + AlonzoEraOnwardsBabbage -> r BabbageEraOnwardsBabbage + AlonzoEraOnwardsConway -> r BabbageEraOnwardsConway + noByronEraInShelleyBasedEra :: ShelleyBasedEra era -> ByronEraOnly era -> a noByronEraInShelleyBasedEra sbe ByronEraOnlyByron = case sbe of {} @@ -195,3 +211,9 @@ alonzoEraOnwardsToMaryEraOnwards = \case AlonzoEraOnwardsAlonzo -> MaryEraOnwardsAlonzo AlonzoEraOnwardsBabbage -> MaryEraOnwardsBabbage AlonzoEraOnwardsConway -> MaryEraOnwardsConway + +alonzoEraOnlyToAlonzoEraOnwards :: () + => AlonzoEraOnly era + -> AlonzoEraOnwards era +alonzoEraOnlyToAlonzoEraOnwards = \case + AlonzoEraOnlyAlonzo -> AlonzoEraOnwardsAlonzo diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 2c382bd9cd..9045460afc 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -155,9 +155,13 @@ module Cardano.Api ( caseShelleyToMaryOrAlonzoEraOnwards, caseShelleyToAlonzoOrBabbageEraOnwards, caseShelleyToBabbageOrConwayEraOnwards, + caseAlonzoOnlyOrBabbageEraOnwards, -- ** Eon relaxation shelleyToAllegraEraToByronToAllegraEra, + alonzoEraOnlyToAlonzoEraOnwards, + + -- Case on AlonzoEraOnwards alonzoEraOnwardsToMaryEraOnwards, -- * Assertions on era