{-# LANGUAGE BlockArguments           #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE EmptyCase                #-}
{-# LANGUAGE FlexibleContexts         #-}
{-# LANGUAGE GADTs                    #-}
{-# LANGUAGE NamedFieldPuns           #-}
-- Code temporarily copied over from cardano-api,
-- until https://github.com/input-output-hk/cardano-node/pull/2936 or something similar gets merged.
module Ledger.Tx.CardanoAPITemp (makeTransactionBody', toShelleyTxOut) where

import Data.List qualified as List
import Data.Map.Strict qualified as Map
import Data.Maybe qualified as Maybe
import Data.Sequence.Strict qualified as Seq
import Data.Set qualified as Set
import Data.Word (Word64)

import Cardano.Api
import Cardano.Api.Shelley hiding (toShelleyTxOut)
import Cardano.Ledger.AuxiliaryData qualified as Ledger (hashAuxiliaryData)
import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Ledger.Serialization qualified as CBOR (mkSized)
import Ouroboros.Consensus.Shelley.Eras (StandardBabbage)

import Cardano.Ledger.Core qualified as Ledger
import Cardano.Ledger.Era qualified as Ledger

import Cardano.Ledger.Alonzo.Data qualified as Alonzo
import Cardano.Ledger.Alonzo.Language qualified as Alonzo
import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo
import Cardano.Ledger.Alonzo.Tx qualified as Alonzo
import Cardano.Ledger.Alonzo.TxBody qualified as Alonzo
import Cardano.Ledger.Alonzo.TxWitness qualified as Alonzo

import Cardano.Ledger.Babbage qualified as Babbage
import Cardano.Ledger.Babbage.PParams qualified as Babbage
import Cardano.Ledger.Babbage.Tx qualified as Babbage
import Cardano.Ledger.Babbage.TxBody qualified as Babbage

import Cardano.Ledger.ShelleyMA.TxBody qualified as Allegra

import Cardano.Ledger.Keys qualified as Shelley
import Cardano.Ledger.Shelley.Tx qualified as Shelley
import Cardano.Ledger.Shelley.TxBody qualified as Shelley

makeTransactionBody'
    :: Maybe (Babbage.PParams (Babbage.BabbageEra StandardCrypto))
    -> Map.Map Alonzo.RdmrPtr Alonzo.ExUnits
    -> TxBodyContent BuildTx BabbageEra
    -> Either TxBodyError (TxBody BabbageEra)
makeTransactionBody' :: Maybe (PParams (BabbageEra StandardCrypto))
-> Map RdmrPtr ExUnits
-> TxBodyContent BuildTx BabbageEra
-> Either TxBodyError (TxBody BabbageEra)
makeTransactionBody'
    Maybe (PParams (BabbageEra StandardCrypto))
mpparams
    Map RdmrPtr ExUnits
exUnits
    txbodycontent :: TxBodyContent BuildTx BabbageEra
txbodycontent@TxBodyContent {
        TxIns BuildTx BabbageEra
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx BabbageEra
txIns,
        TxInsCollateral BabbageEra
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral BabbageEra
txInsCollateral,
        TxInsReference BuildTx BabbageEra
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsReference :: TxInsReference BuildTx BabbageEra
txInsReference,
        [TxOut CtxTx BabbageEra]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx BabbageEra]
txOuts,
        TxReturnCollateral CtxTx BabbageEra
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
txReturnCollateral,
        TxTotalCollateral BabbageEra
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral BabbageEra
txTotalCollateral,
        TxFee BabbageEra
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee BabbageEra
txFee,
        txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txValidityRange = (TxValidityLowerBound BabbageEra
lowerBound, TxValidityUpperBound BabbageEra
upperBound),
        TxExtraKeyWitnesses BabbageEra
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
txExtraKeyWits,
        TxWithdrawals BuildTx BabbageEra
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx BabbageEra
txWithdrawals,
        TxCertificates BuildTx BabbageEra
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx BabbageEra
txCertificates,
        TxMintValue BuildTx BabbageEra
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx BabbageEra
txMintValue,
        TxScriptValidity BabbageEra
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity :: TxScriptValidity BabbageEra
txScriptValidity,
        TxMetadataInEra BabbageEra
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra BabbageEra
txMetadata,
        TxAuxScripts BabbageEra
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts BabbageEra
txAuxScripts
    } =
    TxBody BabbageEra -> Either TxBodyError (TxBody BabbageEra)
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody BabbageEra -> Either TxBodyError (TxBody BabbageEra))
-> TxBody BabbageEra -> Either TxBodyError (TxBody BabbageEra)
forall a b. (a -> b) -> a -> b
$
      ShelleyBasedEra BabbageEra
-> TxBody (ShelleyLedgerEra BabbageEra)
-> [Script (ShelleyLedgerEra BabbageEra)]
-> TxBodyScriptData BabbageEra
-> Maybe (AuxiliaryData (ShelleyLedgerEra BabbageEra))
-> TxScriptValidity BabbageEra
-> TxBody BabbageEra
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody ShelleyBasedEra BabbageEra
era
        (TxBody :: forall era.
BabbageBody era =>
Set (TxIn (Crypto era))
-> Set (TxIn (Crypto era))
-> Set (TxIn (Crypto era))
-> StrictSeq (Sized (TxOut era))
-> StrictMaybe (Sized (TxOut era))
-> StrictMaybe Coin
-> StrictSeq (DCert (Crypto era))
-> Wdrl (Crypto era)
-> Coin
-> ValidityInterval
-> StrictMaybe (Update era)
-> Set (KeyHash 'Witness (Crypto era))
-> Value (Crypto era)
-> StrictMaybe (ScriptIntegrityHash (Crypto era))
-> StrictMaybe (AuxiliaryDataHash (Crypto era))
-> StrictMaybe Network
-> TxBody era
Babbage.TxBody
          { inputs :: Set (TxIn (Crypto (BabbageEra StandardCrypto)))
Babbage.inputs = [TxIn StandardCrypto] -> Set (TxIn StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))
 -> TxIn StandardCrypto)
-> TxIns BuildTx BabbageEra -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn -> TxIn StandardCrypto
toShelleyTxIn (TxIn -> TxIn StandardCrypto)
-> ((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))
    -> TxIn)
-> (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))
-> TxIn StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra)) -> TxIn
forall a b. (a, b) -> a
fst) TxIns BuildTx BabbageEra
txIns)
          , collateral :: Set (TxIn (Crypto (BabbageEra StandardCrypto)))
