{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Ledger.Dijkstra.Binary.Annotator (

) where

import Cardano.Ledger.Allegra.Scripts (invalidBeforeL, invalidHereAfterL)
import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Binary
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Coin (decodePositiveCoin)
import Cardano.Ledger.Conway.Governance (VotingProcedures (..))
import Cardano.Ledger.Dijkstra (DijkstraEra)
import Cardano.Ledger.Dijkstra.BlockBody.Internal (
  DijkstraBlockBody (..),
  DijkstraBlockBodyRaw (..),
  alignedValidFlags,
 )
import Cardano.Ledger.Dijkstra.Core
import Cardano.Ledger.Dijkstra.Scripts
import Cardano.Ledger.Dijkstra.Tx (DijkstraTx (..), Tx (..))
import Cardano.Ledger.Dijkstra.TxBody
import Cardano.Ledger.MemoBytes (decodeMemoized)
import Cardano.Ledger.Val (Val (..))
import Control.Monad (forM_, unless)
import Data.Coerce (coerce)
import Data.Foldable (Foldable (..))
import Data.IntSet (IntSet)
import qualified Data.IntSet as IntSet
import qualified Data.Map.Strict as Map
import qualified Data.OMap.Strict as OMap
import qualified Data.OSet.Strict as OSet
import qualified Data.Sequence as Seq
import qualified Data.Sequence.Strict as StrictSeq
import Data.Typeable (Typeable)
import Data.Word (Word16)
import Lens.Micro
import Test.Cardano.Ledger.Conway.Binary.Annotator ()

deriving newtype instance Typeable l => DecCBOR (TxBody l DijkstraEra)

instance Typeable l => DecCBOR (DijkstraTxBodyRaw l DijkstraEra) where
  decCBOR :: forall s. Decoder s (DijkstraTxBodyRaw l DijkstraEra)
decCBOR = forall (l :: TxLevel) era a.
(Typeable l, HasCallStack) =>
(STxBothLevels l era -> a) -> a
withSTxBothLevels @l ((STxBothLevels l DijkstraEra
  -> Decoder s (DijkstraTxBodyRaw l DijkstraEra))
 -> Decoder s (DijkstraTxBodyRaw l DijkstraEra))
-> (STxBothLevels l DijkstraEra
    -> Decoder s (DijkstraTxBodyRaw l DijkstraEra))
-> Decoder s (DijkstraTxBodyRaw l DijkstraEra)
forall a b. (a -> b) -> a -> b
$ \STxBothLevels l DijkstraEra
sTxLevel ->
    Decode (Closed Dense) (DijkstraTxBodyRaw l DijkstraEra)
-> Decoder s (DijkstraTxBodyRaw l DijkstraEra)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode (Closed Dense) (DijkstraTxBodyRaw l DijkstraEra)
 -> Decoder s (DijkstraTxBodyRaw l DijkstraEra))
-> Decode (Closed Dense) (DijkstraTxBodyRaw l DijkstraEra)
-> Decoder s (DijkstraTxBodyRaw l DijkstraEra)
forall a b. (a -> b) -> a -> b
$
      String
-> DijkstraTxBodyRaw l DijkstraEra
-> (Word -> Field (DijkstraTxBodyRaw l DijkstraEra))
-> [(Word, String)]
-> Decode (Closed Dense) (DijkstraTxBodyRaw l DijkstraEra)
forall t.
Typeable t =>
String
-> t
-> (Word -> Field t)
-> [(Word, String)]
-> Decode (Closed Dense) t
SparseKeyed
        String
"TxBodyRaw"
        (STxBothLevels l DijkstraEra -> DijkstraTxBodyRaw l DijkstraEra
forall era (l :: TxLevel).
EraTxBody era =>
STxBothLevels l era -> DijkstraTxBodyRaw l era
basicDijkstraTxBodyRaw STxBothLevels l DijkstraEra
sTxLevel)
        (STxBothLevels l DijkstraEra
-> Word -> Field (DijkstraTxBodyRaw l DijkstraEra)
bodyFields STxBothLevels l DijkstraEra
sTxLevel)
        (STxBothLevels l DijkstraEra -> [(Word, String)]
requiredFields STxBothLevels l DijkstraEra
sTxLevel)
    where
      bodyFields :: STxBothLevels l DijkstraEra -> Word -> Field (DijkstraTxBodyRaw l DijkstraEra)
      bodyFields :: STxBothLevels l DijkstraEra
-> Word -> Field (DijkstraTxBodyRaw l DijkstraEra)
bodyFields STxBothLevels l DijkstraEra
sTxLevel = \case
        Word
