{-# OPTIONS_GHC -Wno-orphans #-}

module Hydra.Cardano.Api.ChainPoint where

import Hydra.Cardano.Api.Prelude

-- | Get the chain point corresponding to a given 'BlockHeader'.
getChainPoint :: BlockHeader -> ChainPoint
getChainPoint :: BlockHeader -> ChainPoint
getChainPoint BlockHeader
header =
  SlotNo -> Hash BlockHeader -> ChainPoint
ChainPoint SlotNo
slotNo Hash BlockHeader
headerHash
 where
  (BlockHeader SlotNo
slotNo Hash BlockHeader
headerHash BlockNo
_) = BlockHeader
header

-- * Orphans

-- XXX: Incomplete arbitrary instance
instance Arbitrary ChainPoint where
  arbitrary :: Gen ChainPoint
arbitrary =
    ChainPoint -> Gen ChainPoint
forall a. a -> Gen a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ChainPoint
ChainPointAtGenesis