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

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

import Cardano.Ledger.Binary
import Cardano.Ledger.Block (Block (..))
import Cardano.Ledger.Conway (ConwayEra, Tx (..))
import Cardano.Ledger.Conway.Core
import Cardano.Ledger.Conway.TxBody
import Test.Cardano.Ledger.Babbage.Binary.Annotator

deriving newtype instance DecCBOR (TxBody TopTx ConwayEra)

deriving newtype instance DecCBOR (Tx TopTx ConwayEra)

instance DecCBOR h => DecCBOR (Block h ConwayEra) where
  decCBOR :: forall s. Decoder s (Block h ConwayEra)
decCBOR =
    Text
-> (Block h ConwayEra -> Int)
-> Decoder s (Block h ConwayEra)
-> Decoder s (Block h ConwayEra)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"Block" (Int -> Block h ConwayEra -> Int
forall a b. a -> b -> a
const Int
5) (Decoder s (Block h ConwayEra) -> Decoder s (Block h ConwayEra))
-> Decoder s (Block h ConwayEra) -> Decoder s (Block h ConwayEra)
forall a b. (a -> b) -> a -> b
$ h -> BlockBody ConwayEra -> Block h ConwayEra
h -> AlonzoBlockBody ConwayEra -> Block h ConwayEra
forall h era. h -> BlockBody era -> Block h era
Block (h -> AlonzoBlockBody ConwayEra -> Block h ConwayEra)
-> Decoder s h
-> Decoder s (AlonzoBlockBody ConwayEra -> Block h ConwayEra)
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 ConwayEra -> Block h ConwayEra)
-> Decoder s (AlonzoBlockBody ConwayEra)
-> Decoder s (Block h ConwayEra)
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 ConwayEra)
forall s. Decoder s (AlonzoBlockBody ConwayEra)
forall a s. DecCBOR a => Decoder s a
decCBOR