@@ -45,6 +45,7 @@ import Cardano.Chain.Update.Validation.Registration qualified as L.Registration
4545import Cardano.Chain.Update.Validation.Voting qualified as L.Voting
4646import Cardano.Crypto.Hash qualified as Crypto
4747import Cardano.Ledger.Allegra.Rules qualified as L
48+ import Cardano.Ledger.Alonzo qualified as L
4849import Cardano.Ledger.Alonzo.PParams qualified as Ledger
4950import Cardano.Ledger.Alonzo.Rules qualified as Alonzo
5051import Cardano.Ledger.Alonzo.Rules qualified as L
@@ -63,6 +64,8 @@ import Cardano.Ledger.Conway.PParams qualified as Ledger
6364import Cardano.Ledger.Conway.Rules qualified as L
6465import Cardano.Ledger.Conway.TxCert qualified as L
6566import Cardano.Ledger.Core qualified as L hiding (KeyHash )
67+ import Cardano.Ledger.Dijkstra qualified as L
68+ import Cardano.Ledger.Dijkstra.Rules qualified as L
6669import Cardano.Ledger.HKD (NoUpdate (.. ))
6770import Cardano.Ledger.Hashes qualified as L hiding (KeyHash )
6871import Cardano.Ledger.Keys qualified as L.Keys
@@ -108,6 +111,7 @@ import Data.Aeson
108111 )
109112import Data.Aeson qualified as A
110113import Data.Aeson qualified as Aeson
114+ import Data.Aeson.Types (toJSONKeyText )
111115import Data.Bifunctor
112116import Data.ByteString qualified as BS
113117import Data.ByteString.Base16 qualified as B16
@@ -119,7 +123,7 @@ import Data.Data (Data)
119123import Data.Kind (Constraint , Type )
120124import Data.ListMap (ListMap )
121125import Data.ListMap qualified as ListMap
122- import Data.Map.NonEmpty (NonEmptyMap )
126+ import Data.Map.NonEmpty (NonEmptyMap , toMap )
123127import Data.Map.NonEmpty qualified as NonEmptyMap
124128import Data.Maybe.Strict (StrictMaybe (.. ))
125129import Data.Monoid
@@ -204,11 +208,11 @@ deriving anyclass instance ToJSON L.VotingPeriod
204208
205209deriving anyclass instance ToJSON L. Withdrawals
206210
207- instance ToJSON (NonEmptyMap k v ) where
208- toJSON = undefined
211+ instance ( ToJSONKey k , ToJSON v ) => ToJSON (NonEmptyMap k v ) where
212+ toJSON = toJSON . toMap
209213
210- instance ToJSON (NonEmptySet v ) where
211- toJSON = undefined
214+ instance ToJSON v => ToJSON (NonEmptySet v ) where
215+ toJSON = toJSON . NonEmptySet. toSet
212216
213217deriving anyclass instance
214218 ( ToJSON (L. PredicateFailure (L. EraRule " UTXOW" ledgerera ))
@@ -247,8 +251,31 @@ instance
247251 where
248252 toJSON = genericToJSON defaultOptions
249253
250- instance ToJSON (L. ApplyTxError ledgerera ) where
251- toJSON = undefined
254+ instance ToJSON (L. ApplyTxError L. ShelleyEra ) where
255+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
256+
257+ instance ToJSON (L. ApplyTxError L. AllegraEra ) where
258+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
259+
260+ instance ToJSON (L. ApplyTxError L. MaryEra ) where
261+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
262+
263+ instance ToJSON (L. ApplyTxError L. AlonzoEra ) where
264+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
265+
266+ instance ToJSON (L. ApplyTxError L. BabbageEra ) where
267+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
268+
269+ instance ToJSON (L. ApplyTxError L. ConwayEra ) where
270+ toJSON = Aeson. genericToJSON Aeson. defaultOptions
271+
272+ -- TODO: Ledger must expose DijkstraLedgerPredFailure in order to write the
273+ -- instances below.
274+ -- instance ToJSON (L.ApplyTxError L.DijkstraEra) where
275+ -- toJSON = Aeson.genericToJSON Aeson.defaultOptions
276+
277+ -- instance ToJSON (L.DijkstraMempoolPredFailure L.DijkstraEra) where
278+ -- toJSON = Aeson.genericToJSON Aeson.defaultOptions
252279
253280deriving via
254281 ShowOf (L.Keys. VKey L.Keys. Witness )
0 commit comments