Babbage.collateral =
              case TxInsCollateral BabbageEra
txInsCollateral of
                TxInsCollateral BabbageEra
TxInsCollateralNone     -> Set (TxIn (Crypto (BabbageEra StandardCrypto)))
forall a. Set a
Set.empty
                TxInsCollateral CollateralSupportedInEra BabbageEra
_ [TxIn]
txins -> [TxIn StandardCrypto] -> Set (TxIn StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList ((TxIn -> TxIn StandardCrypto) -> [TxIn] -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardCrypto
toShelleyTxIn [TxIn]
txins)
          , referenceInputs :: Set (TxIn (Crypto (BabbageEra StandardCrypto)))
Babbage.referenceInputs =
              case TxInsReference BuildTx BabbageEra
txInsReference of
                TxInsReference BuildTx BabbageEra
TxInsReferenceNone     -> Set (TxIn (Crypto (BabbageEra StandardCrypto)))
forall a. Set a
Set.empty
                TxInsReference ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
_ [TxIn]
txins -> [TxIn StandardCrypto] -> Set (TxIn StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList ((TxIn -> TxIn StandardCrypto) -> [TxIn] -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardCrypto
toShelleyTxIn [TxIn]
txins)
          , outputs :: StrictSeq (Sized (TxOut (BabbageEra StandardCrypto)))
Babbage.outputs = [Sized (TxOut (BabbageEra StandardCrypto))]
-> StrictSeq (Sized (TxOut (BabbageEra StandardCrypto)))
forall a. [a] -> StrictSeq a
Seq.fromList ((TxOut CtxTx BabbageEra
 -> Sized (TxOut (BabbageEra StandardCrypto)))
-> [TxOut CtxTx BabbageEra]
-> [Sized (TxOut (BabbageEra StandardCrypto))]
forall a b. (a -> b) -> [a] -> [b]
map (TxOut (BabbageEra StandardCrypto)
-> Sized (TxOut (BabbageEra StandardCrypto))
forall a. ToCBOR a => a -> Sized a
CBOR.mkSized (TxOut (BabbageEra StandardCrypto)
 -> Sized (TxOut (BabbageEra StandardCrypto)))
-> (TxOut CtxTx BabbageEra -> TxOut (BabbageEra StandardCrypto))
-> TxOut CtxTx BabbageEra
-> Sized (TxOut (BabbageEra StandardCrypto))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyBasedEra BabbageEra
-> TxOut CtxTx BabbageEra -> TxOut (BabbageEra StandardCrypto)
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera, IsShelleyBasedEra era) =>
ShelleyBasedEra era -> TxOut CtxTx era -> TxOut ledgerera
toShelleyTxOut ShelleyBasedEra BabbageEra
era) [TxOut CtxTx BabbageEra]
txOuts)
          , collateralReturn :: StrictMaybe (Sized (TxOut (BabbageEra StandardCrypto)))
Babbage.collateralReturn =
              case TxReturnCollateral CtxTx BabbageEra
txReturnCollateral of
                TxReturnCollateral CtxTx BabbageEra
TxReturnCollateralNone        -> StrictMaybe (Sized (TxOut (BabbageEra StandardCrypto)))
forall a. StrictMaybe a
SNothing
                TxReturnCollateral TxTotalAndReturnCollateralSupportedInEra BabbageEra
_ TxOut CtxTx BabbageEra
colTxOut -> Sized (TxOut (BabbageEra StandardCrypto))
-> StrictMaybe (Sized (TxOut (BabbageEra StandardCrypto)))
forall a. a -> StrictMaybe a
SJust (Sized (TxOut (BabbageEra StandardCrypto))
 -> StrictMaybe (Sized (TxOut (BabbageEra StandardCrypto))))
-> Sized (TxOut (BabbageEra StandardCrypto))
-> StrictMaybe (Sized (TxOut (BabbageEra StandardCrypto)))
forall a b. (a -> b) -> a -> b
$ TxOut (BabbageEra StandardCrypto)
-> Sized (TxOut (BabbageEra StandardCrypto))
forall a. ToCBOR a => a -> Sized a
CBOR.mkSized (TxOut (BabbageEra StandardCrypto)
 -> Sized (TxOut (BabbageEra StandardCrypto)))
-> TxOut (BabbageEra StandardCrypto)
-> Sized (TxOut (BabbageEra StandardCrypto))
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra BabbageEra
-> TxOut CtxTx BabbageEra -> TxOut (BabbageEra StandardCrypto)
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera, IsShelleyBasedEra era) =>
ShelleyBasedEra era -> TxOut CtxTx era -> TxOut ledgerera
toShelleyTxOut ShelleyBasedEra BabbageEra
era TxOut CtxTx BabbageEra
colTxOut
          , totalCollateral :: StrictMaybe Coin
