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

-- | Provides Mary 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.Mary.TxBody.Internal (
  MaryEraTxBody (..),
  MaryTxBody (
    ..,
    MaryTxBody,
    mtbAuxDataHash,
    mtbCerts,
    mtbInputs,
    mtbOutputs,
    mtbTxFee,
    mtbUpdate,
    mtbValidityInterval,
    mtbWithdrawals,
    mtbMint
  ),
  MaryTxBodyRaw (..),
)
where

import Cardano.Ledger.Allegra.Core
import Cardano.Ledger.Allegra.TxBody
import Cardano.Ledger.Binary (Annotator, DecCBOR (..), EncCBOR (..), ToCBOR (..))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Mary.Era (MaryEra)
import Cardano.Ledger.Mary.TxCert ()
import Cardano.Ledger.Mary.TxOut ()
import Cardano.Ledger.Mary.Value
import Cardano.Ledger.MemoBytes (
  EqRaw,
  Mem,
  MemoBytes (Memo),
  MemoHashIndex,
  Memoized (RawType),
  getMemoRawType,
  getMemoSafeHash,
  lensMemoRawType,
  mkMemoized,
 )
import Cardano.Ledger.Shelley.PParams (Update, upgradeUpdate)
import Cardano.Ledger.Shelley.TxBody (getShelleyGenesisKeyHashCountTxBody)
import Cardano.Ledger.TxIn (TxIn (..))
import Control.DeepSeq (NFData (..))
import Data.Sequence.Strict (StrictSeq)
import Data.Set (Set)
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks (..))

class AllegraEraTxBody era => MaryEraTxBody era where
  mintTxBodyL :: Lens' (TxBody era) MultiAsset

  mintValueTxBodyF :: SimpleGetter (TxBody era) (Value era)

  mintedTxBodyF :: SimpleGetter (TxBody era) (Set PolicyID)

-- ===========================================================================
-- Wrap it all up in a newtype, hiding the insides with a pattern constructor.

newtype MaryTxBodyRaw era = MaryTxBodyRaw (AllegraTxBodyRaw MultiAsset era)

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

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

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

deriving instance Generic (MaryTxBodyRaw era)

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

deriving newtype instance AllegraEraTxBody era => DecCBOR (MaryTxBodyRaw era)

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

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

instance
  (Era era, Eq (PParamsUpdate era), Eq (TxOut era), Eq (TxCert era)) =>
  EqRaw (MaryTxBody era)

