From a44dc7eab7cb3f9a29f7d3323eb1fedd82c15bef Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 19 Sep 2023 09:50:41 +1000 Subject: [PATCH] Replace ProtocolUTxOCostPerWordFeature and ProtocolUTxOCostPerByteFeature with eon equivalents --- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 8 +-- .../Cardano/Api/ProtocolParameters.hs | 60 ------------------- cardano-api/src/Cardano/Api.hs | 4 -- 3 files changed, 4 insertions(+), 68 deletions(-) diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 19d318b971..f8550c5ee6 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -915,7 +915,7 @@ genProtocolParameters era = do protocolParamPoolPledgeInfluence <- genRationalInt64 protocolParamMonetaryExpansion <- genRational protocolParamTreasuryCut <- genRational - protocolParamUTxOCostPerWord <- eonInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolParamUTxOCostPerWord <- eonInEra @AlonzoEraOnly (pure Nothing) (const (Just <$> genLovelace)) era protocolParamCostModels <- pure mempty --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances @@ -925,7 +925,7 @@ genProtocolParameters era = do protocolParamMaxValueSize <- Gen.maybe genNat protocolParamCollateralPercent <- Gen.maybe genNat protocolParamMaxCollateralInputs <- Gen.maybe genNat - protocolParamUTxOCostPerByte <- eonInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolParamUTxOCostPerByte <- eonInEra @BabbageEraOnwards (pure Nothing) (const (Just <$> genLovelace)) era pure ProtocolParameters {..} @@ -952,7 +952,7 @@ genProtocolParametersUpdate era = do protocolUpdatePoolPledgeInfluence <- Gen.maybe genRationalInt64 protocolUpdateMonetaryExpansion <- Gen.maybe genRational protocolUpdateTreasuryCut <- Gen.maybe genRational - protocolUpdateUTxOCostPerWord <- eonInEra @ProtocolUTxOCostPerWordFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolUpdateUTxOCostPerWord <- eonInEra @AlonzoEraOnly (pure Nothing) (const (Just <$> genLovelace)) era let protocolUpdateCostModels = mempty -- genCostModels --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances @@ -962,7 +962,7 @@ genProtocolParametersUpdate era = do protocolUpdateMaxValueSize <- Gen.maybe genNat protocolUpdateCollateralPercent <- Gen.maybe genNat protocolUpdateMaxCollateralInputs <- Gen.maybe genNat - protocolUpdateUTxOCostPerByte <- eonInEra @ProtocolUTxOCostPerByteFeature (pure Nothing) (const (Just <$> genLovelace)) era + protocolUpdateUTxOCostPerByte <- eonInEra @BabbageEraOnwards (pure Nothing) (const (Just <$> genLovelace)) era pure ProtocolParametersUpdate{..} diff --git a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs index aae252dda2..21db57fe98 100644 --- a/cardano-api/internal/Cardano/Api/ProtocolParameters.hs +++ b/cardano-api/internal/Cardano/Api/ProtocolParameters.hs @@ -90,10 +90,6 @@ module Cardano.Api.ProtocolParameters ( -- * Data family instances AsType(..), - -- ** Era-dependent protocol features - ProtocolUTxOCostPerByteFeature(..), - ProtocolUTxOCostPerWordFeature(..), - ) where import Cardano.Api.Address @@ -987,62 +983,6 @@ instance FromCBOR ProtocolParametersUpdate where <*> fromCBOR <*> fromCBOR --- ---------------------------------------------------------------------------- --- Features --- - --- | A representation of whether the era supports the 'UTxO Cost Per Byte' --- protocol parameter. --- --- The Babbage and subsequent eras support such a protocol parameter. --- -data ProtocolUTxOCostPerByteFeature era where - ProtocolUTxOCostPerByteInBabbageEra :: ProtocolUTxOCostPerByteFeature BabbageEra - ProtocolUTxOCostPerByteInConwayEra :: ProtocolUTxOCostPerByteFeature ConwayEra - -deriving instance Eq (ProtocolUTxOCostPerByteFeature era) -deriving instance Show (ProtocolUTxOCostPerByteFeature era) - -instance Eon ProtocolUTxOCostPerByteFeature where - eonInEra no yes = \case - ByronEra -> no - ShelleyEra -> no - AllegraEra -> no - MaryEra -> no - AlonzoEra -> no - BabbageEra -> yes ProtocolUTxOCostPerByteInBabbageEra - ConwayEra -> yes ProtocolUTxOCostPerByteInConwayEra - -instance ToCardanoEra ProtocolUTxOCostPerByteFeature where - toCardanoEra = \case - ProtocolUTxOCostPerByteInBabbageEra -> BabbageEra - ProtocolUTxOCostPerByteInConwayEra -> ConwayEra - --- | A representation of whether the era supports the 'UTxO Cost Per Word' --- protocol parameter. --- --- The Babbage and subsequent eras support such a protocol parameter. --- -data ProtocolUTxOCostPerWordFeature era where - ProtocolUpdateUTxOCostPerWordInAlonzoEra :: ProtocolUTxOCostPerWordFeature AlonzoEra - -deriving instance Eq (ProtocolUTxOCostPerWordFeature era) -deriving instance Show (ProtocolUTxOCostPerWordFeature era) - -instance Eon ProtocolUTxOCostPerWordFeature where - eonInEra no yes = \case - ByronEra -> no - ShelleyEra -> no - AllegraEra -> no - MaryEra -> no - AlonzoEra -> yes ProtocolUpdateUTxOCostPerWordInAlonzoEra - BabbageEra -> no - ConwayEra -> no - -instance ToCardanoEra ProtocolUTxOCostPerWordFeature where - toCardanoEra = \case - ProtocolUpdateUTxOCostPerWordInAlonzoEra -> AlonzoEra - -- ---------------------------------------------------------------------------- -- Praos nonce -- diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index dd4f5e9737..86c4f21034 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -377,10 +377,6 @@ module Cardano.Api ( scriptDataSupportedInEra, totalAndReturnCollateralSupportedInEra, - -- ** Era-dependent protocol features - ProtocolUTxOCostPerByteFeature(..), - ProtocolUTxOCostPerWordFeature(..), - -- ** Fee calculation LedgerEpochInfo(..), transactionFee,