content: {-# LANGUAGE LambdaCase #-}
  {-# LANGUAGE TypeFamilies #-}
  {-# OPTIONS_GHC -Wno-orphans #-}
  
  module Cardano.Ledger.Alonzo.TxCert () where
  
  import Cardano.Ledger.Alonzo.Era (AlonzoEra)
  import Cardano.Ledger.Alonzo.PParams ()
  import Cardano.Ledger.Shelley.TxCert
  
  instance EraTxCert AlonzoEra where
    type TxCert AlonzoEra = ShelleyTxCert AlonzoEra
  
    upgradeTxCert = Right . upgradeShelleyTxCert
  
    getVKeyWitnessTxCert = getVKeyWitnessShelleyTxCert
  
    getScriptWitnessTxCert = getScriptWitnessShelleyTxCert
  
    mkRegPoolTxCert = ShelleyTxCertPool . RegPool
  
    getRegPoolTxCert (ShelleyTxCertPool (RegPool poolParams)) = Just poolParams
    getRegPoolTxCert _ = Nothing
  
    mkRetirePoolTxCert poolId epochNo = ShelleyTxCertPool $ RetirePool poolId epochNo
  
    getRetirePoolTxCert (ShelleyTxCertPool (RetirePool poolId epochNo)) = Just (poolId, epochNo)
    getRetirePoolTxCert _ = Nothing
  
    lookupRegStakeTxCert = \case
      RegTxCert c -> Just c
      _ -> Nothing
    lookupUnRegStakeTxCert = \case
      UnRegTxCert c -> Just c
      _ -> Nothing
  
    getTotalDepositsTxCerts = shelleyTotalDepositsTxCerts
  
    getTotalRefundsTxCerts pp lookupStakeDeposit _ = shelleyTotalRefundsTxCerts pp lookupStakeDeposit
  
  instance ShelleyEraTxCert AlonzoEra where
    mkRegTxCert = ShelleyTxCertDelegCert . ShelleyRegCert
  
    getRegTxCert (ShelleyTxCertDelegCert (ShelleyRegCert c)) = Just c
    getRegTxCert _ = Nothing
  
    mkUnRegTxCert = ShelleyTxCertDelegCert . ShelleyUnRegCert
  
    getUnRegTxCert (ShelleyTxCertDelegCert (ShelleyUnRegCert c)) = Just c
    getUnRegTxCert _ = Nothing
  
    mkDelegStakeTxCert c kh = ShelleyTxCertDelegCert $ ShelleyDelegCert c kh
  
    getDelegStakeTxCert (ShelleyTxCertDelegCert (ShelleyDelegCert c kh)) = Just (c, kh)
    getDelegStakeTxCert _ = Nothing
  
    mkGenesisDelegTxCert = ShelleyTxCertGenesisDeleg
  
    getGenesisDelegTxCert (ShelleyTxCertGenesisDeleg c) = Just c
    getGenesisDelegTxCert _ = Nothing
  
    mkMirTxCert = ShelleyTxCertMir
  
    getMirTxCert (ShelleyTxCertMir c) = Just c
    getMirTxCert _ = Nothing
  