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

Rename FeatureInEra to Eon #247

Merged
merged 7 commits into from
Sep 20, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-08-22"
CABAL_CACHE_VERSION: "2023-09-21"

concurrency:
group: >
Expand Down
16 changes: 8 additions & 8 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ library internal
Cardano.Api.Convenience.Query
Cardano.Api.DeserialiseAnyOf
Cardano.Api.DRepMetadata
Cardano.Api.Eon.AlonzoEraOnly
Cardano.Api.Eon.AlonzoEraOnwards
Cardano.Api.Eon.BabbageEraOnwards
Cardano.Api.Eon.ConwayEraOnwards
Cardano.Api.Eon.ShelleyToAllegraEra
Cardano.Api.Eon.ShelleyToAlonzoEra
Cardano.Api.Eon.ShelleyToBabbageEra
Cardano.Api.Eon.ShelleyToMaryEra
Cardano.Api.EraCast
Cardano.Api.Eras
Cardano.Api.Eras.Case
Cardano.Api.Eras.Constraints
Cardano.Api.Eras.Core
Cardano.Api.Error
Cardano.Api.Feature
Cardano.Api.Feature.AlonzoEraOnly
Cardano.Api.Feature.AlonzoEraOnwards
Cardano.Api.Feature.BabbageEraOnwards
Cardano.Api.Feature.ConwayEraOnwards
Cardano.Api.Feature.ShelleyToAllegraEra
Cardano.Api.Feature.ShelleyToAlonzoEra
Cardano.Api.Feature.ShelleyToBabbageEra
Cardano.Api.Feature.ShelleyToMaryEra
Cardano.Api.Fees
Cardano.Api.Genesis
Cardano.Api.GenesisParameters
Expand Down
20 changes: 10 additions & 10 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -735,21 +735,21 @@ genTxBody era = do
-- | Generate a 'Featured' for the given 'CardanoEra' with the provided generator.
genFeaturedInEra :: ()
=> Alternative f
=> feature era
=> eon era
-> f a
-> f (Featured feature era a)
-> f (Featured eon era a)
genFeaturedInEra witness gen =
Featured witness <$> gen

-- | Generate a 'Featured' for the given 'CardanoEra' with the provided generator.
genMaybeFeaturedInEra :: ()
=> FeatureInEra feature
=> Eon eon
=> Alternative f
=> (feature era -> f a)
=> (eon era -> f a)
-> CardanoEra era
-> f (Maybe (Featured feature era a))
-> f (Maybe (Featured eon era a))
genMaybeFeaturedInEra f =
featureInEra (pure Nothing) $ \w ->
inEonForEra (pure Nothing) $ \w ->
pure Nothing <|> fmap Just (genFeaturedInEra w (f w))

genTxScriptValidity :: CardanoEra era -> Gen (TxScriptValidity era)
Expand Down Expand Up @@ -915,7 +915,7 @@ genProtocolParameters era = do
protocolParamPoolPledgeInfluence <- genRationalInt64
protocolParamMonetaryExpansion <- genRational
protocolParamTreasuryCut <- genRational
protocolParamUTxOCostPerWord <- featureInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era
protocolParamUTxOCostPerWord <- inEonForEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era
protocolParamCostModels <- pure mempty
--TODO: Babbage figure out how to deal with
-- asymmetric cost model JSON instances
Expand All @@ -925,7 +925,7 @@ genProtocolParameters era = do
protocolParamMaxValueSize <- Gen.maybe genNat
protocolParamCollateralPercent <- Gen.maybe genNat
protocolParamMaxCollateralInputs <- Gen.maybe genNat
protocolParamUTxOCostPerByte <- featureInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era
protocolParamUTxOCostPerByte <- inEonForEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era

pure ProtocolParameters {..}

Expand All @@ -952,7 +952,7 @@ genProtocolParametersUpdate era = do
protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64
protocolUpdateMonetaryExpansion <- Gen.maybe genRational
protocolUpdateTreasuryCut <- Gen.maybe genRational
protocolUpdateUTxOCostPerWord <- featureInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era
protocolUpdateUTxOCostPerWord <- inEonForEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era
let protocolUpdateCostModels = mempty -- genCostModels
--TODO: Babbage figure out how to deal with
-- asymmetric cost model JSON instances
Expand All @@ -962,7 +962,7 @@ genProtocolParametersUpdate era = do
protocolUpdateMaxValueSize <- Gen.maybe genNat
protocolUpdateCollateralPercent <- Gen.maybe genNat
protocolUpdateMaxCollateralInputs <- Gen.maybe genNat
protocolUpdateUTxOCostPerByte <- featureInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era
protocolUpdateUTxOCostPerByte <- inEonForEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era

pure ProtocolParametersUpdate{..}

