Skip to content

Commit

Permalink
Replace ProtocolUTxOCostPerWordFeature and ProtocolUTxOCostPerByteFea…
Browse files Browse the repository at this point in the history
…ture with eon equivalents
  • Loading branch information
newhoggy committed Sep 18, 2023
1 parent 5cfac73 commit a44dc7e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 68 deletions.
8 changes: 4 additions & 4 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {..}

Expand All @@ -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
Expand All @@ -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{..}

Expand Down
60 changes: 0 additions & 60 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ module Cardano.Api.ProtocolParameters (
-- * Data family instances
AsType(..),

-- ** Era-dependent protocol features
ProtocolUTxOCostPerByteFeature(..),
ProtocolUTxOCostPerWordFeature(..),

) where

import Cardano.Api.Address
Expand Down Expand Up @@ -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
--
Expand Down
4 changes: 0 additions & 4 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,6 @@ module Cardano.Api (
scriptDataSupportedInEra,
totalAndReturnCollateralSupportedInEra,

-- ** Era-dependent protocol features
ProtocolUTxOCostPerByteFeature(..),
ProtocolUTxOCostPerWordFeature(..),

-- ** Fee calculation
LedgerEpochInfo(..),
transactionFee,
Expand Down

0 comments on commit a44dc7e

Please sign in to comment.