{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Allegra.TxWits () where

import Cardano.Ledger.Allegra.Era (AllegraEra)
import Cardano.Ledger.Allegra.TxAuxData ()
import Cardano.Ledger.Core (EraScript (upgradeScript), EraTxWits (..))
import Cardano.Ledger.Shelley.TxWits (
  ShelleyTxWits (..),
  addrShelleyTxWitsL,
  bootAddrShelleyTxWitsL,
  scriptShelleyTxWitsL,
 )

instance EraTxWits AllegraEra where
  type TxWits AllegraEra = ShelleyTxWits AllegraEra

  mkBasicTxWits :: TxWits AllegraEra
mkBasicTxWits = forall a. Monoid a => a
mempty

  addrTxWitsL :: Lens' (TxWits AllegraEra) (Set (WitVKey 'Witness))
addrTxWitsL = forall era.
EraScript era =>
Lens' (ShelleyTxWits era) (Set (WitVKey 'Witness))
addrShelleyTxWitsL
  {-# INLINE addrTxWitsL #-}

  bootAddrTxWitsL :: Lens' (TxWits AllegraEra) (Set BootstrapWitness)
bootAddrTxWitsL = forall era.
EraScript era =>
Lens' (ShelleyTxWits era) (Set BootstrapWitness)
bootAddrShelleyTxWitsL
  {-# INLINE bootAddrTxWitsL #-}

  scriptTxWitsL :: Lens' (TxWits AllegraEra) (Map ScriptHash (Script AllegraEra))
scriptTxWitsL = forall era.
EraScript era =>
Lens' (ShelleyTxWits era) (Map ScriptHash (Script era))
scriptShelleyTxWitsL
  {-# INLINE scriptTxWitsL #-}

  upgradeTxWits :: EraTxWits (PreviousEra AllegraEra) =>
TxWits (PreviousEra AllegraEra) -> TxWits AllegraEra
upgradeTxWits TxWits (PreviousEra AllegraEra)
stw =
    forall era.
EraScript era =>
Set (WitVKey 'Witness)
-> Map ScriptHash (Script era)
-> Set BootstrapWitness
-> ShelleyTxWits era
ShelleyTxWits
      (forall era.
EraScript era =>
ShelleyTxWits era -> Set (WitVKey 'Witness)
addrWits TxWits (PreviousEra AllegraEra)
stw)
      (forall era.
(EraScript era, EraScript (PreviousEra era)) =>
Script (PreviousEra era) -> Script era
upgradeScript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era.
EraScript era =>
ShelleyTxWits era -> Map ScriptHash (Script era)
scriptWits TxWits (PreviousEra AllegraEra)
stw)
      (forall era.
EraScript era =>
ShelleyTxWits era -> Set BootstrapWitness
bootWits TxWits (PreviousEra AllegraEra)
stw)