@@ -98,8 +98,8 @@ import Cardano.Ledger.HKD (HKD, HKDApplicative, HKDFunctor (..), NoUpdate (..))
98
98
import Cardano.Ledger.Plutus.ToPlutusData (ToPlutusData (.. ))
99
99
import Control.DeepSeq (NFData )
100
100
import Control.Monad.Identity (Identity )
101
- import Data.Aeson (FromJSON , ToJSON (.. ), object , pairs , (.=) )
102
- import qualified Data.Aeson as Aeson (KeyValue )
101
+ import Data.Aeson (FromJSON ( .. ) , ToJSON (.. ), object , pairs , (.:) , (.=) )
102
+ import qualified Data.Aeson as Aeson (KeyValue , withObject )
103
103
import qualified Data.Aeson.Key as Aeson (fromText )
104
104
import Data.Default (Default (.. ))
105
105
import qualified Data.Foldable as F (foldMap' , foldl' , foldlM )
@@ -142,8 +142,12 @@ instance EraPParams era => ToJSON (PParams era) where
142
142
toJSON = object . jsonPairsPParams
143
143
toEncoding = pairs . mconcat . jsonPairsPParams
144
144
145
- deriving newtype instance
146
- FromJSON (PParamsHKD Identity era ) => FromJSON (PParams era )
145
+ instance EraPParams era => FromJSON (PParams era ) where
146
+ parseJSON =
147
+ Aeson. withObject (show . typeRep $ Proxy @ (PParams era )) $ \ obj ->
148
+ let accum acc PParam' {ppName, ppLens} =
149
+ set ppLens <$> obj .: Aeson. fromText ppName <*> pure acc
150
+ in F. foldlM accum (emptyPParams @ era ) (eraPParams @ era )
147
151
148
152
instance EraPParams era => EncCBOR (PParams era ) where
149
153
encCBOR pp =
@@ -235,9 +239,6 @@ instance EraPParams era => ToJSON (PParamsUpdate era) where
235
239
toJSON = object . jsonPairsPParamsUpdate
236
240
toEncoding = pairs . mconcat . jsonPairsPParamsUpdate
237
241
238
- deriving newtype instance
239
- FromJSON (PParamsHKD StrictMaybe era ) => FromJSON (PParamsUpdate era )
240
-
241
242
deriving instance Generic (PParamsUpdate era )
242
243
243
244
-- Generic derivation of `applyPPUpdates`
@@ -287,7 +288,6 @@ class
287
288
, Show (PParamsHKD Identity era )
288
289
, NFData (PParamsHKD Identity era )
289
290
, NoThunks (PParamsHKD Identity era )
290
- , FromJSON (PParamsHKD Identity era )
291
291
, Eq (PParamsHKD StrictMaybe era )
292
292
, Ord (PParamsHKD StrictMaybe era )
293
293
, Show (PParamsHKD StrictMaybe era )
0 commit comments