{-# 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.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.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.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)

  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
btbrSpendInputs :: !(Set TxIn)
  , forall era. BabbageTxBodyRaw era -> Set TxIn
btbrCollateralInputs :: !(Set TxIn)
  , forall era. BabbageTxBodyRaw era -> Set TxIn
btbrReferenceInputs :: !(Set TxIn)
  , 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
btbrWithdrawals :: !Withdrawals
  , 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)
btbrReqSignerHashes :: !(Set (KeyHash 'Witness))
  , forall era. BabbageTxBodyRaw era -> MultiAsset
btbrMint :: !MultiAsset
  , -- 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
btbrScriptIntegrityHash :: !(StrictMaybe ScriptIntegrityHash)
  , forall era. BabbageTxBodyRaw era -> StrictMaybe TxAuxDataHash
btbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
  , 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
btbrSpendInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set TxIn
btbrSpendInputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Set TxIn
btbrCollateralInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set TxIn
btbrCollateralInputs BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> Set TxIn
btbrReferenceInputs BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set TxIn
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
btbrWithdrawals BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Withdrawals
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)
btbrReqSignerHashes BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> Set (KeyHash 'Witness)
btbrReqSignerHashes BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> MultiAsset
btbrMint BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> MultiAsset
btbrMint BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash BabbageTxBodyRaw era
b
      Bool -> Bool -> Bool
&& forall era. BabbageTxBodyRaw era -> StrictMaybe TxAuxDataHash
btbrAuxDataHash BabbageTxBodyRaw era
a forall a. Eq a => a -> a -> Bool
== forall era. BabbageTxBodyRaw era -> StrictMaybe TxAuxDataHash
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 i. Proxy i -> BabbageTxBody era -> SafeHash i
forall era. BabbageTxBody era -> Int
forall era. BabbageTxBody era -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall i. Proxy i -> t -> SafeHash i)
-> SafeToHash t
forall era i. Proxy i -> BabbageTxBody era -> SafeHash i
makeHashWithExplicitProxys :: forall i. Proxy i -> BabbageTxBody era -> SafeHash i
$cmakeHashWithExplicitProxys :: forall era i. Proxy i -> BabbageTxBody era -> SafeHash i
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)
inputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set TxIn)
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
btbrSpendInputs forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw Set TxIn
inputs -> RawType BabbageTxBody era
txBodyRaw {btbrSpendInputs :: Set TxIn
btbrSpendInputs = Set TxIn
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 TxAuxDataHash)
auxDataHashBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe TxAuxDataHash)
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 TxAuxDataHash
btbrAuxDataHash forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe TxAuxDataHash
auxDataHash -> RawType BabbageTxBody era
txBodyRaw {btbrAuxDataHash :: StrictMaybe TxAuxDataHash
btbrAuxDataHash = StrictMaybe TxAuxDataHash
auxDataHash}
{-# INLINEABLE auxDataHashBabbageTxBodyL #-}

babbageSpendableInputsTxBodyF ::
  BabbageEraTxBody era => SimpleGetter (TxBody era) (Set TxIn)
babbageSpendableInputsTxBodyF :: forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set TxIn)
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)
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)
collateralInputsTxBodyL)
{-# INLINEABLE babbageSpendableInputsTxBodyF #-}

babbageAllInputsTxBodyF ::
  BabbageEraTxBody era => SimpleGetter (TxBody era) (Set TxIn)
babbageAllInputsTxBodyF :: forall era.
BabbageEraTxBody era =>
SimpleGetter (TxBody era) (Set TxIn)
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)
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)
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)
referenceInputsTxBodyL)
{-# INLINEABLE babbageAllInputsTxBodyF #-}

mintedBabbageTxBodyF :: SimpleGetter (BabbageTxBody era) (Set PolicyID)
mintedBabbageTxBodyF :: forall era. SimpleGetter (BabbageTxBody era) (Set PolicyID)
mintedBabbageTxBodyF = forall s a. (s -> a) -> SimpleGetter s a
to (MultiAsset -> Set PolicyID
policies forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. BabbageTxBodyRaw era -> MultiAsset
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
withdrawalsBabbbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) Withdrawals
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
btbrWithdrawals forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Withdrawals
withdrawals -> RawType BabbageTxBody era
txBodyRaw {btbrWithdrawals :: Withdrawals
btbrWithdrawals = Withdrawals
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
mintBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) MultiAsset
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
btbrMint forall a b. (a -> b) -> a -> b
$ \RawType BabbageTxBody era
txBodyRaw MultiAsset
mint -> RawType BabbageTxBody era
txBodyRaw {btbrMint :: MultiAsset
btbrMint = MultiAsset
mint}
{-# INLINEABLE mintBabbageTxBodyL #-}

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

collateralInputsBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (Set TxIn)
collateralInputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set TxIn)
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
btbrCollateralInputs forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set TxIn
collateral -> RawType BabbageTxBody era
txBodyRaw {btbrCollateralInputs :: Set TxIn
btbrCollateralInputs = Set TxIn
collateral}
{-# INLINEABLE collateralInputsBabbageTxBodyL #-}

reqSignerHashesBabbageTxBodyL ::
  BabbageEraTxBody era => Lens' (BabbageTxBody era) (Set (KeyHash 'Witness))
reqSignerHashesBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set (KeyHash 'Witness))
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)
btbrReqSignerHashes forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set (KeyHash 'Witness)
reqSignerHashes -> RawType BabbageTxBody era
txBodyRaw {btbrReqSignerHashes :: Set (KeyHash 'Witness)
btbrReqSignerHashes = Set (KeyHash 'Witness)
reqSignerHashes}
{-# INLINEABLE reqSignerHashesBabbageTxBodyL #-}

scriptIntegrityHashBabbageTxBodyL ::
  BabbageEraTxBody era =>
  Lens' (BabbageTxBody era) (StrictMaybe ScriptIntegrityHash)
scriptIntegrityHashBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (StrictMaybe ScriptIntegrityHash)
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
btbrScriptIntegrityHash forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw StrictMaybe ScriptIntegrityHash
scriptIntegrityHash -> RawType BabbageTxBody era
txBodyRaw {btbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash = StrictMaybe ScriptIntegrityHash
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)
referenceInputsBabbageTxBodyL :: forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set TxIn)
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
btbrReferenceInputs forall a b. (a -> b) -> a -> b
$
    \RawType BabbageTxBody era
txBodyRaw Set TxIn
reference -> RawType BabbageTxBody era
txBodyRaw {btbrReferenceInputs :: Set TxIn
btbrReferenceInputs = Set TxIn
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 EraTxBody BabbageEra where
  type TxBody BabbageEra = BabbageTxBody BabbageEra
  type TxBodyUpgradeError BabbageEra = BabbageTxBodyUpgradeError

  mkBasicTxBody :: TxBody BabbageEra
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) (Set TxIn)
inputsTxBodyL = forall era.
BabbageEraTxBody era =>
Lens' (BabbageTxBody era) (Set TxIn)
inputsBabbageTxBodyL
  {-# INLINE inputsTxBodyL #-}

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

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

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

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

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

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

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

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

  upgradeTxBody :: EraTxBody (PreviousEra BabbageEra) =>
TxBody (PreviousEra BabbageEra)
-> Either (TxBodyUpgradeError BabbageEra) (TxBody BabbageEra)
upgradeTxBody TxBody (PreviousEra BabbageEra)
txBody = do
    StrictSeq (TxCert BabbageEra)
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)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)
    StrictMaybe (Update BabbageEra)
updates <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Update AlonzoEra
-> Either BabbageTxBodyUpgradeError (Update BabbageEra)
upgradeUpdate (TxBody (PreviousEra BabbageEra)
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
btbInputs = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
inputsTxBodyL
        , btbOutputs :: StrictSeq (Sized (TxOut BabbageEra))
btbOutputs =
            forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @BabbageEra) 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)
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)
btbCerts = StrictSeq (TxCert BabbageEra)
certs
        , btbWithdrawals :: Withdrawals
