{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# 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 Conway 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.Conway.TxBody.Internal (
  ConwayEraTxBody (..),
  ConwayTxBody (
    ..,
    ConwayTxBody,
    ctbSpendInputs,
    ctbCollateralInputs,
    ctbReferenceInputs,
    ctbOutputs,
    ctbCollateralReturn,
    ctbTotalCollateral,
    ctbCerts,
    ctbWithdrawals,
    ctbTxfee,
    ctbVldt,
    ctbReqSignerHashes,
    ctbMint,
    ctbScriptIntegrityHash,
    ctbAdHash,
    ctbTxNetworkId,
    ctbVotingProcedures,
    ctbProposalProcedures,
    ctbCurrentTreasuryValue,
    ctbTreasuryDonation
  ),
  ConwayTxBodyRaw (..),
  conwayTotalDepositsTxBody,
  conwayProposalsDeposits,
) where

import Cardano.Ledger.Alonzo.TxBody (Indexable (..))
import Cardano.Ledger.Babbage.Core
import Cardano.Ledger.Babbage.TxBody (
  BabbageTxBody (..),
  allSizedOutputsBabbageTxBodyF,
  babbageAllInputsTxBodyF,
  babbageSpendableInputsTxBodyF,
 )
import Cardano.Ledger.BaseTypes (Network, fromSMaybe, isSJust)
import Cardano.Ledger.Binary (
  Annotator,
  DecCBOR (..),
  EncCBOR (..),
  Sized (..),
  ToCBOR (..),
  mkSized,
 )
import Cardano.Ledger.Binary.Coders (
  Decode (..),
  Density (..),
  Encode (..),
  Field (..),
  Wrapped (..),
  decode,
  encode,
  encodeKeyedStrictMaybe,
  field,
  fieldGuarded,
  ofield,
  (!>),
 )
import Cardano.Ledger.Coin (Coin (..), decodePositiveCoin)
import Cardano.Ledger.Conway.Era (ConwayEra)
import Cardano.Ledger.Conway.Governance.Procedures (ProposalProcedure, VotingProcedures (..))
import Cardano.Ledger.Conway.PParams (ConwayEraPParams, ppGovActionDepositL)
import Cardano.Ledger.Conway.Scripts (ConwayEraScript, ConwayPlutusPurpose (..))
import Cardano.Ledger.Conway.TxCert (
  ConwayEraTxCert,
  ConwayTxCert (..),
  ConwayTxCertUpgradeError,
 )
import Cardano.Ledger.Conway.TxOut ()
import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..), policies)
import Cardano.Ledger.MemoBytes (
  EqRaw,
  Mem,
  MemoBytes (..),
  MemoHashIndex,
  Memoized (..),
  getMemoRawType,
  getMemoSafeHash,
  lensMemoRawType,
  mkMemoized,
 )
import Cardano.Ledger.TxIn (TxIn (..))
import Cardano.Ledger.Val (Val (..))
import Control.Arrow (left)
import Control.DeepSeq (NFData)
import Control.Monad (unless, when)
import Data.Maybe.Strict (StrictMaybe (..))
import qualified Data.OSet.Strict as OSet
import Data.Sequence.Strict (StrictSeq)
import Data.Set (Set)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Lens.Micro (Lens', to, (^.))
import NoThunks.Class (NoThunks)

instance Memoized ConwayTxBody where
  type RawType ConwayTxBody = ConwayTxBodyRaw

data ConwayTxBodyRaw era = ConwayTxBodyRaw
  { forall era. ConwayTxBodyRaw era -> Set TxIn
ctbrSpendInputs :: !(Set TxIn)
  , forall era. ConwayTxBodyRaw era -> Set TxIn
ctbrCollateralInputs :: !(Set TxIn)
  , forall era. ConwayTxBodyRaw era -> Set TxIn
ctbrReferenceInputs :: !(Set TxIn)
  , forall era. ConwayTxBodyRaw era -> StrictSeq (Sized (TxOut era))
ctbrOutputs :: !(StrictSeq (Sized (TxOut era)))
  , forall era. ConwayTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
ctbrCollateralReturn :: !(StrictMaybe (Sized (TxOut era)))
  , forall era. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrTotalCollateral :: !(StrictMaybe Coin)
  , forall era. ConwayTxBodyRaw era -> OSet (ConwayTxCert era)
ctbrCerts :: !(OSet.OSet (ConwayTxCert era))
  , forall era. ConwayTxBodyRaw era -> Withdrawals
ctbrWithdrawals :: !Withdrawals
  , forall era. ConwayTxBodyRaw era -> Coin
ctbrTxfee :: !Coin
  , forall era. ConwayTxBodyRaw era -> ValidityInterval
ctbrVldt :: !ValidityInterval
  , forall era. ConwayTxBodyRaw era -> Set (KeyHash 'Witness)
ctbrReqSignerHashes :: !(Set (KeyHash 'Witness))
  , forall era. ConwayTxBodyRaw era -> MultiAsset
ctbrMint :: !MultiAsset
  , forall era. ConwayTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
ctbrScriptIntegrityHash :: !(StrictMaybe ScriptIntegrityHash)
  , forall era. ConwayTxBodyRaw era -> StrictMaybe TxAuxDataHash
ctbrAuxDataHash :: !(StrictMaybe TxAuxDataHash)
  , forall era. ConwayTxBodyRaw era -> StrictMaybe Network
ctbrTxNetworkId :: !(StrictMaybe Network)
  , forall era. ConwayTxBodyRaw era -> VotingProcedures era
ctbrVotingProcedures :: !(VotingProcedures era)
  , forall era. ConwayTxBodyRaw era -> OSet (ProposalProcedure era)
ctbrProposalProcedures :: !(OSet.OSet (ProposalProcedure era))
  , forall era. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrCurrentTreasuryValue :: !(StrictMaybe Coin)
  , forall era. ConwayTxBodyRaw era -> Coin
ctbrTreasuryDonation :: !Coin
  }
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (ConwayTxBodyRaw era) x -> ConwayTxBodyRaw era
forall era x. ConwayTxBodyRaw era -> Rep (ConwayTxBodyRaw era) x
$cto :: forall era x. Rep (ConwayTxBodyRaw era) x -> ConwayTxBodyRaw era
$cfrom :: forall era x. ConwayTxBodyRaw era -> Rep (ConwayTxBodyRaw era) x
Generic, Typeable)

deriving instance (EraPParams era, Eq (TxOut era)) => Eq (ConwayTxBodyRaw era)

instance
  (EraPParams era, NoThunks (TxOut era)) =>
  NoThunks (ConwayTxBodyRaw era)

instance
  (EraPParams era, NFData (TxOut era)) =>
  NFData (ConwayTxBodyRaw era)

deriving instance
  (EraPParams era, Show (TxOut era)) =>
  Show (ConwayTxBodyRaw era)

instance
  ( EraPParams era
  , DecCBOR (TxOut era)
  , ShelleyEraTxCert era
  , TxCert era ~ ConwayTxCert era
  ) =>
  DecCBOR (ConwayTxBodyRaw era)
  where
  decCBOR :: forall s. Decoder s (ConwayTxBodyRaw 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
"TxBodyRaw"
        forall era. ConwayTxBodyRaw era
basicConwayTxBodyRaw
        Word -> Field (ConwayTxBodyRaw era)
bodyFields
        [(Word, String)]
requiredFields
    where
      bodyFields :: Word -> Field (ConwayTxBodyRaw era)
      bodyFields :: Word -> Field (ConwayTxBodyRaw era)
bodyFields Word
0 = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Set TxIn
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrSpendInputs :: Set TxIn
ctbrSpendInputs = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrOutputs :: StrictSeq (Sized (TxOut era))
ctbrOutputs = StrictSeq (Sized (TxOut era))
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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrTxfee :: Coin
ctbrTxfee = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrVldt :: ValidityInterval
ctbrVldt = (forall era. ConwayTxBodyRaw era -> ValidityInterval
ctbrVldt ConwayTxBodyRaw 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).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Certificates" String
"non-empty")
          forall a. OSet a -> Bool
OSet.null
          (\OSet (ConwayTxCert era)
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrCerts :: OSet (ConwayTxCert era)
ctbrCerts = OSet (ConwayTxCert era)
x})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
5 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Withdrawals" String
"non-empty")
          (forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall b c a. (b -> c) -> (a -> b) -> a -> c
. Withdrawals -> Map RewardAccount Coin
unWithdrawals)
          (\Withdrawals
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrWithdrawals :: Withdrawals
ctbrWithdrawals = Withdrawals
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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrAuxDataHash :: StrictMaybe TxAuxDataHash
ctbrAuxDataHash = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrVldt :: ValidityInterval
ctbrVldt = (forall era. ConwayTxBodyRaw era -> ValidityInterval
ctbrVldt ConwayTxBodyRaw 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).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Mint" String
"non-empty")
          (forall a. Eq a => a -> a -> Bool
== forall a. Monoid a => a
mempty)
          (\MultiAsset
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrMint :: MultiAsset
ctbrMint = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
ctbrScriptIntegrityHash = StrictMaybe ScriptIntegrityHash
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
13 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Collateral Inputs" String
"non-empty")
          forall (t :: * -> *) a. Foldable t => t a -> Bool
null
          (\Set TxIn
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrCollateralInputs :: Set TxIn
ctbrCollateralInputs = Set TxIn
x})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
14 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Required Signer Hashes" String
"non-empty")
          forall (t :: * -> *) a. Foldable t => t a -> Bool
