{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Conway.Rules.Utxow (
  alonzoToConwayUtxowPredFailure,
  babbageToConwayUtxowPredFailure,
  ConwayUTXOW,
  ConwayUtxowPredFailure (..),
  shelleyToConwayUtxowPredFailure,
) where

import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure)
import Cardano.Ledger.Alonzo.Rules (
  AlonzoUtxoEvent,
  AlonzoUtxoPredFailure,
  AlonzoUtxosPredFailure,
  AlonzoUtxowEvent (WrappedShelleyEraEvent),
  AlonzoUtxowPredFailure,
 )
import qualified Cardano.Ledger.Alonzo.Rules as Alonzo (AlonzoUtxowPredFailure (..))
import Cardano.Ledger.Alonzo.UTxO (AlonzoEraUTxO, AlonzoScriptsNeeded)
import Cardano.Ledger.Babbage.Rules (
  BabbageUtxoPredFailure,
  BabbageUtxowPredFailure,
  babbageUtxowTransition,
 )
import qualified Cardano.Ledger.Babbage.Rules as Babbage (BabbageUtxowPredFailure (..))
import Cardano.Ledger.BaseTypes (Mismatch (..), Relation (..), ShelleyBase)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders (Decode (..), Encode (..), decode, encode, (!>), (<!))
import Cardano.Ledger.Conway.Core
import Cardano.Ledger.Conway.Era (ConwayEra, ConwayUTXO, ConwayUTXOW)
import Cardano.Ledger.Conway.Rules.Utxo (ConwayUtxoPredFailure)
import Cardano.Ledger.Conway.Rules.Utxos (ConwayUtxosPredFailure)
import Cardano.Ledger.Keys (VKey)
import qualified Cardano.Ledger.Shelley.LedgerState as Shelley (UTxOState)
import Cardano.Ledger.Shelley.Rules (
  ShelleyUtxoPredFailure,
  ShelleyUtxowEvent (UtxoEvent),
  ShelleyUtxowPredFailure,
 )
import qualified Cardano.Ledger.Shelley.Rules as Shelley (
  ShelleyUtxowPredFailure (..),
  UtxoEnv,
 )
import Cardano.Ledger.State (EraUTxO (..))
import Cardano.Ledger.TxIn (TxIn)
import Control.DeepSeq (NFData)
import Control.State.Transition.Extended (Embed (..), STS (..))
import Data.Maybe.Strict (StrictMaybe)
import Data.Set (Set)
import GHC.Generics (Generic)
import NoThunks.Class (InspectHeapNamed (..), NoThunks (..))

-- ================================