btbWithdrawals = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) Withdrawals
withdrawalsTxBodyL
        , btbTxFee :: Coin
btbTxFee = TxBody (PreviousEra BabbageEra)
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)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
vldtTxBodyL
        , btbUpdate :: StrictMaybe (Update BabbageEra)
btbUpdate = StrictMaybe (Update BabbageEra)
updates
        , btbAuxDataHash :: StrictMaybe TxAuxDataHash
btbAuxDataHash = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictMaybe TxAuxDataHash)
auxDataHashTxBodyL
        , btbMint :: MultiAsset
btbMint = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
mintTxBodyL
        , btbCollateral :: Set TxIn
btbCollateral = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era. AlonzoEraTxBody era => Lens' (TxBody era) (Set TxIn)
collateralInputsTxBodyL
        , btbReqSignerHashes :: Set (KeyHash 'Witness)
btbReqSignerHashes = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (KeyHash 'Witness))
reqSignerHashesTxBodyL
        , btbScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
btbScriptIntegrityHash = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (StrictMaybe ScriptIntegrityHash)
scriptIntegrityHashTxBodyL
        , btbTxNetworkId :: StrictMaybe Network
btbTxNetworkId = TxBody (PreviousEra BabbageEra)
txBody forall s a. s -> Getting a s a -> a
^. forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Network)
networkIdTxBodyL
        , btbReferenceInputs :: Set TxIn
btbReferenceInputs = forall a. Monoid a => a
mempty
        , btbCollateralReturn :: StrictMaybe (Sized (TxOut BabbageEra))
btbCollateralReturn = forall a. StrictMaybe a
SNothing
        , btbTotalCollateral :: StrictMaybe Coin
btbTotalCollateral = forall a. StrictMaybe a
SNothing
        }
    where
      upgradeUpdate ::
        Update AlonzoEra ->
        Either BabbageTxBodyUpgradeError (Update BabbageEra)
      upgradeUpdate :: Update AlonzoEra
