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

module Test.Cardano.Ledger.Mary.Binary.Annotator (
  module Test.Cardano.Ledger.Allegra.Binary.Annotator,
) where

import Cardano.Ledger.Binary
import Cardano.Ledger.Block (Block (..))
import Cardano.Ledger.Core (TxLevel (..))
import Cardano.Ledger.Mary (MaryEra, Tx (..))
import Cardano.Ledger.Mary.TxBody
import Test.Cardano.Ledger.Allegra.Binary.Annotator

deriving newtype instance DecCBOR (TxBody TopTx MaryEra)

deriving newtype instance DecCBOR (Tx TopTx MaryEra)

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