instance AllegraEraTxBody era => DecCBOR (Annotator (MaryTxBodyRaw era)) where
  decCBOR :: forall s. Decoder s (Annotator (MaryTxBodyRaw 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 newtype instance (EraTxOut era, EraTxCert era) => EncCBOR (MaryTxBodyRaw era)

instance Memoized MaryTxBody where
  type RawType MaryTxBody = MaryTxBodyRaw

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

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

deriving instance Generic (MaryTxBody era)

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

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

deriving via
  Mem MaryTxBodyRaw era
  instance
    MaryEraTxBody era => DecCBOR (Annotator (MaryTxBody era))

type instance MemoHashIndex MaryTxBodyRaw = EraIndependentTxBody

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

-- | A pattern to keep the newtype and the MemoBytes hidden
pattern MaryTxBody ::
  (EraTxOut era, EraTxCert era) =>
  Set TxIn ->
  StrictSeq (TxOut era) ->
  StrictSeq (TxCert era) ->
  Withdrawals ->
  Coin ->
  ValidityInterval ->
  StrictMaybe (Update era) ->
  StrictMaybe TxAuxDataHash ->
  MultiAsset ->
  MaryTxBody era
pattern $bMaryTxBody :: forall era.
(EraTxOut era, EraTxCert era) =>
Set TxIn
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> StrictMaybe TxAuxDataHash
-> MultiAsset
-> MaryTxBody era
$mMaryTxBody :: forall {r} {era}.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era
-> (Set TxIn
    -> StrictSeq (TxOut era)
    -> StrictSeq (TxCert era)
    -> Withdrawals
    -> Coin
    -> ValidityInterval
    -> StrictMaybe (Update era)
    -> StrictMaybe TxAuxDataHash
    -> MultiAsset
    -> r)
-> ((# #) -> r)
-> r
MaryTxBody
  { forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> Set TxIn
mtbInputs
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> StrictSeq (TxOut era)
mtbOutputs
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> StrictSeq (TxCert era)
mtbCerts
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> Withdrawals
mtbWithdrawals
  , forall era. (EraTxOut era, EraTxCert era) => MaryTxBody era -> Coin
mtbTxFee
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> ValidityInterval
mtbValidityInterval
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> StrictMaybe (Update era)
mtbUpdate
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> StrictMaybe TxAuxDataHash
mtbAuxDataHash
  , forall era.
(EraTxOut era, EraTxCert era) =>
MaryTxBody era -> MultiAsset
mtbMint
  } <-
  ( getMemoRawType ->
      MaryTxBodyRaw
        ( AllegraTxBodyRaw
            { atbrInputs = mtbInputs
            , atbrOutputs = mtbOutputs
            , atbrCerts = mtbCerts
            , atbrWithdrawals = mtbWithdrawals
            , atbrTxFee = mtbTxFee
            , atbrValidityInterval = mtbValidityInterval
            , atbrUpdate = mtbUpdate
            , atbrAuxDataHash = mtbAuxDataHash
            , atbrMint = mtbMint
            }
          )
    )
  where
    MaryTxBody
      Set TxIn
inputs
      StrictSeq (TxOut era)
outputs
      StrictSeq (TxCert era)
certs
      Withdrawals
withdrawals
      Coin
txFee
      ValidityInterval
validityInterval
      StrictMaybe (Update era)
update
      StrictMaybe TxAuxDataHash
auxDataHash
      MultiAsset
mint =
        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. AllegraTxBodyRaw MultiAsset era -> MaryTxBodyRaw era
MaryTxBodyRaw forall a b. (a -> b) -> a -> b
$
            AllegraTxBodyRaw
              { atbrInputs :: Set TxIn
atbrInputs = Set TxIn
inputs
              , atbrOutputs :: StrictSeq (TxOut era)
atbrOutputs = StrictSeq (TxOut era)
outputs
              , atbrCerts :: StrictSeq (TxCert era)
atbrCerts = StrictSeq (TxCert era)
certs
              , atbrWithdrawals :: Withdrawals
atbrWithdrawals = Withdrawals
withdrawals
              , atbrTxFee :: Coin
atbrTxFee = Coin
txFee
              , atbrValidityInterval :: ValidityInterval
atbrValidityInterval = ValidityInterval
validityInterval
              , atbrUpdate :: StrictMaybe (Update era)
atbrUpdate = StrictMaybe (Update era)
update
              , atbrAuxDataHash :: StrictMaybe TxAuxDataHash
atbrAuxDataHash = StrictMaybe TxAuxDataHash
auxDataHash
              , atbrMint :: MultiAsset
atbrMint = MultiAsset
mint
              }

{-# COMPLETE MaryTxBody #-}

-- | This is a helper Lens creator for any Memoized type.
lensMaryTxBodyRaw ::
  (EraTxOut era, EraTxCert era) =>
  (AllegraTxBodyRaw MultiAsset era -> a) ->
  (AllegraTxBodyRaw MultiAsset era -> b -> AllegraTxBodyRaw MultiAsset era) ->
  Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw :: forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw AllegraTxBodyRaw MultiAsset era -> a
getter AllegraTxBodyRaw MultiAsset era
-> b -> AllegraTxBodyRaw MultiAsset era
setter =
  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
    (\(MaryTxBodyRaw AllegraTxBodyRaw MultiAsset era
atbr) -> AllegraTxBodyRaw MultiAsset era -> a
getter AllegraTxBodyRaw MultiAsset era
atbr)
    (\(MaryTxBodyRaw AllegraTxBodyRaw MultiAsset era
atbr) b
a -> forall era. AllegraTxBodyRaw MultiAsset era -> MaryTxBodyRaw era
MaryTxBodyRaw (AllegraTxBodyRaw MultiAsset era
-> b -> AllegraTxBodyRaw MultiAsset era
setter AllegraTxBodyRaw MultiAsset era
atbr b
a))
{-# INLINEABLE lensMaryTxBodyRaw #-}

instance EraTxBody MaryEra where
  type TxBody MaryEra = MaryTxBody MaryEra

  mkBasicTxBody :: TxBody MaryEra
mkBasicTxBody = 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. AllegraTxBodyRaw MultiAsset era -> MaryTxBodyRaw era
MaryTxBodyRaw forall ma era. Monoid ma => AllegraTxBodyRaw ma era
emptyAllegraTxBodyRaw

  inputsTxBodyL :: Lens' (TxBody MaryEra) (Set TxIn)
inputsTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> Set TxIn
atbrInputs forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw Set TxIn
inputs -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrInputs :: Set TxIn
atbrInputs = Set TxIn
inputs}
  {-# INLINEABLE inputsTxBodyL #-}

  outputsTxBodyL :: Lens' (TxBody MaryEra) (StrictSeq (TxOut MaryEra))
outputsTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> StrictSeq (TxOut era)
atbrOutputs forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw StrictSeq (TxOut MaryEra)
outputs -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrOutputs :: StrictSeq (TxOut MaryEra)
atbrOutputs = StrictSeq (TxOut MaryEra)
outputs}
  {-# INLINEABLE outputsTxBodyL #-}

  feeTxBodyL :: Lens' (TxBody MaryEra) Coin
feeTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> Coin
atbrTxFee forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw Coin
fee -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrTxFee :: Coin
atbrTxFee = Coin
fee}
  {-# INLINEABLE feeTxBodyL #-}

  auxDataHashTxBodyL :: Lens' (TxBody MaryEra) (StrictMaybe TxAuxDataHash)
auxDataHashTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> StrictMaybe TxAuxDataHash
atbrAuxDataHash forall a b. (a -> b) -> a -> b
$
      \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw StrictMaybe TxAuxDataHash
auxDataHash -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrAuxDataHash :: StrictMaybe TxAuxDataHash
atbrAuxDataHash = StrictMaybe TxAuxDataHash
auxDataHash}
  {-# INLINEABLE auxDataHashTxBodyL #-}

  spendableInputsTxBodyF :: SimpleGetter (TxBody MaryEra) (Set TxIn)
spendableInputsTxBodyF = forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
inputsTxBodyL
  {-# INLINE spendableInputsTxBodyF #-}

  allInputsTxBodyF :: SimpleGetter (TxBody MaryEra) (Set TxIn)
allInputsTxBodyF = forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
inputsTxBodyL
  {-# INLINEABLE allInputsTxBodyF #-}

  withdrawalsTxBodyL :: Lens' (TxBody MaryEra) Withdrawals
withdrawalsTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> Withdrawals
atbrWithdrawals forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw Withdrawals
withdrawals -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrWithdrawals :: Withdrawals
atbrWithdrawals = Withdrawals
withdrawals}
  {-# INLINEABLE withdrawalsTxBodyL #-}

  certsTxBodyL :: Lens' (TxBody MaryEra) (StrictSeq (TxCert MaryEra))
certsTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> StrictSeq (TxCert era)
atbrCerts forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw StrictSeq (TxCert MaryEra)
certs -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrCerts :: StrictSeq (TxCert MaryEra)
atbrCerts = StrictSeq (TxCert MaryEra)
certs}
  {-# INLINEABLE certsTxBodyL #-}

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

  upgradeTxBody :: EraTxBody (PreviousEra MaryEra) =>
TxBody (PreviousEra MaryEra)
-> Either (TxBodyUpgradeError MaryEra) (TxBody MaryEra)
upgradeTxBody TxBody (PreviousEra MaryEra)
atb = do
    StrictSeq (TxCert MaryEra)
certs <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall era.
(EraTxCert era, EraTxCert (PreviousEra era)) =>
TxCert (PreviousEra era)
-> Either (TxCertUpgradeError era) (TxCert era)
upgradeTxCert (forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> StrictSeq (TxCert era)
atbCerts TxBody (PreviousEra MaryEra)
atb)
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
      MaryTxBody
        { mtbInputs :: Set TxIn
mtbInputs = forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> Set TxIn
atbInputs TxBody (PreviousEra MaryEra)
atb
        , mtbOutputs :: StrictSeq (TxOut MaryEra)
mtbOutputs = 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
<$> forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> StrictSeq (TxOut era)
atbOutputs TxBody (PreviousEra MaryEra)
atb
        , mtbCerts :: StrictSeq (TxCert MaryEra)
mtbCerts = StrictSeq (TxCert MaryEra)
certs
        , mtbWithdrawals :: Withdrawals
mtbWithdrawals = forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> Withdrawals
atbWithdrawals TxBody (PreviousEra MaryEra)
atb
        , mtbTxFee :: Coin
mtbTxFee = forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> Coin
atbTxFee TxBody (PreviousEra MaryEra)
atb
        , mtbValidityInterval :: ValidityInterval
mtbValidityInterval = forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> ValidityInterval
atbValidityInterval TxBody (PreviousEra MaryEra)
atb
        , mtbUpdate :: StrictMaybe (Update MaryEra)
mtbUpdate = forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> Update (PreviousEra era) -> Update era
upgradeUpdate () forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> StrictMaybe (Update era)
atbUpdate TxBody (PreviousEra MaryEra)
atb
        , mtbAuxDataHash :: StrictMaybe TxAuxDataHash
mtbAuxDataHash = forall era.
(EraTxOut era, EraTxCert era) =>
AllegraTxBody era -> StrictMaybe TxAuxDataHash
atbAuxDataHash TxBody (PreviousEra MaryEra)
atb
        , mtbMint :: MultiAsset
mtbMint = forall a. Monoid a => a
mempty
        }

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

  updateTxBodyL :: Lens' (TxBody MaryEra) (StrictMaybe (Update MaryEra))
updateTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> StrictMaybe (Update era)
atbrUpdate forall a b. (a -> b) -> a -> b
$ \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw StrictMaybe (Update MaryEra)
update -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrUpdate :: StrictMaybe (Update MaryEra)
atbrUpdate = StrictMaybe (Update MaryEra)
update}
  {-# INLINEABLE updateTxBodyL #-}

instance AllegraEraTxBody MaryEra where
  vldtTxBodyL :: Lens' (TxBody MaryEra) ValidityInterval
vldtTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> ValidityInterval
atbrValidityInterval forall a b. (a -> b) -> a -> b
$
      \AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw ValidityInterval
vldt -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrValidityInterval :: ValidityInterval
atbrValidityInterval = ValidityInterval
vldt}
  {-# INLINEABLE vldtTxBodyL #-}

instance MaryEraTxBody MaryEra where
  mintTxBodyL :: Lens' (TxBody MaryEra) MultiAsset
mintTxBodyL =
    forall era a b.
(EraTxOut era, EraTxCert era) =>
(AllegraTxBodyRaw MultiAsset era -> a)
-> (AllegraTxBodyRaw MultiAsset era
    -> b -> AllegraTxBodyRaw MultiAsset era)
-> Lens (MaryTxBody era) (MaryTxBody era) a b
lensMaryTxBodyRaw forall ma era. AllegraTxBodyRaw ma era -> ma
atbrMint (\AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw MultiAsset
mint -> AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw {atbrMint :: MultiAsset
atbrMint = MultiAsset
mint})
  {-# INLINEABLE mintTxBodyL #-}

  mintValueTxBodyF :: SimpleGetter (TxBody MaryEra) (Value MaryEra)
mintValueTxBodyF =
    forall s a. (s -> a) -> SimpleGetter s a
to forall a b. (a -> b) -> a -> b
$ \(TxBodyConstr (Memo (MaryTxBodyRaw AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw) ShortByteString
_)) ->
      Coin -> MultiAsset -> MaryValue
MaryValue forall a. Monoid a => a
mempty (forall ma era. AllegraTxBodyRaw ma era -> ma
atbrMint AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw)
  {-# INLINEABLE mintValueTxBodyF #-}

  mintedTxBodyF :: SimpleGetter (TxBody MaryEra) (Set PolicyID)
mintedTxBodyF =
    forall s a. (s -> a) -> SimpleGetter s a
to forall a b. (a -> b) -> a -> b
$ \(TxBodyConstr (Memo (MaryTxBodyRaw AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw) ShortByteString
_)) -> MultiAsset -> Set PolicyID
policies (forall ma era. AllegraTxBodyRaw ma era -> ma
atbrMint AllegraTxBodyRaw MultiAsset MaryEra
txBodyRaw)
  {-# INLINEABLE mintedTxBodyF #-}