{-# LANGUAGE DataKinds #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} module Cardano.Ledger.Dijkstra (DijkstraEra, ApplyTxError (..)) where import Cardano.Ledger.BaseTypes (Inject (inject)) import Cardano.Ledger.Binary (DecCBOR, EncCBOR) import Cardano.Ledger.Conway.Governance (RunConwayRatify) import Cardano.Ledger.Dijkstra.BlockBody () import Cardano.Ledger.Dijkstra.Era import Cardano.Ledger.Dijkstra.Genesis () import Cardano.Ledger.Dijkstra.Governance () import Cardano.Ledger.Dijkstra.Rules ( DijkstraLedgerPredFailure, DijkstraMempoolPredFailure (LedgerFailure), ) import Cardano.Ledger.Dijkstra.Scripts () import Cardano.Ledger.Dijkstra.State.CertState () import Cardano.Ledger.Dijkstra.State.Stake () import Cardano.Ledger.Dijkstra.Transition () import Cardano.Ledger.Dijkstra.Translation () import Cardano.Ledger.Dijkstra.Tx () import Cardano.Ledger.Dijkstra.TxBody () import Cardano.Ledger.Dijkstra.TxInfo () import Cardano.Ledger.Dijkstra.TxWits () import Cardano.Ledger.Dijkstra.UTxO () import Cardano.Ledger.Shelley.API (ApplyBlock, ApplyTx (..), ruleApplyTxValidation) import Data.Bifunctor (Bifunctor (first)) import Data.List.NonEmpty (NonEmpty) import GHC.Generics (Generic) instance ApplyTx DijkstraEra where newtype ApplyTxError DijkstraEra = DijkstraApplyTxError (NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) deriving (ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool (ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool) -> (ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool) -> Eq (ApplyTxError DijkstraEra) forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool == :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool $c/= :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool /= :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> Bool Eq, Int -> ApplyTxError DijkstraEra -> ShowS [ApplyTxError DijkstraEra] -> ShowS ApplyTxError DijkstraEra -> String (Int -> ApplyTxError DijkstraEra -> ShowS) -> (ApplyTxError DijkstraEra -> String) -> ([ApplyTxError DijkstraEra] -> ShowS) -> Show (ApplyTxError DijkstraEra) forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ApplyTxError DijkstraEra -> ShowS showsPrec :: Int -> ApplyTxError DijkstraEra -> ShowS $cshow :: ApplyTxError DijkstraEra -> String show :: ApplyTxError DijkstraEra -> String $cshowList :: [ApplyTxError DijkstraEra] -> ShowS showList :: [ApplyTxError DijkstraEra] -> ShowS Show) deriving newtype (ApplyTxError DijkstraEra -> Encoding (ApplyTxError DijkstraEra -> Encoding) -> EncCBOR (ApplyTxError DijkstraEra) forall a. (a -> Encoding) -> EncCBOR a $cencCBOR :: ApplyTxError DijkstraEra -> Encoding encCBOR :: ApplyTxError DijkstraEra -> Encoding EncCBOR, Typeable (ApplyTxError DijkstraEra) Typeable (ApplyTxError DijkstraEra) => (forall s. Decoder s (ApplyTxError DijkstraEra)) -> (forall s. Proxy (ApplyTxError DijkstraEra) -> Decoder s ()) -> (Proxy (ApplyTxError DijkstraEra) -> Text) -> DecCBOR (ApplyTxError DijkstraEra) Proxy (ApplyTxError DijkstraEra) -> Text forall s. Decoder s (ApplyTxError DijkstraEra) forall a. Typeable a => (forall s. Decoder s a) -> (forall s. Proxy a -> Decoder s ()) -> (Proxy a -> Text) -> DecCBOR a forall s. Proxy (ApplyTxError DijkstraEra) -> Decoder s () $cdecCBOR :: forall s. Decoder s (ApplyTxError DijkstraEra) decCBOR :: forall s. Decoder s (ApplyTxError DijkstraEra) $cdropCBOR :: forall s. Proxy (ApplyTxError DijkstraEra) -> Decoder s () dropCBOR :: forall s. Proxy (ApplyTxError DijkstraEra) -> Decoder s () $clabel :: Proxy (ApplyTxError DijkstraEra) -> Text label :: Proxy (ApplyTxError DijkstraEra) -> Text DecCBOR, NonEmpty (ApplyTxError DijkstraEra) -> ApplyTxError DijkstraEra ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra (ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra) -> (NonEmpty (ApplyTxError DijkstraEra) -> ApplyTxError DijkstraEra) -> (forall b. Integral b => b -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra) -> Semigroup (ApplyTxError DijkstraEra) forall b. Integral b => b -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra forall a. (a -> a -> a) -> (NonEmpty a -> a) -> (forall b. Integral b => b -> a -> a) -> Semigroup a $c<> :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra <> :: ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra $csconcat :: NonEmpty (ApplyTxError DijkstraEra) -> ApplyTxError DijkstraEra sconcat :: NonEmpty (ApplyTxError DijkstraEra) -> ApplyTxError DijkstraEra $cstimes :: forall b. Integral b => b -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra stimes :: forall b. Integral b => b -> ApplyTxError DijkstraEra -> ApplyTxError DijkstraEra Semigroup, (forall x. ApplyTxError DijkstraEra -> Rep (ApplyTxError DijkstraEra) x) -> (forall x. Rep (ApplyTxError DijkstraEra) x -> ApplyTxError DijkstraEra) -> Generic (ApplyTxError DijkstraEra) forall x. Rep (ApplyTxError DijkstraEra) x -> ApplyTxError DijkstraEra forall x. ApplyTxError DijkstraEra -> Rep (ApplyTxError DijkstraEra) x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cfrom :: forall x. ApplyTxError DijkstraEra -> Rep (ApplyTxError DijkstraEra) x from :: forall x. ApplyTxError DijkstraEra -> Rep (ApplyTxError DijkstraEra) x $cto :: forall x. Rep (ApplyTxError DijkstraEra) x -> ApplyTxError DijkstraEra to :: forall x. Rep (ApplyTxError DijkstraEra) x -> ApplyTxError DijkstraEra Generic) applyTxValidation :: ValidationPolicy -> Globals -> MempoolEnv DijkstraEra -> MempoolState DijkstraEra -> Tx TopTx DijkstraEra -> Either (ApplyTxError DijkstraEra) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) applyTxValidation ValidationPolicy validationPolicy Globals globals MempoolEnv DijkstraEra env MempoolState DijkstraEra state Tx TopTx DijkstraEra tx = (NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra) -> Either (NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) -> Either (ApplyTxError DijkstraEra) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) forall a b c. (a -> b) -> Either a c -> Either b c forall (p :: * -> * -> *) a b c. Bifunctor p => (a -> b) -> p a c -> p b c first NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra DijkstraApplyTxError (Either (NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) -> Either (ApplyTxError DijkstraEra) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra))) -> Either (NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) -> Either (ApplyTxError DijkstraEra) (MempoolState DijkstraEra, Validated (Tx TopTx DijkstraEra)) forall a b. (a -> b) -> a -> b $ forall (rule :: Symbol) era. (STS (EraRule rule era), BaseM (EraRule rule era) ~ ShelleyBase, Environment (EraRule rule era) ~ LedgerEnv era, State (EraRule rule era) ~ MempoolState era, Signal (EraRule rule era) ~ Tx TopTx era) => ValidationPolicy -> Globals -> LedgerEnv era -> MempoolState era -> Tx TopTx era -> Either (NonEmpty (PredicateFailure (EraRule rule era))) (MempoolState era, Validated (Tx TopTx era)) ruleApplyTxValidation @"MEMPOOL" ValidationPolicy validationPolicy Globals globals MempoolEnv DijkstraEra env MempoolState DijkstraEra state Tx TopTx DijkstraEra tx instance ApplyBlock DijkstraEra instance RunConwayRatify DijkstraEra instance Inject (NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) (ApplyTxError DijkstraEra) where inject :: NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra inject = NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra DijkstraApplyTxError instance Inject (NonEmpty (DijkstraLedgerPredFailure DijkstraEra)) (ApplyTxError DijkstraEra) where inject :: NonEmpty (DijkstraLedgerPredFailure DijkstraEra) -> ApplyTxError DijkstraEra inject = NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra DijkstraApplyTxError (NonEmpty (DijkstraMempoolPredFailure DijkstraEra) -> ApplyTxError DijkstraEra) -> (NonEmpty (DijkstraLedgerPredFailure DijkstraEra) -> NonEmpty (DijkstraMempoolPredFailure DijkstraEra)) -> NonEmpty (DijkstraLedgerPredFailure DijkstraEra) -> ApplyTxError DijkstraEra forall b c a. (b -> c) -> (a -> b) -> a -> c . (DijkstraLedgerPredFailure DijkstraEra -> DijkstraMempoolPredFailure DijkstraEra) -> NonEmpty (DijkstraLedgerPredFailure DijkstraEra) -> NonEmpty (DijkstraMempoolPredFailure DijkstraEra) forall a b. (a -> b) -> NonEmpty a -> NonEmpty b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap PredicateFailure (EraRule "LEDGER" DijkstraEra) -> DijkstraMempoolPredFailure DijkstraEra DijkstraLedgerPredFailure DijkstraEra -> DijkstraMempoolPredFailure DijkstraEra forall era. PredicateFailure (EraRule "LEDGER" era) -> DijkstraMempoolPredFailure era LedgerFailure