{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}

-- | Transactions in the context of a consensus mode, and other types used in
-- the transaction submission protocol.
--
module Cardano.Api.InMode (

    -- * Transaction in a consensus mode
    TxInMode(..),
    fromConsensusGenTx,
    toConsensusGenTx,

    -- * Transaction id in a consensus mode
    TxIdInMode(..),
    toConsensusTxId,

    -- * Transaction validation errors
    TxValidationError(..),
    TxValidationErrorInMode(..),
    fromConsensusApplyTxErr,
  ) where

import           Prelude

import           Data.SOP.Strict (NS (S, Z))

import qualified Ouroboros.Consensus.Byron.Ledger as Consensus
import qualified Ouroboros.Consensus.Cardano.Block as Consensus
import qualified Ouroboros.Consensus.HardFork.Combinator as Consensus
import           Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch)
import qualified Ouroboros.Consensus.HardFork.Combinator.Degenerate as Consensus
import qualified Ouroboros.Consensus.Ledger.SupportsMempool as Consensus
import qualified Ouroboros.Consensus.Ledger.SupportsProtocol as Consensus
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
import qualified Ouroboros.Consensus.Shelley.HFEras as Consensus
import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus
import qualified Ouroboros.Consensus.TypeFamilyWrappers as Consensus

import           Cardano.Api.Eras
import           Cardano.Api.Modes
import           Cardano.Api.Tx
import           Cardano.Api.TxBody


-- ----------------------------------------------------------------------------
-- Transactions in the context of a consensus mode
--

-- | A 'Tx' in one of the eras supported by a given protocol mode.
--
-- For multi-era modes such as the 'CardanoMode' this type is a sum of the
-- different transaction types for all the eras. It is used in the
-- LocalTxSubmission protocol.
--
data TxInMode mode where

     -- | Everything we consider a normal transaction.
     --
     TxInMode :: Tx era -> EraInMode era mode -> TxInMode mode

     -- | Byron has various things we can post to the chain which are not
     -- actually transactions. This covers: update proposals, votes and
     -- delegation certs.
     --
     TxInByronSpecial :: Consensus.GenTx Consensus.ByronBlock
                      -> EraInMode ByronEra mode -> TxInMode mode

deriving instance Show (TxInMode mode)

fromConsensusGenTx
  :: ConsensusBlockForMode mode ~ block
  => ConsensusMode mode -> Consensus.GenTx block -> TxInMode mode
