Skip to content

Commit

Permalink
New caseAlonzoOnlyOrBabbageEraOnwards and alonzoEraOnlyToAlonzoEraOnw…
Browse files Browse the repository at this point in the history
…ards functions
  • Loading branch information
newhoggy committed Sep 29, 2023
1 parent 9f54d2a commit c46dc3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cardano-api/internal/Cardano/Api/Eras/Case.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ module Cardano.Api.Eras.Case
, caseShelleyToAlonzoOrBabbageEraOnwards
, caseShelleyToBabbageOrConwayEraOnwards

-- Case on AlonzoEraOnwards
, caseAlonzoOnlyOrBabbageEraOnwards

-- Proofs
, noByronEraInShelleyBasedEra

-- Conversions
, shelleyToAllegraEraToByronToAllegraEra
, alonzoEraOnlyToAlonzoEraOnwards
, alonzoEraOnwardsToMaryEraOnwards
) where

import Cardano.Api.Eon.AlonzoEraOnly
import Cardano.Api.Eon.AlonzoEraOnwards
import Cardano.Api.Eon.BabbageEraOnwards
import Cardano.Api.Eon.ByronAndAllegraEraOnwards
Expand Down Expand Up @@ -166,6 +172,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 {}

Expand All @@ -181,3 +197,9 @@ alonzoEraOnwardsToMaryEraOnwards = \case
AlonzoEraOnwardsAlonzo -> MaryEraOnwardsAlonzo
AlonzoEraOnwardsBabbage -> MaryEraOnwardsBabbage
AlonzoEraOnwardsConway -> MaryEraOnwardsConway

alonzoEraOnlyToAlonzoEraOnwards :: ()
=> AlonzoEraOnly era
-> AlonzoEraOnwards era
alonzoEraOnlyToAlonzoEraOnwards = \case
AlonzoEraOnlyAlonzo -> AlonzoEraOnwardsAlonzo
4 changes: 4 additions & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ module Cardano.Api (
caseShelleyToMaryOrAlonzoEraOnwards,
caseShelleyToAlonzoOrBabbageEraOnwards,
caseShelleyToBabbageOrConwayEraOnwards,
caseAlonzoOnlyOrBabbageEraOnwards,

-- ** Eon relaxation
shelleyToAllegraEraToByronToAllegraEra,
alonzoEraOnlyToAlonzoEraOnwards,

-- Case on AlonzoEraOnwards
alonzoEraOnwardsToMaryEraOnwards,

-- * Assertions on era
Expand Down

0 comments on commit c46dc3b

Please sign in to comment.