{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Keys.Serialise.Orphans () where
import Cardano.Binary (DecoderError (..), FromCBOR (..), ToCBOR (..))
import Cardano.Binary.FixedSizeCodec qualified as Crypto
import Cardano.Ledger.Core (fromEraCBOR, toEraCBOR)
import Cardano.Ledger.Keys qualified as Ledger
import Cardano.Ledger.Shelley (ShelleyEra)
import Cardano.Protocol.Crypto (StandardCrypto)
import Cardano.Protocol.TPraos.OCert qualified as Ledger
import Codec.Binary.Bech32 qualified as Bech32
import Codec.CBOR.Read qualified as CBOR
import Data.Data (Data)
import Data.Text.Encoding.Error (UnicodeException (..))
import Data.Typeable (Typeable)
deriving instance Data DecoderError
deriving instance Data CBOR.DeserialiseFailure
deriving instance Data Bech32.DecodingError
deriving instance Data Bech32.CharPosition
deriving instance Data UnicodeException
instance ToCBOR (Ledger.OCert StandardCrypto) where
toCBOR :: OCert StandardCrypto -> Encoding
toCBOR = forall era t. (Era era, EncCBOR t) => t -> Encoding
toEraCBOR @ShelleyEra
instance FromCBOR (Ledger.OCert StandardCrypto) where
fromCBOR :: forall s. Decoder s (OCert StandardCrypto)
fromCBOR = forall era t s. (Era era, DecCBOR t) => Decoder s t
fromEraCBOR @ShelleyEra
instance Typeable kd => ToCBOR (Ledger.VKey kd) where
toCBOR :: VKey kd -> Encoding
toCBOR (Ledger.VKey VerKeyDSIGN DSIGN
vk) = VerKeyDSIGN DSIGN -> Encoding
forall a. FixedSizeCodec a => a -> Encoding
Crypto.encodeFixedSized VerKeyDSIGN DSIGN
vk
instance Typeable kd => FromCBOR (Ledger.VKey kd) where
fromCBOR :: forall s. Decoder s (VKey kd)
fromCBOR = VerKeyDSIGN DSIGN -> VKey kd
forall (kd :: KeyRole). VerKeyDSIGN DSIGN -> VKey kd
Ledger.VKey (VerKeyDSIGN DSIGN -> VKey kd)
-> Decoder s (VerKeyDSIGN DSIGN) -> Decoder s (VKey kd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (VerKeyDSIGN DSIGN)
forall a s. FixedSizeCodec a => Decoder s a
Crypto.decodeFixedSized