Skip to content

Commit

Permalink
Add ToJSON instances for ByronHash and OneEraHash
Browse files Browse the repository at this point in the history
  • Loading branch information
intricate committed Jul 10, 2020
1 parent a403b09 commit bea4045
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cardano-config/src/Cardano/Config/Orphanage.hs
Expand Up @@ -14,13 +14,17 @@ import Cardano.Prelude
import qualified Prelude

import Data.Aeson
import qualified Data.ByteString.Base16 as B16
import Data.Scientific (coefficient)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Network.Socket (PortNumber)

import Cardano.BM.Data.Tracer (TracingVerbosity(..))
import qualified Cardano.Chain.Update as Update
import Cardano.Slotting.Block (BlockNo (..))
import Ouroboros.Consensus.Byron.Ledger.Block (ByronHash(..))
import Ouroboros.Consensus.HardFork.Combinator (OneEraHash (..))
import Ouroboros.Consensus.NodeId (CoreNodeId (..))
import Ouroboros.Network.Block (HeaderHash, Tip (..))

Expand Down Expand Up @@ -64,4 +68,8 @@ instance ToJSON (HeaderHash blk) => ToJSON (Tip blk) where
, "blockNo" .= blockNo
]

instance ToJSON (OneEraHash xs) where
toJSON (OneEraHash bs) = toJSON . Text.decodeLatin1 . B16.encode $ bs

deriving newtype instance ToJSON ByronHash
deriving newtype instance ToJSON BlockNo

0 comments on commit bea4045

Please sign in to comment.