Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caseByronToBabbageOrConwayEraOnwards #542

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cardano-api/internal/Cardano/Api/Eras/Case.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Cardano.Api.Eras.Case
( -- Case on CardanoEra
caseByronOrShelleyBasedEra
, caseByronToAlonzoOrBabbageEraOnwards
, caseByronToBabbageOrConwayEraOnwards

-- Case on ShelleyBasedEra
, caseShelleyEraOnlyOrAllegraEraOnwards
Expand Down Expand Up @@ -54,6 +55,21 @@ caseByronOrShelleyBasedEra l r = \case
BabbageEra -> r ShelleyBasedEraBabbage
ConwayEra -> r ShelleyBasedEraConway

-- | @caseByronToBabbageOrConwayEraOnwards f g era@ returns @f@ in Byron to Babbage and applies @g@ to Conway-based eras.
caseByronToBabbageOrConwayEraOnwards :: ()
=> a
-> (ConwayEraOnwardsConstraints era => ConwayEraOnwards era -> a)
-> CardanoEra era
-> a
caseByronToBabbageOrConwayEraOnwards l r = \case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi that's redundant - you can achieve the same with inEonForEra, plus you'd have to conjure the constraints conwayEraOnwardsConstraints

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, so closing 👍

ByronEra -> l
ShelleyEra -> l
AllegraEra -> l
MaryEra -> l
AlonzoEra -> l
BabbageEra -> l
ConwayEra -> r ConwayEraOnwardsConway

-- | @caseByronToAlonzoOrBabbageEraOnwards f g era@ applies @f@ to byron, shelley, allegra, mary, and alonzo;
-- and @g@ to babbage and later eras.
caseByronToAlonzoOrBabbageEraOnwards :: ()
Expand Down
2 changes: 2 additions & 0 deletions cardano-api/internal/Cardano/Api/Tx/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,8 @@ deriving instance Show (TxProposalProcedures build era)
-- Transaction body content
--

-- If you extend this type, consider updating the @friendly*@ family of functions
-- in cardano-cli.
data TxBodyContent build era =
TxBodyContent {
txIns :: TxIns build era,
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ module Cardano.Api (
-- ** Case on CardanoEra
caseByronOrShelleyBasedEra,
caseByronToAlonzoOrBabbageEraOnwards,
caseByronToBabbageOrConwayEraOnwards,

-- ** Case on ShelleyBasedEra
caseShelleyEraOnlyOrAllegraEraOnwards,
Expand Down
Loading