fromConsensusGenTx :: ConsensusMode mode -> GenTx block -> TxInMode mode
fromConsensusGenTx ConsensusMode mode
ByronMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (Z tx'))) =
  GenTx ByronBlock
-> EraInMode ByronEra ByronMode -> TxInMode ByronMode
forall mode.
GenTx ByronBlock -> EraInMode ByronEra mode -> TxInMode mode
TxInByronSpecial GenTx x
GenTx ByronBlock
tx' EraInMode ByronEra ByronMode
ByronEraInByronMode

fromConsensusGenTx ConsensusMode mode
ShelleyMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (Z tx'))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx'
  in Tx ShelleyEra
-> EraInMode ShelleyEra ShelleyMode -> TxInMode ShelleyMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra ShelleyEra
-> Tx (ShelleyLedgerEra ShelleyEra) -> Tx ShelleyEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley Tx StandardShelley
Tx (ShelleyLedgerEra ShelleyEra)
shelleyEraTx) EraInMode ShelleyEra ShelleyMode
ShelleyEraInShelleyMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (Z tx'))) =
  GenTx ByronBlock
-> EraInMode ByronEra CardanoMode -> TxInMode CardanoMode
forall mode.
GenTx ByronBlock -> EraInMode ByronEra mode -> TxInMode mode
TxInByronSpecial GenTx x
GenTx ByronBlock
tx' EraInMode ByronEra CardanoMode
ByronEraInCardanoMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (Z tx')))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx'
  in Tx ShelleyEra
-> EraInMode ShelleyEra CardanoMode -> TxInMode CardanoMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra ShelleyEra
-> Tx (ShelleyLedgerEra ShelleyEra) -> Tx ShelleyEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley Tx StandardShelley
Tx (ShelleyLedgerEra ShelleyEra)
shelleyEraTx) EraInMode ShelleyEra CardanoMode
ShelleyEraInCardanoMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (Z tx'))))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
tx'
  in Tx AllegraEra
-> EraInMode AllegraEra CardanoMode -> TxInMode CardanoMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra AllegraEra
-> Tx (ShelleyLedgerEra AllegraEra) -> Tx AllegraEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra AllegraEra
ShelleyBasedEraAllegra Tx (AllegraEra StandardCrypto)
Tx (ShelleyLedgerEra AllegraEra)
shelleyEraTx) EraInMode AllegraEra CardanoMode
AllegraEraInCardanoMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (Z tx')))))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
tx'
  in Tx MaryEra -> EraInMode MaryEra CardanoMode -> TxInMode CardanoMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra MaryEra
-> Tx (ShelleyLedgerEra MaryEra) -> Tx MaryEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra MaryEra
ShelleyBasedEraMary Tx (MaryEra StandardCrypto)
Tx (ShelleyLedgerEra MaryEra)
shelleyEraTx) EraInMode MaryEra CardanoMode
MaryEraInCardanoMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (Z tx'))))))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
tx'
  in Tx AlonzoEra
-> EraInMode AlonzoEra CardanoMode -> TxInMode CardanoMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra AlonzoEra
-> Tx (ShelleyLedgerEra AlonzoEra) -> Tx AlonzoEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra AlonzoEra
ShelleyBasedEraAlonzo Tx (AlonzoEra StandardCrypto)
Tx (ShelleyLedgerEra AlonzoEra)
shelleyEraTx) EraInMode AlonzoEra CardanoMode
AlonzoEraInCardanoMode

fromConsensusGenTx ConsensusMode mode
CardanoMode (Consensus.HardForkGenTx (Consensus.OneEraGenTx (S (S (S (S (S (Z tx')))))))) =
  let Consensus.ShelleyTx _txid shelleyEraTx = GenTx x
GenTx
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
tx'
  in Tx BabbageEra
-> EraInMode BabbageEra CardanoMode -> TxInMode CardanoMode
forall era mode. Tx era -> EraInMode era mode -> TxInMode mode
TxInMode (ShelleyBasedEra BabbageEra
-> Tx (ShelleyLedgerEra BabbageEra) -> Tx BabbageEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
ShelleyTx ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage Tx (BabbageEra StandardCrypto)
Tx (ShelleyLedgerEra BabbageEra)
shelleyEraTx) EraInMode BabbageEra CardanoMode
BabbageEraInCardanoMode

toConsensusGenTx :: ConsensusBlockForMode mode ~ block
                 => TxInMode mode
                 -> Consensus.GenTx block
toConsensusGenTx :: TxInMode mode -> GenTx block
toConsensusGenTx (TxInMode (ByronTx ATxAux ByteString
tx) EraInMode era mode
ByronEraInByronMode) =
    OneEraGenTx '[ByronBlock] -> GenTx (HardForkBlock '[ByronBlock])
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx '[ByronBlock] -> OneEraGenTx '[ByronBlock]
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (GenTx ByronBlock -> NS GenTx '[ByronBlock]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx ByronBlock
tx'))
  where
    tx' :: GenTx ByronBlock
tx' = TxId -> ATxAux ByteString -> GenTx ByronBlock
Consensus.ByronTx (ATxAux ByteString -> TxId
Consensus.byronIdTx ATxAux ByteString
tx) ATxAux ByteString
tx

toConsensusGenTx (TxInMode (ByronTx ATxAux ByteString
tx) EraInMode era mode
ByronEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (GenTx ByronBlock
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx ByronBlock
tx'))
  where
    tx' :: GenTx ByronBlock
tx' = TxId -> ATxAux ByteString -> GenTx ByronBlock
Consensus.ByronTx (ATxAux ByteString -> TxId
Consensus.byronIdTx ATxAux ByteString
tx) ATxAux ByteString
tx
    --TODO: add the above as mkByronTx to the consensus code,
    -- matching mkShelleyTx below

toConsensusGenTx (TxInByronSpecial GenTx ByronBlock
gtx EraInMode ByronEra mode
ByronEraInByronMode) =
    OneEraGenTx '[ByronBlock] -> GenTx (HardForkBlock '[ByronBlock])
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx '[ByronBlock] -> OneEraGenTx '[ByronBlock]
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (GenTx ByronBlock -> NS GenTx '[ByronBlock]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx ByronBlock
gtx))

toConsensusGenTx (TxInByronSpecial GenTx ByronBlock
gtx EraInMode ByronEra mode
ByronEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (GenTx ByronBlock
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx ByronBlock
gtx))

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
ShelleyEraInShelleyMode) =
    OneEraGenTx '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> GenTx
     (HardForkBlock
        '[ShelleyBlock (TPraos StandardCrypto) StandardShelley])
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> OneEraGenTx
     '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> NS GenTx '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx'))
  where
    tx' :: GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx' = Tx StandardShelley
-> GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx StandardShelley
Tx (ShelleyLedgerEra era)
tx

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
ShelleyEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (NS GenTx (CardanoShelleyEras StandardCrypto)
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> NS GenTx (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx')))
  where
    tx' :: GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
tx' = Tx StandardShelley
-> GenTx (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx StandardShelley
Tx (ShelleyLedgerEra era)
tx

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
AllegraEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (NS GenTx (CardanoShelleyEras StandardCrypto)
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS GenTx (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
tx'))))
  where
    tx' :: GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
tx' = Tx (AllegraEra StandardCrypto)
-> GenTx
     (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx (AllegraEra StandardCrypto)
Tx (ShelleyLedgerEra era)
tx

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
MaryEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (NS GenTx (CardanoShelleyEras StandardCrypto)
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS GenTx (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (GenTx
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
tx')))))
  where
    tx' :: GenTx
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
tx' = Tx (MaryEra StandardCrypto)
-> GenTx
     (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx (MaryEra StandardCrypto)
Tx (ShelleyLedgerEra era)
tx

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
AlonzoEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (NS GenTx (CardanoShelleyEras StandardCrypto)
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS GenTx (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
tx'))))))
  where
    tx' :: GenTx
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
tx' = Tx (AlonzoEra StandardCrypto)
-> GenTx
     (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx (AlonzoEra StandardCrypto)
Tx (ShelleyLedgerEra era)
tx

toConsensusGenTx (TxInMode (ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
tx) EraInMode era mode
BabbageEraInCardanoMode) =
    OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> GenTx
     (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))
forall (xs :: [*]). OneEraGenTx xs -> GenTx (HardForkBlock xs)
Consensus.HardForkGenTx (NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS GenTx xs -> OneEraGenTx xs
Consensus.OneEraGenTx (NS GenTx (CardanoShelleyEras StandardCrypto)
-> NS GenTx (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS GenTx (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  GenTx
  '[ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     GenTx
     '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (GenTx
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
-> NS
     GenTx
     '[ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z GenTx
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
tx')))))))
  where
    tx' :: GenTx
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
tx' = Tx (BabbageEra StandardCrypto)
-> GenTx
     (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
forall era proto.
ShelleyBasedEra era =>
Tx era -> GenTx (ShelleyBlock proto era)
Consensus.mkShelleyTx Tx (BabbageEra StandardCrypto)
Tx (ShelleyLedgerEra era)
tx

-- ----------------------------------------------------------------------------
-- Transaction ids in the context of a consensus mode
--

-- | A 'TxId' in one of the eras supported by a given protocol mode.
--
-- For multi-era modes such as the 'CardanoMode' this type is a sum of the
-- different transaction types for all the eras. It is used in the
-- LocalTxMonitoring protocol.
--

data TxIdInMode mode where
  TxIdInMode :: TxId -> EraInMode era mode -> TxIdInMode mode

toConsensusTxId
  :: ConsensusBlockForMode mode ~ block
  => TxIdInMode mode -> Consensus.TxId  (Consensus.GenTx block)
toConsensusTxId :: TxIdInMode mode -> TxId (GenTx block)
toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
ByronEraInByronMode) =
  OneEraGenTxId '[ByronBlock]
-> TxId (GenTx (HardForkBlock '[ByronBlock]))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (OneEraGenTxId '[ByronBlock]
 -> TxId (GenTx (HardForkBlock '[ByronBlock])))
-> (WrapGenTxId ByronBlock -> OneEraGenTxId '[ByronBlock])
-> WrapGenTxId ByronBlock
-> TxId (GenTx (HardForkBlock '[ByronBlock]))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NS WrapGenTxId '[ByronBlock] -> OneEraGenTxId '[ByronBlock]
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId '[ByronBlock] -> OneEraGenTxId '[ByronBlock])
-> (WrapGenTxId ByronBlock -> NS WrapGenTxId '[ByronBlock])
-> WrapGenTxId ByronBlock
-> OneEraGenTxId '[ByronBlock]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrapGenTxId ByronBlock -> NS WrapGenTxId '[ByronBlock]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (WrapGenTxId ByronBlock
 -> TxId (GenTx (HardForkBlock '[ByronBlock])))
-> WrapGenTxId ByronBlock
-> TxId (GenTx (HardForkBlock '[ByronBlock]))
forall a b. (a -> b) -> a -> b
$ GenTxId ByronBlock -> WrapGenTxId ByronBlock
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId ByronBlock
txid'
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.ByronBlock)
  txid' :: GenTxId ByronBlock
txid' = TxId -> GenTxId ByronBlock
Consensus.ByronTxId (TxId -> GenTxId ByronBlock) -> TxId -> GenTxId ByronBlock
forall a b. (a -> b) -> a -> b
$ TxId -> TxId
toByronTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
t EraInMode era mode
ShelleyEraInShelleyMode) =
    OneEraGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> TxId
     (GenTx
        (HardForkBlock
           '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (OneEraGenTxId
   '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
 -> TxId
      (GenTx
         (HardForkBlock
            '[ShelleyBlock (TPraos StandardCrypto) StandardShelley])))
-> OneEraGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> TxId
     (GenTx
        (HardForkBlock
           '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]))
forall a b. (a -> b) -> a -> b
$ NS
  WrapGenTxId '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> OneEraGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId  (NS
   WrapGenTxId '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
 -> OneEraGenTxId
      '[ShelleyBlock (TPraos StandardCrypto) StandardShelley])
-> NS
     WrapGenTxId '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
-> OneEraGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
forall a b. (a -> b) -> a -> b
$ WrapGenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> NS
     WrapGenTxId '[ShelleyBlock (TPraos StandardCrypto) StandardShelley]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z  (GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> WrapGenTxId
     (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
txid')
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardShelleyBlock)
  txid' :: GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
txid' = TxId (EraCrypto StandardShelley)
-> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto StandardShelley)
 -> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley))
-> TxId (EraCrypto StandardShelley)
-> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
t

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
ByronEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
 -> TxId
      (GenTx
         (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))))
-> (WrapGenTxId ByronBlock
    -> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto))
-> WrapGenTxId ByronBlock
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
 -> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto))
-> (WrapGenTxId ByronBlock
    -> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto))
-> WrapGenTxId ByronBlock
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrapGenTxId ByronBlock
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (WrapGenTxId ByronBlock
 -> TxId
      (GenTx
         (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto))))
-> WrapGenTxId ByronBlock
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall a b. (a -> b) -> a -> b
$ GenTxId ByronBlock -> WrapGenTxId ByronBlock
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId ByronBlock
txid'
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.ByronBlock)
  txid' :: GenTxId ByronBlock
txid' = TxId -> GenTxId ByronBlock
Consensus.ByronTxId (TxId -> GenTxId ByronBlock) -> TxId -> GenTxId ByronBlock
forall a b. (a -> b) -> a -> b
$ TxId -> TxId
toByronTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
ShelleyEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (WrapGenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
-> WrapGenTxId
     (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
txid'))))
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardShelleyBlock)
  txid' :: GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
txid' = TxId (EraCrypto StandardShelley)
-> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto StandardShelley)
 -> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley))
-> TxId (EraCrypto StandardShelley)
-> GenTxId (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
AllegraEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (WrapGenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
-> WrapGenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
txid')))))
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardAllegraBlock)
  txid' :: GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
txid' = TxId (EraCrypto (AllegraEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto (AllegraEra StandardCrypto))
 -> GenTxId
      (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto)))
-> TxId (EraCrypto (AllegraEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
MaryEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (WrapGenTxId
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
-> WrapGenTxId
     (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
txid'))))))
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardMaryBlock)
  txid' :: GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
txid' = TxId (EraCrypto (MaryEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto (MaryEra StandardCrypto))
 -> GenTxId
      (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto)))
-> TxId (EraCrypto (MaryEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
AlonzoEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (WrapGenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
-> WrapGenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
txid')))))))
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardAlonzoBlock)
  txid' :: GenTxId
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
txid' = TxId (EraCrypto (AlonzoEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto (AlonzoEra StandardCrypto))
 -> GenTxId
      (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto)))
-> TxId (EraCrypto (AlonzoEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
txid

toConsensusTxId (TxIdInMode TxId
txid EraInMode era mode
BabbageEraInCardanoMode) =
  OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> TxId
     (GenTx
        (HardForkBlock (ByronBlock : CardanoShelleyEras StandardCrypto)))
forall (xs :: [*]).
OneEraGenTxId xs -> TxId (GenTx (HardForkBlock xs))
Consensus.HardForkGenTxId (NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
-> OneEraGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall (xs :: [*]). NS WrapGenTxId xs -> OneEraGenTxId xs
Consensus.OneEraGenTxId (NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
-> NS WrapGenTxId (ByronBlock : CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS WrapGenTxId (CardanoShelleyEras StandardCrypto)
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
    ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
    ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto),
       ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (NS
  WrapGenTxId
  '[ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
-> NS
     WrapGenTxId
     '[ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto),
       ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (xs :: [k]) (x :: k).
NS a xs -> NS a (x : xs)
S (WrapGenTxId
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
-> NS
     WrapGenTxId
     '[ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)]
forall k (a :: k -> *) (x :: k) (xs :: [k]). a x -> NS a (x : xs)
Z (GenTxId
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
-> WrapGenTxId
     (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
forall blk. GenTxId blk -> WrapGenTxId blk
Consensus.WrapGenTxId GenTxId
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
txid'))))))))
 where
  txid' :: Consensus.TxId (Consensus.GenTx Consensus.StandardBabbageBlock)
  txid' :: GenTxId
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
txid' = TxId (EraCrypto (BabbageEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
forall proto era.
TxId (EraCrypto era) -> TxId (GenTx (ShelleyBlock proto era))
Consensus.ShelleyTxId (TxId (EraCrypto (BabbageEra StandardCrypto))
 -> GenTxId
      (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto)))
-> TxId (EraCrypto (BabbageEra StandardCrypto))
-> GenTxId
     (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
forall a b. (a -> b) -> a -> b
$ TxId -> TxId StandardCrypto
toShelleyTxId TxId
txid

-- ----------------------------------------------------------------------------
-- Transaction validation errors in the context of eras and consensus modes
--

-- | The transaction validations errors that can occur from trying to submit a
-- transaction to a local node. The errors are specific to an era.
--
data TxValidationError era where

     ByronTxValidationError
       :: Consensus.ApplyTxErr Consensus.ByronBlock
       -> TxValidationError ByronEra

     ShelleyTxValidationError
       :: ShelleyBasedEra era
       -> Consensus.ApplyTxErr (Consensus.ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
       -> TxValidationError era

-- The GADT in the ShelleyTxValidationError case requires a custom instance
instance Show (TxValidationError era) where
    showsPrec :: Int -> TxValidationError era -> ShowS
showsPrec Int
p (ByronTxValidationError ApplyTxErr ByronBlock
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ByronTxValidationError "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyMempoolPayloadErr -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxErr ByronBlock
ApplyMempoolPayloadErr
err
        )

    showsPrec Int
p (ShelleyTxValidationError ShelleyBasedEra era
ShelleyBasedEraShelley ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ShelleyTxValidationError ShelleyBasedEraShelley "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyTxError StandardShelley -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxError StandardShelley
ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err
        )

    showsPrec Int
p (ShelleyTxValidationError ShelleyBasedEra era
ShelleyBasedEraAllegra ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ShelleyTxValidationError ShelleyBasedEraAllegra "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyTxError (AllegraEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxError (AllegraEra StandardCrypto)
ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err
        )

    showsPrec Int
p (ShelleyTxValidationError ShelleyBasedEra era
ShelleyBasedEraMary ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ShelleyTxValidationError ShelleyBasedEraMary "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyTxError (MaryEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxError (MaryEra StandardCrypto)
ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err
        )

    showsPrec Int
p (ShelleyTxValidationError ShelleyBasedEra era
ShelleyBasedEraAlonzo ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ShelleyTxValidationError ShelleyBasedEraAlonzo "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyTxError (AlonzoEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxError (AlonzoEra StandardCrypto)
ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err
        )

    showsPrec Int
p (ShelleyTxValidationError ShelleyBasedEra era
ShelleyBasedEraBabbage ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err) =
      Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11)
        ( String -> ShowS
showString String
"ShelleyTxValidationError ShelleyBasedEraBabbage "
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ApplyTxError (BabbageEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ApplyTxError (BabbageEra StandardCrypto)
ApplyTxErr
  (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
err
        )

-- | A 'TxValidationError' in one of the eras supported by a given protocol
-- mode.
--
-- This is used in the LocalStateQuery protocol.
--
data TxValidationErrorInMode mode where
     TxValidationErrorInMode :: TxValidationError era
                             -> EraInMode era mode
                             -> TxValidationErrorInMode mode

     TxValidationEraMismatch :: EraMismatch
                             -> TxValidationErrorInMode mode

deriving instance Show (TxValidationErrorInMode mode)


fromConsensusApplyTxErr :: ConsensusBlockForMode mode ~ block
                        => Consensus.LedgerSupportsProtocol
                             (Consensus.ShelleyBlock
                             (TPraos.TPraos Consensus.StandardCrypto)
                             (Consensus.ShelleyEra Consensus.StandardCrypto))
                        => ConsensusMode mode
                        -> Consensus.ApplyTxErr block
                        -> TxValidationErrorInMode mode
fromConsensusApplyTxErr :: ConsensusMode mode
-> ApplyTxErr block -> TxValidationErrorInMode mode
fromConsensusApplyTxErr ConsensusMode mode
ByronMode (Consensus.DegenApplyTxErr err) =
    TxValidationError ByronEra
-> EraInMode ByronEra ByronMode
-> TxValidationErrorInMode ByronMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ApplyTxErr ByronBlock -> TxValidationError ByronEra
ByronTxValidationError ApplyTxErr ByronBlock
err)
      EraInMode ByronEra ByronMode
ByronEraInByronMode

fromConsensusApplyTxErr ConsensusMode mode
ShelleyMode (Consensus.DegenApplyTxErr err) =
    TxValidationError ShelleyEra
-> EraInMode ShelleyEra ShelleyMode
-> TxValidationErrorInMode ShelleyMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra ShelleyEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol ShelleyEra) (ShelleyLedgerEra ShelleyEra))
-> TxValidationError ShelleyEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley ApplyTxErr (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol ShelleyEra) (ShelleyLedgerEra ShelleyEra))
err)
      EraInMode ShelleyEra ShelleyMode
ShelleyEraInShelleyMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrByron err) =
    TxValidationError ByronEra
-> EraInMode ByronEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ApplyTxErr ByronBlock -> TxValidationError ByronEra
ByronTxValidationError ApplyTxErr ByronBlock
err)
      EraInMode ByronEra CardanoMode
ByronEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrShelley err) =
    TxValidationError ShelleyEra
-> EraInMode ShelleyEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra ShelleyEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol ShelleyEra) (ShelleyLedgerEra ShelleyEra))
-> TxValidationError ShelleyEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra ShelleyEra
ShelleyBasedEraShelley ApplyTxErr (ShelleyBlock (TPraos StandardCrypto) StandardShelley)
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol ShelleyEra) (ShelleyLedgerEra ShelleyEra))
err)
      EraInMode ShelleyEra CardanoMode
ShelleyEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrAllegra err) =
    TxValidationError AllegraEra
-> EraInMode AllegraEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra AllegraEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol AllegraEra) (ShelleyLedgerEra AllegraEra))
-> TxValidationError AllegraEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra AllegraEra
ShelleyBasedEraAllegra ApplyTxErr
  (ShelleyBlock (TPraos StandardCrypto) (AllegraEra StandardCrypto))
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol AllegraEra) (ShelleyLedgerEra AllegraEra))
err)
      EraInMode AllegraEra CardanoMode
AllegraEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrMary err) =
    TxValidationError MaryEra
-> EraInMode MaryEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra MaryEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol MaryEra) (ShelleyLedgerEra MaryEra))
-> TxValidationError MaryEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra MaryEra
ShelleyBasedEraMary ApplyTxErr
  (ShelleyBlock (TPraos StandardCrypto) (MaryEra StandardCrypto))
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol MaryEra) (ShelleyLedgerEra MaryEra))
err)
      EraInMode MaryEra CardanoMode
MaryEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrAlonzo err) =
    TxValidationError AlonzoEra
-> EraInMode AlonzoEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra AlonzoEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol AlonzoEra) (ShelleyLedgerEra AlonzoEra))
-> TxValidationError AlonzoEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra AlonzoEra
ShelleyBasedEraAlonzo ApplyTxErr
  (ShelleyBlock (TPraos StandardCrypto) (AlonzoEra StandardCrypto))
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol AlonzoEra) (ShelleyLedgerEra AlonzoEra))
err)
      EraInMode AlonzoEra CardanoMode
AlonzoEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrBabbage err) =
    TxValidationError BabbageEra
-> EraInMode BabbageEra CardanoMode
-> TxValidationErrorInMode CardanoMode
forall era mode.
TxValidationError era
-> EraInMode era mode -> TxValidationErrorInMode mode
TxValidationErrorInMode
      (ShelleyBasedEra BabbageEra
-> ApplyTxErr
     (ShelleyBlock
        (ConsensusProtocol BabbageEra) (ShelleyLedgerEra BabbageEra))
-> TxValidationError BabbageEra
forall era.
ShelleyBasedEra era
-> ApplyTxErr
     (ShelleyBlock (ConsensusProtocol era) (ShelleyLedgerEra era))
-> TxValidationError era
ShelleyTxValidationError ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage ApplyTxErr
  (ShelleyBlock (Praos StandardCrypto) (BabbageEra StandardCrypto))
ApplyTxErr
  (ShelleyBlock
     (ConsensusProtocol BabbageEra) (ShelleyLedgerEra BabbageEra))
err)
      EraInMode BabbageEra CardanoMode
BabbageEraInCardanoMode

fromConsensusApplyTxErr ConsensusMode mode
CardanoMode (Consensus.ApplyTxErrWrongEra err) =
    EraMismatch -> TxValidationErrorInMode mode
forall mode. EraMismatch -> TxValidationErrorInMode mode
TxValidationEraMismatch EraMismatch
err