-- | Predicate failure type for the Conway Era
data ConwayUtxowPredFailure era
  = UtxoFailure (PredicateFailure (EraRule "UTXO" era))
  | InvalidWitnessesUTXOW
      [VKey 'Witness]
  | -- | witnesses which failed in verifiedWits function
    MissingVKeyWitnessesUTXOW
      -- | witnesses which were needed and not supplied
      (Set (KeyHash 'Witness))
  | -- | missing scripts
    MissingScriptWitnessesUTXOW
      (Set ScriptHash)
  | -- | failed scripts
    ScriptWitnessNotValidatingUTXOW
      (Set ScriptHash)
  | -- | hash of the full metadata
    MissingTxBodyMetadataHash
      TxAuxDataHash
  | -- | hash of the metadata included in the transaction body
    MissingTxMetadata
      TxAuxDataHash
  | ConflictingMetadataHash
      (Mismatch 'RelEQ TxAuxDataHash)
  | -- | Contains out of range values (string`s too long)
    InvalidMetadata
  | -- | extraneous scripts
    ExtraneousScriptWitnessesUTXOW
      (Set ScriptHash)
  | MissingRedeemers
      [(PlutusPurpose AsItem era, ScriptHash)]
  | MissingRequiredDatums
      -- TODO: Make this NonEmpty #4066

      -- | Set of missing data hashes
      (Set DataHash)
      -- | Set of received data hashes
      (Set DataHash)
  | NotAllowedSupplementalDatums
      -- TODO: Make this NonEmpty #4066

      -- | Set of unallowed data hashes.
      (Set DataHash)
      -- | Set of acceptable supplemental data hashes
      (Set DataHash)
  | PPViewHashesDontMatch
      (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash))
  | -- | Set of transaction inputs that are TwoPhase scripts, and should have a DataHash but don't
    UnspendableUTxONoDatumHash
      -- TODO: Make this NonEmpty #4066
      (Set TxIn)
  | -- | List of redeemers not needed
    ExtraRedeemers [PlutusPurpose AsIx era]
  | -- | Embed UTXO rule failures
    MalformedScriptWitnesses
      (Set ScriptHash)
  | -- | the set of malformed script witnesses
    MalformedReferenceScripts
      (Set ScriptHash)
  deriving ((forall x.
 ConwayUtxowPredFailure era -> Rep (ConwayUtxowPredFailure era) x)
-> (forall x.
    Rep (ConwayUtxowPredFailure era) x -> ConwayUtxowPredFailure era)
-> Generic (ConwayUtxowPredFailure era)
forall x.
Rep (ConwayUtxowPredFailure era) x -> ConwayUtxowPredFailure era
forall x.
ConwayUtxowPredFailure era -> Rep (ConwayUtxowPredFailure era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (ConwayUtxowPredFailure era) x -> ConwayUtxowPredFailure era
forall era x.
ConwayUtxowPredFailure era -> Rep (ConwayUtxowPredFailure era) x
$cfrom :: forall era x.
ConwayUtxowPredFailure era -> Rep (ConwayUtxowPredFailure era) x
from :: forall x.
ConwayUtxowPredFailure era -> Rep (ConwayUtxowPredFailure era) x
$cto :: forall era x.
Rep (ConwayUtxowPredFailure era) x -> ConwayUtxowPredFailure era
to :: forall x.
Rep (ConwayUtxowPredFailure era) x -> ConwayUtxowPredFailure era
Generic)

type instance EraRuleFailure "UTXOW" ConwayEra = ConwayUtxowPredFailure ConwayEra

type instance EraRuleEvent "UTXOW" ConwayEra = AlonzoUtxowEvent ConwayEra

instance InjectRuleFailure "UTXOW" ConwayUtxowPredFailure ConwayEra

instance InjectRuleFailure "UTXOW" BabbageUtxowPredFailure ConwayEra where
  injectFailure :: BabbageUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = BabbageUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
BabbageUtxowPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall era.
BabbageUtxowPredFailure era -> ConwayUtxowPredFailure era
babbageToConwayUtxowPredFailure

instance InjectRuleFailure "UTXOW" AlonzoUtxowPredFailure ConwayEra where
  injectFailure :: AlonzoUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = AlonzoUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
AlonzoUtxowPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall era.
AlonzoUtxowPredFailure era -> ConwayUtxowPredFailure era
alonzoToConwayUtxowPredFailure

instance InjectRuleFailure "UTXOW" ShelleyUtxowPredFailure ConwayEra where
  injectFailure :: ShelleyUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = ShelleyUtxowPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
ShelleyUtxowPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall era.
ShelleyUtxowPredFailure era -> ConwayUtxowPredFailure era
shelleyToConwayUtxowPredFailure

instance InjectRuleFailure "UTXOW" ConwayUtxoPredFailure ConwayEra where
  injectFailure :: ConwayUtxoPredFailure ConwayEra -> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (ConwayUtxoPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> ConwayUtxoPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConwayUtxoPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" BabbageUtxoPredFailure ConwayEra where
  injectFailure :: BabbageUtxoPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (BabbageUtxoPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> BabbageUtxoPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BabbageUtxoPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
BabbageUtxoPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" AlonzoUtxoPredFailure ConwayEra where
  injectFailure :: AlonzoUtxoPredFailure ConwayEra -> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (AlonzoUtxoPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> AlonzoUtxoPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoUtxoPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
AlonzoUtxoPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" AlonzoUtxosPredFailure ConwayEra where
  injectFailure :: AlonzoUtxosPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (AlonzoUtxosPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> AlonzoUtxosPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoUtxosPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
AlonzoUtxosPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" ConwayUtxosPredFailure ConwayEra where
  injectFailure :: ConwayUtxosPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (ConwayUtxosPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> ConwayUtxosPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConwayUtxosPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
ConwayUtxosPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" ShelleyUtxoPredFailure ConwayEra where
  injectFailure :: ShelleyUtxoPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (ShelleyUtxoPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> ShelleyUtxoPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyUtxoPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
ShelleyUtxoPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

instance InjectRuleFailure "UTXOW" AllegraUtxoPredFailure ConwayEra where
  injectFailure :: AllegraUtxoPredFailure ConwayEra
-> EraRuleFailure "UTXOW" ConwayEra
injectFailure = PredicateFailure (EraRule "UTXO" ConwayEra)
-> ConwayUtxowPredFailure ConwayEra
ConwayUtxoPredFailure ConwayEra -> ConwayUtxowPredFailure ConwayEra
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure (ConwayUtxoPredFailure ConwayEra
 -> ConwayUtxowPredFailure ConwayEra)
-> (AllegraUtxoPredFailure ConwayEra
    -> ConwayUtxoPredFailure ConwayEra)
-> AllegraUtxoPredFailure ConwayEra
-> ConwayUtxowPredFailure ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AllegraUtxoPredFailure ConwayEra -> EraRuleFailure "UTXO" ConwayEra
AllegraUtxoPredFailure ConwayEra -> ConwayUtxoPredFailure ConwayEra
forall (rule :: Symbol) (t :: * -> *) era.
InjectRuleFailure rule t era =>
t era -> EraRuleFailure rule era
injectFailure

deriving instance
  ( ConwayEraScript era
  , Show (PredicateFailure (EraRule "UTXO" era))
  ) =>
  Show (ConwayUtxowPredFailure era)

deriving instance
  ( ConwayEraScript era
  , Eq (PredicateFailure (EraRule "UTXO" era))
  ) =>
  Eq (ConwayUtxowPredFailure era)

deriving via
  InspectHeapNamed "ConwayUtxowPred" (ConwayUtxowPredFailure era)
  instance
    NoThunks (ConwayUtxowPredFailure era)

instance
  ( ConwayEraScript era
  , NFData (TxCert era)
  , NFData (PredicateFailure (EraRule "UTXO" era))
  ) =>
  NFData (ConwayUtxowPredFailure era)

--------------------------------------------------------------------------------
-- ConwayUTXOW STS
--------------------------------------------------------------------------------

instance
  forall era.
  ( AlonzoEraTx era
  , AlonzoEraUTxO era
  , ScriptsNeeded era ~ AlonzoScriptsNeeded era
  , ConwayEraTxBody era
  , EraRule "UTXOW" era ~ ConwayUTXOW era
  , InjectRuleFailure "UTXOW" ShelleyUtxowPredFailure era
  , InjectRuleFailure "UTXOW" AlonzoUtxowPredFailure era
  , InjectRuleFailure "UTXOW" BabbageUtxowPredFailure era
  , -- Allow UTXOW to call UTXO
    Embed (EraRule "UTXO" era) (ConwayUTXOW era)
  , Environment (EraRule "UTXO" era) ~ Shelley.UtxoEnv era
  , State (EraRule "UTXO" era) ~ Shelley.UTxOState era
  , Signal (EraRule "UTXO" era) ~ Tx era
  , Eq (PredicateFailure (EraRule "UTXOS" era))
  , Show (PredicateFailure (EraRule "UTXOS" era))
  ) =>
  STS (ConwayUTXOW era)
  where
  type State (ConwayUTXOW era) = Shelley.UTxOState era
  type Signal (ConwayUTXOW era) = Tx era
  type Environment (ConwayUTXOW era) = Shelley.UtxoEnv era
  type BaseM (ConwayUTXOW era) = ShelleyBase
  type PredicateFailure (ConwayUTXOW era) = ConwayUtxowPredFailure era
  type Event (ConwayUTXOW era) = AlonzoUtxowEvent era
  transitionRules :: [TransitionRule (ConwayUTXOW era)]
transitionRules = [forall era.
(AlonzoEraTx era, AlonzoEraUTxO era,
 ScriptsNeeded era ~ AlonzoScriptsNeeded era, BabbageEraTxBody era,
 Environment (EraRule "UTXOW" era) ~ UtxoEnv era,
 Signal (EraRule "UTXOW" era) ~ Tx era,
 State (EraRule "UTXOW" era) ~ UTxOState era,
 InjectRuleFailure "UTXOW" ShelleyUtxowPredFailure era,
 InjectRuleFailure "UTXOW" AlonzoUtxowPredFailure era,
 InjectRuleFailure "UTXOW" BabbageUtxowPredFailure era,
 Embed (EraRule "UTXO" era) (EraRule "UTXOW" era),
 Environment (EraRule "UTXO" era) ~ UtxoEnv era,
 Signal (EraRule "UTXO" era) ~ Tx era,
 State (EraRule "UTXO" era) ~ UTxOState era) =>
TransitionRule (EraRule "UTXOW" era)
babbageUtxowTransition @era]
  initialRules :: [InitialRule (ConwayUTXOW era)]
initialRules = []

instance
  ( Era era
  , STS (ConwayUTXO era)
  , PredicateFailure (EraRule "UTXO" era) ~ ConwayUtxoPredFailure era
  , Event (EraRule "UTXO" era) ~ AlonzoUtxoEvent era
  , BaseM (ConwayUTXOW era) ~ ShelleyBase
  , PredicateFailure (ConwayUTXOW era) ~ ConwayUtxowPredFailure era
  , Event (ConwayUTXOW era) ~ AlonzoUtxowEvent era
  ) =>
  Embed (ConwayUTXO era) (ConwayUTXOW era)
  where
  wrapFailed :: PredicateFailure (ConwayUTXO era)
-> PredicateFailure (ConwayUTXOW era)
wrapFailed = PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
PredicateFailure (ConwayUTXO era)
-> PredicateFailure (ConwayUTXOW era)
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure
  wrapEvent :: Event (ConwayUTXO era) -> Event (ConwayUTXOW era)
wrapEvent = ShelleyUtxowEvent era -> AlonzoUtxowEvent era
forall era. ShelleyUtxowEvent era -> AlonzoUtxowEvent era
WrappedShelleyEraEvent (ShelleyUtxowEvent era -> AlonzoUtxowEvent era)
-> (AlonzoUtxoEvent era -> ShelleyUtxowEvent era)
-> AlonzoUtxoEvent era
-> AlonzoUtxowEvent era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoUtxoEvent era -> ShelleyUtxowEvent era
Event (EraRule "UTXO" era) -> ShelleyUtxowEvent era
forall era. Event (EraRule "UTXO" era) -> ShelleyUtxowEvent era
UtxoEvent

--------------------------------------------------------------------------------
-- Serialisation
--------------------------------------------------------------------------------

instance
  ( ConwayEraScript era
  , EncCBOR (PredicateFailure (EraRule "UTXO" era))
  ) =>
  EncCBOR (ConwayUtxowPredFailure era)
  where
  encCBOR :: ConwayUtxowPredFailure era -> Encoding
encCBOR =
    Encode 'Open (ConwayUtxowPredFailure era) -> Encoding
forall (w :: Wrapped) t. Encode w t -> Encoding
encode (Encode 'Open (ConwayUtxowPredFailure era) -> Encoding)
-> (ConwayUtxowPredFailure era
    -> Encode 'Open (ConwayUtxowPredFailure era))
-> ConwayUtxowPredFailure era
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
      UtxoFailure PredicateFailure (EraRule "UTXO" era)
x -> (PredicateFailure (EraRule "UTXO" era)
 -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open
     (PredicateFailure (EraRule "UTXO" era)
      -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure Word
0 Encode
  'Open
  (PredicateFailure (EraRule "UTXO" era)
   -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (PredicateFailure (EraRule "UTXO" era))
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> PredicateFailure (EraRule "UTXO" era)
-> Encode ('Closed 'Dense) (PredicateFailure (EraRule "UTXO" era))
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To PredicateFailure (EraRule "UTXO" era)
x
      InvalidWitnessesUTXOW [VKey 'Witness]
xs -> ([VKey 'Witness] -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open ([VKey 'Witness] -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum [VKey 'Witness] -> ConwayUtxowPredFailure era
forall era. [VKey 'Witness] -> ConwayUtxowPredFailure era
InvalidWitnessesUTXOW Word
1 Encode 'Open ([VKey 'Witness] -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) [VKey 'Witness]
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> [VKey 'Witness] -> Encode ('Closed 'Dense) [VKey 'Witness]
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To [VKey 'Witness]
xs
      MissingVKeyWitnessesUTXOW Set (KeyHash 'Witness)
xs -> (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
forall era. Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
MissingVKeyWitnessesUTXOW Word
2 Encode 'Open (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set (KeyHash 'Witness))
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set (KeyHash 'Witness)
-> Encode ('Closed 'Dense) (Set (KeyHash 'Witness))
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (KeyHash 'Witness)
xs
      MissingScriptWitnessesUTXOW Set ScriptHash
xs -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MissingScriptWitnessesUTXOW Word
3 Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set ScriptHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set ScriptHash -> Encode ('Closed 'Dense) (Set ScriptHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set ScriptHash
xs
      ScriptWitnessNotValidatingUTXOW Set ScriptHash
xs -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW Word
4 Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set ScriptHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set ScriptHash -> Encode ('Closed 'Dense) (Set ScriptHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set ScriptHash
xs
      MissingTxBodyMetadataHash TxAuxDataHash
xs -> (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxBodyMetadataHash Word
5 Encode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) TxAuxDataHash
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> TxAuxDataHash -> Encode ('Closed 'Dense) TxAuxDataHash
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To TxAuxDataHash
xs
      MissingTxMetadata TxAuxDataHash
xs -> (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxMetadata Word
6 Encode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) TxAuxDataHash
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> TxAuxDataHash -> Encode ('Closed 'Dense) TxAuxDataHash
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To TxAuxDataHash
xs
      ConflictingMetadataHash Mismatch 'RelEQ TxAuxDataHash
mm -> (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
ConflictingMetadataHash Word
7 Encode
  'Open (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Mismatch 'RelEQ TxAuxDataHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Mismatch 'RelEQ TxAuxDataHash
-> Encode ('Closed 'Dense) (Mismatch 'RelEQ TxAuxDataHash)
forall t. EncCBORGroup t => t -> Encode ('Closed 'Dense) t
ToGroup Mismatch 'RelEQ TxAuxDataHash
mm
      ConwayUtxowPredFailure era
InvalidMetadata -> ConwayUtxowPredFailure era
-> Word -> Encode 'Open (ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum ConwayUtxowPredFailure era
forall era. ConwayUtxowPredFailure era
InvalidMetadata Word
8
      ExtraneousScriptWitnessesUTXOW Set ScriptHash
xs -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ExtraneousScriptWitnessesUTXOW Word
9 Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set ScriptHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set ScriptHash -> Encode ('Closed 'Dense) (Set ScriptHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set ScriptHash
xs
      MissingRedeemers [(PlutusPurpose AsItem era, ScriptHash)]
x -> ([(PlutusPurpose AsItem era, ScriptHash)]
 -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open
     ([(PlutusPurpose AsItem era, ScriptHash)]
      -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum [(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
forall era.
[(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
MissingRedeemers Word
10 Encode
  'Open
  ([(PlutusPurpose AsItem era, ScriptHash)]
   -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) [(PlutusPurpose AsItem era, ScriptHash)]
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> [(PlutusPurpose AsItem era, ScriptHash)]
-> Encode ('Closed 'Dense) [(PlutusPurpose AsItem era, ScriptHash)]
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To [(PlutusPurpose AsItem era, ScriptHash)]
x
      MissingRequiredDatums Set DataHash
x Set DataHash
y -> (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
MissingRequiredDatums Word
11 Encode
  'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set DataHash)
-> Encode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set DataHash -> Encode ('Closed 'Dense) (Set DataHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set DataHash
x Encode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set DataHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set DataHash -> Encode ('Closed 'Dense) (Set DataHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set DataHash
y
      NotAllowedSupplementalDatums Set DataHash
x Set DataHash
y -> (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
NotAllowedSupplementalDatums Word
12 Encode
  'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set DataHash)
-> Encode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set DataHash -> Encode ('Closed 'Dense) (Set DataHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set DataHash
x Encode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set DataHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set DataHash -> Encode ('Closed 'Dense) (Set DataHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set DataHash
y
      PPViewHashesDontMatch Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
mm -> (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
 -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open
     (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
      -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
PPViewHashesDontMatch Word
13 Encode
  'Open
  (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
   -> ConwayUtxowPredFailure era)
-> Encode
     ('Closed 'Dense)
     (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash))
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> Encode
     ('Closed 'Dense)
     (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash))
forall t. EncCBORGroup t => t -> Encode ('Closed 'Dense) t
ToGroup Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
mm
      UnspendableUTxONoDatumHash Set TxIn
x -> (Set TxIn -> ConwayUtxowPredFailure era)
-> Word -> Encode 'Open (Set TxIn -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set TxIn -> ConwayUtxowPredFailure era
forall era. Set TxIn -> ConwayUtxowPredFailure era
UnspendableUTxONoDatumHash Word
14 Encode 'Open (Set TxIn -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set TxIn)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set TxIn -> Encode ('Closed 'Dense) (Set TxIn)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set TxIn
x
      ExtraRedeemers [PlutusPurpose AsIx era]
x -> ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
-> Word
-> Encode
     'Open ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
forall era. [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
ExtraRedeemers Word
15 Encode
  'Open ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) [PlutusPurpose AsIx era]
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> [PlutusPurpose AsIx era]
-> Encode ('Closed 'Dense) [PlutusPurpose AsIx era]
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To [PlutusPurpose AsIx era]
x
      MalformedScriptWitnesses Set ScriptHash
x -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedScriptWitnesses Word
16 Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set ScriptHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set ScriptHash -> Encode ('Closed 'Dense) (Set ScriptHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set ScriptHash
x
      MalformedReferenceScripts Set ScriptHash
x -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Word
-> Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Word -> Encode 'Open t
Sum Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedReferenceScripts Word
17 Encode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Encode ('Closed 'Dense) (Set ScriptHash)
-> Encode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Set ScriptHash -> Encode ('Closed 'Dense) (Set ScriptHash)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set ScriptHash
x

instance
  ( ConwayEraScript era
  , DecCBOR (PredicateFailure (EraRule "UTXO" era))
  ) =>
  DecCBOR (ConwayUtxowPredFailure era)
  where
  decCBOR :: forall s. Decoder s (ConwayUtxowPredFailure era)
decCBOR = Decode ('Closed 'Dense) (ConwayUtxowPredFailure era)
-> Decoder s (ConwayUtxowPredFailure era)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode ('Closed 'Dense) (ConwayUtxowPredFailure era)
 -> Decoder s (ConwayUtxowPredFailure era))
-> ((Word -> Decode 'Open (ConwayUtxowPredFailure era))
    -> Decode ('Closed 'Dense) (ConwayUtxowPredFailure era))
-> (Word -> Decode 'Open (ConwayUtxowPredFailure era))
-> Decoder s (ConwayUtxowPredFailure era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text
-> (Word -> Decode 'Open (ConwayUtxowPredFailure era))
-> Decode ('Closed 'Dense) (ConwayUtxowPredFailure era)
forall t.
Text -> (Word -> Decode 'Open t) -> Decode ('Closed 'Dense) t
Summands Text
"ConwayUtxowPred" ((Word -> Decode 'Open (ConwayUtxowPredFailure era))
 -> Decoder s (ConwayUtxowPredFailure era))
-> (Word -> Decode 'Open (ConwayUtxowPredFailure era))
-> Decoder s (ConwayUtxowPredFailure era)
forall a b. (a -> b) -> a -> b
$ \case
    Word
0 -> (PredicateFailure (EraRule "UTXO" era)
 -> ConwayUtxowPredFailure era)
-> Decode
     'Open
     (PredicateFailure (EraRule "UTXO" era)
      -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure Decode
  'Open
  (PredicateFailure (EraRule "UTXO" era)
   -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (PredicateFailure (EraRule "UTXO" era))
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (PredicateFailure (EraRule "UTXO" era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
1 -> ([VKey 'Witness] -> ConwayUtxowPredFailure era)
-> Decode 'Open ([VKey 'Witness] -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD [VKey 'Witness] -> ConwayUtxowPredFailure era
forall era. [VKey 'Witness] -> ConwayUtxowPredFailure era
InvalidWitnessesUTXOW Decode 'Open ([VKey 'Witness] -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) [VKey 'Witness]
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) [VKey 'Witness]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
2 -> (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
-> Decode
     'Open (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
forall era. Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
MissingVKeyWitnessesUTXOW Decode 'Open (Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set (KeyHash 'Witness))
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set (KeyHash 'Witness))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
3 -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MissingScriptWitnessesUTXOW Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set ScriptHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set ScriptHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
4 -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set ScriptHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set ScriptHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
5 -> (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxBodyMetadataHash Decode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) TxAuxDataHash
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) TxAuxDataHash
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
6 -> (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxMetadata Decode 'Open (TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) TxAuxDataHash
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) TxAuxDataHash
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
7 -> (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode
     'Open (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
ConflictingMetadataHash Decode
  'Open (Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Mismatch 'RelEQ TxAuxDataHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Mismatch 'RelEQ TxAuxDataHash)
forall t (w :: Wrapped).
(EncCBORGroup t, DecCBORGroup t) =>
Decode w t
FromGroup
    Word
8 -> ConwayUtxowPredFailure era
-> Decode 'Open (ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD ConwayUtxowPredFailure era
forall era. ConwayUtxowPredFailure era
InvalidMetadata
    Word
9 -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ExtraneousScriptWitnessesUTXOW Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set ScriptHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set ScriptHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
10 -> ([(PlutusPurpose AsItem era, ScriptHash)]
 -> ConwayUtxowPredFailure era)
-> Decode
     'Open
     ([(PlutusPurpose AsItem era, ScriptHash)]
      -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD [(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
forall era.
[(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
MissingRedeemers Decode
  'Open
  ([(PlutusPurpose AsItem era, ScriptHash)]
   -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) [(PlutusPurpose AsItem era, ScriptHash)]
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) [(PlutusPurpose AsItem era, ScriptHash)]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
11 -> (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Decode
     'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
MissingRequiredDatums Decode
  'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set DataHash)
-> Decode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set DataHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set DataHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set DataHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
12 -> (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Decode
     'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
NotAllowedSupplementalDatums Decode
  'Open (Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set DataHash)
-> Decode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set DataHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode 'Open (Set DataHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set DataHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set DataHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
13 -> (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
 -> ConwayUtxowPredFailure era)
-> Decode
     'Open
     (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
      -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
PPViewHashesDontMatch Decode
  'Open
  (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
   -> ConwayUtxowPredFailure era)
-> Decode
     ('Closed Any) (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash))
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode
  ('Closed Any) (Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash))
forall t (w :: Wrapped).
(EncCBORGroup t, DecCBORGroup t) =>
Decode w t
FromGroup
    Word
14 -> (Set TxIn -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set TxIn -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set TxIn -> ConwayUtxowPredFailure era
forall era. Set TxIn -> ConwayUtxowPredFailure era
UnspendableUTxONoDatumHash Decode 'Open (Set TxIn -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set TxIn)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set TxIn)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
15 -> ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
-> Decode
     'Open ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
forall era. [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
ExtraRedeemers Decode
  'Open ([PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) [PlutusPurpose AsIx era]
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) [PlutusPurpose AsIx era]
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
16 -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedScriptWitnesses Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set ScriptHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set ScriptHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
17 -> (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
forall t. t -> Decode 'Open t
SumD Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedReferenceScripts Decode 'Open (Set ScriptHash -> ConwayUtxowPredFailure era)
-> Decode ('Closed Any) (Set ScriptHash)
-> Decode 'Open (ConwayUtxowPredFailure era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Set ScriptHash)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
n -> Word -> Decode 'Open (ConwayUtxowPredFailure era)
forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n

-- =====================================================
-- Injecting from one PredicateFailure to another

babbageToConwayUtxowPredFailure ::
  forall era.
  BabbageUtxowPredFailure era ->
  ConwayUtxowPredFailure era
babbageToConwayUtxowPredFailure :: forall era.
BabbageUtxowPredFailure era -> ConwayUtxowPredFailure era
babbageToConwayUtxowPredFailure = \case
  Babbage.AlonzoInBabbageUtxowPredFailure AlonzoUtxowPredFailure era
x -> AlonzoUtxowPredFailure era -> ConwayUtxowPredFailure era
forall era.
AlonzoUtxowPredFailure era -> ConwayUtxowPredFailure era
alonzoToConwayUtxowPredFailure AlonzoUtxowPredFailure era
x
  Babbage.UtxoFailure PredicateFailure (EraRule "UTXO" era)
x -> PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure PredicateFailure (EraRule "UTXO" era)
x
  Babbage.MalformedScriptWitnesses Set ScriptHash
xs -> Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedScriptWitnesses Set ScriptHash
xs
  Babbage.MalformedReferenceScripts Set ScriptHash
xs -> Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MalformedReferenceScripts Set ScriptHash
xs

alonzoToConwayUtxowPredFailure ::
  forall era.
  AlonzoUtxowPredFailure era ->
  ConwayUtxowPredFailure era
alonzoToConwayUtxowPredFailure :: forall era.
AlonzoUtxowPredFailure era -> ConwayUtxowPredFailure era
alonzoToConwayUtxowPredFailure = \case
  Alonzo.ShelleyInAlonzoUtxowPredFailure ShelleyUtxowPredFailure era
f -> ShelleyUtxowPredFailure era -> ConwayUtxowPredFailure era
forall era.
ShelleyUtxowPredFailure era -> ConwayUtxowPredFailure era
shelleyToConwayUtxowPredFailure ShelleyUtxowPredFailure era
f
  Alonzo.MissingRedeemers [(PlutusPurpose AsItem era, ScriptHash)]
rs -> [(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
forall era.
[(PlutusPurpose AsItem era, ScriptHash)]
-> ConwayUtxowPredFailure era
MissingRedeemers [(PlutusPurpose AsItem era, ScriptHash)]
rs
  Alonzo.MissingRequiredDatums Set DataHash
mds Set DataHash
rds -> Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
MissingRequiredDatums Set DataHash
mds Set DataHash
rds
  Alonzo.NotAllowedSupplementalDatums Set DataHash
uds Set DataHash
ads -> Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
forall era.
Set DataHash -> Set DataHash -> ConwayUtxowPredFailure era
NotAllowedSupplementalDatums Set DataHash
uds Set DataHash
ads
  Alonzo.PPViewHashesDontMatch Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
m -> Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
-> ConwayUtxowPredFailure era
PPViewHashesDontMatch Mismatch 'RelEQ (StrictMaybe ScriptIntegrityHash)
m
  Alonzo.MissingRequiredSigners Set (KeyHash 'Witness)
_xs ->
    String -> ConwayUtxowPredFailure era
forall a. HasCallStack => String -> a
error String
"Impossible case. It will be removed once we are in Conway. See #3972"
  Alonzo.UnspendableUTxONoDatumHash Set TxIn
ins -> Set TxIn -> ConwayUtxowPredFailure era
forall era. Set TxIn -> ConwayUtxowPredFailure era
UnspendableUTxONoDatumHash Set TxIn
ins
  Alonzo.ExtraRedeemers [PlutusPurpose AsIx era]
xs -> [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
forall era. [PlutusPurpose AsIx era] -> ConwayUtxowPredFailure era
ExtraRedeemers [PlutusPurpose AsIx era]
xs

shelleyToConwayUtxowPredFailure :: ShelleyUtxowPredFailure era -> ConwayUtxowPredFailure era
shelleyToConwayUtxowPredFailure :: forall era.
ShelleyUtxowPredFailure era -> ConwayUtxowPredFailure era
shelleyToConwayUtxowPredFailure = \case
  Shelley.InvalidWitnessesUTXOW [VKey 'Witness]
xs -> [VKey 'Witness] -> ConwayUtxowPredFailure era
forall era. [VKey 'Witness] -> ConwayUtxowPredFailure era
InvalidWitnessesUTXOW [VKey 'Witness]
xs
  Shelley.MissingVKeyWitnessesUTXOW Set (KeyHash 'Witness)
xs -> Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
forall era. Set (KeyHash 'Witness) -> ConwayUtxowPredFailure era
MissingVKeyWitnessesUTXOW Set (KeyHash 'Witness)
xs
  Shelley.MissingScriptWitnessesUTXOW Set ScriptHash
xs -> Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
MissingScriptWitnessesUTXOW Set ScriptHash
xs
  Shelley.ScriptWitnessNotValidatingUTXOW Set ScriptHash
xs -> Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ScriptWitnessNotValidatingUTXOW Set ScriptHash
xs
  Shelley.UtxoFailure PredicateFailure (EraRule "UTXO" era)
x -> PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
forall era.
PredicateFailure (EraRule "UTXO" era) -> ConwayUtxowPredFailure era
UtxoFailure PredicateFailure (EraRule "UTXO" era)
x
  Shelley.MIRInsufficientGenesisSigsUTXOW Set (KeyHash 'Witness)
_xs ->
    String -> ConwayUtxowPredFailure era
forall a. HasCallStack => String -> a
error String
"Impossible: MIR has been removed in Conway"
  Shelley.MissingTxBodyMetadataHash TxAuxDataHash
x -> TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxBodyMetadataHash TxAuxDataHash
x
  Shelley.MissingTxMetadata TxAuxDataHash
x -> TxAuxDataHash -> ConwayUtxowPredFailure era
forall era. TxAuxDataHash -> ConwayUtxowPredFailure era
MissingTxMetadata TxAuxDataHash
x
  Shelley.ConflictingMetadataHash Mismatch 'RelEQ TxAuxDataHash
mm -> Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
forall era.
Mismatch 'RelEQ TxAuxDataHash -> ConwayUtxowPredFailure era
ConflictingMetadataHash Mismatch 'RelEQ TxAuxDataHash
mm
  ShelleyUtxowPredFailure era
Shelley.InvalidMetadata -> ConwayUtxowPredFailure era
forall era. ConwayUtxowPredFailure era
InvalidMetadata
  Shelley.ExtraneousScriptWitnessesUTXOW Set ScriptHash
xs -> Set ScriptHash -> ConwayUtxowPredFailure era
forall era. Set ScriptHash -> ConwayUtxowPredFailure era
ExtraneousScriptWitnessesUTXOW Set ScriptHash
xs