{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Ledger.Babbage.Binary.Annotator (
  module Test.Cardano.Ledger.Alonzo.Binary.Annotator,
) where

import Cardano.Ledger.Babbage (BabbageEra, Tx (..))
import Cardano.Ledger.Babbage.Core
import Cardano.Ledger.Babbage.TxBody
import Cardano.Ledger.Binary
import Cardano.Ledger.Block (Block (..))
import Test.Cardano.Ledger.Alonzo.Binary.Annotator

deriving newtype instance DecCBOR (TxBody TopTx BabbageEra)

deriving newtype instance DecCBOR (Tx TopTx BabbageEra)

instance DecCBOR h => DecCBOR (Block h BabbageEra) where
  decCBOR :: forall s. Decoder s (Block h BabbageEra)
decCBOR =
    Text
-> (Block h BabbageEra -> Int)
-> Decoder s (Block h BabbageEra)
-> Decoder s (Block h BabbageEra)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"Block" (Int -> Block h BabbageEra -> Int
forall a b. a -> b -> a
const Int
5) (Decoder s (Block h BabbageEra) -> Decoder s (Block h BabbageEra))
-> Decoder s (Block h BabbageEra) -> Decoder s (Block h BabbageEra)
forall a b. (a -> b) -> a -> b
$ h -> BlockBody BabbageEra -> Block h BabbageEra
h -> AlonzoBlockBody BabbageEra -> Block h BabbageEra
forall h era. h -> BlockBody era -> Block h era
Block (h -> AlonzoBlockBody BabbageEra -> Block h BabbageEra)
-> Decoder s h
-> Decoder s (AlonzoBlockBody BabbageEra -> Block h BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s h
forall s. Decoder s h
forall a s. DecCBOR a => Decoder s a
decCBOR Decoder s (AlonzoBlockBody BabbageEra -> Block h BabbageEra)
-> Decoder s (AlonzoBlockBody BabbageEra)
-> Decoder s (Block h BabbageEra)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (AlonzoBlockBody BabbageEra)
forall s. Decoder s (AlonzoBlockBody BabbageEra)
forall a s. DecCBOR a => Decoder s a
decCBOR