null
          (\Set (KeyHash 'Witness)
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrReqSignerHashes :: Set (KeyHash 'Witness)
ctbrReqSignerHashes = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrTxNetworkId :: StrictMaybe Network
ctbrTxNetworkId = StrictMaybe Network
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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
ctbrCollateralReturn = 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 ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrTotalCollateral :: StrictMaybe Coin
ctbrTotalCollateral = StrictMaybe Coin
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
18 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"Reference Inputs" String
"non-empty")
          forall (t :: * -> *) a. Foldable t => t a -> Bool
null
          (\Set TxIn
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrReferenceInputs :: Set TxIn
ctbrReferenceInputs = Set TxIn
x})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
19 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"VotingProcedures" String
"non-empty")
          (forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
VotingProcedures era
-> Map Voter (Map GovActionId (VotingProcedure era))
unVotingProcedures)
          (\VotingProcedures era
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrVotingProcedures :: VotingProcedures era
ctbrVotingProcedures = VotingProcedures era
x})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
20 =
        forall x t (d :: Density).
String
-> (x -> Bool) -> (x -> t -> t) -> Decode ('Closed d) x -> Field t
fieldGuarded
          (String -> ShowS
emptyFailure String
"ProposalProcedures" String
"non-empty")
          forall a. OSet a -> Bool
OSet.null
          (\OSet (ProposalProcedure era)
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrProposalProcedures :: OSet (ProposalProcedure era)
ctbrProposalProcedures = OSet (ProposalProcedure era)
x})
          forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
21 = forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield (\StrictMaybe Coin
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrCurrentTreasuryValue :: StrictMaybe Coin
ctbrCurrentTreasuryValue = StrictMaybe Coin
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      bodyFields Word
22 =
        forall x t (d :: Density).
(StrictMaybe x -> t -> t) -> Decode ('Closed d) x -> Field t
ofield
          (\StrictMaybe Coin
x ConwayTxBodyRaw era
tx -> ConwayTxBodyRaw era
tx {ctbrTreasuryDonation :: Coin
ctbrTreasuryDonation = forall a. a -> StrictMaybe a -> a
fromSMaybe forall t. Val t => t
zero StrictMaybe Coin
x})
          (forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D (forall s. String -> Decoder s Coin
decodePositiveCoin forall a b. (a -> b) -> a -> b
$ String -> ShowS
emptyFailure String
"Treasury Donation" String
"non-zero"))
      bodyFields Word
n = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Any
_ ConwayTxBodyRaw era
t -> ConwayTxBodyRaw era
t) (forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n)
      requiredFields :: [(Word, String)]
      requiredFields :: [(Word, String)]
requiredFields =
        [ (Word
0, String
"inputs")
        , (Word
1, String
"outputs")
        , (Word
2, String
"fee")
        ]
      emptyFailure :: String -> ShowS
emptyFailure String
fieldName String
requirement =
        String
"TxBody: '" forall a. Semigroup a => a -> a -> a
<> String
fieldName forall a. Semigroup a => a -> a -> a
<> String
"' must be " forall a. Semigroup a => a -> a -> a
<> String
requirement forall a. Semigroup a => a -> a -> a
<> String
" when supplied"

newtype ConwayTxBody era = TxBodyConstr (MemoBytes ConwayTxBodyRaw era)
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (ConwayTxBody era) x -> ConwayTxBody era
forall era x. ConwayTxBody era -> Rep (ConwayTxBody era) x
$cto :: forall era x. Rep (ConwayTxBody era) x -> ConwayTxBody era
$cfrom :: forall era x. ConwayTxBody era -> Rep (ConwayTxBody era) x
Generic, ConwayTxBody era -> Int
ConwayTxBody era -> ByteString
forall i. Proxy i -> ConwayTxBody era -> SafeHash i
forall era. ConwayTxBody era -> Int
forall era. ConwayTxBody era -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall i. Proxy i -> t -> SafeHash i)
-> SafeToHash t
forall era i. Proxy i -> ConwayTxBody era -> SafeHash i
makeHashWithExplicitProxys :: forall i. Proxy i -> ConwayTxBody era -> SafeHash i
$cmakeHashWithExplicitProxys :: forall era i. Proxy i -> ConwayTxBody era -> SafeHash i
originalBytesSize :: ConwayTxBody era -> Int
$coriginalBytesSize :: forall era. ConwayTxBody era -> Int
originalBytes :: ConwayTxBody era -> ByteString
$coriginalBytes :: forall era. ConwayTxBody era -> ByteString
SafeToHash, ConwayTxBody era -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [ConwayTxBody era] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (ConwayTxBody era) -> Size
forall {era}. Typeable era => Typeable (ConwayTxBody era)
forall era. Typeable era => ConwayTxBody 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 [ConwayTxBody era] -> Size
forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (ConwayTxBody era) -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [ConwayTxBody era] -> Size
$cencodedListSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [ConwayTxBody era] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (ConwayTxBody era) -> Size
$cencodedSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (ConwayTxBody era) -> Size
toCBOR :: ConwayTxBody era -> Encoding
$ctoCBOR :: forall era. Typeable era => ConwayTxBody era -> Encoding
ToCBOR)

deriving instance
  (EraPParams era, NoThunks (TxOut era)) =>
  NoThunks (ConwayTxBody era)

deriving instance
  (EraPParams era, Eq (TxOut era)) =>
  Eq (ConwayTxBody era)

deriving newtype instance
  (EraPParams era, NFData (TxOut era)) =>
  NFData (ConwayTxBody era)

deriving instance
  (EraPParams era, Show (TxOut era)) =>
  Show (ConwayTxBody era)

type instance MemoHashIndex ConwayTxBodyRaw = EraIndependentTxBody

instance HashAnnotated (ConwayTxBody era) EraIndependentTxBody where
  hashAnnotated :: ConwayTxBody era -> SafeHash EraIndependentTxBody
