{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_HADDOCK not-home #-}

-- | Provides Babbage TxBody internals
--
-- = Warning
--
-- This module is considered __internal__.
--
-- The contents of this module may change __in any way whatsoever__
-- and __without any warning__ between minor versions of this package.
module Cardano.Ledger.Babbage.TxBody.Internal (
  BabbageTxOut (
    BabbageTxOut,
    TxOutCompact,
    TxOutCompactDH,
    TxOutCompactDatum,
    TxOutCompactRefScript
  ),
  allSizedOutputsBabbageTxBodyF,
  babbageMinUTxOValue,
  BabbageTxBody (
    ..,
    BabbageTxBody,
    btbInputs,
    btbCollateral,
    btbReferenceInputs,
    btbOutputs,
    btbCollateralReturn,
    btbTotalCollateral,
    btbCerts,
    btbWithdrawals,
    btbTxFee,
    btbValidityInterval,
    btbUpdate,
    btbReqSignerHashes,
    btbMint,
    btbScriptIntegrityHash,
    btbAuxDataHash,
    btbTxNetworkId
  ),
  BabbageTxBodyRaw (..),
  BabbageTxBodyUpgradeError (..),
  babbageAllInputsTxBodyF,
  babbageSpendableInputsTxBodyF,
  BabbageEraTxBody (..),
  spendInputs',
  collateralInputs',
  referenceInputs',
  outputs',
  collateralReturn',
  totalCollateral',
  certs',
  withdrawals',
  txfee',
  vldt',
  update',
  reqSignerHashes',
  mint',
  scriptIntegrityHash',
  adHash',
  txnetworkid',
  getEitherAddrBabbageTxOut,
  EraIndependentScriptIntegrity,
  ScriptIntegrityHash,
  txOutData,
  txOutDataHash,
  txOutScript,
) where

import Cardano.Ledger.Alonzo (AlonzoEra)
import Cardano.Ledger.Alonzo.Core
import Cardano.Ledger.Alonzo.PParams (AlonzoPParams (appExtraEntropy), appD)
import Cardano.Ledger.Alonzo.TxAuxData (AuxiliaryDataHash (..))
import Cardano.Ledger.Alonzo.TxBody (alonzoRedeemerPointer, alonzoRedeemerPointerInverse)
import Cardano.Ledger.Babbage.Era (BabbageEra)
import Cardano.Ledger.Babbage.PParams (upgradeBabbagePParams)
import Cardano.Ledger.Babbage.Scripts ()
import Cardano.Ledger.Babbage.TxCert ()
import Cardano.Ledger.Babbage.TxOut hiding (TxOut)
import Cardano.Ledger.BaseTypes (
  Network (..),
  StrictMaybe (..),
  isSJust,
 )
import Cardano.Ledger.Binary (
  Annotator (..),
  DecCBOR (..),
  EncCBOR (..),
  Sized (..),
  ToCBOR (..),
  mkSized,
 )
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Crypto
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.Mary.Value (MaryValue (MaryValue), MultiAsset, PolicyID (..), policies)
import Cardano.Ledger.MemoBytes (
  EqRaw,
  Mem,
  MemoBytes,
  MemoHashIndex,
  Memoized (..),
  eqRaw,
  getMemoRawType,
  getMemoSafeHash,
  lensMemoRawType,
  mkMemoized,
  zipMemoRawType,
 )
import Cardano.Ledger.SafeHash (HashAnnotated (..), SafeToHash)
import Cardano.Ledger.Shelley.PParams (ProposedPPUpdates (ProposedPPUpdates), Update (..))
import Cardano.Ledger.Shelley.TxBody (getShelleyGenesisKeyHashCountTxBody)
import Cardano.Ledger.TxIn (TxIn (..))
import Control.Arrow (left)
import Control.DeepSeq (NFData)
import Control.Monad (when)
import Data.Foldable as F (foldl')
import Data.Sequence.Strict (StrictSeq, (|>))
import qualified Data.Sequence.Strict as StrictSeq
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Typeable (Typeable)
import Data.Void (absurd)
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks)

class (AlonzoEraTxBody era, BabbageEraTxOut era) => BabbageEraTxBody era where
  sizedOutputsTxBodyL :: Lens' (TxBody era) (StrictSeq (Sized (TxOut era)))

  referenceInputsTxBodyL :: Lens' (TxBody era) (Set (TxIn (EraCrypto era)))

  totalCollateralTxBodyL :: Lens' (TxBody era) (StrictMaybe Coin)

  collateralReturnTxBodyL :: Lens' (TxBody era) (StrictMaybe (TxOut era))

  sizedCollateralReturnTxBodyL :: Lens' (TxBody era) (StrictMaybe (Sized (TxOut era)))

  allSizedOutputsTxBodyF :: SimpleGetter (TxBody era) (StrictSeq (Sized (TxOut era)))

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

data BabbageTxBodyRaw era = BabbageTxBodyRaw
  { forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs :: !(Set (TxIn (EraCrypto era)))
  , forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs :: !(Set (TxIn (EraCrypto era)))
  , forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs :: !(Set (TxIn (EraCrypto era)))
  , forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs :: !(StrictSeq (Sized (TxOut era)))
  , forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn :: !(StrictMaybe (Sized (TxOut era)))
  , forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral :: !(StrictMaybe Coin)
  , forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts :: !(StrictSeq (TxCert era))
  , forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals :: !(Withdrawals (EraCrypto era))
  , forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee :: !Coin
  , forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval :: !ValidityInterval
  , forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate :: !(StrictMaybe (Update era))
  , forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes :: !(Set (KeyHash 'Witness (EraCrypto era)))
  , forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint :: !(MultiAsset (EraCrypto era))
  , -- The spec makes it clear that the mint field is a
    -- Cardano.Ledger.Mary.Value.MaryValue, not a Value.
    -- Operations on the TxBody in the BabbageEra depend upon this.
    -- We now store only the MultiAsset part of a Mary.Value.
    forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash :: !(StrictMaybe (ScriptIntegrityHash (EraCrypto era)))
  , forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash :: !(StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
  , forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId :: !(StrictMaybe Network)
  }
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (BabbageTxBodyRaw era) x -> BabbageTxBodyRaw era
forall era x. BabbageTxBodyRaw era -> Rep (BabbageTxBodyRaw era) x
$cto :: forall era x. Rep (BabbageTxBodyRaw era) x -> BabbageTxBodyRaw era
$cfrom :: forall era x. BabbageTxBodyRaw era -> Rep (BabbageTxBodyRaw era) x
Generic, Typeable)

-- We override this instance because the 'Sized' types also reference their
-- serialisation and as such cannot be compared directly. An alternative would
-- be to derive `EqRaw` for `Sized`.
instance
  (Era era, Eq (TxOut era), Eq (TxCert era), Eq (PParamsUpdate era)) =>
  EqRaw (BabbageTxBodyRaw era)
  where
  eqRaw :: BabbageTxBodyRaw era -> BabbageTxBodyRaw era -> Bool
eqRaw BabbageTxBodyRaw era
a BabbageTxBodyRaw era
b =
    forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs BabbageTxBodyRaw era
a forall {a}.
Eq a =>
StrictSeq (Sized a) -> StrictSeq (Sized a) -> Bool
`eqSeqUnsized` forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn BabbageTxBodyRaw era
a forall {a}.
Eq a =>
StrictMaybe (Sized a) -> StrictMaybe (Sized a) -> Bool
`eqMbUnsized` forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId BabbageTxBodyRaw era
b
    where
      eqMbUnsized :: StrictMaybe (Sized a) -> StrictMaybe (Sized a) -> Bool
eqMbUnsized StrictMaybe (Sized a)
x StrictMaybe (Sized a)
y = case (StrictMaybe (Sized a)
x, StrictMaybe (Sized a)
y) of
        (SJust Sized a
a', SJust Sized a
b') -> Sized a
a' forall {a}. Eq a => Sized a -> Sized a -> Bool
`eqUnsized` Sized a
b'
        (StrictMaybe (Sized a)
SNothing, StrictMaybe (Sized a)
SNothing) -> Bool
True
        (StrictMaybe (Sized a), StrictMaybe (Sized a))
_ -> Bool
False
      eqSeqUnsized :: StrictSeq (Sized a) -> StrictSeq (Sized a) -> Bool
eqSeqUnsized StrictSeq (Sized a)
x StrictSeq (Sized a)
y =
        forall (t :: * -> *) a. Foldable t => t a -> Int
length StrictSeq (Sized a)
x forall a. Eq a => a -> a -> Bool
== forall (t :: * -> *) a. Foldable t => t a -> Int
length StrictSeq (Sized a)
y
          Bool -> Bool -> Bool
&& forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' (\Bool
acc (Sized a
x', Sized a
y') -> Bool
acc Bool -> Bool -> Bool
&& Sized a
x' forall {a}. Eq a => Sized a -> Sized a -> Bool
`eqUnsized` Sized a
y') Bool
True (forall a b. StrictSeq a -> StrictSeq b -> StrictSeq (a, b)
StrictSeq.zip StrictSeq (Sized a)
x StrictSeq (Sized a)
y)
      eqUnsized :: Sized a -> Sized a -> Bool
eqUnsized Sized a
x Sized a
y = forall a. Sized a -> a
sizedValue Sized a
x forall a. Eq a => a -> a -> Bool
== forall a. Sized a -> a
sizedValue Sized a
y

type instance MemoHashIndex BabbageTxBodyRaw = EraIndependentTxBody

deriving instance
  (Era era, Eq (TxOut era), Eq (TxCert era), Eq (PParamsUpdate era)) =>
  Eq (BabbageTxBodyRaw era)

instance
  (Era era, NoThunks (TxOut era), NoThunks (TxCert era), NoThunks (PParamsUpdate era)) =>
  NoThunks (BabbageTxBodyRaw era)

instance
  (Era era, NFData (TxOut era), NFData (TxCert era), NFData (PParamsUpdate era)) =>
  NFData (BabbageTxBodyRaw era)

deriving instance
  (Era era, Show (TxOut era), Show (TxCert era), Show (PParamsUpdate era)) =>
  Show (BabbageTxBodyRaw era)

newtype BabbageTxBody era = TxBodyConstr (MemoBytes BabbageTxBodyRaw era)
  deriving newtype (forall x. Rep (BabbageTxBody era) x -> BabbageTxBody era
forall x. BabbageTxBody era -> Rep (BabbageTxBody era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (BabbageTxBody era) x -> BabbageTxBody era
forall era x. BabbageTxBody era -> Rep (BabbageTxBody era) x
to :: forall x. Rep (BabbageTxBody era) x -> BabbageTxBody era
$cto :: forall era x. Rep (BabbageTxBody era) x -> BabbageTxBody era
from :: forall x. BabbageTxBody era -> Rep (BabbageTxBody era) x
$cfrom :: forall era x. BabbageTxBody era -> Rep (BabbageTxBody era) x
Generic, BabbageTxBody era -> Int
BabbageTxBody era -> ByteString
forall era. BabbageTxBody era -> Int
forall era. BabbageTxBody era -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall c index.
    HashAlgorithm (HASH c) =>
    Proxy c -> Proxy index -> t -> SafeHash c index)
-> SafeToHash t
forall c index.
HashAlgorithm (HASH c) =>
Proxy c -> Proxy index -> BabbageTxBody era -> SafeHash c index
forall era c index.
HashAlgorithm (HASH c) =>
Proxy c -> Proxy index -> BabbageTxBody era -> SafeHash c index
makeHashWithExplicitProxys :: forall c index.
HashAlgorithm (HASH c) =>
Proxy c -> Proxy index -> BabbageTxBody era -> SafeHash c index
$cmakeHashWithExplicitProxys :: forall era c index.
HashAlgorithm (HASH c) =>
Proxy c -> Proxy index -> BabbageTxBody era -> SafeHash c index
originalBytesSize :: BabbageTxBody era -> Int
$coriginalBytesSize :: forall era. BabbageTxBody era -> Int
originalBytes :: BabbageTxBody era -> ByteString
$coriginalBytes :: forall era. BabbageTxBody era -> ByteString
SafeToHash, BabbageTxBody era -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [BabbageTxBody era] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (BabbageTxBody era) -> Size
forall {era}. Typeable era => Typeable (BabbageTxBody era)
forall era. Typeable era => BabbageTxBody era -> Encoding
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [BabbageTxBody era] -> Size
forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (BabbageTxBody era) -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [BabbageTxBody era] -> Size
$cencodedListSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [BabbageTxBody era] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (BabbageTxBody era) -> Size
$cencodedSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (BabbageTxBody era) -> Size
toCBOR :: BabbageTxBody era -> Encoding
$ctoCBOR :: forall era. Typeable era => BabbageTxBody era -> Encoding
ToCBOR)

instance Memoized BabbageTxBody where
  type RawType BabbageTxBody = BabbageTxBodyRaw

deriving newtype instance
  (Era era, NFData (TxOut era), NFData (TxCert era), NFData (PParamsUpdate era)) =>
  NFData (BabbageTxBody era)

inputsBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
inputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
inputsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw Set (TxIn (EraCrypto era))
inputs -> RawType BabbageTxBody era
txBodyRaw {btbrSpendInputs :: Set (TxIn (EraCrypto era))
btbrSpendInputs = Set (TxIn (EraCrypto era))
inputs}
{-# INLINEABLE inputsBabbageTxBodyL #-}

outputsBabbageTxBodyL ::
  forall era. BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictSeq (TxOut era))
outputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (TxOut era))
outputsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Sized a -> a
sizedValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs) forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictSeq (TxOut era)
outputs -> RawType BabbageTxBody era
txBodyRaw {btbrOutputs :: StrictSeq (Sized (TxOut era))
btbrOutputs = forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @era) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (TxOut era)
outputs}
{-# INLINEABLE outputsBabbageTxBodyL #-}

feeBabbageTxBodyL :: BabbageEraTxBody era => Lens' (BabbageTxBody era) Coin
feeBabbageTxBodyL :: forall era. BabbageEraTxBody era => Lens' (BabbageTxBody era) Coin
feeBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw Coin
fee -> RawType BabbageTxBody era
txBodyRaw {btbrTxFee :: Coin
btbrTxFee = Coin
fee}
{-# INLINEABLE feeBabbageTxBodyL #-}

auxDataHashBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
auxDataHashBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens'
  (BabbageTxBody era)
  (StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
auxDataHashBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe (AuxiliaryDataHash (EraCrypto era))
auxDataHash -> RawType BabbageTxBody era
txBodyRaw {btbrAuxDataHash :: StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash = StrictMaybe (AuxiliaryDataHash (EraCrypto era))
auxDataHash}
{-# INLINEABLE auxDataHashBabbageTxBodyL #-}

babbageSpendableInputsTxBodyF ::
  BabbageEraTxBody era => SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageSpendableInputsTxBodyF :: forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageSpendableInputsTxBodyF =
  forall s a. (s -> a) -> SimpleGetter s a
to forall a b. (a -> b) -> a -> b
$ \TxBody era
txBody ->
    (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
inputsTxBodyL)
      forall a. Ord a => Set a -> Set a -> Set a
`Set.union` (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsTxBodyL)
{-# INLINEABLE babbageSpendableInputsTxBodyF #-}

babbageAllInputsTxBodyF ::
  BabbageEraTxBody era => SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageAllInputsTxBodyF :: forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageAllInputsTxBodyF =
  forall s a. (s -> a) -> SimpleGetter s a
to forall a b. (a -> b) -> a -> b
$ \TxBody era
txBody ->
    (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
inputsTxBodyL)
      forall a. Ord a => Set a -> Set a -> Set a
`Set.union` (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsTxBodyL)
      forall a. Ord a => Set a -> Set a -> Set a
`Set.union` (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
referenceInputsTxBodyL)
{-# INLINEABLE babbageAllInputsTxBodyF #-}

mintedBabbageTxBodyF :: SimpleGetter (BabbageTxBody era) (Set (PolicyID (EraCrypto era)))
mintedBabbageTxBodyF :: forall era.
SimpleGetter (BabbageTxBody era) (Set (PolicyID (EraCrypto era)))
mintedBabbageTxBodyF = forall s a. (s -> a) -> SimpleGetter s a
to (forall c. MultiAsset c -> Set (PolicyID c)
policies forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType)
{-# INLINEABLE mintedBabbageTxBodyF #-}

withdrawalsBabbbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (Withdrawals (EraCrypto era))
withdrawalsBabbbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Withdrawals (EraCrypto era))
withdrawalsBabbbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Withdrawals (EraCrypto era)
withdrawals -> RawType BabbageTxBody era
txBodyRaw {btbrWithdrawals :: Withdrawals (EraCrypto era)
btbrWithdrawals = Withdrawals (EraCrypto era)
withdrawals}
{-# INLINEABLE withdrawalsBabbbageTxBodyL #-}

updateBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe (Update era))
updateBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (Update era))
updateBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw StrictMaybe (Update era)
update -> RawType BabbageTxBody era
txBodyRaw {btbrUpdate :: StrictMaybe (Update era)
btbrUpdate = StrictMaybe (Update era)
update}
{-# INLINEABLE updateBabbageTxBodyL #-}

certsBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictSeq (TxCert era))
certsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (TxCert era))
certsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw StrictSeq (TxCert era)
certs -> RawType BabbageTxBody era
txBodyRaw {btbrCerts :: StrictSeq (TxCert era)
btbrCerts = StrictSeq (TxCert era)
certs}
{-# INLINEABLE certsBabbageTxBodyL #-}

vldtBabbageTxBodyL :: BabbageEraTxBody era => Lens' (BabbageTxBody era) ValidityInterval
vldtBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) ValidityInterval
vldtBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw ValidityInterval
vldt -> RawType BabbageTxBody era
txBodyRaw {btbrValidityInterval :: ValidityInterval
btbrValidityInterval = ValidityInterval
vldt}
{-# INLINEABLE vldtBabbageTxBodyL #-}

mintBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (MultiAsset (EraCrypto era))
mintBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (MultiAsset (EraCrypto era))
mintBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw MultiAsset (EraCrypto era)
mint -> RawType BabbageTxBody era
txBodyRaw {btbrMint :: MultiAsset (EraCrypto era)
btbrMint = MultiAsset (EraCrypto era)
mint}
{-# INLINEABLE mintBabbageTxBodyL #-}

mintValueBabbageTxBodyF ::
  (BabbageEraTxBody era, Value era ~ MaryValue (EraCrypto era)) =>
  SimpleGetter (BabbageTxBody era) (Value era)
mintValueBabbageTxBodyF :: forall era.
(BabbageEraTxBody era, Value era ~ MaryValue (EraCrypto era)) =>
SimpleGetter (BabbageTxBody era) (Value era)
mintValueBabbageTxBodyF = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (MultiAsset (EraCrypto era))
mintBabbageTxBodyL forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. (s -> a) -> SimpleGetter s a
to (forall c. Coin -> MultiAsset c -> MaryValue c
MaryValue forall a. Monoid a => a
mempty)
{-# INLINEABLE mintValueBabbageTxBodyF #-}

collateralInputsBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set (TxIn (EraCrypto era))
collateral -> RawType BabbageTxBody era
txBodyRaw {btbrCollateralInputs :: Set (TxIn (EraCrypto era))
btbrCollateralInputs = Set (TxIn (EraCrypto era))
collateral}
{-# INLINEABLE collateralInputsBabbageTxBodyL #-}

reqSignerHashesBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
reqSignerHashesBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
reqSignerHashesBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set (KeyHash 'Witness (EraCrypto era))
reqSignerHashes -> RawType BabbageTxBody era
txBodyRaw {btbrReqSignerHashes :: Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes = Set (KeyHash 'Witness (EraCrypto era))
reqSignerHashes}
{-# INLINEABLE reqSignerHashesBabbageTxBodyL #-}

scriptIntegrityHashBabbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (StrictMaybe (ScriptIntegrityHash (EraCrypto era)))
scriptIntegrityHashBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens'
  (BabbageTxBody era)
  (StrictMaybe (ScriptIntegrityHash (EraCrypto era)))
scriptIntegrityHashBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe (ScriptIntegrityHash (EraCrypto era))
scriptIntegrityHash -> RawType BabbageTxBody era
txBodyRaw {btbrScriptIntegrityHash :: StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash = StrictMaybe (ScriptIntegrityHash (EraCrypto era))
scriptIntegrityHash}
{-# INLINEABLE scriptIntegrityHashBabbageTxBodyL #-}

networkIdBabbageTxBodyL :: BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe Network)
networkIdBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe Network)
networkIdBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw StrictMaybe Network
networkId -> RawType BabbageTxBody era
txBodyRaw {btbrTxNetworkId :: StrictMaybe Network
btbrTxNetworkId = StrictMaybe Network
networkId}
{-# INLINEABLE networkIdBabbageTxBodyL #-}

sizedOutputsBabbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (StrictSeq (Sized (TxOut era)))
sizedOutputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (Sized (TxOut era)))
sizedOutputsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw StrictSeq (Sized (TxOut era))
outputs -> RawType BabbageTxBody era
txBodyRaw {btbrOutputs :: StrictSeq (Sized (TxOut era))
btbrOutputs = StrictSeq (Sized (TxOut era))
outputs}
{-# INLINEABLE sizedOutputsBabbageTxBodyL #-}

referenceInputsBabbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
referenceInputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
referenceInputsBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set (TxIn (EraCrypto era))
reference -> RawType BabbageTxBody era
txBodyRaw {btbrReferenceInputs :: Set (TxIn (EraCrypto era))
btbrReferenceInputs = Set (TxIn (EraCrypto era))
reference}
{-# INLINEABLE referenceInputsBabbageTxBodyL #-}

totalCollateralBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (StrictMaybe Coin)
totalCollateralBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe Coin)
totalCollateralBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe Coin
totalCollateral -> RawType BabbageTxBody era
txBodyRaw {btbrTotalCollateral :: StrictMaybe Coin
btbrTotalCollateral = StrictMaybe Coin
totalCollateral}
{-# INLINEABLE totalCollateralBabbageTxBodyL #-}

collateralReturnBabbageTxBodyL ::
  forall era.
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (StrictMaybe (TxOut era))
collateralReturnBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (TxOut era))
collateralReturnBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Sized a -> a
sizedValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn) forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe (TxOut era)
collateralReturn ->
      RawType BabbageTxBody era
txBodyRaw {btbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
btbrCollateralReturn = forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @era) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictMaybe (TxOut era)
collateralReturn}
{-# INLINEABLE collateralReturnBabbageTxBodyL #-}

sizedCollateralReturnBabbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (StrictMaybe (Sized (TxOut era)))
sizedCollateralReturnBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (Sized (TxOut era)))
sizedCollateralReturnBabbageTxBodyL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe (Sized (TxOut era))
collateralReturn -> RawType BabbageTxBody era
txBodyRaw {btbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
btbrCollateralReturn = StrictMaybe (Sized (TxOut era))
collateralReturn}
{-# INLINEABLE sizedCollateralReturnBabbageTxBodyL #-}

allSizedOutputsBabbageTxBodyF ::
  BabbageEraTxBody era =>
  SimpleGetter (TxBody era) (StrictSeq (Sized (TxOut era)))
allSizedOutputsBabbageTxBodyF :: forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (StrictSeq (Sized (TxOut era)))
allSizedOutputsBabbageTxBodyF =
  forall s a. (s -> a) -> SimpleGetter s a
to forall a b. (a -> b) -> a -> b
$ \TxBody era
txBody ->
    let txOuts :: StrictSeq (Sized (TxOut era))
txOuts = TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (StrictSeq (Sized (TxOut era)))
sizedOutputsTxBodyL
     in case TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (StrictMaybe (Sized (TxOut era)))
sizedCollateralReturnTxBodyL of
          StrictMaybe (Sized (TxOut era))
SNothing -> StrictSeq (Sized (TxOut era))
txOuts
          SJust Sized (TxOut era)
collTxOut -> StrictSeq (Sized (TxOut era))
txOuts forall a. StrictSeq a -> a -> StrictSeq a
|> Sized (TxOut era)
collTxOut
{-# INLINEABLE allSizedOutputsBabbageTxBodyF #-}

data BabbageTxBodyUpgradeError
  = -- | The update attempts to update the decentralistion parameter, which is
    -- dropped in Babbage.
    BTBUEUpdatesD
  | -- | The update attempts to update the extra entropy, which is dropped in
    --   Babbage.
    BTBUEUpdatesExtraEntropy
  deriving (BabbageTxBodyUpgradeError -> BabbageTxBodyUpgradeError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BabbageTxBodyUpgradeError -> BabbageTxBodyUpgradeError -> Bool
$c/= :: BabbageTxBodyUpgradeError -> BabbageTxBodyUpgradeError -> Bool
== :: BabbageTxBodyUpgradeError -> BabbageTxBodyUpgradeError -> Bool
$c== :: BabbageTxBodyUpgradeError -> BabbageTxBodyUpgradeError -> Bool
Eq, Int -> BabbageTxBodyUpgradeError -> ShowS
[BabbageTxBodyUpgradeError] -> ShowS
BabbageTxBodyUpgradeError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BabbageTxBodyUpgradeError] -> ShowS
$cshowList :: [BabbageTxBodyUpgradeError] -> ShowS
show :: BabbageTxBodyUpgradeError -> String
$cshow :: BabbageTxBodyUpgradeError -> String
showsPrec :: Int -> BabbageTxBodyUpgradeError -> ShowS
$cshowsPrec :: Int -> BabbageTxBodyUpgradeError -> ShowS
Show)

instance Crypto c => EraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance EraTxBody (BabbageEra StandardCrypto) #-}

  type TxBody (BabbageEra c) = BabbageTxBody (BabbageEra c)
  type TxBodyUpgradeError (BabbageEra c) = BabbageTxBodyUpgradeError

  mkBasicTxBody :: TxBody (BabbageEra c)
mkBasicTxBody = forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall era. BabbageTxBodyRaw era
basicBabbageTxBodyRaw

  inputsTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (Set (TxIn (EraCrypto (BabbageEra c))))
inputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
inputsBabbageTxBodyL
  {-# INLINE inputsTxBodyL #-}

  outputsTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictSeq (TxOut (BabbageEra c)))
outputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (TxOut era))
outputsBabbageTxBodyL
  {-# INLINE outputsTxBodyL #-}

  feeTxBodyL :: Lens' (TxBody (BabbageEra c)) Coin
feeTxBodyL = forall era. BabbageEraTxBody era => Lens' (BabbageTxBody era) Coin
feeBabbageTxBodyL
  {-# INLINE feeTxBodyL #-}

  auxDataHashTxBodyL :: Lens'
  (TxBody (BabbageEra c))
  (StrictMaybe (AuxiliaryDataHash (EraCrypto (BabbageEra c))))
auxDataHashTxBodyL = forall era.
BabbageEraTxBody era =>
Lens'
  (BabbageTxBody era)
  (StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
auxDataHashBabbageTxBodyL
  {-# INLINE auxDataHashTxBodyL #-}

  spendableInputsTxBodyF :: SimpleGetter
  (TxBody (BabbageEra c)) (Set (TxIn (EraCrypto (BabbageEra c))))
spendableInputsTxBodyF = forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageSpendableInputsTxBodyF
  {-# INLINE spendableInputsTxBodyF #-}

  allInputsTxBodyF :: SimpleGetter
  (TxBody (BabbageEra c)) (Set (TxIn (EraCrypto (BabbageEra c))))
allInputsTxBodyF = forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set (TxIn (EraCrypto era)))
babbageAllInputsTxBodyF
  {-# INLINE allInputsTxBodyF #-}

  withdrawalsTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (Withdrawals (EraCrypto (BabbageEra c)))
withdrawalsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Withdrawals (EraCrypto era))
withdrawalsBabbbageTxBodyL
  {-# INLINE withdrawalsTxBodyL #-}

  certsTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictSeq (TxCert (BabbageEra c)))
certsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (TxCert era))
certsBabbageTxBodyL
  {-# INLINE certsTxBodyL #-}

  getGenesisKeyHashCountTxBody :: TxBody (BabbageEra c) -> Int
getGenesisKeyHashCountTxBody = forall era. ShelleyEraTxBody era => TxBody era -> Int
getShelleyGenesisKeyHashCountTxBody

  upgradeTxBody :: EraTxBody (PreviousEra (BabbageEra c)) =>
TxBody (PreviousEra (BabbageEra c))
-> Either
     (TxBodyUpgradeError (BabbageEra c)) (TxBody (BabbageEra c))
upgradeTxBody TxBody (PreviousEra (BabbageEra c))
txBody = do
    StrictSeq (TxCert (BabbageEra c))
certs <-
      forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
        (forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left forall a. Void -> a
absurd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraTxCert era, EraTxCert (PreviousEra era)) =>
TxCert (PreviousEra era)
-> Either (TxCertUpgradeError era) (TxCert era)
upgradeTxCert)
        (TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)
    StrictMaybe (Update (BabbageEra c))
updates <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Update (AlonzoEra c)
-> Either BabbageTxBodyUpgradeError (Update (BabbageEra c))
upgradeUpdate (TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ShelleyEraTxBody era =>
Lens' (TxBody era) (StrictMaybe (Update era))
updateTxBodyL)
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
      BabbageTxBody
        { btbInputs :: Set (TxIn (EraCrypto (BabbageEra c)))
btbInputs = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
inputsTxBodyL
        , btbOutputs :: StrictSeq (Sized (TxOut (BabbageEra c)))
btbOutputs =
            forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @(BabbageEra c)) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraTxOut era, EraTxOut (PreviousEra era)) =>
TxOut (PreviousEra era) -> TxOut era
upgradeTxOut forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
outputsTxBodyL)
        , btbCerts :: StrictSeq (TxCert (BabbageEra c))
btbCerts = StrictSeq (TxCert (BabbageEra c))
certs
        , btbWithdrawals :: Withdrawals (EraCrypto (BabbageEra c))
btbWithdrawals = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (Withdrawals (EraCrypto era))
withdrawalsTxBodyL
        , btbTxFee :: Coin
btbTxFee = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) Coin
feeTxBodyL
        , btbValidityInterval :: ValidityInterval
btbValidityInterval = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
vldtTxBodyL
        , btbUpdate :: StrictMaybe (Update (BabbageEra c))
btbUpdate = StrictMaybe (Update (BabbageEra c))
updates
        , btbAuxDataHash :: StrictMaybe (AuxiliaryDataHash (EraCrypto (BabbageEra c)))
btbAuxDataHash = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens'
  (TxBody era) (StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
auxDataHashTxBodyL
        , btbMint :: MultiAsset (EraCrypto (BabbageEra c))
btbMint = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
MaryEraTxBody era =>
Lens' (TxBody era) (MultiAsset (EraCrypto era))
mintTxBodyL
        , btbCollateral :: Set (TxIn (EraCrypto (BabbageEra c)))
btbCollateral = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsTxBodyL
        , btbReqSignerHashes :: Set (KeyHash 'Witness (EraCrypto (BabbageEra c)))
btbReqSignerHashes = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
reqSignerHashesTxBodyL
        , btbScriptIntegrityHash :: StrictMaybe (ScriptIntegrityHash (EraCrypto (BabbageEra c)))
btbScriptIntegrityHash = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens'
  (TxBody era) (StrictMaybe (ScriptIntegrityHash (EraCrypto era)))
scriptIntegrityHashTxBodyL
        , btbTxNetworkId :: StrictMaybe Network
btbTxNetworkId = TxBody (PreviousEra (BabbageEra c))
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Network)
networkIdTxBodyL
        , btbReferenceInputs :: Set (TxIn (EraCrypto (BabbageEra c)))
btbReferenceInputs = forall a. Monoid a => a
mempty
        , btbCollateralReturn :: StrictMaybe (Sized (TxOut (BabbageEra c)))
btbCollateralReturn = forall a. StrictMaybe a
SNothing
        , btbTotalCollateral :: StrictMaybe Coin
btbTotalCollateral = forall a. StrictMaybe a
SNothing
        }
    where
      upgradeUpdate ::
        Update (AlonzoEra c) ->
        Either BabbageTxBodyUpgradeError (Update (BabbageEra c))
      upgradeUpdate :: Update (AlonzoEra c)
-> Either BabbageTxBodyUpgradeError (Update (BabbageEra c))
upgradeUpdate (Update ProposedPPUpdates (AlonzoEra c)
pp EpochNo
epoch) =
        forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ProposedPPUpdates (AlonzoEra c)
-> Either
     BabbageTxBodyUpgradeError (ProposedPPUpdates (BabbageEra c))
upgradeProposedPPUpdates ProposedPPUpdates (AlonzoEra c)
pp forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure EpochNo
epoch

      -- Note that here we use 'upgradeBabbagePParams False' in order to
      -- preserve 'CoinsPerUTxOWord', in spite of the value now being
      -- semantically incorrect. Anything else will result in an invalid
      -- transaction.
      upgradeProposedPPUpdates ::
        ProposedPPUpdates (AlonzoEra c) ->
        Either BabbageTxBodyUpgradeError (ProposedPPUpdates (BabbageEra c))
      upgradeProposedPPUpdates :: ProposedPPUpdates (AlonzoEra c)
-> Either
     BabbageTxBodyUpgradeError (ProposedPPUpdates (BabbageEra c))
upgradeProposedPPUpdates (ProposedPPUpdates Map
  (KeyHash 'Genesis (EraCrypto (AlonzoEra c)))
  (PParamsUpdate (AlonzoEra c))
m) =
        forall era.
Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
ProposedPPUpdates
          forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
            ( \(PParamsUpdate PParamsHKD StrictMaybe (AlonzoEra c)
pphkd) -> do
                forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. StrictMaybe a -> Bool
isSJust forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) era. AlonzoPParams f era -> HKD f UnitInterval
appD PParamsHKD StrictMaybe (AlonzoEra c)
pphkd) forall a b. (a -> b) -> a -> b
$
                  forall a b. a -> Either a b
Left BabbageTxBodyUpgradeError
BTBUEUpdatesD
                forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. StrictMaybe a -> Bool
isSJust forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) era. AlonzoPParams f era -> HKD f Nonce
appExtraEntropy PParamsHKD StrictMaybe (AlonzoEra c)
pphkd) forall a b. (a -> b) -> a -> b
$
                  forall a b. a -> Either a b
Left BabbageTxBodyUpgradeError
BTBUEUpdatesExtraEntropy
                forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
PParamsUpdate forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) c.
HKDFunctor f =>
Bool
-> PParamsHKD f (AlonzoEra c) -> BabbagePParams f (BabbageEra c)
upgradeBabbagePParams Bool
False PParamsHKD StrictMaybe (AlonzoEra c)
pphkd
            )
            Map
  (KeyHash 'Genesis (EraCrypto (AlonzoEra c)))
  (PParamsUpdate (AlonzoEra c))
m

instance Crypto c => ShelleyEraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance ShelleyEraTxBody (BabbageEra StandardCrypto) #-}

  ttlTxBodyL :: ExactEra ShelleyEra (BabbageEra c) =>
Lens' (TxBody (BabbageEra c)) SlotNo
ttlTxBodyL = forall a b. HasCallStack => Lens' a b
notSupportedInThisEraL
  {-# INLINE ttlTxBodyL #-}

  updateTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictMaybe (Update (BabbageEra c)))
updateTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (Update era))
updateBabbageTxBodyL
  {-# INLINE updateTxBodyL #-}

instance Crypto c => AllegraEraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance AllegraEraTxBody (BabbageEra StandardCrypto) #-}

  vldtTxBodyL :: Lens' (TxBody (BabbageEra c)) ValidityInterval
vldtTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) ValidityInterval
vldtBabbageTxBodyL
  {-# INLINE vldtTxBodyL #-}

instance Crypto c => MaryEraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance MaryEraTxBody (BabbageEra StandardCrypto) #-}

  mintTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (MultiAsset (EraCrypto (BabbageEra c)))
mintTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (MultiAsset (EraCrypto era))
mintBabbageTxBodyL
  {-# INLINE mintTxBodyL #-}

  mintValueTxBodyF :: SimpleGetter (TxBody (BabbageEra c)) (Value (BabbageEra c))
mintValueTxBodyF = forall era.
(BabbageEraTxBody era, Value era ~ MaryValue (EraCrypto era)) =>
SimpleGetter (BabbageTxBody era) (Value era)
mintValueBabbageTxBodyF
  {-# INLINE mintValueTxBodyF #-}

  mintedTxBodyF :: SimpleGetter
  (TxBody (BabbageEra c)) (Set (PolicyID (EraCrypto (BabbageEra c))))
mintedTxBodyF = forall era.
SimpleGetter (BabbageTxBody era) (Set (PolicyID (EraCrypto era)))
mintedBabbageTxBodyF
  {-# INLINE mintedTxBodyF #-}

instance Crypto c => AlonzoEraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance AlonzoEraTxBody (BabbageEra StandardCrypto) #-}

  collateralInputsTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (Set (TxIn (EraCrypto (BabbageEra c))))
collateralInputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
collateralInputsBabbageTxBodyL
  {-# INLINE collateralInputsTxBodyL #-}

  reqSignerHashesTxBodyL :: Lens'
  (TxBody (BabbageEra c))
  (Set (KeyHash 'Witness (EraCrypto (BabbageEra c))))
reqSignerHashesTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
reqSignerHashesBabbageTxBodyL
  {-# INLINE reqSignerHashesTxBodyL #-}

  scriptIntegrityHashTxBodyL :: Lens'
  (TxBody (BabbageEra c))
  (StrictMaybe (ScriptIntegrityHash (EraCrypto (BabbageEra c))))
scriptIntegrityHashTxBodyL = forall era.
BabbageEraTxBody era =>
Lens'
  (BabbageTxBody era)
  (StrictMaybe (ScriptIntegrityHash (EraCrypto era)))
scriptIntegrityHashBabbageTxBodyL
  {-# INLINE scriptIntegrityHashTxBodyL #-}

  networkIdTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictMaybe Network)
networkIdTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe Network)
networkIdBabbageTxBodyL
  {-# INLINE networkIdTxBodyL #-}

  redeemerPointer :: TxBody (BabbageEra c)
-> PlutusPurpose AsItem (BabbageEra c)
-> StrictMaybe (PlutusPurpose AsIx (BabbageEra c))
redeemerPointer = forall era.
MaryEraTxBody era =>
TxBody era
-> AlonzoPlutusPurpose AsItem era
-> StrictMaybe (AlonzoPlutusPurpose AsIx era)
alonzoRedeemerPointer

  redeemerPointerInverse :: TxBody (BabbageEra c)
-> PlutusPurpose AsIx (BabbageEra c)
-> StrictMaybe (PlutusPurpose AsIxItem (BabbageEra c))
redeemerPointerInverse = forall era.
MaryEraTxBody era =>
TxBody era
-> AlonzoPlutusPurpose AsIx era
-> StrictMaybe (AlonzoPlutusPurpose AsIxItem era)
alonzoRedeemerPointerInverse

instance Crypto c => BabbageEraTxBody (BabbageEra c) where
  {-# SPECIALIZE instance BabbageEraTxBody (BabbageEra StandardCrypto) #-}

  sizedOutputsTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (StrictSeq (Sized (TxOut (BabbageEra c))))
sizedOutputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictSeq (Sized (TxOut era)))
sizedOutputsBabbageTxBodyL
  {-# INLINE sizedOutputsTxBodyL #-}

  referenceInputsTxBodyL :: Lens'
  (TxBody (BabbageEra c)) (Set (TxIn (EraCrypto (BabbageEra c))))
referenceInputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (TxIn (EraCrypto era)))
referenceInputsBabbageTxBodyL
  {-# INLINE referenceInputsTxBodyL #-}

  totalCollateralTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictMaybe Coin)
totalCollateralTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe Coin)
totalCollateralBabbageTxBodyL
  {-# INLINE totalCollateralTxBodyL #-}

  collateralReturnTxBodyL :: Lens' (TxBody (BabbageEra c)) (StrictMaybe (TxOut (BabbageEra c)))
collateralReturnTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (TxOut era))
collateralReturnBabbageTxBodyL
  {-# INLINE collateralReturnTxBodyL #-}

  sizedCollateralReturnTxBodyL :: Lens'
  (TxBody (BabbageEra c))
  (StrictMaybe (Sized (TxOut (BabbageEra c))))
sizedCollateralReturnTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe (Sized (TxOut era)))
sizedCollateralReturnBabbageTxBodyL
  {-# INLINE sizedCollateralReturnTxBodyL #-}

  allSizedOutputsTxBodyF :: SimpleGetter
  (TxBody (BabbageEra c)) (StrictSeq (Sized (TxOut (BabbageEra c))))
allSizedOutputsTxBodyF = forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (StrictSeq (Sized (TxOut era)))
allSizedOutputsBabbageTxBodyF
  {-# INLINE allSizedOutputsTxBodyF #-}

instance
  (Era era, Eq (PParamsUpdate era), Eq (TxOut era), Eq (TxCert era)) =>
  EqRaw (BabbageTxBody era)
  where
  eqRaw :: BabbageTxBody era -> BabbageTxBody era -> Bool
eqRaw = forall (t1 :: * -> *) (t2 :: * -> *) era a.
(Memoized t1, Memoized t2) =>
(RawType t1 era -> RawType t2 era -> a) -> t1 era -> t2 era -> a
zipMemoRawType forall a. EqRaw a => a -> a -> Bool
eqRaw

deriving newtype instance
  (Era era, Eq (TxOut era), Eq (TxCert era), Eq (PParamsUpdate era)) =>
  Eq (BabbageTxBody era)

deriving instance
  (Era era, NoThunks (TxOut era), NoThunks (TxCert era), NoThunks (PParamsUpdate era)) =>
  NoThunks (BabbageTxBody era)

deriving instance
  (Era era, Show (TxOut era), Show (TxCert era), Show (PParamsUpdate era)) =>
  Show (BabbageTxBody era)

deriving via
  (Mem BabbageTxBodyRaw era)
  instance
    (Era era, DecCBOR (TxOut era), DecCBOR (TxCert era), DecCBOR (PParamsUpdate era)) =>
    DecCBOR (Annotator (BabbageTxBody era))

instance
  (Era era, DecCBOR (TxOut era), DecCBOR (TxCert era), DecCBOR (PParamsUpdate era)) =>
  DecCBOR (Annotator (BabbageTxBodyRaw era))
  where
  decCBOR :: forall s. Decoder s (Annotator (BabbageTxBodyRaw era))
decCBOR = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. DecCBOR a => Decoder s a
decCBOR

pattern BabbageTxBody ::
  BabbageEraTxBody era =>
  Set (TxIn (EraCrypto era)) ->
  Set (TxIn (EraCrypto era)) ->
  Set (TxIn (EraCrypto era)) ->
  StrictSeq (Sized (TxOut era)) ->
  StrictMaybe (Sized (TxOut era)) ->
  StrictMaybe Coin ->
  StrictSeq (TxCert era) ->
  Withdrawals (EraCrypto era) ->
  Coin ->
  ValidityInterval ->
  StrictMaybe (Update era) ->
  Set (KeyHash 'Witness (EraCrypto era)) ->
  MultiAsset (EraCrypto era) ->
  StrictMaybe (ScriptIntegrityHash (EraCrypto era)) ->
  StrictMaybe (AuxiliaryDataHash (EraCrypto era)) ->
  StrictMaybe Network ->
  BabbageTxBody era
pattern $bBabbageTxBody :: forall era.
BabbageEraTxBody era =>
Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness (EraCrypto era))
-> MultiAsset (EraCrypto era)
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> StrictMaybe Network
-> BabbageTxBody era
$mBabbageTxBody :: forall {r} {era}.
BabbageEraTxBody era =>
BabbageTxBody era
-> (Set (TxIn (EraCrypto era))
    -> Set (TxIn (EraCrypto era))
    -> Set (TxIn (EraCrypto era))
    -> StrictSeq (Sized (TxOut era))
    -> StrictMaybe (Sized (TxOut era))
    -> StrictMaybe Coin
    -> StrictSeq (TxCert era)
    -> Withdrawals (EraCrypto era)
    -> Coin
    -> ValidityInterval
    -> StrictMaybe (Update era)
    -> Set (KeyHash 'Witness (EraCrypto era))
    -> MultiAsset (EraCrypto era)
    -> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
    -> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
    -> StrictMaybe Network
    -> r)
-> ((# #) -> r)
-> r
BabbageTxBody
  { forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Set (TxIn (EraCrypto era))
btbInputs
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Set (TxIn (EraCrypto era))
btbCollateral
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Set (TxIn (EraCrypto era))
btbReferenceInputs
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictSeq (Sized (TxOut era))
btbOutputs
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe (Sized (TxOut era))
btbCollateralReturn
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe Coin
btbTotalCollateral
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictSeq (TxCert era)
btbCerts
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Withdrawals (EraCrypto era)
btbWithdrawals
  , forall era. BabbageEraTxBody era => BabbageTxBody era -> Coin
btbTxFee
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> ValidityInterval
btbValidityInterval
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe (Update era)
btbUpdate
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Set (KeyHash 'Witness (EraCrypto era))
btbReqSignerHashes
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> MultiAsset (EraCrypto era)
btbMint
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbScriptIntegrityHash
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbAuxDataHash
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe Network
btbTxNetworkId
  } <-
  ( getMemoRawType ->
      BabbageTxBodyRaw
        { btbrSpendInputs = btbInputs
        , btbrCollateralInputs = btbCollateral
        , btbrReferenceInputs = btbReferenceInputs
        , btbrOutputs = btbOutputs
        , btbrCollateralReturn = btbCollateralReturn
        , btbrTotalCollateral = btbTotalCollateral
        , btbrCerts = btbCerts
        , btbrWithdrawals = btbWithdrawals
        , btbrTxFee = btbTxFee
        , btbrValidityInterval = btbValidityInterval
        , btbrUpdate = btbUpdate
        , btbrReqSignerHashes = btbReqSignerHashes
        , btbrMint = btbMint
        , btbrScriptIntegrityHash = btbScriptIntegrityHash
        , btbrAuxDataHash = btbAuxDataHash
        , btbrTxNetworkId = btbTxNetworkId
        }
    )
  where
    BabbageTxBody
      Set (TxIn (EraCrypto era))
inputs
      Set (TxIn (EraCrypto era))
collateral
      Set (TxIn (EraCrypto era))
referenceInputs
      StrictSeq (Sized (TxOut era))
outputs
      StrictMaybe (Sized (TxOut era))
collateralReturn
      StrictMaybe Coin
totalCollateral
      StrictSeq (TxCert era)
certs
      Withdrawals (EraCrypto era)
withdrawals
      Coin
txFee
      ValidityInterval
validityInterval
      StrictMaybe (Update era)
update
      Set (KeyHash 'Witness (EraCrypto era))
reqSignerHashes
      MultiAsset (EraCrypto era)
mint
      StrictMaybe (ScriptIntegrityHash (EraCrypto era))
scriptIntegrityHash
      StrictMaybe (AuxiliaryDataHash (EraCrypto era))
auxDataHash
      StrictMaybe Network
txNetworkId =
        forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall a b. (a -> b) -> a -> b
$
          BabbageTxBodyRaw
            { btbrSpendInputs :: Set (TxIn (EraCrypto era))
btbrSpendInputs = Set (TxIn (EraCrypto era))
inputs
            , btbrCollateralInputs :: Set (TxIn (EraCrypto era))
btbrCollateralInputs = Set (TxIn (EraCrypto era))
collateral
            , btbrReferenceInputs :: Set (TxIn (EraCrypto era))
btbrReferenceInputs = Set (TxIn (EraCrypto era))
referenceInputs
            , btbrOutputs :: StrictSeq (Sized (TxOut era))
btbrOutputs = StrictSeq (Sized (TxOut era))
outputs
            , btbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
btbrCollateralReturn = StrictMaybe (Sized (TxOut era))
collateralReturn
            , btbrTotalCollateral :: StrictMaybe Coin
btbrTotalCollateral = StrictMaybe Coin
totalCollateral
            , btbrCerts :: StrictSeq (TxCert era)
btbrCerts = StrictSeq (TxCert era)
certs
            , btbrWithdrawals :: Withdrawals (EraCrypto era)
btbrWithdrawals = Withdrawals (EraCrypto era)
withdrawals
            , btbrTxFee :: Coin
btbrTxFee = Coin
txFee
            , btbrValidityInterval :: ValidityInterval
btbrValidityInterval = ValidityInterval
validityInterval
            , btbrUpdate :: StrictMaybe (Update era)
btbrUpdate = StrictMaybe (Update era)
update
            , btbrReqSignerHashes :: Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes = Set (KeyHash 'Witness (EraCrypto era))
reqSignerHashes
            , btbrMint :: MultiAsset (EraCrypto era)
btbrMint = MultiAsset (EraCrypto era)
mint
            , btbrScriptIntegrityHash :: StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash = StrictMaybe (ScriptIntegrityHash (EraCrypto era))
scriptIntegrityHash
            , btbrAuxDataHash :: StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash = StrictMaybe (AuxiliaryDataHash (EraCrypto era))
auxDataHash
            , btbrTxNetworkId :: StrictMaybe Network
btbrTxNetworkId = StrictMaybe Network
txNetworkId
            }

{-# COMPLETE BabbageTxBody #-}

instance c ~ EraCrypto era => HashAnnotated (BabbageTxBody era) EraIndependentTxBody c where
  hashAnnotated :: HashAlgorithm (HASH c) =>
BabbageTxBody era -> SafeHash c EraIndependentTxBody
hashAnnotated = forall (t :: * -> *) era.
Memoized t =>
t era -> SafeHash (EraCrypto era) (MemoHashIndex (RawType t))
getMemoSafeHash

-- ==============================================================================
-- We define these accessor functions manually, because if we define them using
-- the record syntax in the TxBody pattern, they inherit the (BabbageBody era)
-- constraint as a precondition. This is unnecessary, as one can see below
-- they need not be constrained at all. This should be fixed in the GHC compiler.

spendInputs' :: BabbageTxBody era -> Set (TxIn (EraCrypto era))
collateralInputs' :: BabbageTxBody era -> Set (TxIn (EraCrypto era))
referenceInputs' :: BabbageTxBody era -> Set (TxIn (EraCrypto era))
outputs' :: BabbageTxBody era -> StrictSeq (TxOut era)
collateralReturn' :: BabbageTxBody era -> StrictMaybe (TxOut era)
totalCollateral' :: BabbageTxBody era -> StrictMaybe Coin
certs' :: BabbageTxBody era -> StrictSeq (TxCert era)
txfee' :: BabbageTxBody era -> Coin
withdrawals' :: BabbageTxBody era -> Withdrawals (EraCrypto era)
vldt' :: BabbageTxBody era -> ValidityInterval
update' :: BabbageTxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: BabbageTxBody era -> Set (KeyHash 'Witness (EraCrypto era))
adHash' :: BabbageTxBody era -> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
mint' :: BabbageTxBody era -> MultiAsset (EraCrypto era)
scriptIntegrityHash' :: BabbageTxBody era -> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
spendInputs' :: forall era. BabbageTxBody era -> Set (TxIn (EraCrypto era))
spendInputs' = forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

txnetworkid' :: BabbageTxBody era -> StrictMaybe Network

collateralInputs' :: forall era. BabbageTxBody era -> Set (TxIn (EraCrypto era))
collateralInputs' = forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

referenceInputs' :: forall era. BabbageTxBody era -> Set (TxIn (EraCrypto era))
referenceInputs' = forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

outputs' :: forall era. BabbageTxBody era -> StrictSeq (TxOut era)
outputs' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Sized a -> a
sizedValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

collateralReturn' :: forall era. BabbageTxBody era -> StrictMaybe (TxOut era)
collateralReturn' = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Sized a -> a
sizedValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

totalCollateral' :: forall era. BabbageTxBody era -> StrictMaybe Coin
totalCollateral' = forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

certs' :: forall era. BabbageTxBody era -> StrictSeq (TxCert era)
certs' = forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

withdrawals' :: forall era. BabbageTxBody era -> Withdrawals (EraCrypto era)
withdrawals' = forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

txfee' :: forall era. BabbageTxBody era -> Coin
txfee' = forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

vldt' :: forall era. BabbageTxBody era -> ValidityInterval
vldt' = forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

update' :: forall era. BabbageTxBody era -> StrictMaybe (Update era)
update' = forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

reqSignerHashes' :: forall era.
BabbageTxBody era -> Set (KeyHash 'Witness (EraCrypto era))
reqSignerHashes' = forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

adHash' :: forall era.
BabbageTxBody era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
adHash' = forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

mint' :: forall era. BabbageTxBody era -> MultiAsset (EraCrypto era)
mint' = forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

scriptIntegrityHash' :: forall era.
BabbageTxBody era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
scriptIntegrityHash' = forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

txnetworkid' :: forall era. BabbageTxBody era -> StrictMaybe Network
txnetworkid' = forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) era. Memoized t => t era -> RawType t era
getMemoRawType

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

-- | Encodes memoized bytes created upon construction.
instance Era era => EncCBOR (BabbageTxBody era)

instance
  (Era era, EncCBOR (TxOut era), EncCBOR (TxCert era), EncCBOR (PParamsUpdate era)) =>
  EncCBOR (BabbageTxBodyRaw era)
  where
  encCBOR :: BabbageTxBodyRaw era -> Encoding
encCBOR
    BabbageTxBodyRaw
      { Set (TxIn (EraCrypto era))
btbrSpendInputs :: Set (TxIn (EraCrypto era))
btbrSpendInputs :: forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrSpendInputs
      , Set (TxIn (EraCrypto era))
btbrCollateralInputs :: Set (TxIn (EraCrypto era))
btbrCollateralInputs :: forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrCollateralInputs
      , Set (TxIn (EraCrypto era))
btbrReferenceInputs :: Set (TxIn (EraCrypto era))
btbrReferenceInputs :: forall era. BabbageTxBodyRaw era -> Set (TxIn (EraCrypto era))
btbrReferenceInputs
      , StrictSeq (Sized (TxOut era))
btbrOutputs :: StrictSeq (Sized (TxOut era))
btbrOutputs :: forall era. BabbageTxBodyRaw era -> StrictSeq (Sized (TxOut era))
btbrOutputs
      , StrictMaybe (Sized (TxOut era))
btbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
btbrCollateralReturn :: forall era. BabbageTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
btbrCollateralReturn
      , StrictMaybe Coin
btbrTotalCollateral :: StrictMaybe Coin
btbrTotalCollateral :: forall era. BabbageTxBodyRaw era -> StrictMaybe Coin
btbrTotalCollateral
      , StrictSeq (TxCert era)
btbrCerts :: StrictSeq (TxCert era)
btbrCerts :: forall era. BabbageTxBodyRaw era -> StrictSeq (TxCert era)
btbrCerts
      , Withdrawals (EraCrypto era)
btbrWithdrawals :: Withdrawals (EraCrypto era)
btbrWithdrawals :: forall era. BabbageTxBodyRaw era -> Withdrawals (EraCrypto era)
btbrWithdrawals
      , Coin
btbrTxFee :: Coin
btbrTxFee :: forall era. BabbageTxBodyRaw era -> Coin
btbrTxFee
      , btbrValidityInterval :: forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval = ValidityInterval StrictMaybe SlotNo
bot StrictMaybe SlotNo
top
      , StrictMaybe (Update era)
btbrUpdate :: StrictMaybe (Update era)
btbrUpdate :: forall era. BabbageTxBodyRaw era -> StrictMaybe (Update era)
btbrUpdate
      , Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes :: Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes :: forall era.
BabbageTxBodyRaw era -> Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes
      , MultiAsset (EraCrypto era)
btbrMint :: MultiAsset (EraCrypto era)
btbrMint :: forall era. BabbageTxBodyRaw era -> MultiAsset (EraCrypto era)
btbrMint
      , StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash :: StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash :: forall era.
BabbageTxBodyRaw era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash
      , StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash :: StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash :: forall era.
BabbageTxBodyRaw era
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash
      , StrictMaybe Network
btbrTxNetworkId :: StrictMaybe Network
btbrTxNetworkId :: forall era. BabbageTxBodyRaw era -> StrictMaybe Network
btbrTxNetworkId
      } =
      forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
        forall t. t -> Encode ('Closed 'Sparse) t
Keyed
          ( \Set (TxIn (EraCrypto era))
i Set (TxIn (EraCrypto era))
ifee Set (TxIn (EraCrypto era))
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc Coin
f StrictMaybe SlotNo
t StrictSeq (TxCert era)
c Withdrawals (EraCrypto era)
w StrictMaybe (Update era)
u StrictMaybe SlotNo
b Set (KeyHash 'Witness (EraCrypto era))
rsh MultiAsset (EraCrypto era)
mi StrictMaybe (ScriptIntegrityHash (EraCrypto era))
sh StrictMaybe (AuxiliaryDataHash (EraCrypto era))
ah StrictMaybe Network
ni ->
              forall era.
Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness (EraCrypto era))
-> MultiAsset (EraCrypto era)
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> StrictMaybe Network
-> BabbageTxBodyRaw era
BabbageTxBodyRaw Set (TxIn (EraCrypto era))
i Set (TxIn (EraCrypto era))
ifee Set (TxIn (EraCrypto era))
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc StrictSeq (TxCert era)
c Withdrawals (EraCrypto era)
w Coin
f (StrictMaybe SlotNo -> StrictMaybe SlotNo -> ValidityInterval
ValidityInterval StrictMaybe SlotNo
b StrictMaybe SlotNo
t) StrictMaybe (Update era)
u Set (KeyHash 'Witness (EraCrypto era))
rsh MultiAsset (EraCrypto era)
mi StrictMaybe (ScriptIntegrityHash (EraCrypto era))
sh StrictMaybe (AuxiliaryDataHash (EraCrypto era))
ah StrictMaybe Network
ni
          )
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
0 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (TxIn (EraCrypto era))
btbrSpendInputs)
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
13 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (TxIn (EraCrypto era))
btbrCollateralInputs))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
18 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (TxIn (EraCrypto era))
btbrReferenceInputs))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
1 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To StrictSeq (Sized (TxOut era))
btbrOutputs)
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
16 StrictMaybe (Sized (TxOut era))
btbrCollateralReturn
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
17 StrictMaybe Coin
btbrTotalCollateral
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
2 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
btbrTxFee)
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
3 StrictMaybe SlotNo
top
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
4 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To StrictSeq (TxCert era)
btbrCerts))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit (forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. Withdrawals c -> Map (RewardAccount c) Coin
unWithdrawals) (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
5 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Withdrawals (EraCrypto era)
btbrWithdrawals))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
6 StrictMaybe (Update era)
btbrUpdate
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
8 StrictMaybe SlotNo
bot
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
14 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit (forall a. Eq a => a -> a -> Bool
== forall a. Monoid a => a
mempty) (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
9 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To MultiAsset (EraCrypto era)
btbrMint))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
11 StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
7 StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall a.
EncCBOR a =>
Word -> StrictMaybe a -> Encode ('Closed 'Sparse) (StrictMaybe a)
encodeKeyedStrictMaybe Word
15 StrictMaybe Network
btbrTxNetworkId

instance
  (Era era, DecCBOR (TxOut era), DecCBOR (TxCert era), DecCBOR (PParamsUpdate era)) =>
  DecCBOR (BabbageTxBodyRaw era)
  where
  decCBOR :: forall s. Decoder s (BabbageTxBodyRaw era)
decCBOR =
    forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
      forall t.
Typeable t =>
String
-> t
-> (Word -> Field t)
-> [(Word, String)]
-> Decode ('Closed 'Dense) t
SparseKeyed
        String
"BabbageTxBodyRaw"
        forall era. BabbageTxBodyRaw era
basicBabbageTxBodyRaw
        Word -> Field (BabbageTxBodyRaw era)
bodyFields
        [(Word, String)]
requiredFields
    where
      bodyFields :: Word -> Field (BabbageTxBodyRaw era)
      bodyFields :: Word -> Field (BabbageTxBodyRaw era)
bodyFields Word
0 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Set (TxIn (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrSpendInputs :: Set (TxIn (EraCrypto era))
btbrSpendInputs = Set (TxIn (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
13 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Set (TxIn (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrCollateralInputs :: Set (TxIn (EraCrypto era))
btbrCollateralInputs = Set (TxIn (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
18 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Set (TxIn (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrReferenceInputs :: Set (TxIn (EraCrypto era))
btbrReferenceInputs = Set (TxIn (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
1 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\StrictSeq (Sized (TxOut era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrOutputs :: StrictSeq (Sized (TxOut era))
btbrOutputs = StrictSeq (Sized (TxOut era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
16 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe (Sized (TxOut era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
btbrCollateralReturn = StrictMaybe (Sized (TxOut era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
17 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe Coin
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrTotalCollateral :: StrictMaybe Coin
btbrTotalCollateral = StrictMaybe Coin
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
2 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Coin
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrTxFee :: Coin
btbrTxFee = Coin
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
3 =
        forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield
          (\StrictMaybe SlotNo
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrValidityInterval :: ValidityInterval
btbrValidityInterval = (forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval BabbageTxBodyRaw era
tx) {invalidHereafter :: StrictMaybe SlotNo
invalidHereafter = StrictMaybe SlotNo
x}})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
4 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\StrictSeq (TxCert era)
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrCerts :: StrictSeq (TxCert era)
btbrCerts = StrictSeq (TxCert era)
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
5 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Withdrawals (EraCrypto era)
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrWithdrawals :: Withdrawals (EraCrypto era)
btbrWithdrawals = Withdrawals (EraCrypto era)
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
6 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe (Update era)
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrUpdate :: StrictMaybe (Update era)
btbrUpdate = StrictMaybe (Update era)
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
7 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe (AuxiliaryDataHash (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrAuxDataHash :: StrictMaybe (AuxiliaryDataHash (EraCrypto era))
btbrAuxDataHash = StrictMaybe (AuxiliaryDataHash (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
8 =
        forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield
          (\StrictMaybe SlotNo
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrValidityInterval :: ValidityInterval
btbrValidityInterval = (forall era. BabbageTxBodyRaw era -> ValidityInterval
btbrValidityInterval BabbageTxBodyRaw era
tx) {invalidBefore :: StrictMaybe SlotNo
invalidBefore = StrictMaybe SlotNo
x}})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
9 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\MultiAsset (EraCrypto era)
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrMint :: MultiAsset (EraCrypto era)
btbrMint = MultiAsset (EraCrypto era)
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
11 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe (ScriptIntegrityHash (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrScriptIntegrityHash :: StrictMaybe (ScriptIntegrityHash (EraCrypto era))
btbrScriptIntegrityHash = StrictMaybe (ScriptIntegrityHash (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
14 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Set (KeyHash 'Witness (EraCrypto era))
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrReqSignerHashes :: Set (KeyHash 'Witness (EraCrypto era))
btbrReqSignerHashes = Set (KeyHash 'Witness (EraCrypto era))
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
15 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe Network
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrTxNetworkId :: StrictMaybe Network
btbrTxNetworkId = StrictMaybe Network
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
n = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Any
_ BabbageTxBodyRaw era
t -> BabbageTxBodyRaw era
t) (forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n)
      {-# INLINE bodyFields #-}
      requiredFields :: [(Word, String)]
      requiredFields :: [(Word, String)]
requiredFields =
        [ (Word
0, String
"inputs")
        , (Word
1, String
"outputs")
        , (Word
2, String
"fee")
        ]
  {-# INLINE decCBOR #-}

basicBabbageTxBodyRaw :: BabbageTxBodyRaw era
basicBabbageTxBodyRaw :: forall era. BabbageTxBodyRaw era
basicBabbageTxBodyRaw =
  forall era.
Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> Set (TxIn (EraCrypto era))
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness (EraCrypto era))
-> MultiAsset (EraCrypto era)
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> StrictMaybe Network
-> BabbageTxBodyRaw era
BabbageTxBodyRaw
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. StrictSeq a
StrictSeq.empty
    forall a. StrictMaybe a
SNothing
    forall a. StrictMaybe a
SNothing
    forall a. StrictSeq a
StrictSeq.empty
    (forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall a. Monoid a => a
mempty)
    forall a. Monoid a => a
mempty
    (StrictMaybe SlotNo -> StrictMaybe SlotNo -> ValidityInterval
ValidityInterval forall a. StrictMaybe a
SNothing forall a. StrictMaybe a
SNothing)
    forall a. StrictMaybe a
SNothing
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. StrictMaybe a
SNothing
    forall a. StrictMaybe a
SNothing
    forall a. StrictMaybe a
SNothing