Expand Down
12 changes: 6 additions & 6 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ module Cardano.Api.Certificate (

import Cardano.Api.Address
import Cardano.Api.DRepMetadata
import Cardano.Api.Eon.ConwayEraOnwards
import Cardano.Api.Eon.ShelleyToBabbageEra
import Cardano.Api.EraCast
import Cardano.Api.Eras
import Cardano.Api.Feature.ConwayEraOnwards
import Cardano.Api.Feature.ShelleyToBabbageEra
import Cardano.Api.Governance.Actions.VotingProcedure
import Cardano.Api.HasTypeProxy
import Cardano.Api.Keys.Praos
Expand Down Expand Up @@ -270,8 +270,8 @@ instance EraCast Certificate where
case cert of
ShelleyRelatedCertificate sourceWit sourceLedgerCert ->
shelleyToBabbageEraConstraints sourceWit
$ inEraFeature targetEra
( inEraFeature targetEra
$ forEraInEon targetEra
( forEraInEon targetEra
( Left $ EraCastError
{ originalValue = cert
, fromEra = shelleyToBabbageEraToCardanoEra sourceWit
Expand Down Expand Up @@ -299,8 +299,8 @@ instance EraCast Certificate where

ConwayCertificate sourceWit sourceLedgerCert ->
conwayEraOnwardsConstraints sourceWit
$ inEraFeature targetEra
( inEraFeature targetEra
$ forEraInEon targetEra
( forEraInEon targetEra
( Left $ EraCastError
{ originalValue = cert
, fromEra = conwayEraOnwardsToCardanoEra sourceWit
Expand Down
4 changes: 2 additions & 2 deletions cardano-api/internal/Cardano/Api/Convenience/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module Cardano.Api.Convenience.Query (
import Cardano.Api.Address
import Cardano.Api.Certificate
import Cardano.Api.Convenience.Constraints
import Cardano.Api.Eon.ConwayEraOnwards (ConwayEraOnwards)
import Cardano.Api.Eras
import Cardano.Api.Feature.ConwayEraOnwards (ConwayEraOnwards)
import Cardano.Api.IO
import Cardano.Api.IPC
import Cardano.Api.IPC.Monad
Expand Down Expand Up @@ -126,7 +126,7 @@ queryStateForBalancedTx era allTxIns certs = runExceptT $ do
& onLeft (left . QueryEraMismatch)

drepDelegDeposits <-
inEraFeature @ConwayEraOnwards era (pure mempty) $ \_ ->
forEraInEon @ConwayEraOnwards era (pure mempty) $ \_ ->
Map.map (fromShelleyLovelace . drepDeposit) <$>
(lift (queryDRepState qeInMode sbe drepCreds)
& onLeft (left . QceUnsupportedNtcVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.AlonzoEraOnly
module Cardano.Api.Eon.AlonzoEraOnly
( AlonzoEraOnly(..)
, IsAlonzoEraOnly(..)
, AnyAlonzoEraOnly(..)
Expand Down Expand Up @@ -50,8 +50,8 @@ deriving instance Eq (AlonzoEraOnly era)
instance IsAlonzoEraOnly AlonzoEra where
alonzoEraOnly = AlonzoEraOnlyAlonzo

instance FeatureInEra AlonzoEraOnly where
featureInEra no yes = \case
instance Eon AlonzoEraOnly where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> no
AllegraEra -> no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.AlonzoEraOnwards
module Cardano.Api.Eon.AlonzoEraOnwards
( AlonzoEraOnwards(..)
, IsAlonzoEraOnwards(..)
, AnyAlonzoEraOnwards(..)
Expand Down Expand Up @@ -58,8 +58,8 @@ instance IsAlonzoEraOnwards BabbageEra where
instance IsAlonzoEraOnwards ConwayEra where
alonzoEraOnwards = AlonzoEraOnwardsConway

instance FeatureInEra AlonzoEraOnwards where
featureInEra no yes = \case
instance Eon AlonzoEraOnwards where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> no
AllegraEra -> no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.BabbageEraOnwards
module Cardano.Api.Eon.BabbageEraOnwards
( BabbageEraOnwards(..)
, IsBabbageEraOnwards(..)
, AnyBabbageEraOnwards(..)
Expand Down Expand Up @@ -54,8 +54,8 @@ instance IsBabbageEraOnwards BabbageEra where
instance IsBabbageEraOnwards ConwayEra where
babbageEraOnwards = BabbageEraOnwardsConway

instance FeatureInEra BabbageEraOnwards where
featureInEra no yes = \case
instance Eon BabbageEraOnwards where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> no
AllegraEra -> no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.ConwayEraOnwards
module Cardano.Api.Eon.ConwayEraOnwards
( ConwayEraOnwards(..)
, IsConwayEraOnwards(..)
, AnyConwayEraOnwards(..)
Expand Down Expand Up @@ -52,8 +52,8 @@ deriving instance Eq (ConwayEraOnwards era)
instance IsConwayEraOnwards ConwayEra where
conwayEraOnwards = ConwayEraOnwardsConway

instance FeatureInEra ConwayEraOnwards where
featureInEra no yes = \case
instance Eon ConwayEraOnwards where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> no
AllegraEra -> no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.ShelleyToAllegraEra
module Cardano.Api.Eon.ShelleyToAllegraEra
( ShelleyToAllegraEra(..)
, IsShelleyToAllegraEra(..)
, AnyShelleyToAllegraEra(..)
Expand Down Expand Up @@ -55,8 +55,8 @@ instance IsShelleyToAllegraEra ShelleyEra where
instance IsShelleyToAllegraEra AllegraEra where
shelleyToAllegraEra = ShelleyToAllegraEraAllegra

instance FeatureInEra ShelleyToAllegraEra where
featureInEra no yes = \case
instance Eon ShelleyToAllegraEra where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> yes ShelleyToAllegraEraShelley
AllegraEra -> yes ShelleyToAllegraEraAllegra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.ShelleyToAlonzoEra
module Cardano.Api.Eon.ShelleyToAlonzoEra
( ShelleyToAlonzoEra(..)
, IsShelleyToAlonzoEra(..)
, AnyShelleyToAlonzoEra(..)
Expand Down Expand Up @@ -63,8 +63,8 @@ instance IsShelleyToAlonzoEra MaryEra where
instance IsShelleyToAlonzoEra AlonzoEra where
shelleyToAlonzoEra = ShelleyToAlonzoEraAlonzo

instance FeatureInEra ShelleyToAlonzoEra where
featureInEra no yes = \case
instance Eon ShelleyToAlonzoEra where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> yes ShelleyToAlonzoEraShelley
AllegraEra -> yes ShelleyToAlonzoEraAllegra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.ShelleyToBabbageEra
module Cardano.Api.Eon.ShelleyToBabbageEra
( ShelleyToBabbageEra(..)
, IsShelleyToBabbageEra(..)
, AnyShelleyToBabbageEra(..)
Expand Down Expand Up @@ -67,8 +67,8 @@ instance IsShelleyToBabbageEra AlonzoEra where
instance IsShelleyToBabbageEra BabbageEra where
shelleyToBabbageEra = ShelleyToBabbageEraBabbage

instance FeatureInEra ShelleyToBabbageEra where
featureInEra no yes = \case
instance Eon ShelleyToBabbageEra where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> yes ShelleyToBabbageEraShelley
AllegraEra -> yes ShelleyToBabbageEraAllegra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.Feature.ShelleyToMaryEra
module Cardano.Api.Eon.ShelleyToMaryEra
( ShelleyToMaryEra(..)
, IsShelleyToMaryEra(..)
, AnyShelleyToMaryEra(..)
Expand Down Expand Up @@ -59,8 +59,8 @@ instance IsShelleyToMaryEra AllegraEra where
instance IsShelleyToMaryEra MaryEra where
shelleyToMaryEra = ShelleyToMaryEraMary

instance FeatureInEra ShelleyToMaryEra where
featureInEra no yes = \case
instance Eon ShelleyToMaryEra where
inEonForEra no yes = \case
ByronEra -> no
ShelleyEra -> yes ShelleyToMaryEraShelley
AllegraEra -> yes ShelleyToMaryEraAllegra
Expand Down
19 changes: 9 additions & 10 deletions cardano-api/internal/Cardano/Api/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ module Cardano.Api.Eras
, CardanoLedgerEra
, ToCardanoEra(..)

-- * FeatureInEra
, FeatureInEra(..)
, inEraFeature
, inEraFeatureMaybe
, maybeFeatureInEra

, featureInShelleyBasedEra
, inShelleyBasedEraFeature
, inShelleyBasedEraFeatureMaybe
, maybeFeatureInShelleyBasedEra
-- * IsEon
, Eon(..)
, forEraInEon
, inEraEonMaybe
, maybeEonInEra
, eonInShelleyBasedEra
, inShelleyBasedEraEon
, inShelleyBasedEraEonMaybe
, maybeEonInShelleyBasedEra

-- * Shelley-based eras
, ShelleyBasedEra(..)
Expand Down
12 changes: 6 additions & 6 deletions cardano-api/internal/Cardano/Api/Eras/Case.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ module Cardano.Api.Eras.Case
, caseShelleyToBabbageOrConwayEraOnwards
) where

import Cardano.Api.Eon.AlonzoEraOnwards
import Cardano.Api.Eon.BabbageEraOnwards
import Cardano.Api.Eon.ConwayEraOnwards
import Cardano.Api.Eon.ShelleyToAlonzoEra
import Cardano.Api.Eon.ShelleyToBabbageEra
import Cardano.Api.Eon.ShelleyToMaryEra
import Cardano.Api.Eras.Constraints
import Cardano.Api.Eras.Core
import Cardano.Api.Feature.AlonzoEraOnwards
import Cardano.Api.Feature.BabbageEraOnwards
import Cardano.Api.Feature.ConwayEraOnwards
import Cardano.Api.Feature.ShelleyToAlonzoEra
import Cardano.Api.Feature.ShelleyToBabbageEra
import Cardano.Api.Feature.ShelleyToMaryEra

caseByronOrShelleyBasedEra :: ()
=> (CardanoEra ByronEra -> a)
Expand Down
Loading