0 -> (Set TxIn
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 11)) (Set TxIn)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(x -> t -> t) -> Decode (Closed d) x -> Field t
field ((Set TxIn -> Identity (Set TxIn))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(Set TxIn -> f (Set TxIn))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
inputsDijkstraTxBodyRawL ((Set TxIn -> Identity (Set TxIn))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Set TxIn
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 11)) (Set TxIn)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
1 -> (StrictSeq (BabbageTxOut DijkstraEra)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode
     (Closed (ZonkAny 12)) (StrictSeq (BabbageTxOut DijkstraEra))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(x -> t -> t) -> Decode (Closed d) x -> Field t
field ((StrictSeq (TxOut DijkstraEra)
 -> Identity (StrictSeq (TxOut DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(StrictSeq (BabbageTxOut DijkstraEra)
 -> Identity (StrictSeq (BabbageTxOut DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall era (l :: TxLevel).
EraTxOut era =>
Lens' (DijkstraTxBodyRaw l era) (StrictSeq (TxOut era))
Lens'
  (DijkstraTxBodyRaw l DijkstraEra) (StrictSeq (TxOut DijkstraEra))
outputsDijkstraTxBodyRawL ((StrictSeq (BabbageTxOut DijkstraEra)
  -> Identity (StrictSeq (BabbageTxOut DijkstraEra)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictSeq (BabbageTxOut DijkstraEra)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 12)) (StrictSeq (BabbageTxOut DijkstraEra))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
2 | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel -> (Coin
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 13)) Coin
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(x -> t -> t) -> Decode (Closed d) x -> Field t
field ((Coin -> Identity Coin)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(Coin -> Identity Coin)
-> DijkstraTxBodyRaw TopTx DijkstraEra
-> Identity (DijkstraTxBodyRaw TopTx DijkstraEra)
forall era (f :: * -> *).
Functor f =>
(Coin -> f Coin)
-> DijkstraTxBodyRaw TopTx era -> f (DijkstraTxBodyRaw TopTx era)
feeDijkstraTxBodyRawL ((Coin -> Identity Coin)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Coin
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 13)) Coin
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
3 -> (StrictMaybe SlotNo
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 14)) SlotNo
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((ValidityInterval -> Identity ValidityInterval)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(ValidityInterval -> f ValidityInterval)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
vldtDijkstraTxBodyRawL ((ValidityInterval -> Identity ValidityInterval)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> ((StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
    -> ValidityInterval -> Identity ValidityInterval)
-> (StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
-> ValidityInterval -> Identity ValidityInterval
Lens' ValidityInterval (StrictMaybe SlotNo)
invalidHereAfterL ((StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe SlotNo
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 14)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
4 ->
          String
-> (OSet (DijkstraTxCert DijkstraEra) -> Bool)
-> (OSet (DijkstraTxCert DijkstraEra)
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 15)) (OSet (DijkstraTxCert DijkstraEra))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Certificates" String
"non-empty")
            OSet (DijkstraTxCert DijkstraEra) -> Bool
forall a. OSet a -> Bool
OSet.null
            ((OSet (TxCert DijkstraEra) -> Identity (OSet (TxCert DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(OSet (DijkstraTxCert DijkstraEra)
 -> Identity (OSet (DijkstraTxCert DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(OSet (TxCert era) -> f (OSet (TxCert era)))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
certsDijkstraTxBodyRawL ((OSet (DijkstraTxCert DijkstraEra)
  -> Identity (OSet (DijkstraTxCert DijkstraEra)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> OSet (DijkstraTxCert DijkstraEra)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 15)) (OSet (DijkstraTxCert DijkstraEra))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
5 ->
          String
-> (Withdrawals -> Bool)
-> (Withdrawals
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 16)) Withdrawals
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Withdrawals" String
"non-empty")
            (Map AccountAddress Coin -> Bool
forall a. Map AccountAddress a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map AccountAddress Coin -> Bool)
-> (Withdrawals -> Map AccountAddress Coin) -> Withdrawals -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Withdrawals -> Map AccountAddress Coin
unWithdrawals)
            ((Withdrawals -> Identity Withdrawals)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(Withdrawals -> f Withdrawals)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
withdrawalsDijkstraTxBodyRawL ((Withdrawals -> Identity Withdrawals)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Withdrawals
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 16)) Withdrawals
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
7 -> (StrictMaybe TxAuxDataHash
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 17)) TxAuxDataHash
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe TxAuxDataHash -> Identity (StrictMaybe TxAuxDataHash))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(StrictMaybe TxAuxDataHash -> f (StrictMaybe TxAuxDataHash))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
auxDataHashDijkstraTxBodyRawL ((StrictMaybe TxAuxDataHash
  -> Identity (StrictMaybe TxAuxDataHash))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe TxAuxDataHash
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 17)) TxAuxDataHash
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
8 -> (StrictMaybe SlotNo
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 18)) SlotNo
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((ValidityInterval -> Identity ValidityInterval)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(ValidityInterval -> f ValidityInterval)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
vldtDijkstraTxBodyRawL ((ValidityInterval -> Identity ValidityInterval)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> ((StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
    -> ValidityInterval -> Identity ValidityInterval)
-> (StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
-> ValidityInterval -> Identity ValidityInterval
Lens' ValidityInterval (StrictMaybe SlotNo)
invalidBeforeL ((StrictMaybe SlotNo -> Identity (StrictMaybe SlotNo))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe SlotNo
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 18)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
9 ->
          String
-> (MultiAsset -> Bool)
-> (MultiAsset
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 19)) MultiAsset
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Mint" String
"non-empty")
            (MultiAsset -> MultiAsset -> Bool
forall a. Eq a => a -> a -> Bool
== MultiAsset
forall a. Monoid a => a
mempty)
            ((MultiAsset -> Identity MultiAsset)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(MultiAsset -> f MultiAsset)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
mintDijkstraTxBodyRawL ((MultiAsset -> Identity MultiAsset)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> MultiAsset
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 19)) MultiAsset
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
11 -> (StrictMaybe ScriptIntegrityHash
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 20)) ScriptIntegrityHash
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe ScriptIntegrityHash
 -> Identity (StrictMaybe ScriptIntegrityHash))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(StrictMaybe ScriptIntegrityHash
 -> f (StrictMaybe ScriptIntegrityHash))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
scriptIntegrityHashDijkstraTxBodyRawL ((StrictMaybe ScriptIntegrityHash
  -> Identity (StrictMaybe ScriptIntegrityHash))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe ScriptIntegrityHash
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 20)) ScriptIntegrityHash
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
13
          | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel ->
              String
-> (Set TxIn -> Bool)
-> (Set TxIn
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 21)) (Set TxIn)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
                (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Collateral Inputs" String
"non-empty")
                Set TxIn -> Bool
forall a. Set a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null
                ((Set TxIn -> Identity (Set TxIn))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(Set TxIn -> Identity (Set TxIn))
-> DijkstraTxBodyRaw TopTx DijkstraEra
-> Identity (DijkstraTxBodyRaw TopTx DijkstraEra)
forall era (f :: * -> *).
Functor f =>
(Set TxIn -> f (Set TxIn))
-> DijkstraTxBodyRaw TopTx era -> f (DijkstraTxBodyRaw TopTx era)
collateralInputsDijkstraTxBodyRawL ((Set TxIn -> Identity (Set TxIn))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Set TxIn
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
                Decode (Closed (ZonkAny 21)) (Set TxIn)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
14 ->
          (StrictMaybe (OSet (Credential Guard))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed Dense) (OSet (Credential Guard))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield
            (\StrictMaybe (OSet (Credential Guard))
x -> (OSet (Credential Guard) -> Identity (OSet (Credential Guard)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(OSet (Credential Guard) -> f (OSet (Credential Guard)))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
guardsDijkstraTxBodyRawL ((OSet (Credential Guard) -> Identity (OSet (Credential Guard)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> OSet (Credential Guard)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~ OSet (Credential Guard)
-> StrictMaybe (OSet (Credential Guard)) -> OSet (Credential Guard)
forall a. a -> StrictMaybe a -> a
fromSMaybe OSet (Credential Guard)
forall a. Monoid a => a
mempty StrictMaybe (OSet (Credential Guard))
x)
            ((forall s. Decoder s (OSet (Credential Guard)))
-> Decode (Closed Dense) (OSet (Credential Guard))
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D Decoder s (OSet (Credential Guard))
forall s. Decoder s (OSet (Credential Guard))
decodeGuards)
        Word
15 -> (StrictMaybe Network
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 22)) Network
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe Network -> Identity (StrictMaybe Network))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(StrictMaybe Network -> f (StrictMaybe Network))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
networkIdDijkstraTxBodyRawL ((StrictMaybe Network -> Identity (StrictMaybe Network))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe Network
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 22)) Network
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
16
          | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel ->
              (StrictMaybe (BabbageTxOut DijkstraEra)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 23)) (BabbageTxOut DijkstraEra)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe (TxOut DijkstraEra)
 -> Identity (StrictMaybe (TxOut DijkstraEra)))
-> DijkstraTxBodyRaw TopTx DijkstraEra
-> Identity (DijkstraTxBodyRaw TopTx DijkstraEra)
(StrictMaybe (BabbageTxOut DijkstraEra)
 -> Identity (StrictMaybe (BabbageTxOut DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall era.
EraTxBody era =>
Lens' (DijkstraTxBodyRaw TopTx era) (StrictMaybe (TxOut era))
Lens'
  (DijkstraTxBodyRaw TopTx DijkstraEra)
  (StrictMaybe (TxOut DijkstraEra))
collateralReturnDijkstraTxBodyRawL ((StrictMaybe (BabbageTxOut DijkstraEra)
  -> Identity (StrictMaybe (BabbageTxOut DijkstraEra)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe (BabbageTxOut DijkstraEra)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 23)) (BabbageTxOut DijkstraEra)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
17
          | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel ->
              (StrictMaybe Coin
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 24)) Coin
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> DijkstraTxBodyRaw TopTx DijkstraEra
-> Identity (DijkstraTxBodyRaw TopTx DijkstraEra)
forall era (f :: * -> *).
Functor f =>
(StrictMaybe Coin -> f (StrictMaybe Coin))
-> DijkstraTxBodyRaw TopTx era -> f (DijkstraTxBodyRaw TopTx era)
totalCollateralDijkstraTxBodyRawL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe Coin
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 24)) Coin
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
18 ->
          String
-> (Set TxIn -> Bool)
-> (Set TxIn
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 25)) (Set TxIn)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Reference Inputs" String
"non-empty")
            Set TxIn -> Bool
forall a. Set a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null
            ((Set TxIn -> Identity (Set TxIn))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(Set TxIn -> f (Set TxIn))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
referenceInputsDijkstraTxBodyRawL ((Set TxIn -> Identity (Set TxIn))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Set TxIn
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 25)) (Set TxIn)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
19 ->
          String
-> (VotingProcedures DijkstraEra -> Bool)
-> (VotingProcedures DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 26)) (VotingProcedures DijkstraEra)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"VotingProcedures" String
"non-empty")
            (Map Voter (Map GovActionId (VotingProcedure DijkstraEra)) -> Bool
forall a. Map Voter a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map Voter (Map GovActionId (VotingProcedure DijkstraEra)) -> Bool)
-> (VotingProcedures DijkstraEra
    -> Map Voter (Map GovActionId (VotingProcedure DijkstraEra)))
-> VotingProcedures DijkstraEra
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VotingProcedures DijkstraEra
-> Map Voter (Map GovActionId (VotingProcedure DijkstraEra))
forall era.
VotingProcedures era
-> Map Voter (Map GovActionId (VotingProcedure era))
unVotingProcedures)
            ((VotingProcedures DijkstraEra
 -> Identity (VotingProcedures DijkstraEra))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(VotingProcedures era -> f (VotingProcedures era))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
votingProceduresDijkstraTxBodyRawL ((VotingProcedures DijkstraEra
  -> Identity (VotingProcedures DijkstraEra))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> VotingProcedures DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 26)) (VotingProcedures DijkstraEra)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
20 ->
          String
-> (OSet (ProposalProcedure DijkstraEra) -> Bool)
-> (OSet (ProposalProcedure DijkstraEra)
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode
     (Closed (ZonkAny 27)) (OSet (ProposalProcedure DijkstraEra))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"ProposalProcedures" String
"non-empty")
            OSet (ProposalProcedure DijkstraEra) -> Bool
forall a. OSet a -> Bool
OSet.null
            ((OSet (ProposalProcedure DijkstraEra)
 -> Identity (OSet (ProposalProcedure DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(OSet (ProposalProcedure era) -> f (OSet (ProposalProcedure era)))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
proposalProceduresDijkstraTxBodyRawL ((OSet (ProposalProcedure DijkstraEra)
  -> Identity (OSet (ProposalProcedure DijkstraEra)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> OSet (ProposalProcedure DijkstraEra)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 27)) (OSet (ProposalProcedure DijkstraEra))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
21 -> (StrictMaybe Coin
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 28)) Coin
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(StrictMaybe Coin -> f (StrictMaybe Coin))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
currentTreasuryValueDijkstraTxBodyRawL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> StrictMaybe Coin
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~) Decode (Closed (ZonkAny 28)) Coin
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
22 ->
          (StrictMaybe Coin
 -> DijkstraTxBodyRaw l DijkstraEra
 -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed Dense) Coin
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
(StrictMaybe x -> t -> t) -> Decode (Closed d) x -> Field t
ofield
            (\StrictMaybe Coin
x -> (Coin -> Identity Coin)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(Coin -> f Coin)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
treasuryDonationDijkstraTxBodyRawL ((Coin -> Identity Coin)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Coin
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> StrictMaybe Coin -> Coin
forall a. a -> StrictMaybe a -> a
fromSMaybe Coin
forall t. Val t => t
zero StrictMaybe Coin
x)
            ((forall s. Decoder s Coin) -> Decode (Closed Dense) Coin
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D (String -> Decoder s Coin
forall s. String -> Decoder s Coin
decodePositiveCoin (String -> Decoder s Coin) -> String -> Decoder s Coin
forall a b. (a -> b) -> a -> b
$ String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Treasury Donation" String
"non-zero"))
        Word
23
          | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel ->
              String
-> (OMap TxId (Tx SubTx DijkstraEra) -> Bool)
-> (OMap TxId (Tx SubTx DijkstraEra)
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed Dense) (OMap TxId (Tx SubTx DijkstraEra))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
                (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"Subtransactions" String
"non-empty")
                OMap TxId (Tx SubTx DijkstraEra) -> Bool
forall k v. OMap k v -> Bool
OMap.null
                ((OMap TxId (Tx SubTx DijkstraEra)
 -> Identity (OMap TxId (Tx SubTx DijkstraEra)))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(OMap TxId (Tx SubTx DijkstraEra)
 -> Identity (OMap TxId (Tx SubTx DijkstraEra)))
-> DijkstraTxBodyRaw TopTx DijkstraEra
-> Identity (DijkstraTxBodyRaw TopTx DijkstraEra)
forall era (f :: * -> *).
Functor f =>
(OMap TxId (Tx SubTx era) -> f (OMap TxId (Tx SubTx era)))
-> DijkstraTxBodyRaw TopTx era -> f (DijkstraTxBodyRaw TopTx era)
subTransactionsDijkstraTxBodyRawL ((OMap TxId (Tx SubTx DijkstraEra)
  -> Identity (OMap TxId (Tx SubTx DijkstraEra)))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> OMap TxId (Tx SubTx DijkstraEra)
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
                ((forall s. Decoder s (OMap TxId (Tx SubTx DijkstraEra)))
-> Decode (Closed Dense) (OMap TxId (Tx SubTx DijkstraEra))
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D ((forall s. Decoder s (OMap TxId (Tx SubTx DijkstraEra)))
 -> Decode (Closed Dense) (OMap TxId (Tx SubTx DijkstraEra)))
-> (forall s. Decoder s (OMap TxId (Tx SubTx DijkstraEra)))
-> Decode (Closed Dense) (OMap TxId (Tx SubTx DijkstraEra))
forall a b. (a -> b) -> a -> b
$ Word -> Decoder s ()
forall s. Word -> Decoder s ()
allowTag Word
setTag Decoder s ()
-> Decoder s (OMap TxId (Tx SubTx DijkstraEra))
-> Decoder s (OMap TxId (Tx SubTx DijkstraEra))
forall a b. Decoder s a -> Decoder s b -> Decoder s b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Decoder s (OMap TxId (Tx SubTx DijkstraEra))
forall s. Decoder s (OMap TxId (Tx SubTx DijkstraEra))
forall a s. DecCBOR a => Decoder s a
decCBOR)
        Word
24
          | STxBothLevels l DijkstraEra
SSubTx <- STxBothLevels l DijkstraEra
sTxLevel ->
              String
-> (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
    -> Bool)
-> (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode
     (Closed Dense)
     (Map (Credential Guard) (StrictMaybe (Data DijkstraEra)))
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
                (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"RequiredTopLevelGuards" String
"non-empty")
                Map (Credential Guard) (StrictMaybe (Data DijkstraEra)) -> Bool
forall k a. Map k a -> Bool
Map.null
                ((Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
 -> Identity
      (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
(Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
 -> Identity
      (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))))
-> DijkstraTxBodyRaw SubTx DijkstraEra
-> Identity (DijkstraTxBodyRaw SubTx DijkstraEra)
forall era (f :: * -> *).
Functor f =>
(Map (Credential Guard) (StrictMaybe (Data era))
 -> f (Map (Credential Guard) (StrictMaybe (Data era))))
-> DijkstraTxBodyRaw SubTx era -> f (DijkstraTxBodyRaw SubTx era)
requiredTopLevelGuardsDijkstraTxBodyRawL ((Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
  -> Identity
       (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> Map (Credential Guard) (StrictMaybe (Data DijkstraEra))
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
                ((forall s.
 Decoder
   s (Map (Credential Guard) (StrictMaybe (Data DijkstraEra))))
-> Decode
     (Closed Dense)
     (Map (Credential Guard) (StrictMaybe (Data DijkstraEra)))
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D (Decoder s (Credential Guard)
-> Decoder s (StrictMaybe (Data DijkstraEra))
-> Decoder
     s (Map (Credential Guard) (StrictMaybe (Data DijkstraEra)))
forall k s v.
Ord k =>
Decoder s k -> Decoder s v -> Decoder s (Map k v)
decodeMap Decoder s (Credential Guard)
forall s. Decoder s (Credential Guard)
forall a s. DecCBOR a => Decoder s a
decCBOR (Decoder s (Data DijkstraEra)
-> Decoder s (StrictMaybe (Data DijkstraEra))
forall s a. Decoder s a -> Decoder s (StrictMaybe a)
decodeNullStrictMaybe Decoder s (Data DijkstraEra)
forall s. Decoder s (Data DijkstraEra)
forall a s. DecCBOR a => Decoder s a
decCBOR)))
        Word
25 ->
          String
-> (DirectDeposits -> Bool)
-> (DirectDeposits
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode (Closed (ZonkAny 29)) DirectDeposits
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"DirectDeposits" String
"non-empty")
            (Map AccountAddress Coin -> Bool
forall a. Map AccountAddress a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map AccountAddress Coin -> Bool)
-> (DirectDeposits -> Map AccountAddress Coin)
-> DirectDeposits
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DirectDeposits -> Map AccountAddress Coin
unDirectDeposits)
            ((DirectDeposits -> Identity DirectDeposits)
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(DirectDeposits -> f DirectDeposits)
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
directDepositsDijkstraTxBodyRawL ((DirectDeposits -> Identity DirectDeposits)
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> DirectDeposits
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 29)) DirectDeposits
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
26 ->
          String
-> (AccountBalanceIntervals DijkstraEra -> Bool)
-> (AccountBalanceIntervals DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra
    -> DijkstraTxBodyRaw l DijkstraEra)
-> Decode
     (Closed (ZonkAny 30)) (AccountBalanceIntervals DijkstraEra)
-> Field (DijkstraTxBodyRaw l DijkstraEra)
forall x t (d :: Density).
Typeable x =>
String
-> (x -> Bool) -> (x -> t -> t) -> Decode (Closed d) x -> Field t
fieldGuarded
            (String -> String -> String
forall {a}. (Semigroup a, IsString a) => a -> a -> a
emptyFailure String
"AccountBalanceIntervals" String
"non-empty")
            (Map AccountId (AccountBalanceInterval DijkstraEra) -> Bool
forall a. Map AccountId a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Map AccountId (AccountBalanceInterval DijkstraEra) -> Bool)
-> (AccountBalanceIntervals DijkstraEra
    -> Map AccountId (AccountBalanceInterval DijkstraEra))
-> AccountBalanceIntervals DijkstraEra
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AccountBalanceIntervals DijkstraEra
-> Map AccountId (AccountBalanceInterval DijkstraEra)
forall era.
AccountBalanceIntervals era
-> Map AccountId (AccountBalanceInterval era)
unAccountBalanceIntervals)
            ((AccountBalanceIntervals DijkstraEra
 -> Identity (AccountBalanceIntervals DijkstraEra))
-> DijkstraTxBodyRaw l DijkstraEra
-> Identity (DijkstraTxBodyRaw l DijkstraEra)
forall (l :: TxLevel) era (f :: * -> *).
Functor f =>
(AccountBalanceIntervals era -> f (AccountBalanceIntervals era))
-> DijkstraTxBodyRaw l era -> f (DijkstraTxBodyRaw l era)
accountBalanceIntervalsDijkstraTxBodyRawL ((AccountBalanceIntervals DijkstraEra
  -> Identity (AccountBalanceIntervals DijkstraEra))
 -> DijkstraTxBodyRaw l DijkstraEra
 -> Identity (DijkstraTxBodyRaw l DijkstraEra))
-> AccountBalanceIntervals DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
-> DijkstraTxBodyRaw l DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
.~)
            Decode (Closed (ZonkAny 30)) (AccountBalanceIntervals DijkstraEra)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Word
n -> Word -> Field (DijkstraTxBodyRaw l DijkstraEra)
forall t. Word -> Field t
invalidField Word
n
      requiredFields :: STxBothLevels l DijkstraEra -> [(Word, String)]
      requiredFields :: STxBothLevels l DijkstraEra -> [(Word, String)]
requiredFields STxBothLevels l DijkstraEra
sTxLevel
        | STxBothLevels l DijkstraEra
STopTx <- STxBothLevels l DijkstraEra
sTxLevel =
            [ (Word
0, String
"inputs")
            , (Word
1, String
"outputs")
            , (Word
2, String
"fee")
            ]
        | STxBothLevels l DijkstraEra
SSubTx <- STxBothLevels l DijkstraEra
sTxLevel =
            [ (Word
0, String
"inputs")
            , (Word
1, String
"outputs")
            ]

      emptyFailure :: a -> a -> a
emptyFailure a
fieldName a
requirement =
        a
"TxBody: '" a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
fieldName a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
"' must be " a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
requirement a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
" when supplied"

instance Era era => DecCBOR (DijkstraNativeScriptRaw era) where
  decCBOR :: forall s. Decoder s (DijkstraNativeScriptRaw era)
decCBOR = Decode (Closed Dense) (DijkstraNativeScriptRaw era)
-> Decoder s (DijkstraNativeScriptRaw era)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode (Closed Dense) (DijkstraNativeScriptRaw era)
 -> Decoder s (DijkstraNativeScriptRaw era))
-> Decode (Closed Dense) (DijkstraNativeScriptRaw era)
-> Decoder s (DijkstraNativeScriptRaw era)
forall a b. (a -> b) -> a -> b
$ Text
-> (Word -> Decode Open (DijkstraNativeScriptRaw era))
-> Decode (Closed Dense) (DijkstraNativeScriptRaw era)
forall t.
Text -> (Word -> Decode Open t) -> Decode (Closed Dense) t
Summands Text
"DijkstraNativeScriptRaw" ((Word -> Decode Open (DijkstraNativeScriptRaw era))
 -> Decode (Closed Dense) (DijkstraNativeScriptRaw era))
-> (Word -> Decode Open (DijkstraNativeScriptRaw era))
-> Decode (Closed Dense) (DijkstraNativeScriptRaw era)
forall a b. (a -> b) -> a -> b
$ \case
    Word
0 -> (KeyHash Witness -> DijkstraNativeScriptRaw era)
-> Decode Open (KeyHash Witness -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD KeyHash Witness -> DijkstraNativeScriptRaw era
forall era. KeyHash Witness -> DijkstraNativeScriptRaw era
DijkstraRequireSignature Decode Open (KeyHash Witness -> DijkstraNativeScriptRaw era)
-> Decode (Closed (ZonkAny 3)) (KeyHash Witness)
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 3)) (KeyHash Witness)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
1 -> (StrictSeq (DijkstraNativeScript era)
 -> DijkstraNativeScriptRaw era)
-> Decode
     Open
     (StrictSeq (DijkstraNativeScript era)
      -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD StrictSeq (DijkstraNativeScript era) -> DijkstraNativeScriptRaw era
forall era.
StrictSeq (DijkstraNativeScript era) -> DijkstraNativeScriptRaw era
DijkstraRequireAllOf Decode
  Open
  (StrictSeq (DijkstraNativeScript era)
   -> DijkstraNativeScriptRaw era)
-> Decode
     (Closed (ZonkAny 4)) (StrictSeq (DijkstraNativeScript era))
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 4)) (StrictSeq (DijkstraNativeScript era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
2 -> (StrictSeq (DijkstraNativeScript era)
 -> DijkstraNativeScriptRaw era)
-> Decode
     Open
     (StrictSeq (DijkstraNativeScript era)
      -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD StrictSeq (DijkstraNativeScript era) -> DijkstraNativeScriptRaw era
forall era.
StrictSeq (DijkstraNativeScript era) -> DijkstraNativeScriptRaw era
DijkstraRequireAnyOf Decode
  Open
  (StrictSeq (DijkstraNativeScript era)
   -> DijkstraNativeScriptRaw era)
-> Decode
     (Closed (ZonkAny 5)) (StrictSeq (DijkstraNativeScript era))
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 5)) (StrictSeq (DijkstraNativeScript era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
3 -> (Int
 -> StrictSeq (DijkstraNativeScript era)
 -> DijkstraNativeScriptRaw era)
-> Decode
     Open
     (Int
      -> StrictSeq (DijkstraNativeScript era)
      -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD Int
-> StrictSeq (DijkstraNativeScript era)
-> DijkstraNativeScriptRaw era
forall era.
Int
-> StrictSeq (DijkstraNativeScript era)
-> DijkstraNativeScriptRaw era
DijkstraRequireMOf Decode
  Open
  (Int
   -> StrictSeq (DijkstraNativeScript era)
   -> DijkstraNativeScriptRaw era)
-> Decode (Closed (ZonkAny 7)) Int
-> Decode
     Open
     (StrictSeq (DijkstraNativeScript era)
      -> DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 7)) Int
forall t (w :: Wrapped). DecCBOR t => Decode w t
From Decode
  Open
  (StrictSeq (DijkstraNativeScript era)
   -> DijkstraNativeScriptRaw era)
-> Decode
     (Closed (ZonkAny 6)) (StrictSeq (DijkstraNativeScript era))
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 6)) (StrictSeq (DijkstraNativeScript era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
4 -> (SlotNo -> DijkstraNativeScriptRaw era)
-> Decode Open (SlotNo -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD SlotNo -> DijkstraNativeScriptRaw era
forall era. SlotNo -> DijkstraNativeScriptRaw era
DijkstraTimeStart Decode Open (SlotNo -> DijkstraNativeScriptRaw era)
-> Decode (Closed (ZonkAny 8)) SlotNo
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 8)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
5 -> (SlotNo -> DijkstraNativeScriptRaw era)
-> Decode Open (SlotNo -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD SlotNo -> DijkstraNativeScriptRaw era
forall era. SlotNo -> DijkstraNativeScriptRaw era
DijkstraTimeExpire Decode Open (SlotNo -> DijkstraNativeScriptRaw era)
-> Decode (Closed (ZonkAny 9)) SlotNo
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 9)) SlotNo
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
6 -> (Credential Guard -> DijkstraNativeScriptRaw era)
-> Decode Open (Credential Guard -> DijkstraNativeScriptRaw era)
forall t. t -> Decode Open t
SumD Credential Guard -> DijkstraNativeScriptRaw era
forall era. Credential Guard -> DijkstraNativeScriptRaw era
DijkstraRequireGuard Decode Open (Credential Guard -> DijkstraNativeScriptRaw era)
-> Decode (Closed (ZonkAny 10)) (Credential Guard)
-> Decode Open (DijkstraNativeScriptRaw era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 10)) (Credential Guard)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
    Word
n -> Word -> Decode Open (DijkstraNativeScriptRaw era)
forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n

instance Era era => DecCBOR (DijkstraNativeScript era) where
  decCBOR :: forall s. Decoder s (DijkstraNativeScript era)
decCBOR = MemoBytes (DijkstraNativeScriptRaw era) -> DijkstraNativeScript era
forall era.
MemoBytes (DijkstraNativeScriptRaw era) -> DijkstraNativeScript era
MkDijkstraNativeScript (MemoBytes (DijkstraNativeScriptRaw era)
 -> DijkstraNativeScript era)
-> Decoder s (MemoBytes (DijkstraNativeScriptRaw era))
-> Decoder s (DijkstraNativeScript era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (DijkstraNativeScriptRaw era)
-> Decoder s (MemoBytes (DijkstraNativeScriptRaw era))
forall s t. Decoder s t -> Decoder s (MemoBytes t)
decodeMemoized Decoder s (DijkstraNativeScriptRaw era)
forall s. Decoder s (DijkstraNativeScriptRaw era)
forall a s. DecCBOR a => Decoder s a
decCBOR

instance Typeable l => DecCBOR (DijkstraTx l DijkstraEra) where
  decCBOR :: forall s. Decoder s (DijkstraTx l DijkstraEra)
decCBOR =
    forall (l :: TxLevel) era a.
(Typeable l, HasCallStack) =>
(STxBothLevels l era -> a) -> a
withSTxBothLevels @l ((STxBothLevels l (ZonkAny 0)
  -> Decoder s (DijkstraTx l DijkstraEra))
 -> Decoder s (DijkstraTx l DijkstraEra))
-> (STxBothLevels l (ZonkAny 0)
    -> Decoder s (DijkstraTx l DijkstraEra))
-> Decoder s (DijkstraTx l DijkstraEra)
forall a b. (a -> b) -> a -> b
$ \case
      STxBothLevels l (ZonkAny 0)
STopTx -> Bool -> Decoder s (DijkstraTx TopTx DijkstraEra)
forall era s.
(DecCBOR (TxBody TopTx era), DecCBOR (TxWits era),
 DecCBOR (TxAuxData era)) =>
Bool -> Decoder s (DijkstraTx TopTx era)
decodeDijkstraTopTx Bool
True
      STxBothLevels l (ZonkAny 0)
SSubTx ->
        Decode (Closed Dense) (DijkstraTx l DijkstraEra)
-> Decoder s (DijkstraTx l DijkstraEra)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode (Closed Dense) (DijkstraTx l DijkstraEra)
 -> Decoder s (DijkstraTx l DijkstraEra))
-> Decode (Closed Dense) (DijkstraTx l DijkstraEra)
-> Decoder s (DijkstraTx l DijkstraEra)
forall a b. (a -> b) -> a -> b
$
          (TxBody SubTx DijkstraEra
 -> AlonzoTxWits DijkstraEra
 -> StrictMaybe (AlonzoTxAuxData DijkstraEra)
 -> DijkstraTx l DijkstraEra)
-> Decode
     (Closed Dense)
     (TxBody SubTx DijkstraEra
      -> AlonzoTxWits DijkstraEra
      -> StrictMaybe (AlonzoTxAuxData DijkstraEra)
      -> DijkstraTx l DijkstraEra)
forall t. t -> Decode (Closed Dense) t
RecD TxBody SubTx DijkstraEra
-> TxWits DijkstraEra
-> StrictMaybe (TxAuxData DijkstraEra)
-> DijkstraTx SubTx DijkstraEra
TxBody SubTx DijkstraEra
-> AlonzoTxWits DijkstraEra
-> StrictMaybe (AlonzoTxAuxData DijkstraEra)
-> DijkstraTx l DijkstraEra
forall era.
TxBody SubTx era
-> TxWits era
-> StrictMaybe (TxAuxData era)
-> DijkstraTx SubTx era
DijkstraSubTx
            Decode
  (Closed Dense)
  (TxBody SubTx DijkstraEra
   -> AlonzoTxWits DijkstraEra
   -> StrictMaybe (AlonzoTxAuxData DijkstraEra)
   -> DijkstraTx l DijkstraEra)
-> Decode (Closed (ZonkAny 2)) (TxBody SubTx DijkstraEra)
-> Decode
     (Closed Dense)
     (AlonzoTxWits DijkstraEra
      -> StrictMaybe (AlonzoTxAuxData DijkstraEra)
      -> DijkstraTx l DijkstraEra)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 2)) (TxBody SubTx DijkstraEra)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
            Decode
  (Closed Dense)
  (AlonzoTxWits DijkstraEra
   -> StrictMaybe (AlonzoTxAuxData DijkstraEra)
   -> DijkstraTx l DijkstraEra)
-> Decode (Closed (ZonkAny 1)) (AlonzoTxWits DijkstraEra)
-> Decode
     (Closed Dense)
     (StrictMaybe (AlonzoTxAuxData DijkstraEra)
      -> DijkstraTx l DijkstraEra)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 1)) (AlonzoTxWits DijkstraEra)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
            Decode
  (Closed Dense)
  (StrictMaybe (AlonzoTxAuxData DijkstraEra)
   -> DijkstraTx l DijkstraEra)
-> Decode
     (Closed Dense) (StrictMaybe (AlonzoTxAuxData DijkstraEra))
-> Decode (Closed Dense) (DijkstraTx l DijkstraEra)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! (forall s. Decoder s (StrictMaybe (AlonzoTxAuxData DijkstraEra)))
-> Decode
     (Closed Dense) (StrictMaybe (AlonzoTxAuxData DijkstraEra))
forall t. (forall s. Decoder s t) -> Decode (Closed Dense) t
D (Decoder s (AlonzoTxAuxData DijkstraEra)
-> Decoder s (StrictMaybe (AlonzoTxAuxData DijkstraEra))
forall s a. Decoder s a -> Decoder s (StrictMaybe a)
decodeNullStrictMaybe Decoder s (AlonzoTxAuxData DijkstraEra)
forall s. Decoder s (AlonzoTxAuxData DijkstraEra)
forall a s. DecCBOR a => Decoder s a
decCBOR)
  {-# INLINE decCBOR #-}

deriving newtype instance Typeable l => DecCBOR (Tx l DijkstraEra)

decodeDijkstraTopTx ::
  ( DecCBOR (TxBody TopTx era)
  , DecCBOR (TxWits era)
  , DecCBOR (TxAuxData era)
  ) =>
  Bool -> Decoder s (DijkstraTx TopTx era)
decodeDijkstraTopTx :: forall era s.
(DecCBOR (TxBody TopTx era), DecCBOR (TxWits era),
 DecCBOR (TxAuxData era)) =>
Bool -> Decoder s (DijkstraTx TopTx era)
decodeDijkstraTopTx Bool
allowIsValid =
  (DijkstraTx TopTx era, Bool) -> DijkstraTx TopTx era
forall a b. (a, b) -> a
fst ((DijkstraTx TopTx era, Bool) -> DijkstraTx TopTx era)
-> Decoder s (DijkstraTx TopTx era, Bool)
-> Decoder s (DijkstraTx TopTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
    let isValidBackwardsCompatibleLength :: Bool -> a
isValidBackwardsCompatibleLength Bool
isValidFlagSupplied = if Bool
isValidFlagSupplied then a
4 else a
3
    Text
-> ((DijkstraTx TopTx era, Bool) -> Int)
-> Decoder s (DijkstraTx TopTx era, Bool)
-> Decoder s (DijkstraTx TopTx era, Bool)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"DijkstraTx" (Bool -> Int
forall {a}. Num a => Bool -> a
isValidBackwardsCompatibleLength (Bool -> Int)
-> ((DijkstraTx TopTx era, Bool) -> Bool)
-> (DijkstraTx TopTx era, Bool)
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DijkstraTx TopTx era, Bool) -> Bool
forall a b. (a, b) -> b
snd) (Decoder s (DijkstraTx TopTx era, Bool)
 -> Decoder s (DijkstraTx TopTx era, Bool))
-> Decoder s (DijkstraTx TopTx era, Bool)
-> Decoder s (DijkstraTx TopTx era, Bool)
forall a b. (a -> b) -> a -> b
$ do
      body <- Decoder s (TxBody TopTx era)
forall s. Decoder s (TxBody TopTx era)
forall a s. DecCBOR a => Decoder s a
decCBOR
      wits <- decCBOR
      isValidFlagSupplied <-
        if allowIsValid
          then
            peekTokenType >>= \case
              TokenType
TypeBool ->
                Decoder s Bool
forall s. Decoder s Bool
forall a s. DecCBOR a => Decoder s a
decCBOR Decoder s Bool -> (Bool -> Decoder s Bool) -> Decoder s Bool
forall a b. Decoder s a -> (a -> Decoder s b) -> Decoder s b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
                  Bool
True -> Bool -> Decoder s Bool
forall a. a -> Decoder s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
True
                  Bool
False -> String -> Decoder s Bool
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Value `false` not allowed for `isValid`"
              TokenType
_ -> Bool -> Decoder s Bool
forall a. a -> Decoder s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
          else pure False
      aux <- decodeNullStrictMaybe decCBOR
      pure (DijkstraTx body wits (IsValid True) aux, isValidFlagSupplied)

instance DecCBOR (DijkstraBlockBodyRaw DijkstraEra) where
  decCBOR :: forall s. Decoder s (DijkstraBlockBodyRaw DijkstraEra)
decCBOR = Text
-> (DijkstraBlockBodyRaw DijkstraEra -> Int)
-> Decoder s (DijkstraBlockBodyRaw DijkstraEra)
-> Decoder s (DijkstraBlockBodyRaw DijkstraEra)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"DijkstraBlockBodyRaw" (Int -> DijkstraBlockBodyRaw DijkstraEra -> Int
forall a b. a -> b -> a
const Int
3) (Decoder s (DijkstraBlockBodyRaw DijkstraEra)
 -> Decoder s (DijkstraBlockBodyRaw DijkstraEra))
-> Decoder s (DijkstraBlockBodyRaw DijkstraEra)
-> Decoder s (DijkstraBlockBodyRaw DijkstraEra)
forall a b. (a -> b) -> a -> b
$ do
    let
      decodeInvalidTxs :: Decoder s IntSet
decodeInvalidTxs =
        (Word16 -> IntSet -> IntSet)
-> (IntSet -> (Int, IntSet))
-> Decoder s Word16
-> Decoder s IntSet
forall s a b c.
Monoid b =>
(a -> b -> b) -> (b -> (Int, c)) -> Decoder s a -> Decoder s c
decodeNonEmptySetLikeEnforceNoDuplicates
          (Int -> IntSet -> IntSet
IntSet.insert (Int -> IntSet -> IntSet)
-> (Word16 -> Int) -> Word16 -> IntSet -> IntSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Integral a, Num b) => a -> b
fromIntegral @Word16 @Int)
          (\IntSet
x -> (IntSet -> Int
IntSet.size IntSet
x, IntSet
x))
          (forall a s. DecCBOR a => Decoder s a
decCBOR @Word16)
    invalidTxs :: IntSet <- Maybe IntSet -> IntSet
forall m. Monoid m => Maybe m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Maybe IntSet -> IntSet)
-> Decoder s (Maybe IntSet) -> Decoder s IntSet
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s IntSet -> Decoder s (Maybe IntSet)
forall s a. Decoder s a -> Decoder s (Maybe a)
decodeNullMaybe Decoder s IntSet
forall {s}. Decoder s IntSet
decodeInvalidTxs
    txs <- decodeSeq (decodeDijkstraTopTx @DijkstraEra False)
    perasCert <- decodeNullStrictMaybe decCBOR

    let txsLength = Seq (DijkstraTx TopTx DijkstraEra) -> Int
forall a. Seq a -> Int
Seq.length Seq (DijkstraTx TopTx DijkstraEra)
txs
        inRange Int
x = Int
0 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
x Bool -> Bool -> Bool
&& Int
x Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
txsLength Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
    forM_ (IntSet.toList invalidTxs) $ \Int
i ->
      Bool -> Decoder s () -> Decoder s ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Bool
inRange Int
i) (Decoder s () -> Decoder s ())
-> (String -> Decoder s ()) -> String -> Decoder s ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Decoder s ()
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Decoder s ()) -> String -> Decoder s ()
forall a b. (a -> b) -> a -> b
$
        String
"index is out of range: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
i
    let
      validityFlags = Int -> IntSet -> Seq IsValid
alignedValidFlags Int
txsLength IntSet
invalidTxs
      txsWithIsValid = (IsValid -> Tx TopTx DijkstraEra -> Tx TopTx DijkstraEra)
-> Seq IsValid
-> Seq (Tx TopTx DijkstraEra)
-> Seq (Tx TopTx DijkstraEra)
forall a b c. (a -> b -> c) -> Seq a -> Seq b -> Seq c
Seq.zipWith (ASetter
  (Tx TopTx DijkstraEra) (Tx TopTx DijkstraEra) IsValid IsValid
-> IsValid -> Tx TopTx DijkstraEra -> Tx TopTx DijkstraEra
forall s t a b. ASetter s t a b -> b -> s -> t
set ASetter
  (Tx TopTx DijkstraEra) (Tx TopTx DijkstraEra) IsValid IsValid
forall era. AlonzoEraTx era => Lens' (Tx TopTx era) IsValid
Lens' (Tx TopTx DijkstraEra) IsValid
isValidTxL) Seq IsValid
validityFlags (DijkstraTx TopTx DijkstraEra -> Tx TopTx DijkstraEra
forall a b. Coercible a b => a -> b
coerce (DijkstraTx TopTx DijkstraEra -> Tx TopTx DijkstraEra)
-> Seq (DijkstraTx TopTx DijkstraEra) -> Seq (Tx TopTx DijkstraEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Seq (DijkstraTx TopTx DijkstraEra)
txs)
    pure $ DijkstraBlockBodyRaw (StrictSeq.forceToStrict txsWithIsValid) perasCert

instance DecCBOR (DijkstraBlockBody DijkstraEra) where
  decCBOR :: forall s. Decoder s (DijkstraBlockBody DijkstraEra)
decCBOR = MemoBytes (DijkstraBlockBodyRaw DijkstraEra)
-> DijkstraBlockBody DijkstraEra
forall era.
MemoBytes (DijkstraBlockBodyRaw era) -> DijkstraBlockBody era
MkDijkstraBlockBody (MemoBytes (DijkstraBlockBodyRaw DijkstraEra)
 -> DijkstraBlockBody DijkstraEra)
-> Decoder s (MemoBytes (DijkstraBlockBodyRaw DijkstraEra))
-> Decoder s (DijkstraBlockBody DijkstraEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (DijkstraBlockBodyRaw DijkstraEra)
-> Decoder s (MemoBytes (DijkstraBlockBodyRaw DijkstraEra))
forall s t. Decoder s t -> Decoder s (MemoBytes t)
decodeMemoized Decoder s (DijkstraBlockBodyRaw DijkstraEra)
forall s. Decoder s (DijkstraBlockBodyRaw DijkstraEra)
forall a s. DecCBOR a => Decoder s a
decCBOR