Skip to content

Commit f42140d

Browse files
committed
Remove explicit FromJSON, ToJSON instances for AlonzoPParams
in favour of the ones defined for `EraPParams`
1 parent d8885e5 commit f42140d

File tree

2 files changed

+1
-86
lines changed
  • eras

2 files changed

+1
-86
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,9 @@ import Cardano.Ledger.Plutus.Language (Language (..))
110110
import Cardano.Ledger.Shelley.PParams
111111
import Control.DeepSeq (NFData)
112112
import Data.Aeson as Aeson (
113-
FromJSON (parseJSON),
113+
FromJSON,
114114
Key,
115-
KeyValue ((.=)),
116115
ToJSON (..),
117-
object,
118-
pairs,
119-
withObject,
120-
(.:),
121116
)
122117
import qualified Data.Aeson.Types as Aeson
123118
import Data.ByteString (ByteString)
@@ -397,47 +392,6 @@ instance EraGov AlonzoEra where
397392

398393
obligationGovState = const mempty
399394

400-
instance ToJSON (AlonzoPParams Identity AlonzoEra) where
401-
toJSON = object . alonzoPParamsPairs
402-
toEncoding = pairs . mconcat . alonzoPParamsPairs
403-
404-
alonzoPParamsPairs ::
405-
forall a e.
406-
KeyValue e a =>
407-
PParamsHKD Identity AlonzoEra ->
408-
[a]
409-
alonzoPParamsPairs pp =
410-
uncurry (.=) <$> alonzoPParamsHKDPairs (Proxy @Identity) pp
411-
412-
instance FromJSON (AlonzoPParams Identity era) where
413-
parseJSON =
414-
Aeson.withObject "PParams" $ \obj ->
415-
AlonzoPParams
416-
<$> obj .: "txFeePerByte"
417-
<*> obj .: "txFeeFixed"
418-
<*> obj .: "maxBlockBodySize"
419-
<*> obj .: "maxTxSize"
420-
<*> obj .: "maxBlockHeaderSize"
421-
<*> obj .: "stakeAddressDeposit"
422-
<*> obj .: "stakePoolDeposit"
423-
<*> obj .: "poolRetireMaxEpoch"
424-
<*> obj .: "stakePoolTargetNum"
425-
<*> obj .: "poolPledgeInfluence"
426-
<*> obj .: "monetaryExpansion"
427-
<*> obj .: "treasuryCut"
428-
<*> obj .: "decentralization"
429-
<*> obj .: "extraPraosEntropy"
430-
<*> obj .: "protocolVersion"
431-
<*> obj .: "minPoolCost"
432-
<*> obj .: "utxoCostPerByte"
433-
<*> obj .: "costModels"
434-
<*> obj .: "executionUnitPrices"
435-
<*> obj .: "maxTxExecutionUnits"
436-
<*> obj .: "maxBlockExecutionUnits"
437-
<*> obj .: "maxValueSize"
438-
<*> obj .: "collateralPercentage"
439-
<*> obj .: "maxCollateralInputs"
440-
441395
newtype CoinPerWord = CoinPerWord {unCoinPerWord :: Coin}
442396
deriving stock (Eq, Ord)
443397
deriving newtype (EncCBOR, DecCBOR, ToJSON, FromJSON, NFData, NoThunks, Show)
@@ -562,32 +516,6 @@ emptyAlonzoPParamsUpdate =
562516
, appMaxCollateralInputs = SNothing
563517
}
564518

565-
instance ToJSON (AlonzoPParams StrictMaybe AlonzoEra) where
566-
toJSON = object . alonzoPParamsUpdatePairs
567-
toEncoding = pairs . mconcat . alonzoPParamsUpdatePairs
568-
569-
alonzoPParamsUpdatePairs ::
570-
forall a e.
571-
KeyValue e a =>
572-
PParamsHKD StrictMaybe AlonzoEra ->
573-
[a]
574-
alonzoPParamsUpdatePairs pp =
575-
[ k .= v
576-
| (k, SJust v) <- alonzoPParamsHKDPairs (Proxy @StrictMaybe) pp
577-
]
578-
579-
alonzoPParamsHKDPairs ::
580-
forall f.
581-
HKDFunctor f =>
582-
Proxy f ->
583-
PParamsHKD f AlonzoEra ->
584-
[(Key, HKD f Aeson.Value)]
585-
alonzoPParamsHKDPairs px pp =
586-
alonzoCommonPParamsHKDPairs px pp
587-
++ shelleyCommonPParamsHKDPairsV8 px pp
588-
++ shelleyCommonPParamsHKDPairsV6 px pp
589-
++ [("utxoCostPerByte", hkdMap px (toJSON @CoinPerWord) (pp ^. hkdCoinsPerUTxOWordL @_ @f))]
590-
591519
-- | These are the fields that are common across all eras starting with Alonzo.
592520
alonzoCommonPParamsHKDPairs ::
593521
forall f era.

eras/shelley/impl/src/Cardano/Ledger/Shelley/PParams.hs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ module Cardano.Ledger.Shelley.PParams (
3333

3434
-- * JSON helpers
3535
shelleyCommonPParamsHKDPairs,
36-
shelleyCommonPParamsHKDPairsV6,
3736
shelleyCommonPParamsHKDPairsV8,
3837

3938
-- * PParam
@@ -267,18 +266,6 @@ instance NoThunks PPUpdateEnv
267266

268267
{-# DEPRECATED PPUpdateEnv "As unused" #-}
269268

270-
-- | These are the fields that are common only up to major protocol version 6
271-
shelleyCommonPParamsHKDPairsV6 ::
272-
forall f era.
273-
(HKDFunctor f, EraPParams era, ProtVerAtMost era 6) =>
274-
Proxy f ->
275-
PParamsHKD f era ->
276-
[(Key, HKD f Aeson.Value)]
277-
shelleyCommonPParamsHKDPairsV6 px pp =
278-
[ ("decentralization", hkdMap px (toJSON @UnitInterval) (pp ^. hkdDL @era @f))
279-
, ("extraPraosEntropy", hkdMap px (toJSON @Nonce) (pp ^. hkdExtraEntropyL @era @f))
280-
]
281-
282269
shelleyCommonPParamsHKDPairsV8 ::
283270
forall f era.
284271
(HKDFunctor f, EraPParams era, ProtVerAtMost era 8) =>

0 commit comments

Comments
 (0)