Babbage.totalCollateral =
              case TxTotalCollateral BabbageEra
txTotalCollateral of
                TxTotalCollateral BabbageEra
TxTotalCollateralNone  -> StrictMaybe Coin
forall a. StrictMaybe a
SNothing
                TxTotalCollateral TxTotalAndReturnCollateralSupportedInEra BabbageEra
_ Lovelace
lv -> Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust (Coin -> StrictMaybe Coin) -> Coin -> StrictMaybe Coin
forall a b. (a -> b) -> a -> b
$ Lovelace -> Coin
toShelleyLovelace Lovelace
lv
          , txcerts :: StrictSeq (DCert (Crypto (BabbageEra StandardCrypto)))
Babbage.txcerts =
              case TxCertificates BuildTx BabbageEra
txCertificates of
                TxCertificates BuildTx BabbageEra
TxCertificatesNone    -> StrictSeq (DCert (Crypto (BabbageEra StandardCrypto)))
forall a. StrictSeq a
Seq.empty
                TxCertificates CertificatesSupportedInEra BabbageEra
_ [Certificate]
cs BuildTxWith
  BuildTx (Map StakeCredential (Witness WitCtxStake BabbageEra))
_ -> [DCert StandardCrypto] -> StrictSeq (DCert StandardCrypto)
forall a. [a] -> StrictSeq a
Seq.fromList ((Certificate -> DCert StandardCrypto)
-> [Certificate] -> [DCert StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map Certificate -> DCert StandardCrypto
toShelleyCertificate [Certificate]
cs)
          , txwdrls :: Wdrl (Crypto (BabbageEra StandardCrypto))
Babbage.txwdrls =
              case TxWithdrawals BuildTx BabbageEra
txWithdrawals of
                TxWithdrawals BuildTx BabbageEra
TxWithdrawalsNone  -> Map (RewardAcnt StandardCrypto) Coin -> Wdrl StandardCrypto
forall crypto. Map (RewardAcnt crypto) Coin -> Wdrl crypto
Shelley.Wdrl Map (RewardAcnt StandardCrypto) Coin
forall k a. Map k a
Map.empty
                TxWithdrawals WithdrawalsSupportedInEra BabbageEra
_ [(StakeAddress, Lovelace,
  BuildTxWith BuildTx (Witness WitCtxStake BabbageEra))]
ws -> [(StakeAddress, Lovelace,
  BuildTxWith BuildTx (Witness WitCtxStake BabbageEra))]
-> Wdrl StandardCrypto
forall a. [(StakeAddress, Lovelace, a)] -> Wdrl StandardCrypto
toShelleyWithdrawal [(StakeAddress, Lovelace,
  BuildTxWith BuildTx (Witness WitCtxStake BabbageEra))]
ws
          , txfee :: Coin
Babbage.txfee =
              case TxFee BabbageEra
txFee of
                TxFeeImplicit TxFeesImplicitInEra BabbageEra
era'  -> case TxFeesImplicitInEra BabbageEra
era' of {}
                TxFeeExplicit TxFeesExplicitInEra BabbageEra
_ Lovelace
fee -> Lovelace -> Coin
toShelleyLovelace Lovelace
fee
          , txvldt :: ValidityInterval
Babbage.txvldt =
              ValidityInterval :: StrictMaybe SlotNo -> StrictMaybe SlotNo -> ValidityInterval
Allegra.ValidityInterval {
                invalidBefore :: StrictMaybe SlotNo
invalidBefore    = case TxValidityLowerBound BabbageEra
lowerBound of
                                              TxValidityLowerBound BabbageEra
TxValidityNoLowerBound   -> StrictMaybe SlotNo
forall a. StrictMaybe a
SNothing
                                              TxValidityLowerBound ValidityLowerBoundSupportedInEra BabbageEra
_ SlotNo
s -> SlotNo -> StrictMaybe SlotNo
forall a. a -> StrictMaybe a
SJust SlotNo
s,
                invalidHereafter :: StrictMaybe SlotNo
invalidHereafter = case TxValidityUpperBound BabbageEra
upperBound of
                                              TxValidityNoUpperBound ValidityNoUpperBoundSupportedInEra BabbageEra
_ -> StrictMaybe SlotNo
forall a. StrictMaybe a
SNothing
                                              TxValidityUpperBound ValidityUpperBoundSupportedInEra BabbageEra
_ SlotNo
s -> SlotNo -> StrictMaybe SlotNo
forall a. a -> StrictMaybe a
SJust SlotNo
s
              }
          , txUpdates :: StrictMaybe (Update (BabbageEra StandardCrypto))
Babbage.txUpdates = StrictMaybe (Update (BabbageEra StandardCrypto))
forall a. StrictMaybe a
SNothing -- ignoring txUpdateProposal in CardanoAPITemp
          , reqSignerHashes :: Set (KeyHash 'Witness (Crypto (BabbageEra StandardCrypto)))
Babbage.reqSignerHashes =
              case TxExtraKeyWitnesses BabbageEra
txExtraKeyWits of
                TxExtraKeyWitnesses BabbageEra
TxExtraKeyWitnessesNone   -> Set (KeyHash 'Witness (Crypto (BabbageEra StandardCrypto)))
forall a. Set a
Set.empty
                TxExtraKeyWitnesses TxExtraKeyWitnessesSupportedInEra BabbageEra
_ [Hash PaymentKey]
khs -> [KeyHash 'Witness StandardCrypto]
-> Set (KeyHash 'Witness StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList
                                                [ KeyHash 'Payment StandardCrypto -> KeyHash 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) crypto
       (r' :: KeyRole).
HasKeyRole a =>
a r crypto -> a r' crypto
Shelley.coerceKeyRole KeyHash 'Payment StandardCrypto
kh
                                                | PaymentKeyHash kh <- [Hash PaymentKey]
khs ]
          , mint :: Value (Crypto (BabbageEra StandardCrypto))
Babbage.mint =
              case TxMintValue BuildTx BabbageEra
txMintValue of
                TxMintValue BuildTx BabbageEra
TxMintNone        -> Value (Crypto (BabbageEra StandardCrypto))
forall a. Monoid a => a
mempty
                TxMintValue MultiAssetSupportedInEra BabbageEra
_ Value
v BuildTxWith
  BuildTx (Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
_ -> Value -> Value StandardCrypto
toMaryValue Value
v
          , scriptIntegrityHash :: StrictMaybe
  (ScriptIntegrityHash (Crypto (BabbageEra StandardCrypto)))
Babbage.scriptIntegrityHash =
              case Maybe (PParams (BabbageEra StandardCrypto))
mpparams of
                Maybe (PParams (BabbageEra StandardCrypto))
Nothing        -> StrictMaybe
  (ScriptIntegrityHash (Crypto (BabbageEra StandardCrypto)))
forall a. StrictMaybe a
SNothing
                Just PParams (BabbageEra StandardCrypto)
pparams ->
                  Set LangDepView
-> Redeemers (BabbageEra StandardCrypto)
-> TxDats (BabbageEra StandardCrypto)
-> StrictMaybe
     (ScriptIntegrityHash (Crypto (BabbageEra StandardCrypto)))
forall era.
Era era =>
Set LangDepView
-> Redeemers era
-> TxDats era
-> StrictMaybe (ScriptIntegrityHash (Crypto era))
Alonzo.hashScriptIntegrity
                    ((Language -> LangDepView) -> Set Language -> Set LangDepView
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map
                        (PParams (BabbageEra StandardCrypto) -> Language -> LangDepView
forall era.
HasField "_costmdls" (PParams era) CostModels =>
PParams era -> Language -> LangDepView
Alonzo.getLanguageView PParams (BabbageEra StandardCrypto)
PParams (BabbageEra StandardCrypto)
pparams)
                        Set Language
languages
                    )
                    Redeemers (BabbageEra StandardCrypto)
redeemers
                    TxDats (BabbageEra StandardCrypto)
datums
          , adHash :: StrictMaybe
  (AuxiliaryDataHash (Crypto (BabbageEra StandardCrypto)))
Babbage.adHash =
              Maybe (AuxiliaryDataHash StandardCrypto)
-> StrictMaybe (AuxiliaryDataHash StandardCrypto)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (AuxiliaryData (BabbageEra StandardCrypto)
-> AuxiliaryDataHash StandardCrypto
forall era c.
ValidateAuxiliaryData era c =>
AuxiliaryData era -> AuxiliaryDataHash c
Ledger.hashAuxiliaryData (AuxiliaryData (BabbageEra StandardCrypto)
 -> AuxiliaryDataHash StandardCrypto)
-> Maybe (AuxiliaryData (BabbageEra StandardCrypto))
-> Maybe (AuxiliaryDataHash StandardCrypto)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (AuxiliaryData (BabbageEra StandardCrypto))
Maybe (AuxiliaryData (BabbageEra StandardCrypto))
txAuxData)
          , txnetworkid :: StrictMaybe Network
Babbage.txnetworkid = StrictMaybe Network
forall a. StrictMaybe a
SNothing
          })
        [Script (BabbageEra StandardCrypto)]
[Script (ShelleyLedgerEra BabbageEra)]
scripts
        (ScriptDataSupportedInEra BabbageEra
-> TxDats (ShelleyLedgerEra BabbageEra)
-> Redeemers (ShelleyLedgerEra BabbageEra)
-> TxBodyScriptData BabbageEra
forall era.
ScriptDataSupportedInEra era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData ScriptDataSupportedInEra BabbageEra
ScriptDataInBabbageEra TxDats (BabbageEra StandardCrypto)
TxDats (ShelleyLedgerEra BabbageEra)
datums Redeemers (BabbageEra StandardCrypto)
Redeemers (ShelleyLedgerEra BabbageEra)
redeemers)
        Maybe (AuxiliaryData (BabbageEra StandardCrypto))
Maybe (AuxiliaryData (ShelleyLedgerEra BabbageEra))
txAuxData
        TxScriptValidity BabbageEra
txScriptValidity
        -- TODO alonzo: support the supplementary script data
  where
    era :: ShelleyBasedEra BabbageEra
era = ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage

    witnesses :: [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
    witnesses :: [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses = TxBodyContent BuildTx BabbageEra
-> [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
forall era.
TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses TxBodyContent BuildTx BabbageEra
txbodycontent

    scripts :: [Ledger.Script StandardBabbage]
    scripts :: [Script (BabbageEra StandardCrypto)]
scripts = [Maybe (Script (BabbageEra StandardCrypto))]
-> [Script (BabbageEra StandardCrypto)]
forall a. [Maybe a] -> [a]
Maybe.catMaybes
      [ ScriptInEra BabbageEra -> Script (BabbageEra StandardCrypto)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra BabbageEra -> Script (BabbageEra StandardCrypto))
-> Maybe (ScriptInEra BabbageEra)
-> Maybe (Script (BabbageEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx BabbageEra -> Maybe (ScriptInEra BabbageEra)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
scriptWitnessScript ScriptWitness witctx BabbageEra
scriptwitness
      | (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx BabbageEra
scriptwitness) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
      ]

    datums :: Alonzo.TxDats StandardBabbage
    datums :: TxDats (BabbageEra StandardCrypto)
datums =
      Map
  (DataHash (Crypto (BabbageEra StandardCrypto)))
  (Data (BabbageEra StandardCrypto))
-> TxDats (BabbageEra StandardCrypto)
forall era.
Typeable era =>
Map (DataHash (Crypto era)) (Data era) -> TxDats era
Alonzo.TxDats (Map
   (DataHash (Crypto (BabbageEra StandardCrypto)))
   (Data (BabbageEra StandardCrypto))
 -> TxDats (BabbageEra StandardCrypto))
-> Map
     (DataHash (Crypto (BabbageEra StandardCrypto)))
     (Data (BabbageEra StandardCrypto))
-> TxDats (BabbageEra StandardCrypto)
forall a b. (a -> b) -> a -> b
$
        [(DataHash StandardCrypto, Data (BabbageEra StandardCrypto))]
-> Map (DataHash StandardCrypto) (Data (BabbageEra StandardCrypto))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
          [ (Data (BabbageEra StandardCrypto)
-> DataHash (Crypto (BabbageEra StandardCrypto))
forall era. Era era => Data era -> DataHash (Crypto era)
Alonzo.hashData Data (BabbageEra StandardCrypto)
d', Data (BabbageEra StandardCrypto)
d')
          | ScriptData
d <- [ScriptData]
scriptdata
          , let d' :: Data (BabbageEra StandardCrypto)
d' = ScriptData -> Data (BabbageEra StandardCrypto)
forall ledgerera. ScriptData -> Data ledgerera
toAlonzoData ScriptData
d
          ]

    scriptdata :: [ScriptData]
    scriptdata :: [ScriptData]
scriptdata = [ScriptData] -> [ScriptData]
forall a. Eq a => [a] -> [a]
List.nub ([ScriptData] -> [ScriptData]) -> [ScriptData] -> [ScriptData]
forall a b. (a -> b) -> a -> b
$
      [ ScriptData
d | TxOut AddressInEra BabbageEra
_ TxOutValue BabbageEra
_ (TxOutDatumInTx ScriptDataSupportedInEra BabbageEra
_ ScriptData
d) ReferenceScript BabbageEra
_ <- [TxOut CtxTx BabbageEra]
txOuts ]
      [ScriptData] -> [ScriptData] -> [ScriptData]
forall a. [a] -> [a] -> [a]
++ [ ScriptData
d | (ScriptWitnessIndex
_, AnyScriptWitness
                      (PlutusScriptWitness
                        ScriptLanguageInEra lang BabbageEra
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ (ScriptDatumForTxIn ScriptData
d) ScriptData
_ ExecutionUnits
_)) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
              ]

    redeemers :: Alonzo.Redeemers StandardBabbage
    redeemers :: Redeemers (BabbageEra StandardCrypto)
redeemers =
      Map RdmrPtr (Data (BabbageEra StandardCrypto), ExUnits)
-> Redeemers (BabbageEra StandardCrypto)
forall era.
Era era =>
Map RdmrPtr (Data era, ExUnits) -> Redeemers era
Alonzo.Redeemers (Map RdmrPtr (Data (BabbageEra StandardCrypto), ExUnits)
 -> Redeemers (BabbageEra StandardCrypto))
-> Map RdmrPtr (Data (BabbageEra StandardCrypto), ExUnits)
-> Redeemers (BabbageEra StandardCrypto)
forall a b. (a -> b) -> a -> b
$
        [(RdmrPtr, (Data (BabbageEra StandardCrypto), ExUnits))]
-> Map RdmrPtr (Data (BabbageEra StandardCrypto), ExUnits)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
          [ let ptr :: RdmrPtr
ptr = ScriptWitnessIndex -> RdmrPtr
toAlonzoRdmrPtr ScriptWitnessIndex
idx in (RdmrPtr
ptr, (ScriptData -> Data (BabbageEra StandardCrypto)
forall ledgerera. ScriptData -> Data ledgerera
toAlonzoData ScriptData
d, ExUnits -> Maybe ExUnits -> ExUnits
forall a. a -> Maybe a -> a
Maybe.fromMaybe (ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
e) (Maybe ExUnits -> ExUnits) -> Maybe ExUnits -> ExUnits
forall a b. (a -> b) -> a -> b
$ RdmrPtr -> Map RdmrPtr ExUnits -> Maybe ExUnits
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup RdmrPtr
ptr Map RdmrPtr ExUnits
exUnits))
          | (ScriptWitnessIndex
idx, AnyScriptWitness
                    (PlutusScriptWitness ScriptLanguageInEra lang BabbageEra
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ ScriptData
d ExecutionUnits
e)) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
          ]

    languages :: Set.Set Alonzo.Language
    languages :: Set Language
languages =
      [Language] -> Set Language
forall a. Ord a => [a] -> Set a
Set.fromList ([Language] -> Set Language) -> [Language] -> Set Language
forall a b. (a -> b) -> a -> b
$ [Maybe Language] -> [Language]
forall a. [Maybe a] -> [a]
Maybe.catMaybes
        [ ScriptWitness witctx BabbageEra -> Maybe Language
forall witctx era. ScriptWitness witctx era -> Maybe Language
getScriptLanguage ScriptWitness witctx BabbageEra
sw
        | (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx BabbageEra
sw) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
        ]

    getScriptLanguage :: ScriptWitness witctx era -> Maybe Alonzo.Language
    getScriptLanguage :: ScriptWitness witctx era -> Maybe Language
getScriptLanguage (PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ ScriptData
_ ExecutionUnits
_) =
      Language -> Maybe Language
forall a. a -> Maybe a
Just (Language -> Maybe Language) -> Language -> Maybe Language
forall a b. (a -> b) -> a -> b
$ AnyPlutusScriptVersion -> Language
toAlonzoLanguage (PlutusScriptVersion lang -> AnyPlutusScriptVersion
forall lang. PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
    getScriptLanguage SimpleScriptWitness{} = Maybe Language
forall a. Maybe a
Nothing

    txAuxData :: Maybe (Ledger.AuxiliaryData StandardBabbage)
    txAuxData :: Maybe (AuxiliaryData (BabbageEra StandardCrypto))
txAuxData
      | Map Word64 TxMetadataValue -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 TxMetadataValue
ms
      , [ScriptInEra BabbageEra] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ScriptInEra BabbageEra]
ss   = Maybe (AuxiliaryData (BabbageEra StandardCrypto))
forall a. Maybe a
Nothing
      | Bool
otherwise = AuxiliaryData (BabbageEra StandardCrypto)
-> Maybe (AuxiliaryData (BabbageEra StandardCrypto))
forall a. a -> Maybe a
Just (Map Word64 TxMetadataValue
-> [ScriptInEra BabbageEra]
-> AuxiliaryData (BabbageEra StandardCrypto)
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera,
 AuxiliaryData ledgerera ~ AuxiliaryData ledgerera,
 Script ledgerera ~ Script ledgerera, Era ledgerera) =>
Map Word64 TxMetadataValue
-> [ScriptInEra era] -> AuxiliaryData ledgerera
toAlonzoAuxiliaryData Map Word64 TxMetadataValue
ms [ScriptInEra BabbageEra]
ss)
      where
        ms :: Map Word64 TxMetadataValue
ms = case TxMetadataInEra BabbageEra
txMetadata of
               TxMetadataInEra BabbageEra
TxMetadataNone                     -> Map Word64 TxMetadataValue
forall k a. Map k a
Map.empty
               TxMetadataInEra TxMetadataSupportedInEra BabbageEra
_ (TxMetadata Map Word64 TxMetadataValue
ms') -> Map Word64 TxMetadataValue
ms'
        ss :: [ScriptInEra BabbageEra]
ss = case TxAuxScripts BabbageEra
txAuxScripts of
               TxAuxScripts BabbageEra
TxAuxScriptsNone   -> []
               TxAuxScripts AuxScriptsSupportedInEra BabbageEra
_ [ScriptInEra BabbageEra]
ss' -> [ScriptInEra BabbageEra]
ss'


toShelleyWithdrawal :: [(StakeAddress, Lovelace, a)] -> Shelley.Wdrl StandardCrypto
toShelleyWithdrawal :: [(StakeAddress, Lovelace, a)] -> Wdrl StandardCrypto
toShelleyWithdrawal [(StakeAddress, Lovelace, a)]
withdrawals =
    Map (RewardAcnt StandardCrypto) Coin -> Wdrl StandardCrypto
forall crypto. Map (RewardAcnt crypto) Coin -> Wdrl crypto
Shelley.Wdrl (Map (RewardAcnt StandardCrypto) Coin -> Wdrl StandardCrypto)
-> Map (RewardAcnt StandardCrypto) Coin -> Wdrl StandardCrypto
forall a b. (a -> b) -> a -> b
$
      [(RewardAcnt StandardCrypto, Coin)]
-> Map (RewardAcnt StandardCrypto) Coin
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
        [ (StakeAddress -> RewardAcnt StandardCrypto
toShelleyStakeAddr StakeAddress
stakeAddr, Lovelace -> Coin
toShelleyLovelace Lovelace
value)
        | (StakeAddress
stakeAddr, Lovelace
value, a
_) <- [(StakeAddress, Lovelace, a)]
withdrawals ]

toShelleyTxOut :: forall era ledgerera.
                 (ShelleyLedgerEra era ~ ledgerera, IsShelleyBasedEra era)
               => ShelleyBasedEra era -> TxOut CtxTx era -> Ledger.TxOut ledgerera
toShelleyTxOut :: ShelleyBasedEra era -> TxOut CtxTx era -> TxOut ledgerera
toShelleyTxOut ShelleyBasedEra era
_ (TxOut AddressInEra era
_ (TxOutAdaOnly OnlyAdaSupportedInEra era
AdaOnlyInByronEra Lovelace
_) TxOutDatum CtxTx era
_ ReferenceScript era
_) =
    case ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra :: ShelleyBasedEra era of {}

toShelleyTxOut ShelleyBasedEra era
_ (TxOut AddressInEra era
addr (TxOutAdaOnly OnlyAdaSupportedInEra era
AdaOnlyInShelleyEra Lovelace
value) TxOutDatum CtxTx era
_ ReferenceScript era
_) =
    Addr (Crypto (ShelleyEra StandardCrypto))
-> Value (ShelleyEra StandardCrypto)
-> TxOut (ShelleyEra StandardCrypto)
forall era.
(Era era, Show (Value era), Compactible (Value era)) =>
Addr (Crypto era) -> Value era -> TxOut era
Shelley.TxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) (Lovelace -> Coin
toShelleyLovelace Lovelace
value)

toShelleyTxOut ShelleyBasedEra era
_ (TxOut AddressInEra era
addr (TxOutAdaOnly OnlyAdaSupportedInEra era
AdaOnlyInAllegraEra Lovelace
value) TxOutDatum CtxTx era
_ ReferenceScript era
_) =
    Addr (Crypto (ShelleyMAEra 'Allegra StandardCrypto))
-> Value (ShelleyMAEra 'Allegra StandardCrypto)
-> TxOut (ShelleyMAEra 'Allegra StandardCrypto)
forall era.
(Era era, Show (Value era), Compactible (Value era)) =>
Addr (Crypto era) -> Value era -> TxOut era
Shelley.TxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) (Lovelace -> Coin
toShelleyLovelace Lovelace
value)

toShelleyTxOut ShelleyBasedEra era
_ (TxOut AddressInEra era
addr (TxOutValue MultiAssetSupportedInEra era
MultiAssetInMaryEra Value
value) TxOutDatum CtxTx era
_ ReferenceScript era
_) =
    Addr (Crypto (ShelleyMAEra 'Mary StandardCrypto))
-> Value (ShelleyMAEra 'Mary StandardCrypto)
-> TxOut (ShelleyMAEra 'Mary StandardCrypto)
forall era.
(Era era, Show (Value era), Compactible (Value era)) =>
Addr (Crypto era) -> Value era -> TxOut era
Shelley.TxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) (Value -> Value StandardCrypto
toMaryValue Value
value)

-- | Copied from Cardano API to handle all TxOut contexts, we can
-- propose a PR to cardano-node to propagate this version and remove the code duplication
toShelleyTxOut ShelleyBasedEra era
_ (TxOut AddressInEra era
addr (TxOutValue MultiAssetSupportedInEra era
MultiAssetInAlonzoEra Value
value) TxOutDatum CtxTx era
txoutdata ReferenceScript era
_) =
    Addr (Crypto (AlonzoEra StandardCrypto))
-> Value (AlonzoEra StandardCrypto)
-> StrictMaybe (DataHash (Crypto (AlonzoEra StandardCrypto)))
-> TxOut (AlonzoEra StandardCrypto)
forall era.
(Era era, Compactible (Value era), Val (Value era),
 HasCallStack) =>
Addr (Crypto era)
-> Value era -> StrictMaybe (DataHash (Crypto era)) -> TxOut era
Alonzo.TxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) (Value -> Value StandardCrypto
toMaryValue Value
value)
                 (TxOutDatum CtxTx era -> StrictMaybe (DataHash StandardCrypto)
forall era.
TxOutDatum CtxTx era -> StrictMaybe (DataHash StandardCrypto)
toAlonzoTxOutDataHash TxOutDatum CtxTx era
txoutdata)

toShelleyTxOut ShelleyBasedEra era
era (TxOut AddressInEra era
addr (TxOutValue MultiAssetSupportedInEra era
MultiAssetInBabbageEra Value
value) TxOutDatum CtxTx era
txoutdata ReferenceScript era
refScript) =
    let cEra :: CardanoEra era
cEra = ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
shelleyBasedToCardanoEra ShelleyBasedEra era
era
     in Addr (Crypto (BabbageEra StandardCrypto))
-> Value (BabbageEra StandardCrypto)
-> Datum (BabbageEra StandardCrypto)
-> StrictMaybe (Script (BabbageEra StandardCrypto))
-> TxOut (BabbageEra StandardCrypto)
forall era.
(Era era, Compactible (Value era), Val (Value era),
 HasCallStack) =>
Addr (Crypto era)
-> Value era -> Datum era -> StrictMaybe (Script era) -> TxOut era
Babbage.TxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) (Value -> Value StandardCrypto
toMaryValue Value
value)
                      (TxOutDatum CtxTx era -> Datum (ShelleyLedgerEra era)
forall era.
(Crypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum CtxTx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum TxOutDatum CtxTx era
txoutdata)
                      (CardanoEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall era.
CardanoEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
refScriptToShelleyScript CardanoEra era
cEra ReferenceScript era
refScript)


toAlonzoTxOutDataHash :: TxOutDatum CtxTx era
                      -> StrictMaybe (Alonzo.DataHash StandardCrypto)
toAlonzoTxOutDataHash :: TxOutDatum CtxTx era -> StrictMaybe (DataHash StandardCrypto)
toAlonzoTxOutDataHash TxOutDatum CtxTx era
TxOutDatumNone                         = StrictMaybe (DataHash StandardCrypto)
forall a. StrictMaybe a
SNothing
toAlonzoTxOutDataHash (TxOutDatumHash ScriptDataSupportedInEra era
_ (ScriptDataHash dh)) = DataHash StandardCrypto -> StrictMaybe (DataHash StandardCrypto)
forall a. a -> StrictMaybe a
SJust DataHash StandardCrypto
dh
toAlonzoTxOutDataHash (TxOutDatumInTx ScriptDataSupportedInEra era
_ ScriptData
d)                   = let ScriptDataHash dh = ScriptData -> Hash ScriptData
hashScriptData ScriptData
d in DataHash StandardCrypto -> StrictMaybe (DataHash StandardCrypto)
forall a. a -> StrictMaybe a
SJust DataHash StandardCrypto
dh
toAlonzoTxOutDataHash (TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra era
_ ScriptData
d)                 = let ScriptDataHash dh = ScriptData -> Hash ScriptData
hashScriptData ScriptData
d in DataHash StandardCrypto -> StrictMaybe (DataHash StandardCrypto)
forall a. a -> StrictMaybe a
SJust DataHash StandardCrypto
dh

toBabbageTxOutDatum
  :: Ledger.Crypto (ShelleyLedgerEra era) ~ StandardCrypto
  => TxOutDatum CtxTx era -> Babbage.Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum :: TxOutDatum CtxTx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum  TxOutDatum CtxTx era
TxOutDatumNone = Datum (ShelleyLedgerEra era)
forall era. Datum era
Babbage.NoDatum
toBabbageTxOutDatum (TxOutDatumHash ScriptDataSupportedInEra era
_ (ScriptDataHash dh)) = DataHash (Crypto (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall era. DataHash (Crypto era) -> Datum era
Babbage.DatumHash DataHash StandardCrypto
DataHash (Crypto (ShelleyLedgerEra era))
dh
toBabbageTxOutDatum (TxOutDatumInTx ScriptDataSupportedInEra era
_ ScriptData
d) = let ScriptDataHash dh = ScriptData -> Hash ScriptData
hashScriptData ScriptData
d in DataHash (Crypto (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall era. DataHash (Crypto era) -> Datum era
Babbage.DatumHash DataHash StandardCrypto
DataHash (Crypto (ShelleyLedgerEra era))
dh
toBabbageTxOutDatum (TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra era
_ ScriptData
sd) = ScriptData -> Datum (ShelleyLedgerEra era)
forall ledgerera. ScriptData -> Datum ledgerera
scriptDataToInlineDatum ScriptData
sd

scriptDataToInlineDatum :: ScriptData -> Babbage.Datum ledgerera
scriptDataToInlineDatum :: ScriptData -> Datum ledgerera
scriptDataToInlineDatum = BinaryData ledgerera -> Datum ledgerera
forall era. BinaryData era -> Datum era
Babbage.Datum (BinaryData ledgerera -> Datum ledgerera)
-> (ScriptData -> BinaryData ledgerera)
-> ScriptData
-> Datum ledgerera
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Data ledgerera -> BinaryData ledgerera
forall era. Data era -> BinaryData era
Alonzo.dataToBinaryData (Data ledgerera -> BinaryData ledgerera)
-> (ScriptData -> Data ledgerera)
-> ScriptData
-> BinaryData ledgerera
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScriptData -> Data ledgerera
forall ledgerera. ScriptData -> Data ledgerera
toAlonzoData

toAlonzoLanguage :: AnyPlutusScriptVersion -> Alonzo.Language
toAlonzoLanguage :: AnyPlutusScriptVersion -> Language
toAlonzoLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV1) = Language
Alonzo.PlutusV1
toAlonzoLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV2) = Language
Alonzo.PlutusV2

-- | In the Alonzo and later eras the auxiliary data consists of the tx metadata
-- and the axiliary scripts, and the axiliary script data.
--
toAlonzoAuxiliaryData :: forall era ledgerera.
                         ShelleyLedgerEra era ~ ledgerera
                      => Ledger.AuxiliaryData ledgerera ~ Alonzo.AuxiliaryData ledgerera
                      => Ledger.Script ledgerera ~ Alonzo.Script ledgerera
                      => Ledger.Era ledgerera
                      => Map.Map Word64 TxMetadataValue
                      -> [ScriptInEra era]
                      -> Ledger.AuxiliaryData ledgerera
toAlonzoAuxiliaryData :: Map Word64 TxMetadataValue
-> [ScriptInEra era] -> AuxiliaryData ledgerera
toAlonzoAuxiliaryData Map Word64 TxMetadataValue
m [ScriptInEra era]
ss =
    Map Word64 Metadatum
-> StrictSeq (Script ledgerera) -> AuxiliaryData ledgerera
forall era.
(Era era, ToCBOR (Script era), Script era ~ Script era,
 Ord (Script era)) =>
Map Word64 Metadatum -> StrictSeq (Script era) -> AuxiliaryData era
Alonzo.AuxiliaryData
      (Map Word64 TxMetadataValue -> Map Word64 Metadatum
toShelleyMetadata Map Word64 TxMetadataValue
m)
      ([Script ledgerera] -> StrictSeq (Script ledgerera)
forall a. [a] -> StrictSeq a
Seq.fromList ((ScriptInEra era -> Script ledgerera)
-> [ScriptInEra era] -> [Script ledgerera]
forall a b. (a -> b) -> [a] -> [b]
map ScriptInEra era -> Script ledgerera
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript [ScriptInEra era]
ss))