hashAnnotated = forall (t :: * -> *) era.
Memoized t =>
t era -> SafeHash (MemoHashIndex (RawType t))
getMemoSafeHash

instance
  ( DecCBOR (TxOut era)
  , EraPParams era
  , ShelleyEraTxCert era
  , TxCert era ~ ConwayTxCert era
  ) =>
  DecCBOR (Annotator (ConwayTxBodyRaw era))
  where
  decCBOR :: forall s. Decoder s (Annotator (ConwayTxBodyRaw 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

deriving via
  (Mem ConwayTxBodyRaw era)
  instance
    ( DecCBOR (TxOut era)
    , EraPParams era
    , ShelleyEraTxCert era
    , TxCert era ~ ConwayTxCert era
    ) =>
    DecCBOR (Annotator (ConwayTxBody era))

mkConwayTxBody :: ConwayEraTxBody era => ConwayTxBody era
mkConwayTxBody :: forall era. ConwayEraTxBody era => ConwayTxBody era
mkConwayTxBody = forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall era. ConwayTxBodyRaw era
basicConwayTxBodyRaw

basicConwayTxBodyRaw :: ConwayTxBodyRaw era
basicConwayTxBodyRaw :: forall era. ConwayTxBodyRaw era
basicConwayTxBodyRaw =
  forall era.
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> OSet (ConwayTxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> VotingProcedures era
-> OSet (ProposalProcedure era)
-> StrictMaybe Coin
-> Coin
-> ConwayTxBodyRaw era
ConwayTxBodyRaw
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. Monoid a => a
mempty
    forall a. StrictMaybe a
SNothing
    forall a. StrictMaybe a
SNothing
    forall a. OSet a
OSet.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. 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
    (forall era.
Map Voter (Map GovActionId (VotingProcedure era))
-> VotingProcedures era
VotingProcedures forall a. Monoid a => a
mempty)
    forall a. OSet a
OSet.empty
    forall a. StrictMaybe a
SNothing
    forall a. Monoid a => a
mempty

data ConwayTxBodyUpgradeError
  = CTBUETxCert ConwayTxCertUpgradeError
  | -- | The TxBody contains an update proposal from a pre-Conway era. Since
    --   this can only have come from the genesis delegates, we just discard it.
    CTBUEContainsUpdate
  | -- | In eras prior to Conway duplicate certificates where allowed
    CTBUEContainsDuplicateCerts (Set (TxCert ConwayEra))
  deriving (ConwayTxBodyUpgradeError -> ConwayTxBodyUpgradeError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConwayTxBodyUpgradeError -> ConwayTxBodyUpgradeError -> Bool
$c/= :: ConwayTxBodyUpgradeError -> ConwayTxBodyUpgradeError -> Bool
== :: ConwayTxBodyUpgradeError -> ConwayTxBodyUpgradeError -> Bool
$c== :: ConwayTxBodyUpgradeError -> ConwayTxBodyUpgradeError -> Bool
Eq, Int -> ConwayTxBodyUpgradeError -> ShowS
[ConwayTxBodyUpgradeError] -> ShowS
ConwayTxBodyUpgradeError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConwayTxBodyUpgradeError] -> ShowS
$cshowList :: [ConwayTxBodyUpgradeError] -> ShowS
show :: ConwayTxBodyUpgradeError -> String
$cshow :: ConwayTxBodyUpgradeError -> String
showsPrec :: Int -> ConwayTxBodyUpgradeError -> ShowS
$cshowsPrec :: Int -> ConwayTxBodyUpgradeError -> ShowS
Show)

instance EraTxBody ConwayEra where
  type TxBody ConwayEra = ConwayTxBody ConwayEra
  type TxBodyUpgradeError ConwayEra = ConwayTxBodyUpgradeError

  mkBasicTxBody :: TxBody ConwayEra
mkBasicTxBody = forall era. ConwayEraTxBody era => ConwayTxBody era
mkConwayTxBody

  inputsTxBodyL :: Lens' (TxBody ConwayEra) (Set TxIn)
inputsTxBodyL = 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. ConwayTxBodyRaw era -> Set TxIn
ctbrSpendInputs (\RawType ConwayTxBody ConwayEra
txb Set TxIn
x -> RawType ConwayTxBody ConwayEra
txb {ctbrSpendInputs :: Set TxIn
ctbrSpendInputs = Set TxIn
x})
  {-# INLINE inputsTxBodyL #-}

  outputsTxBodyL :: Lens' (TxBody ConwayEra) (StrictSeq (TxOut ConwayEra))
outputsTxBodyL =
    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. ConwayTxBodyRaw era -> StrictSeq (Sized (TxOut era))
ctbrOutputs)
      (\RawType ConwayTxBody ConwayEra
txb StrictSeq (BabbageTxOut ConwayEra)
x -> RawType ConwayTxBody ConwayEra
txb {ctbrOutputs :: StrictSeq (Sized (TxOut ConwayEra))
ctbrOutputs = forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @ConwayEra) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (BabbageTxOut ConwayEra)
x})
  {-# INLINE outputsTxBodyL #-}

  feeTxBodyL :: Lens' (TxBody ConwayEra) Coin
feeTxBodyL = 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. ConwayTxBodyRaw era -> Coin
ctbrTxfee (\RawType ConwayTxBody ConwayEra
txb Coin
x -> RawType ConwayTxBody ConwayEra
txb {ctbrTxfee :: Coin
ctbrTxfee = Coin
x})
  {-# INLINE feeTxBodyL #-}

  auxDataHashTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe TxAuxDataHash)
auxDataHashTxBodyL = 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. ConwayTxBodyRaw era -> StrictMaybe TxAuxDataHash
ctbrAuxDataHash (\RawType ConwayTxBody ConwayEra
txb StrictMaybe TxAuxDataHash
x -> RawType ConwayTxBody ConwayEra
txb {ctbrAuxDataHash :: StrictMaybe TxAuxDataHash
ctbrAuxDataHash = StrictMaybe TxAuxDataHash
x})
  {-# INLINE auxDataHashTxBodyL #-}

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

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

  withdrawalsTxBodyL :: Lens' (TxBody ConwayEra) Withdrawals
withdrawalsTxBodyL = 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. ConwayTxBodyRaw era -> Withdrawals
ctbrWithdrawals (\RawType ConwayTxBody ConwayEra
txb Withdrawals
x -> RawType ConwayTxBody ConwayEra
txb {ctbrWithdrawals :: Withdrawals
ctbrWithdrawals = Withdrawals
x})
  {-# INLINE withdrawalsTxBodyL #-}

  certsTxBodyL :: Lens' (TxBody ConwayEra) (StrictSeq (TxCert ConwayEra))
certsTxBodyL =
    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 a. OSet a -> StrictSeq a
OSet.toStrictSeq forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era. ConwayTxBodyRaw era -> OSet (ConwayTxCert era)
ctbrCerts) (\RawType ConwayTxBody ConwayEra
txb StrictSeq (ConwayTxCert ConwayEra)
x -> RawType ConwayTxBody ConwayEra
txb {ctbrCerts :: OSet (ConwayTxCert ConwayEra)
ctbrCerts = forall a. Ord a => StrictSeq a -> OSet a
OSet.fromStrictSeq StrictSeq (ConwayTxCert ConwayEra)
x})
  {-# INLINE certsTxBodyL #-}

  getTotalDepositsTxBody :: PParams ConwayEra
-> (KeyHash 'StakePool -> Bool) -> TxBody ConwayEra -> Coin
getTotalDepositsTxBody = forall era.
ConwayEraTxBody era =>
PParams era -> (KeyHash 'StakePool -> Bool) -> TxBody era -> Coin
conwayTotalDepositsTxBody

  getTotalRefundsTxBody :: PParams ConwayEra
-> (Credential 'Staking -> Maybe Coin)
-> (Credential 'DRepRole -> Maybe Coin)
-> TxBody ConwayEra
-> Coin
getTotalRefundsTxBody PParams ConwayEra
pp Credential 'Staking -> Maybe Coin
lookupStakingDeposit Credential 'DRepRole -> Maybe Coin
lookupDRepDeposit TxBody ConwayEra
txBody =
    forall era (f :: * -> *).
(EraTxCert era, Foldable f) =>
PParams era
-> (Credential 'Staking -> Maybe Coin)
-> (Credential 'DRepRole -> Maybe Coin)
-> f (TxCert era)
-> Coin
getTotalRefundsTxCerts PParams ConwayEra
pp Credential 'Staking -> Maybe Coin
lookupStakingDeposit Credential 'DRepRole -> Maybe Coin
lookupDRepDeposit (TxBody ConwayEra
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)

  upgradeTxBody :: EraTxBody (PreviousEra ConwayEra) =>
TxBody (PreviousEra ConwayEra)
-> Either (TxBodyUpgradeError ConwayEra) (TxBody ConwayEra)
upgradeTxBody TxBody (PreviousEra ConwayEra)
btb = do
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. StrictMaybe a -> Bool
isSJust (forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe (Update era)
btbUpdate TxBody (PreviousEra ConwayEra)
btb)) forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left ConwayTxBodyUpgradeError
CTBUEContainsUpdate
    StrictSeq (ConwayTxCert ConwayEra)
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 ConwayTxCertUpgradeError -> ConwayTxBodyUpgradeError
CTBUETxCert 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) (forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictSeq (TxCert era)
btbCerts TxBody (PreviousEra ConwayEra)
btb)
    let (Set (ConwayTxCert ConwayEra)
duplicates, OSet (ConwayTxCert ConwayEra)
certsOSet) = forall a. Ord a => StrictSeq a -> (Set a, OSet a)
OSet.fromStrictSeqDuplicates StrictSeq (ConwayTxCert ConwayEra)
certs
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set (ConwayTxCert ConwayEra)
duplicates) forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Set (TxCert ConwayEra) -> ConwayTxBodyUpgradeError
CTBUEContainsDuplicateCerts Set (ConwayTxCert ConwayEra)
duplicates
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
      ConwayTxBody
        { ctbSpendInputs :: Set TxIn
ctbSpendInputs = forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
btbInputs TxBody (PreviousEra ConwayEra)
btb
        , ctbOutputs :: StrictSeq (Sized (TxOut ConwayEra))
ctbOutputs =
            forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @ConwayEra)
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraTxOut era, EraTxOut (PreviousEra era)) =>
TxOut (PreviousEra era) -> TxOut era
upgradeTxOut
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Sized a -> a
sizedValue
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictSeq (Sized (TxOut era))
btbOutputs TxBody (PreviousEra ConwayEra)
btb
        , ctbCerts :: OSet (ConwayTxCert ConwayEra)
ctbCerts = OSet (ConwayTxCert ConwayEra)
certsOSet
        , ctbWithdrawals :: Withdrawals
ctbWithdrawals = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Withdrawals
btbWithdrawals TxBody (PreviousEra ConwayEra)
btb
        , ctbTxfee :: Coin
ctbTxfee = forall era. BabbageEraTxBody era => BabbageTxBody era -> Coin
btbTxFee TxBody (PreviousEra ConwayEra)
btb
        , ctbVldt :: ValidityInterval
ctbVldt = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> ValidityInterval
btbValidityInterval TxBody (PreviousEra ConwayEra)
btb
        , ctbAdHash :: StrictMaybe TxAuxDataHash
ctbAdHash = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe TxAuxDataHash
btbAuxDataHash TxBody (PreviousEra ConwayEra)
btb
        , ctbMint :: MultiAsset
ctbMint = forall era. BabbageEraTxBody era => BabbageTxBody era -> MultiAsset
btbMint TxBody (PreviousEra ConwayEra)
btb
        , ctbCollateralInputs :: Set TxIn
ctbCollateralInputs = forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
btbCollateral TxBody (PreviousEra ConwayEra)
btb
        , ctbReqSignerHashes :: Set (KeyHash 'Witness)
ctbReqSignerHashes = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> Set (KeyHash 'Witness)
btbReqSignerHashes TxBody (PreviousEra ConwayEra)
btb
        , ctbScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
ctbScriptIntegrityHash = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe ScriptIntegrityHash
btbScriptIntegrityHash TxBody (PreviousEra ConwayEra)
btb
        , ctbTxNetworkId :: StrictMaybe Network
ctbTxNetworkId = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe Network
btbTxNetworkId TxBody (PreviousEra ConwayEra)
btb
        , ctbReferenceInputs :: Set TxIn
ctbReferenceInputs = forall era. BabbageEraTxBody era => BabbageTxBody era -> Set TxIn
btbReferenceInputs TxBody (PreviousEra ConwayEra)
btb
        , ctbCollateralReturn :: StrictMaybe (Sized (TxOut ConwayEra))
ctbCollateralReturn =
            forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @ConwayEra)
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraTxOut era, EraTxOut (PreviousEra era)) =>
TxOut (PreviousEra era) -> TxOut era
upgradeTxOut
              forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Sized a -> a
sizedValue
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe (Sized (TxOut era))
btbCollateralReturn TxBody (PreviousEra ConwayEra)
btb
        , ctbTotalCollateral :: StrictMaybe Coin
ctbTotalCollateral = forall era.
BabbageEraTxBody era =>
BabbageTxBody era -> StrictMaybe Coin
btbTotalCollateral TxBody (PreviousEra ConwayEra)
btb
        , ctbCurrentTreasuryValue :: StrictMaybe Coin
ctbCurrentTreasuryValue = forall a. StrictMaybe a
SNothing
        , ctbProposalProcedures :: OSet (ProposalProcedure ConwayEra)
ctbProposalProcedures = forall a. OSet a
OSet.empty
        , ctbVotingProcedures :: VotingProcedures ConwayEra
ctbVotingProcedures = forall era.
Map Voter (Map GovActionId (VotingProcedure era))
-> VotingProcedures era
VotingProcedures forall a. Monoid a => a
mempty
        , ctbTreasuryDonation :: Coin
ctbTreasuryDonation = Integer -> Coin
Coin Integer
0
        }

-- ==========================================
-- Deposits and Refunds for Conway TxBody

-- | Compute all the deposits in a TxBody. This includes deposits for:
--
--   1. registering Stake
--   2. registering a StakePool
--   3. registering a DRep
--   4. submitting a Proposal
--
-- This is the contribution of a TxBody towards the total
-- `Cardano.Ledger.CertState.Obligations`
conwayTotalDepositsTxBody ::
  ConwayEraTxBody era =>
  PParams era ->
  (KeyHash 'StakePool -> Bool) ->
  TxBody era ->
  Coin
conwayTotalDepositsTxBody :: forall era.
ConwayEraTxBody era =>
PParams era -> (KeyHash 'StakePool -> Bool) -> TxBody era -> Coin
conwayTotalDepositsTxBody PParams era
pp KeyHash 'StakePool -> Bool
isPoolRegisted TxBody era
txBody =
  forall era (f :: * -> *).
(EraTxCert era, Foldable f) =>
PParams era
-> (KeyHash 'StakePool -> Bool) -> f (TxCert era) -> Coin
getTotalDepositsTxCerts PParams era
pp KeyHash 'StakePool -> Bool
isPoolRegisted (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)
    forall t. Val t => t -> t -> t
<+> forall era.
ConwayEraTxBody era =>
PParams era -> TxBody era -> Coin
conwayProposalsDeposits PParams era
pp TxBody era
txBody

-- | Total number of deposits in the proposals in TxBody
conwayProposalsDeposits ::
  ConwayEraTxBody era =>
  PParams era ->
  TxBody era ->
  Coin
conwayProposalsDeposits :: forall era.
ConwayEraTxBody era =>
PParams era -> TxBody era -> Coin
conwayProposalsDeposits PParams era
pp TxBody era
txBody = Int
numProposals forall t i. (Val t, Integral i) => i -> t -> t
<×> Coin
depositPerProposal
  where
    numProposals :: Int
numProposals = forall (t :: * -> *) a. Foldable t => t a -> Int
length (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
proposalProceduresTxBodyL)
    depositPerProposal :: Coin
depositPerProposal = PParams era
pp forall s a. s -> Getting a s a -> a
^. forall era. ConwayEraPParams era => Lens' (PParams era) Coin
ppGovActionDepositL

instance AllegraEraTxBody ConwayEra where
  vldtTxBodyL :: Lens' (TxBody ConwayEra) ValidityInterval
vldtTxBodyL = 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. ConwayTxBodyRaw era -> ValidityInterval
ctbrVldt (\RawType ConwayTxBody ConwayEra
txb ValidityInterval
x -> RawType ConwayTxBody ConwayEra
txb {ctbrVldt :: ValidityInterval
ctbrVldt = ValidityInterval
x})
  {-# INLINE vldtTxBodyL #-}

instance MaryEraTxBody ConwayEra where
  mintTxBodyL :: Lens' (TxBody ConwayEra) MultiAsset
mintTxBodyL = 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. ConwayTxBodyRaw era -> MultiAsset
ctbrMint (\RawType ConwayTxBody ConwayEra
txb MultiAsset
x -> RawType ConwayTxBody ConwayEra
txb {ctbrMint :: MultiAsset
ctbrMint = MultiAsset
x})
  {-# INLINE mintTxBodyL #-}

  mintValueTxBodyF :: SimpleGetter (TxBody ConwayEra) (Value ConwayEra)
mintValueTxBodyF = forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
mintTxBodyL 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)

  mintedTxBodyF :: SimpleGetter (TxBody ConwayEra) (Set PolicyID)
mintedTxBodyF =
    forall s a. (s -> a) -> SimpleGetter s a
to (\(TxBodyConstr (Memo ConwayTxBodyRaw ConwayEra
txBodyRaw ShortByteString
_)) -> MultiAsset -> Set PolicyID
policies (forall era. ConwayTxBodyRaw era -> MultiAsset
ctbrMint ConwayTxBodyRaw ConwayEra
txBodyRaw))
  {-# INLINE mintedTxBodyF #-}

instance AlonzoEraTxBody ConwayEra where
  collateralInputsTxBodyL :: Lens' (TxBody ConwayEra) (Set TxIn)
collateralInputsTxBodyL =
    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. ConwayTxBodyRaw era -> Set TxIn
ctbrCollateralInputs (\RawType ConwayTxBody ConwayEra
txb Set TxIn
x -> RawType ConwayTxBody ConwayEra
txb {ctbrCollateralInputs :: Set TxIn
ctbrCollateralInputs = Set TxIn
x})
  {-# INLINE collateralInputsTxBodyL #-}

  reqSignerHashesTxBodyL :: Lens' (TxBody ConwayEra) (Set (KeyHash 'Witness))
reqSignerHashesTxBodyL =
    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. ConwayTxBodyRaw era -> Set (KeyHash 'Witness)
ctbrReqSignerHashes (\RawType ConwayTxBody ConwayEra
txb Set (KeyHash 'Witness)
x -> RawType ConwayTxBody ConwayEra
txb {ctbrReqSignerHashes :: Set (KeyHash 'Witness)
ctbrReqSignerHashes = Set (KeyHash 'Witness)
x})
  {-# INLINE reqSignerHashesTxBodyL #-}

  scriptIntegrityHashTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe ScriptIntegrityHash)
scriptIntegrityHashTxBodyL =
    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. ConwayTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
ctbrScriptIntegrityHash (\RawType ConwayTxBody ConwayEra
txb StrictMaybe ScriptIntegrityHash
x -> RawType ConwayTxBody ConwayEra
txb {ctbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
ctbrScriptIntegrityHash = StrictMaybe ScriptIntegrityHash
x})
  {-# INLINE scriptIntegrityHashTxBodyL #-}

  networkIdTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe Network)
networkIdTxBodyL = 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. ConwayTxBodyRaw era -> StrictMaybe Network
ctbrTxNetworkId (\RawType ConwayTxBody ConwayEra
txb StrictMaybe Network
x -> RawType ConwayTxBody ConwayEra
txb {ctbrTxNetworkId :: StrictMaybe Network
ctbrTxNetworkId = StrictMaybe Network
x})
  {-# INLINE networkIdTxBodyL #-}

  redeemerPointer :: TxBody ConwayEra
-> PlutusPurpose AsItem ConwayEra
-> StrictMaybe (PlutusPurpose AsIx ConwayEra)
redeemerPointer = forall era.
ConwayEraTxBody era =>
TxBody era
-> ConwayPlutusPurpose AsItem era
-> StrictMaybe (ConwayPlutusPurpose AsIx era)
conwayRedeemerPointer

  redeemerPointerInverse :: TxBody ConwayEra
-> PlutusPurpose AsIx ConwayEra
-> StrictMaybe (PlutusPurpose AsIxItem ConwayEra)
redeemerPointerInverse = forall era.
ConwayEraTxBody era =>
TxBody era
-> ConwayPlutusPurpose AsIx era
-> StrictMaybe (ConwayPlutusPurpose AsIxItem era)
conwayRedeemerPointerInverse

instance BabbageEraTxBody ConwayEra where
  sizedOutputsTxBodyL :: Lens' (TxBody ConwayEra) (StrictSeq (Sized (TxOut ConwayEra)))
sizedOutputsTxBodyL = 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. ConwayTxBodyRaw era -> StrictSeq (Sized (TxOut era))
ctbrOutputs (\RawType ConwayTxBody ConwayEra
txb StrictSeq (Sized (BabbageTxOut ConwayEra))
x -> RawType ConwayTxBody ConwayEra
txb {ctbrOutputs :: StrictSeq (Sized (TxOut ConwayEra))
ctbrOutputs = StrictSeq (Sized (BabbageTxOut ConwayEra))
x})
  {-# INLINE sizedOutputsTxBodyL #-}

  referenceInputsTxBodyL :: Lens' (TxBody ConwayEra) (Set TxIn)
referenceInputsTxBodyL =
    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. ConwayTxBodyRaw era -> Set TxIn
ctbrReferenceInputs (\RawType ConwayTxBody ConwayEra
txb Set TxIn
x -> RawType ConwayTxBody ConwayEra
txb {ctbrReferenceInputs :: Set TxIn
ctbrReferenceInputs = Set TxIn
x})
  {-# INLINE referenceInputsTxBodyL #-}

  totalCollateralTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe Coin)
totalCollateralTxBodyL =
    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. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrTotalCollateral (\RawType ConwayTxBody ConwayEra
txb StrictMaybe Coin
x -> RawType ConwayTxBody ConwayEra
txb {ctbrTotalCollateral :: StrictMaybe Coin
ctbrTotalCollateral = StrictMaybe Coin
x})
  {-# INLINE totalCollateralTxBodyL #-}

  collateralReturnTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe (TxOut ConwayEra))
collateralReturnTxBodyL =
    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. ConwayTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
ctbrCollateralReturn)
      (\RawType ConwayTxBody ConwayEra
txb StrictMaybe (BabbageTxOut ConwayEra)
x -> RawType ConwayTxBody ConwayEra
txb {ctbrCollateralReturn :: StrictMaybe (Sized (TxOut ConwayEra))
ctbrCollateralReturn = forall a. EncCBOR a => Version -> a -> Sized a
mkSized (forall era. Era era => Version
eraProtVerLow @ConwayEra) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictMaybe (BabbageTxOut ConwayEra)
x})
  {-# INLINE collateralReturnTxBodyL #-}

  sizedCollateralReturnTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe (Sized (TxOut ConwayEra)))
sizedCollateralReturnTxBodyL =
    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. ConwayTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
ctbrCollateralReturn (\RawType ConwayTxBody ConwayEra
txb StrictMaybe (Sized (BabbageTxOut ConwayEra))
x -> RawType ConwayTxBody ConwayEra
txb {ctbrCollateralReturn :: StrictMaybe (Sized (TxOut ConwayEra))
ctbrCollateralReturn = StrictMaybe (Sized (BabbageTxOut ConwayEra))
x})
  {-# INLINE sizedCollateralReturnTxBodyL #-}

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

instance ConwayEraTxBody ConwayEra where
  votingProceduresTxBodyL :: Lens' (TxBody ConwayEra) (VotingProcedures ConwayEra)
votingProceduresTxBodyL =
    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. ConwayTxBodyRaw era -> VotingProcedures era
ctbrVotingProcedures (\RawType ConwayTxBody ConwayEra
txb VotingProcedures ConwayEra
x -> RawType ConwayTxBody ConwayEra
txb {ctbrVotingProcedures :: VotingProcedures ConwayEra
ctbrVotingProcedures = VotingProcedures ConwayEra
x})
  {-# INLINE votingProceduresTxBodyL #-}
  proposalProceduresTxBodyL :: Lens' (TxBody ConwayEra) (OSet (ProposalProcedure ConwayEra))
proposalProceduresTxBodyL =
    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. ConwayTxBodyRaw era -> OSet (ProposalProcedure era)
ctbrProposalProcedures (\RawType ConwayTxBody ConwayEra
txb OSet (ProposalProcedure ConwayEra)
x -> RawType ConwayTxBody ConwayEra
txb {ctbrProposalProcedures :: OSet (ProposalProcedure ConwayEra)
ctbrProposalProcedures = OSet (ProposalProcedure ConwayEra)
x})
  {-# INLINE proposalProceduresTxBodyL #-}
  currentTreasuryValueTxBodyL :: Lens' (TxBody ConwayEra) (StrictMaybe Coin)
currentTreasuryValueTxBodyL =
    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. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrCurrentTreasuryValue (\RawType ConwayTxBody ConwayEra
txb StrictMaybe Coin
x -> RawType ConwayTxBody ConwayEra
txb {ctbrCurrentTreasuryValue :: StrictMaybe Coin
ctbrCurrentTreasuryValue = StrictMaybe Coin
x})
  {-# INLINE currentTreasuryValueTxBodyL #-}
  treasuryDonationTxBodyL :: Lens' (TxBody ConwayEra) Coin
treasuryDonationTxBodyL =
    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. ConwayTxBodyRaw era -> Coin
ctbrTreasuryDonation (\RawType ConwayTxBody ConwayEra
txb Coin
x -> RawType ConwayTxBody ConwayEra
txb {ctbrTreasuryDonation :: Coin
ctbrTreasuryDonation = Coin
x})
  {-# INLINE treasuryDonationTxBodyL #-}

instance
  (EraPParams era, Eq (TxOut era), Eq (TxCert era)) =>
  EqRaw (ConwayTxBody era)

pattern ConwayTxBody ::
  ConwayEraTxBody era =>
  Set TxIn ->
  Set TxIn ->
  Set TxIn ->
  StrictSeq (Sized (TxOut era)) ->
  StrictMaybe (Sized (TxOut era)) ->
  StrictMaybe Coin ->
  OSet.OSet (ConwayTxCert era) ->
  Withdrawals ->
  Coin ->
  ValidityInterval ->
  Set (KeyHash 'Witness) ->
  MultiAsset ->
  StrictMaybe ScriptIntegrityHash ->
  StrictMaybe TxAuxDataHash ->
  StrictMaybe Network ->
  VotingProcedures era ->
  OSet.OSet (ProposalProcedure era) ->
  StrictMaybe Coin ->
  Coin ->
  ConwayTxBody era
pattern $bConwayTxBody :: forall era.
ConwayEraTxBody era =>
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> OSet (ConwayTxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> VotingProcedures era
-> OSet (ProposalProcedure era)
-> StrictMaybe Coin
-> Coin
-> ConwayTxBody era
$mConwayTxBody :: forall {r} {era}.
ConwayEraTxBody era =>
ConwayTxBody era
-> (Set TxIn
    -> Set TxIn
    -> Set TxIn
    -> StrictSeq (Sized (TxOut era))
    -> StrictMaybe (Sized (TxOut era))
    -> StrictMaybe Coin
    -> OSet (ConwayTxCert era)
    -> Withdrawals
    -> Coin
    -> ValidityInterval
    -> Set (KeyHash 'Witness)
    -> MultiAsset
    -> StrictMaybe ScriptIntegrityHash
    -> StrictMaybe TxAuxDataHash
    -> StrictMaybe Network
    -> VotingProcedures era
    -> OSet (ProposalProcedure era)
    -> StrictMaybe Coin
    -> Coin
    -> r)
-> ((# #) -> r)
-> r
ConwayTxBody
  { forall era. ConwayEraTxBody era => ConwayTxBody era -> Set TxIn
ctbSpendInputs
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> Set TxIn
ctbCollateralInputs
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> Set TxIn
ctbReferenceInputs
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictSeq (Sized (TxOut era))
ctbOutputs
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe (Sized (TxOut era))
ctbCollateralReturn
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe Coin
ctbTotalCollateral
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> OSet (ConwayTxCert era)
ctbCerts
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> Withdrawals
ctbWithdrawals
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> Coin
ctbTxfee
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> ValidityInterval
ctbVldt
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> Set (KeyHash 'Witness)
ctbReqSignerHashes
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> MultiAsset
ctbMint
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe ScriptIntegrityHash
ctbScriptIntegrityHash
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe TxAuxDataHash
ctbAdHash
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe Network
ctbTxNetworkId
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> VotingProcedures era
ctbVotingProcedures
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> OSet (ProposalProcedure era)
ctbProposalProcedures
  , forall era.
ConwayEraTxBody era =>
ConwayTxBody era -> StrictMaybe Coin
ctbCurrentTreasuryValue
  , forall era. ConwayEraTxBody era => ConwayTxBody era -> Coin
ctbTreasuryDonation
  } <-
  ( getMemoRawType ->
      ConwayTxBodyRaw
        { ctbrSpendInputs = ctbSpendInputs
        , ctbrCollateralInputs = ctbCollateralInputs
        , ctbrReferenceInputs = ctbReferenceInputs
        , ctbrOutputs = ctbOutputs
        , ctbrCollateralReturn = ctbCollateralReturn
        , ctbrTotalCollateral = ctbTotalCollateral
        , ctbrCerts = ctbCerts
        , ctbrWithdrawals = ctbWithdrawals
        , ctbrTxfee = ctbTxfee
        , ctbrVldt = ctbVldt
        , ctbrReqSignerHashes = ctbReqSignerHashes
        , ctbrMint = ctbMint
        , ctbrScriptIntegrityHash = ctbScriptIntegrityHash
        , ctbrAuxDataHash = ctbAdHash
        , ctbrTxNetworkId = ctbTxNetworkId
        , ctbrVotingProcedures = ctbVotingProcedures
        , ctbrProposalProcedures = ctbProposalProcedures
        , ctbrCurrentTreasuryValue = ctbCurrentTreasuryValue
        , ctbrTreasuryDonation = ctbTreasuryDonation
        }
    )
  where
    ConwayTxBody
      Set TxIn
inputsX
      Set TxIn
collateralX
      Set TxIn
referenceInputsX
      StrictSeq (Sized (TxOut era))
outputsX
      StrictMaybe (Sized (TxOut era))
collateralReturnX
      StrictMaybe Coin
totalCollateralX
      OSet (ConwayTxCert era)
certsX
      Withdrawals
withdrawalsX
      Coin
txfeeX
      ValidityInterval
vldtX
      Set (KeyHash 'Witness)
reqSignerHashesX
      MultiAsset
mintX
      StrictMaybe ScriptIntegrityHash
scriptIntegrityHashX
      StrictMaybe TxAuxDataHash
adHashX
      StrictMaybe Network
txnetworkidX
      VotingProcedures era
votingProcedures
      OSet (ProposalProcedure era)
proposalProcedures
      StrictMaybe Coin
currentTreasuryValue
      Coin
treasuryDonation =
        forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall a b. (a -> b) -> a -> b
$
          forall era.
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> OSet (ConwayTxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> VotingProcedures era
-> OSet (ProposalProcedure era)
-> StrictMaybe Coin
-> Coin
-> ConwayTxBodyRaw era
ConwayTxBodyRaw
            Set TxIn
inputsX
            Set TxIn
collateralX
            Set TxIn
referenceInputsX
            StrictSeq (Sized (TxOut era))
outputsX
            StrictMaybe (Sized (TxOut era))
collateralReturnX
            StrictMaybe Coin
totalCollateralX
            OSet (ConwayTxCert era)
certsX
            Withdrawals
withdrawalsX
            Coin
txfeeX
            ValidityInterval
vldtX
            Set (KeyHash 'Witness)
reqSignerHashesX
            MultiAsset
mintX
            StrictMaybe ScriptIntegrityHash
scriptIntegrityHashX
            StrictMaybe TxAuxDataHash
adHashX
            StrictMaybe Network
txnetworkidX
            VotingProcedures era
votingProcedures
            OSet (ProposalProcedure era)
proposalProcedures
            StrictMaybe Coin
currentTreasuryValue
            Coin
treasuryDonation

{-# COMPLETE ConwayTxBody #-}

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

encodeTxBodyRaw ::
  ConwayEraTxBody era =>
  ConwayTxBodyRaw era ->
  Encode ('Closed 'Sparse) (ConwayTxBodyRaw era)
encodeTxBodyRaw :: forall era.
ConwayEraTxBody era =>
ConwayTxBodyRaw era
-> Encode ('Closed 'Sparse) (ConwayTxBodyRaw era)
encodeTxBodyRaw ConwayTxBodyRaw {Set (KeyHash 'Witness)
Set TxIn
OSet (ProposalProcedure era)
OSet (ConwayTxCert era)
Withdrawals
ValidityInterval
StrictMaybe ScriptIntegrityHash
StrictMaybe TxAuxDataHash
StrictMaybe (Sized (TxOut era))
StrictMaybe Coin
StrictMaybe Network
StrictSeq (Sized (TxOut era))
Coin
MultiAsset
VotingProcedures era
ctbrTreasuryDonation :: Coin
ctbrCurrentTreasuryValue :: StrictMaybe Coin
ctbrProposalProcedures :: OSet (ProposalProcedure era)
ctbrVotingProcedures :: VotingProcedures era
ctbrTxNetworkId :: StrictMaybe Network
ctbrAuxDataHash :: StrictMaybe TxAuxDataHash
ctbrScriptIntegrityHash :: StrictMaybe ScriptIntegrityHash
ctbrMint :: MultiAsset
ctbrReqSignerHashes :: Set (KeyHash 'Witness)
ctbrVldt :: ValidityInterval
ctbrTxfee :: Coin
ctbrWithdrawals :: Withdrawals
ctbrCerts :: OSet (ConwayTxCert era)
ctbrTotalCollateral :: StrictMaybe Coin
ctbrCollateralReturn :: StrictMaybe (Sized (TxOut era))
ctbrOutputs :: StrictSeq (Sized (TxOut era))
ctbrReferenceInputs :: Set TxIn
ctbrCollateralInputs :: Set TxIn
ctbrSpendInputs :: Set TxIn
ctbrTreasuryDonation :: forall era. ConwayTxBodyRaw era -> Coin
ctbrCurrentTreasuryValue :: forall era. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrProposalProcedures :: forall era. ConwayTxBodyRaw era -> OSet (ProposalProcedure era)
ctbrVotingProcedures :: forall era. ConwayTxBodyRaw era -> VotingProcedures era
ctbrTxNetworkId :: forall era. ConwayTxBodyRaw era -> StrictMaybe Network
ctbrAuxDataHash :: forall era. ConwayTxBodyRaw era -> StrictMaybe TxAuxDataHash
ctbrScriptIntegrityHash :: forall era. ConwayTxBodyRaw era -> StrictMaybe ScriptIntegrityHash
ctbrMint :: forall era. ConwayTxBodyRaw era -> MultiAsset
ctbrReqSignerHashes :: forall era. ConwayTxBodyRaw era -> Set (KeyHash 'Witness)
ctbrVldt :: forall era. ConwayTxBodyRaw era -> ValidityInterval
ctbrTxfee :: forall era. ConwayTxBodyRaw era -> Coin
ctbrWithdrawals :: forall era. ConwayTxBodyRaw era -> Withdrawals
ctbrCerts :: forall era. ConwayTxBodyRaw era -> OSet (ConwayTxCert era)
ctbrTotalCollateral :: forall era. ConwayTxBodyRaw era -> StrictMaybe Coin
ctbrCollateralReturn :: forall era. ConwayTxBodyRaw era -> StrictMaybe (Sized (TxOut era))
ctbrOutputs :: forall era. ConwayTxBodyRaw era -> StrictSeq (Sized (TxOut era))
ctbrReferenceInputs :: forall era. ConwayTxBodyRaw era -> Set TxIn
ctbrCollateralInputs :: forall era. ConwayTxBodyRaw era -> Set TxIn
ctbrSpendInputs :: forall era. ConwayTxBodyRaw era -> Set TxIn
..} =
  let ValidityInterval StrictMaybe SlotNo
bot StrictMaybe SlotNo
top = ValidityInterval
ctbrVldt
   in forall t. t -> Encode ('Closed 'Sparse) t
Keyed
        ( \Set TxIn
i Set TxIn
ci Set TxIn
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc Coin
f StrictMaybe SlotNo
t OSet (ConwayTxCert era)
c Withdrawals
w StrictMaybe SlotNo
b ->
            forall era.
Set TxIn
-> Set TxIn
-> Set TxIn
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> OSet (ConwayTxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> Set (KeyHash 'Witness)
-> MultiAsset
-> StrictMaybe ScriptIntegrityHash
-> StrictMaybe TxAuxDataHash
-> StrictMaybe Network
-> VotingProcedures era
-> OSet (ProposalProcedure era)
-> StrictMaybe Coin
-> Coin
-> ConwayTxBodyRaw era
ConwayTxBodyRaw Set TxIn
i Set TxIn
ci Set TxIn
ri StrictSeq (Sized (TxOut era))
o StrictMaybe (Sized (TxOut era))
cr StrictMaybe Coin
tc OSet (ConwayTxCert era)
c Withdrawals
w Coin
f (StrictMaybe SlotNo -> StrictMaybe SlotNo -> ValidityInterval
ValidityInterval StrictMaybe SlotNo
b StrictMaybe SlotNo
t)
        )
        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
ctbrSpendInputs)
        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
ctbrCollateralInputs))
        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
ctbrReferenceInputs))
        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))
ctbrOutputs)
        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))
ctbrCollateralReturn
        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
ctbrTotalCollateral
        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
ctbrTxfee)
        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 a. OSet a -> Bool
OSet.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 OSet (ConwayTxCert era)
ctbrCerts))
        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
ctbrWithdrawals))
        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)
ctbrReqSignerHashes))
        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
ctbrMint))
        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
ctbrScriptIntegrityHash
        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
ctbrAuxDataHash
        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
ctbrTxNetworkId
        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 era.
VotingProcedures era
-> Map Voter (Map GovActionId (VotingProcedure era))
unVotingProcedures) (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
19 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To VotingProcedures era
ctbrVotingProcedures))
        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. OSet a -> Bool
OSet.null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
20 (forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To OSet (ProposalProcedure era)
ctbrProposalProcedures))
        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
21 StrictMaybe Coin
ctbrCurrentTreasuryValue
        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
22 forall a b. (a -> b) -> a -> b
$ forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
ctbrTreasuryDonation)

instance ConwayEraTxBody era => EncCBOR (ConwayTxBodyRaw era) where
  encCBOR :: ConwayTxBodyRaw era -> Encoding
encCBOR = forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
ConwayEraTxBody era =>
ConwayTxBodyRaw era
-> Encode ('Closed 'Sparse) (ConwayTxBodyRaw era)
encodeTxBodyRaw

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

class
  (BabbageEraTxBody era, ConwayEraTxCert era, ConwayEraPParams era, ConwayEraScript era) =>
  ConwayEraTxBody era
  where
  -- | Lens for getting and setting number of `Coin` that is expected to be in the
  -- Treasury at the current Epoch
  currentTreasuryValueTxBodyL :: Lens' (TxBody era) (StrictMaybe Coin)

  -- | Lens for getting and setting `VotingProcedures`.
  votingProceduresTxBodyL :: Lens' (TxBody era) (VotingProcedures era)

  -- | Lens for getting and setting `ProposalProcedures`.
  proposalProceduresTxBodyL :: Lens' (TxBody era) (OSet.OSet (ProposalProcedure era))

  treasuryDonationTxBodyL :: Lens' (TxBody era) Coin

conwayRedeemerPointer ::
  forall era.
  ConwayEraTxBody era =>
  TxBody era ->
  ConwayPlutusPurpose AsItem era ->
  StrictMaybe (ConwayPlutusPurpose AsIx era)
conwayRedeemerPointer :: forall era.
ConwayEraTxBody era =>
TxBody era
-> ConwayPlutusPurpose AsItem era
-> StrictMaybe (ConwayPlutusPurpose AsIx era)
conwayRedeemerPointer TxBody era
txBody = \case
  ConwayMinting AsItem Word32 PolicyID
policyID ->
    forall (f :: * -> * -> *) era.
f Word32 PolicyID -> ConwayPlutusPurpose f era
ConwayMinting forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 PolicyID
policyID (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
MaryEraTxBody era =>
SimpleGetter (TxBody era) (Set PolicyID)
mintedTxBodyF)
  ConwaySpending AsItem Word32 TxIn
txIn ->
    forall (f :: * -> * -> *) era.
f Word32 TxIn -> ConwayPlutusPurpose f era
ConwaySpending forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 TxIn
txIn (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
inputsTxBodyL)
  ConwayRewarding AsItem Word32 RewardAccount
rewardAccount ->
    forall (f :: * -> * -> *) era.
f Word32 RewardAccount -> ConwayPlutusPurpose f era
ConwayRewarding forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 RewardAccount
rewardAccount (Withdrawals -> Map RewardAccount Coin
unWithdrawals (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) Withdrawals
withdrawalsTxBodyL))
  ConwayCertifying AsItem Word32 (TxCert era)
txCert ->
    forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> ConwayPlutusPurpose f era
ConwayCertifying forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 (TxCert era)
txCert (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)
  ConwayVoting AsItem Word32 Voter
votingProcedure ->
    forall (f :: * -> * -> *) era.
f Word32 Voter -> ConwayPlutusPurpose f era
ConwayVoting forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 Voter
votingProcedure (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (VotingProcedures era)
votingProceduresTxBodyL)
  ConwayProposing AsItem Word32 (ProposalProcedure era)
proposalProcedure ->
    forall (f :: * -> * -> *) era.
f Word32 (ProposalProcedure era) -> ConwayPlutusPurpose f era
ConwayProposing forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsItem Word32 elem -> container -> StrictMaybe (AsIx Word32 elem)
indexOf AsItem Word32 (ProposalProcedure era)
proposalProcedure (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
proposalProceduresTxBodyL)

conwayRedeemerPointerInverse ::
  ConwayEraTxBody era =>
  TxBody era ->
  ConwayPlutusPurpose AsIx era ->
  StrictMaybe (ConwayPlutusPurpose AsIxItem era)
conwayRedeemerPointerInverse :: forall era.
ConwayEraTxBody era =>
TxBody era
-> ConwayPlutusPurpose AsIx era
-> StrictMaybe (ConwayPlutusPurpose AsIxItem era)
conwayRedeemerPointerInverse TxBody era
txBody = \case
  ConwayMinting AsIx Word32 PolicyID
idx ->
    forall (f :: * -> * -> *) era.
f Word32 PolicyID -> ConwayPlutusPurpose f era
ConwayMinting forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 PolicyID
idx (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
MaryEraTxBody era =>
SimpleGetter (TxBody era) (Set PolicyID)
mintedTxBodyF)
  ConwaySpending AsIx Word32 TxIn
idx ->
    forall (f :: * -> * -> *) era.
f Word32 TxIn -> ConwayPlutusPurpose f era
ConwaySpending forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 TxIn
idx (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
inputsTxBodyL)
  ConwayRewarding AsIx Word32 RewardAccount
idx ->
    forall (f :: * -> * -> *) era.
f Word32 RewardAccount -> ConwayPlutusPurpose f era
ConwayRewarding forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 RewardAccount
idx (Withdrawals -> Map RewardAccount Coin
unWithdrawals (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era. EraTxBody era => Lens' (TxBody era) Withdrawals
withdrawalsTxBodyL))
  ConwayCertifying AsIx Word32 (TxCert era)
idx ->
    forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> ConwayPlutusPurpose f era
ConwayCertifying forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 (TxCert era)
idx (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
certsTxBodyL)
  ConwayVoting AsIx Word32 Voter
idx ->
    forall (f :: * -> * -> *) era.
f Word32 Voter -> ConwayPlutusPurpose f era
ConwayVoting forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 Voter
idx (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (VotingProcedures era)
votingProceduresTxBodyL)
  ConwayProposing AsIx Word32 (ProposalProcedure era)
idx ->
    forall (f :: * -> * -> *) era.
f Word32 (ProposalProcedure era) -> ConwayPlutusPurpose f era
ConwayProposing forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall elem container.
Indexable elem container =>
AsIx Word32 elem -> container -> StrictMaybe (AsIxItem Word32 elem)
fromIndex AsIx Word32 (ProposalProcedure era)
idx (TxBody era
txBody forall s a. s -> Getting a s a -> a
^. forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
proposalProceduresTxBodyL)