Skip to content

Commit

Permalink
Merge pull request #547 from IntersectMBO/smelc/deprecate-protocol-pa…
Browse files Browse the repository at this point in the history
…rameters

Prepare deprecation of ProtocolParameters
  • Loading branch information
smelc authored Jun 7, 2024
2 parents d8599ab + 0481fd8 commit dc448a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cardano-api/internal/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ instance IsShelleyBasedEra era => Eq (LedgerProtocolParameters era) where
shelleyBasedEraConstraints (shelleyBasedEra @era)
$ a == b

-- TODO: Conway era - remove me when we begin relying on the JSON
-- instances of Ledger.PParams
{-# DEPRECATED convertToLedgerProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
convertToLedgerProtocolParameters
:: ShelleyBasedEra era
-> ProtocolParameters
Expand Down Expand Up @@ -465,6 +464,7 @@ createIntroducedInBabbagePParams w (IntroducedInBabbagePParams coinsPerUTxOByte)
--
-- There are also parameters fixed in the Genesis file. See 'GenesisParameters'.
--
{-# DEPRECATED ProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters" #-}
data ProtocolParameters =
ProtocolParameters {

Expand Down Expand Up @@ -1669,6 +1669,7 @@ toConwayPParams = toBabbagePParams
-- Conversion functions: protocol parameters from ledger types
--

{-# DEPRECATED fromLedgerPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromLedgerPParams
:: ShelleyBasedEra era
-> Ledger.PParams (ShelleyLedgerEra era)
Expand All @@ -1681,6 +1682,7 @@ fromLedgerPParams ShelleyBasedEraBabbage = fromBabbagePParams
fromLedgerPParams ShelleyBasedEraConway = fromConwayPParams


{-# DEPRECATED fromShelleyCommonPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromShelleyCommonPParams :: EraPParams ledgerera
=> PParams ledgerera
-> ProtocolParameters
Expand Down Expand Up @@ -1714,6 +1716,7 @@ fromShelleyCommonPParams pp =
, protocolParamMinUTxOValue = Nothing -- Obsolete from Alonzo onwards
}

{-# DEPRECATED fromShelleyPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromShelleyPParams :: ( EraPParams ledgerera
, Ledger.AtMostEra Ledger.MaryEra ledgerera
, Ledger.AtMostEra Ledger.AlonzoEra ledgerera
Expand All @@ -1728,6 +1731,7 @@ fromShelleyPParams pp =
}


{-# DEPRECATED fromAlonzoPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromAlonzoPParams :: AlonzoEraPParams ledgerera
=> PParams ledgerera
-> ProtocolParameters
Expand All @@ -1743,6 +1747,7 @@ fromAlonzoPParams pp =
, protocolParamMaxCollateralInputs = Just $ pp ^. ppMaxCollateralInputsL
}

{-# DEPRECATED fromExactlyAlonzoPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromExactlyAlonzoPParams :: (AlonzoEraPParams ledgerera, Ledger.ExactEra Ledger.AlonzoEra ledgerera)
=> PParams ledgerera
-> ProtocolParameters
Expand All @@ -1751,6 +1756,7 @@ fromExactlyAlonzoPParams pp =
protocolParamUTxOCostPerByte = Just . unCoinPerWord $ pp ^. ppCoinsPerUTxOWordL
}

{-# DEPRECATED fromBabbagePParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromBabbagePParams :: BabbageEraPParams ledgerera
=> PParams ledgerera
-> ProtocolParameters
Expand All @@ -1760,11 +1766,13 @@ fromBabbagePParams pp =
, protocolParamDecentralization = Nothing
}

{-# DEPRECATED fromConwayPParams "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters." #-}
fromConwayPParams :: BabbageEraPParams ledgerera
=> PParams ledgerera
-> ProtocolParameters
fromConwayPParams = fromBabbagePParams

{-# DEPRECATED checkProtocolParameters "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters. PParams natively enforce these checks." #-}
checkProtocolParameters :: ()
=> ShelleyBasedEra era
-> ProtocolParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- TODO remove me when ProtocolParameters is deleted
{-# OPTIONS_GHC -Wno-deprecations #-}

module Test.Golden.Cardano.Api.ProtocolParameters
( test_golden_ProtocolParameters
, test_golden_ProtocolParameters_to_PParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

-- TODO remove me when ProtocolParameters is deleted
{-# OPTIONS_GHC -Wno-deprecations #-}

module Test.Cardano.Api.ProtocolParameters
( tests
) where
Expand Down

0 comments on commit dc448a2

Please sign in to comment.