{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Conway.TxAuxData () where

import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.TxAuxData (
  AlonzoTxAuxData (..),
  hashAlonzoTxAuxData,
  metadataAlonzoTxAuxDataL,
  plutusScriptsAllegraTxAuxDataL,
  timelockScriptsAlonzoTxAuxDataL,
  translateAlonzoTxAuxData,
  validateAlonzoTxAuxData,
 )
import Cardano.Ledger.Conway.Era
import Cardano.Ledger.Conway.Scripts ()
import Cardano.Ledger.Crypto

instance Crypto c => EraTxAuxData (ConwayEra c) where
  type TxAuxData (ConwayEra c) = AlonzoTxAuxData (ConwayEra c)

  mkBasicTxAuxData :: TxAuxData (ConwayEra c)
mkBasicTxAuxData = forall era.
(HasCallStack, AlonzoEraScript era) =>
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxData era
AlonzoTxAuxData forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

  metadataTxAuxDataL :: Lens' (TxAuxData (ConwayEra c)) (Map Word64 Metadatum)
metadataTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Word64 Metadatum)
metadataAlonzoTxAuxDataL

  upgradeTxAuxData :: EraTxAuxData (PreviousEra (ConwayEra c)) =>
TxAuxData (PreviousEra (ConwayEra c)) -> TxAuxData (ConwayEra c)
upgradeTxAuxData = forall era1 era2.
(AlonzoEraScript era1, AlonzoEraScript era2,
 EraCrypto era1 ~ EraCrypto era2) =>
AlonzoTxAuxData era1 -> AlonzoTxAuxData era2
translateAlonzoTxAuxData

  hashTxAuxData :: TxAuxData (ConwayEra c)
-> AuxiliaryDataHash (EraCrypto (ConwayEra c))
hashTxAuxData = forall c x.
(HashAlgorithm (HASH c),
 HashAnnotated x EraIndependentTxAuxData c) =>
x -> AuxiliaryDataHash c
hashAlonzoTxAuxData

  validateTxAuxData :: ProtVer -> TxAuxData (ConwayEra c) -> Bool
validateTxAuxData = forall era.
(AlonzoEraScript era, Script era ~ AlonzoScript era) =>
ProtVer -> AuxiliaryData era -> Bool
validateAlonzoTxAuxData

instance Crypto c => AllegraEraTxAuxData (ConwayEra c) where
  timelockScriptsTxAuxDataL :: Lens'
  (TxAuxData (ConwayEra c)) (StrictSeq (Timelock (ConwayEra c)))
timelockScriptsTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (StrictSeq (Timelock era))
timelockScriptsAlonzoTxAuxDataL

instance Crypto c => AlonzoEraTxAuxData (ConwayEra c) where
  plutusScriptsTxAuxDataL :: Lens'
  (TxAuxData (ConwayEra c)) (Map Language (NonEmpty PlutusBinary))
plutusScriptsTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Language (NonEmpty PlutusBinary))
plutusScriptsAllegraTxAuxDataL