-> Either BabbageTxBodyUpgradeError (Update BabbageEra)
upgradeUpdate (Update ProposedPPUpdates AlonzoEra
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
-> Either BabbageTxBodyUpgradeError (ProposedPPUpdates BabbageEra)
upgradeProposedPPUpdates ProposedPPUpdates AlonzoEra
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 ->
        Either BabbageTxBodyUpgradeError (ProposedPPUpdates BabbageEra)
      upgradeProposedPPUpdates :: ProposedPPUpdates AlonzoEra
-> Either BabbageTxBodyUpgradeError (ProposedPPUpdates BabbageEra)
upgradeProposedPPUpdates (ProposedPPUpdates Map (KeyHash 'Genesis) (PParamsUpdate AlonzoEra)
m) =
        forall era.
Map (KeyHash 'Genesis) (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
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
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
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 :: * -> *).
HKDFunctor f =>
Bool -> PParamsHKD f AlonzoEra -> BabbagePParams f BabbageEra
upgradeBabbagePParams Bool
False PParamsHKD StrictMaybe AlonzoEra
pphkd
            )
            Map (KeyHash 'Genesis) (PParamsUpdate AlonzoEra)
m

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  allSizedOutputsTxBodyF :: SimpleGetter
  (TxBody BabbageEra) (StrictSeq (Sized (TxOut BabbageEra)))
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 ->
  Set TxIn ->
  Set TxIn ->
  StrictSeq (Sized (TxOut era)) ->
  StrictMaybe (Sized (TxOut era)) ->
  StrictMaybe Coin ->
  StrictSeq (TxCert era) ->
  Withdrawals ->
  Coin ->
  ValidityInterval ->
  StrictMaybe (Update era) ->
  Set (KeyHash 'Witness) ->
  MultiAsset ->
  StrictMaybe ScriptIntegrityHash ->
  StrictMaybe TxAuxDataHash ->
  StrictMaybe Network ->
  BabbageTxBody era
pattern $bBabbageTxBody :: forall era.
BabbageEraTxBody era =>
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> BabbageTxBody era
$mBabbageTxBody :: forall {r} {era}.
BabbageEraTxBody era =>
BabbageTxBody era
-> (Set TxIn
    -> Set TxIn
    -> Set TxIn
    -> StrictSeq (Sized (TxOut era))
    -> StrictMaybe (Sized (TxOut era))
    -> StrictMaybe Coin
    -> StrictSeq (TxCert era)
    -> Withdrawals
    -> Coin
    -> ValidityInterval
    -> StrictMaybe (Update era)
    -> Set (KeyHash 'Witness)
    -> MultiAsset
    -> StrictMaybe ScriptIntegrityHash
    -> StrictMaybe TxAuxDataHash
    -> StrictMaybe Network
    -> r)
-> ((# #) -> r)
-> r
BabbageTxBody
  { forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
btbInputs
  , forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
btbCollateral
  , forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
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
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)
btbReqSignerHashes
  , forall era. BabbageEraTxBody era => BabbageTxBody era -> MultiAsset
btbMint
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe ScriptIntegrityHash
btbScriptIntegrityHash
  , forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe TxAuxDataHash
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
inputs
      Set TxIn
collateral
      Set TxIn
referenceInputs
      StrictSeq (Sized (TxOut era))
outputs
      StrictMaybe (Sized (TxOut era))
collateralReturn
      StrictMaybe Coin
totalCollateral
      StrictSeq (TxCert era)
certs
      Withdrawals
withdrawals
      Coin
txFee
      ValidityInterval
validityInterval
      StrictMaybe (Update era)
update
      Set (KeyHash 'Witness)
reqSignerHashes
      MultiAsset
mint
      StrictMaybe ScriptIntegrityHash
scriptIntegrityHash
      StrictMaybe TxAuxDataHash
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
btbrSpendInputs = Set TxIn
inputs
            , btbrCollateralInputs :: Set TxIn
btbrCollateralInputs = Set TxIn
collateral
            , btbrReferenceInputs :: Set TxIn
btbrReferenceInputs = Set TxIn
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
btbrWithdrawals = Withdrawals
withdrawals
            , btbrTxFee :: Coin
btbrTxFee = Coin
txFee
            , btbrValidityInterval :: ValidityInterval
btbrValidityInterval = ValidityInterval
validityInterval
            , btbrUpdate :: StrictMaybe (Update era)
btbrUpdate = StrictMaybe (Update era)
update
            , btbrReqSignerHashes :: Set (KeyHash 'Witness)
btbrReqSignerHashes = Set (KeyHash 'Witness)
reqSignerHashes
            , btbrMint :: MultiAsset
btbrMint = MultiAsset
mint
            , btbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash = StrictMaybe ScriptIntegrityHash
scriptIntegrityHash
            , btbrAuxDataHash :: StrictMaybe TxAuxDataHash
btbrAuxDataHash = StrictMaybe TxAuxDataHash
auxDataHash
            , btbrTxNetworkId :: StrictMaybe Network
btbrTxNetworkId = StrictMaybe Network
txNetworkId
            }

{-# COMPLETE BabbageTxBody #-}

instance HashAnnotated (BabbageTxBody era) EraIndependentTxBody where
  hashAnnotated :: BabbageTxBody era -> SafeHash EraIndependentTxBody
hashAnnotated = forall (t :: * -> *) era.
Memoized t =>
t era -> SafeHash (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
collateralInputs' :: BabbageTxBody era -> Set TxIn
referenceInputs' :: BabbageTxBody era -> Set TxIn
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
vldt' :: BabbageTxBody era -> ValidityInterval
update' :: BabbageTxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: BabbageTxBody era -> Set (KeyHash 'Witness)
adHash' :: BabbageTxBody era -> StrictMaybe TxAuxDataHash
mint' :: BabbageTxBody era -> MultiAsset
scriptIntegrityHash' :: BabbageTxBody era -> StrictMaybe ScriptIntegrityHash
spendInputs' :: forall era. BabbageTxBody era -> Set TxIn
spendInputs' = forall era. BabbageTxBodyRaw era -> Set TxIn
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
collateralInputs' = forall era. BabbageTxBodyRaw era -> Set TxIn
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
referenceInputs' = forall era. BabbageTxBodyRaw era -> Set TxIn
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
withdrawals' = forall era. BabbageTxBodyRaw era -> Withdrawals
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)
reqSignerHashes' = forall era. BabbageTxBodyRaw era -> Set (KeyHash 'Witness)
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 TxAuxDataHash
adHash' = forall era. BabbageTxBodyRaw era -> StrictMaybe TxAuxDataHash
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
mint' = forall era. BabbageTxBodyRaw era -> MultiAsset
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
scriptIntegrityHash' = forall era. BabbageTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
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
btbrSpendInputs :: Set TxIn
btbrSpendInputs :: forall era. BabbageTxBodyRaw era -> Set TxIn
btbrSpendInputs
      , Set TxIn
btbrCollateralInputs :: Set TxIn
btbrCollateralInputs :: forall era. BabbageTxBodyRaw era -> Set TxIn
btbrCollateralInputs
      , Set TxIn
btbrReferenceInputs :: Set TxIn
btbrReferenceInputs :: forall era. BabbageTxBodyRaw era -> Set TxIn
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
btbrWithdrawals :: Withdrawals
btbrWithdrawals :: forall era. BabbageTxBodyRaw era -> Withdrawals
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)
btbrReqSignerHashes :: Set (KeyHash 'Witness)
btbrReqSignerHashes :: forall era. BabbageTxBodyRaw era -> Set (KeyHash 'Witness)
btbrReqSignerHashes
      , MultiAsset
btbrMint :: MultiAsset
btbrMint :: forall era. BabbageTxBodyRaw era -> MultiAsset
btbrMint
      , StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash :: forall era. BabbageTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash
      , StrictMaybe TxAuxDataHash
btbrAuxDataHash :: StrictMaybe TxAuxDataHash
btbrAuxDataHash :: forall era. BabbageTxBodyRaw era -> StrictMaybe TxAuxDataHash
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
i Set TxIn
ifee Set TxIn
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc Coin
f StrictMaybe SlotNo
t StrictSeq (TxCert era)
c Withdrawals
w StrictMaybe (Update era)
u StrictMaybe SlotNo
b Set (KeyHash 'Witness)
rsh MultiAsset
mi StrictMaybe ScriptIntegrityHash
sh StrictMaybe TxAuxDataHash
ah StrictMaybe Network
ni ->
              forall era.
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> BabbageTxBodyRaw era
BabbageTxBodyRaw Set TxIn
i Set TxIn
ifee Set TxIn
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc StrictSeq (TxCert era)
c Withdrawals
w Coin
f (StrictMaybe SlotNo -> StrictMaybe SlotNo -> ValidityInterval
ValidityInterval StrictMaybe SlotNo
b StrictMaybe SlotNo
t) StrictMaybe (Update era)
u Set (KeyHash 'Witness)
rsh MultiAsset
mi StrictMaybe ScriptIntegrityHash
sh StrictMaybe TxAuxDataHash
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
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
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
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
. Withdrawals -> Map RewardAccount 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
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)
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
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
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 TxAuxDataHash
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrSpendInputs :: Set TxIn
btbrSpendInputs = Set TxIn
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrCollateralInputs :: Set TxIn
btbrCollateralInputs = Set TxIn
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrReferenceInputs :: Set TxIn
btbrReferenceInputs = Set TxIn
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrWithdrawals :: Withdrawals
btbrWithdrawals = Withdrawals
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 TxAuxDataHash
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrAuxDataHash :: StrictMaybe TxAuxDataHash
btbrAuxDataHash = StrictMaybe TxAuxDataHash
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrMint :: MultiAsset
btbrMint = MultiAsset
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
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
btbrScriptIntegrityHash = StrictMaybe ScriptIntegrityHash
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)
x BabbageTxBodyRaw era
tx -> BabbageTxBodyRaw era
tx {btbrReqSignerHashes :: Set (KeyHash 'Witness)
btbrReqSignerHashes = Set (KeyHash 'Witness)
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
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (TxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> 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
    (Map RewardAccount Coin -> Withdrawals
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