Skip to content

Commit

Permalink
New ProtocolUpdateUTxOCostPerByteSupportedInEra type
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jun 5, 2023
1 parent 2c031c1 commit 9583b39
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}

{- HLINT ignore "Redundant ==" -}
Expand Down Expand Up @@ -70,11 +71,16 @@ module Cardano.Api.ProtocolParameters (

-- * Data family instances
AsType(..),

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

) where

import Cardano.Api.Address
import Cardano.Api.Eras
import Cardano.Api.Error
import Cardano.Api.Feature
import Cardano.Api.Hash
import Cardano.Api.HasTypeProxy
import Cardano.Api.Json (toRationalJSON)
Expand Down Expand Up @@ -667,6 +673,31 @@ 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 FeatureInEra ProtocolUTxOCostPerByteFeature where
featureInEra no yes = \case
ByronEra -> no
ShelleyEra -> no
AllegraEra -> no
MaryEra -> no
AlonzoEra -> no
BabbageEra -> yes ProtocolUTxOCostPerByteInBabbageEra
ConwayEra -> yes ProtocolUTxOCostPerByteInConwayEra

-- ----------------------------------------------------------------------------
-- Praos nonce
Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api.hs
Expand Up @@ -294,6 +294,9 @@ module Cardano.Api (
scriptDataSupportedInEra,
totalAndReturnCollateralSupportedInEra,

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

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

0 comments on commit 9583b39

Please sign in to comment.